aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/util
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-15 06:44:20 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-15 06:44:20 -0500
commit89b7a1411e4658e831f5d635534b24355dbb941d (patch)
tree77f84979931ac4bf8bcf14d293154fe29e8491bc /libbe/util
parent380889988b6d7881c4e0b5968053f85676d27211 (diff)
downloadbugseverywhere-89b7a1411e4658e831f5d635534b24355dbb941d.tar.gz
Fixed libbe.command.diff + ugly BugDir.duplicate_bugdir implementation
duplicate_bugdir() works, but for the vcs backends, it could require shelling out for _every_ file read. This could, and probably will, be horribly slow. Still it works ;). I'm not sure what a better implementation would be. The old implementation checked out the entire earlier state into a temporary directory pros: single shell out, simple upgrade implementation cons: wouldn't work well for HTTP backens I think a good solution would run along the lines of the currently commented out code in duplicate_bugdir(), where a VersionedStorage.changed_since(revision) call would give you a list of changed files. diff could work off of that directly, without the need to generate a whole duplicate bugdir. I'm stuck on how to handle upgrades though... Also removed trailing whitespace from all python files.
Diffstat (limited to 'libbe/util')
-rw-r--r--libbe/util/encoding.py2
-rw-r--r--libbe/util/id.py10
-rw-r--r--libbe/util/plugin.py2
-rw-r--r--libbe/util/subproc.py8
-rw-r--r--libbe/util/utility.py6
5 files changed, 14 insertions, 14 deletions
diff --git a/libbe/util/encoding.py b/libbe/util/encoding.py
index dcc41f8..7706105 100644
--- a/libbe/util/encoding.py
+++ b/libbe/util/encoding.py
@@ -72,7 +72,7 @@ def get_file_contents(path, mode='r', encoding=None, decode=False):
encoding = get_filesystem_encoding()
f = codecs.open(path, mode, encoding)
else:
- f = open(path, mode)
+ f = open(path, mode)
contents = f.read()
f.close()
return contents
diff --git a/libbe/util/id.py b/libbe/util/id.py
index 3838259..adc827c 100644
--- a/libbe/util/id.py
+++ b/libbe/util/id.py
@@ -50,7 +50,7 @@ except ImportError:
q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
else:
# win32 don't have os.execvp() so have to run command in a shell
- q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE,
+ q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE,
shell=True, cwd=cwd)
except OSError, e :
strerror = "%s\nwhile executing %s" % (e.args[1], args)
@@ -210,7 +210,7 @@ def child_uuids(child_storage_ids):
fields = _split(id)
if len(fields) == 1:
yield fields[0]
-
+
REGEXP = '#([-a-f0-9]*)(/[-a-g0-9]*)?(/[-a-g0-9]*)?#'
@@ -298,7 +298,7 @@ if libbe.TESTING == True:
self._siblings = siblings
def sibling_uuids(self):
return self._siblings
-
+
class IDtestCase(unittest.TestCase):
def setUp(self):
self.bugdir = DummyObject('1234abcd')
@@ -342,11 +342,11 @@ if libbe.TESTING == True:
self.bug = DummyObject('abcdef', ['a1234', 'ab9876'])
self.bug.bugdir = self.bugdir
self.bugdir.bug_from_uuid = lambda uuid: self.bug
- self.bugdir.uuids = lambda : self.bug.sibling_uuids() + [self.bug.uuid]
+ self.bugdir.uuids = lambda : self.bug.sibling_uuids() + [self.bug.uuid]
self.comment = DummyObject('12345678', ['1234abcd', '1234cdef'])
self.comment.bug = self.bug
self.bug.comment_from_uuid = lambda uuid: self.comment
- self.bug.uuids = lambda : self.comment.sibling_uuids() + [self.comment.uuid]
+ self.bug.uuids = lambda : self.comment.sibling_uuids() + [self.comment.uuid]
self.bd_id = ID(self.bugdir, 'bugdir')
self.b_id = ID(self.bug, 'bug')
self.c_id = ID(self.comment, 'comment')
diff --git a/libbe/util/plugin.py b/libbe/util/plugin.py
index 982c5ca..0326cda 100644
--- a/libbe/util/plugin.py
+++ b/libbe/util/plugin.py
@@ -57,7 +57,7 @@ def modnames(prefix):
>>> 'plugin' in [n for n in modnames('libbe.util')]
True
"""
- components = prefix.split('.')
+ components = prefix.split('.')
modfiles = os.listdir(os.path.join(_PLUGIN_PATH, *components))
modfiles.sort()
for modfile in modfiles:
diff --git a/libbe/util/subproc.py b/libbe/util/subproc.py
index 8806e26..06716b3 100644
--- a/libbe/util/subproc.py
+++ b/libbe/util/subproc.py
@@ -61,7 +61,7 @@ def invoke(args, stdin=None, stdout=PIPE, stderr=PIPE, expect=(0,),
else:
assert _MSWINDOWS==True, 'invalid platform'
# win32 don't have os.execvp() so have to run command in a shell
- q = Popen(args, stdin=PIPE, stdout=stdout, stderr=stderr,
+ q = Popen(args, stdin=PIPE, stdout=stdout, stderr=stderr,
shell=True, cwd=cwd)
except OSError, e:
raise CommandError(args, status=e.args[0], stderr=e)
@@ -133,7 +133,7 @@ class Pipe (object):
thread.start()
threads.append(thread)
std_X_arrays.append(stderr_array)
-
+
# also listen to the last processes stdout
stdout_array = []
thread = Thread(target=proc._readerthread,
@@ -142,11 +142,11 @@ class Pipe (object):
thread.start()
threads.append(thread)
std_X_arrays.append(stdout_array)
-
+
# join threads as they die
for thread in threads:
thread.join()
-
+
# read output from reader threads
std_X_strings = []
for std_X_array in std_X_arrays:
diff --git a/libbe/util/utility.py b/libbe/util/utility.py
index 779eaa5..31d4c14 100644
--- a/libbe/util/utility.py
+++ b/libbe/util/utility.py
@@ -51,7 +51,7 @@ def search_parent_directories(path, filename):
"""
Find the file (or directory) named filename in path or in any
of path's parents.
-
+
e.g.
search_parent_directories("/a/b/c", ".be")
will return the path to the first existing file from
@@ -112,7 +112,7 @@ def str_to_time(str_time):
time_val = calendar.timegm(time.strptime(str_time, RFC_2822_TIME_FMT))
timesign = -int(timezone_str[0]+"1") # "+" -> time_val ahead of GMT
timezone_tuple = time.strptime(timezone_str[1:], "%H%M")
- timezone = timezone_tuple.tm_hour*3600 + timezone_tuple.tm_min*60
+ timezone = timezone_tuple.tm_hour*3600 + timezone_tuple.tm_min*60
return time_val + timesign*timezone
def handy_time(time_val):
@@ -153,7 +153,7 @@ def underlined(instring):
>>> underlined("Underlined String")
'Underlined String\\n================='
"""
-
+
return "%s\n%s" % (instring, "="*len(instring))
if libbe.TESTING == True: