direntry parser wasn't eating a trailing newline
authorDiane Trout <diane@caltech.edu>
Sun, 30 Dec 2007 23:47:11 +0000 (23:47 +0000)
committerDiane Trout <diane@caltech.edu>
Sun, 30 Dec 2007 23:47:11 +0000 (23:47 +0000)
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..   "

gaworkflow/copier.py
test/test_copier.py

index b78ad6abac0bafce83a71449761796bbb0844f4d..c28ea326d0d7d8557e43fa79aa1683d0e25fc4e8 100644 (file)
@@ -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 
index a67df2e44be8771dd592ce18e84fc908311dd085..6caf6a8cc311c9a2bc4a5f1f03c1f283300594d6 100644 (file)
@@ -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')