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):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.