Commits

Alexander Solovyov committed 66caa6e

search re should be MULTILINE to work properly

Comments (0)

Files changed (1)

  • +8 -6
    sr
 import re
 import warnings
 import time
+from itertools import imap
 
 IGNORE_DIRS = ['autom4te.cache', 'blib', '_build', '.bzr', '.cdv', 'cover_db',
                'CVS', '_darcs', '~.dep', '~.dot', '.git', '.hg', '~.nib',
             config.replace = opts.replace
             config.mode = 'replace'
 
-        flags = 0
+        flags = re.MULTILINE
         if opts.flags:
             for flag in opts.flags:
                 flags |= getattr(re, flag.upper())
 
 def search_line(line):
     eliminate = config.eliminate and config.eliminate.search(line) or False
-    return config.search.search(line) and not eliminate
+    r = config.search.search(line) and not eliminate
+    return r
 
 def search(path, f):
     """
     """
     Search and replace patterns in file.
 
-    If backup setting is on then for each modified file create unique backup file with .FILENAME.XXX~
-    there XXX is numeral suffix
+    If backup setting is on then for each modified file create unique backup
+    file with .FILENAME.XXX~ there XXX is numeral suffix
     """
 
     base, name = os.path.split(path)
     data = f.read()
 
     if search_line(data):
-        print path
+        print relpath(path)
 
         if config.explain:
             return
             logging.error('Can\'t create temporary file for %s' % path)
             return
 
-        if config.backup: 
+        if config.backup:
             # Create backup
             backup_path = None
             for count in xrange(999):