[node-patches] Change in ovirt-node[master]: fs: Add sub()/search() to File

fabiand at redhat.com fabiand at redhat.com
Fri Jul 18 15:48:52 UTC 2014


Fabian Deutsch has uploaded a new change for review.

Change subject: fs: Add sub()/search() to File
......................................................................

fs: Add sub()/search() to File

sub() and search() allow simple operations on the file contents.

Change-Id: I2e2f7d9578fb9b00b44d78a93f43f7c5198d66e4
Signed-off-by: Fabian Deutsch <fabiand at redhat.com>
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/utils/fs/__init__.py
1 file changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/53/30453/1

diff --git a/src/ovirt/node/utils/fs/__init__.py b/src/ovirt/node/utils/fs/__init__.py
index a660dd2..fe2c2c6 100644
--- a/src/ovirt/node/utils/fs/__init__.py
+++ b/src/ovirt/node/utils/fs/__init__.py
@@ -27,8 +27,8 @@
 import shutil
 import errno
 import os
-import re
 import StringIO
+import re
 
 from . import mount
 from .. import process, parse_varfile
@@ -272,6 +272,13 @@
         def access(self, mode):
             return self.filename in FakeFs.filemap
 
+        def sed(self, expr, inplace=True):
+            newval = process.pipe(["sed", "-e", expr],
+                                  stdin=self.read())
+            if inplace:
+                self.write(newval)
+            return newval
+
         def __iter__(self):
             for line in StringIO.StringIO(self.read()):
                 yield line


-- 
To view, visit http://gerrit.ovirt.org/30453
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e2f7d9578fb9b00b44d78a93f43f7c5198d66e4
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>



More information about the node-patches mailing list