From: Diane Trout Date: Sun, 30 Dec 2007 23:47:11 +0000 (+0000) Subject: direntry parser wasn't eating a trailing newline X-Git-Tag: 0.1.0~27 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=8c5dcf6278ada95a506f4b1b6cfb7074a2aa8df7 direntry parser wasn't eating a trailing newline This patch assumes that there always will be a single trailing whitespace character to handle, on the off chance that someone will make a horrific filename with trailing whitespace. e.g. filename = "oh why do you do this.. " --- diff --git a/gaworkflow/copier.py b/gaworkflow/copier.py index b78ad6a..c28ea32 100644 --- a/gaworkflow/copier.py +++ b/gaworkflow/copier.py @@ -44,7 +44,7 @@ class rsync(object): parse rsync directory listing """ dirs_to_copy = [] - direntries = [ x[0:42].split() + [x[43:]] for x in lines ] + direntries = [ x[0:42].split() + [x[43:-1]] for x in lines ] for permissions, size, filedate, filetime, filename in direntries: if permissions[0] == 'd': # hey its a directory, the first step to being something we want to diff --git a/test/test_copier.py b/test/test_copier.py index a67df2e..6caf6a8 100644 --- a/test/test_copier.py +++ b/test/test_copier.py @@ -51,11 +51,14 @@ notify_users: user3@example.fake r = copier.rsync('/', '/', '/') listing = [ - '-rwxrw-r-- 123268 2007/12/29 17:39:31 2038EAAXX.rtf', - '-rwxrw-r-- 6 2007/12/29 15:10:29 New Text Document.txt', + 'drwxrwxr-x 0 2007/12/29 12:34:56 071229_USI-EAS229_001_FC1234\n', + '-rwxrw-r-- 123268 2007/12/29 17:39:31 2038EAAXX.rtf\n', + '-rwxrw-r-- 6 2007/12/29 15:10:29 New Text Document.txt\n', ] result = r.list_filter(listing) + self.failUnlessEqual(len(result), 1) + self.failUnlessEqual(result[0][-1], '4') def suite(): return unittest.makeSuite(testCopier,'test')