Commits

Seraphim Mellos committed 2b4049f

Added support for multiple <lang> occurrences in the file expression

  • Participants
  • Parent commits bf470ed

Comments (0)

Files changed (2)

File txclib/commands.py

         # Force expr to be a valid regex expr (escaped) but keep <lang> intact
         expr_re = re.escape(expression)
         expr_re = re.sub(r"\\<lang\\>", '<lang>', expr_re)
-        expr_re = re.sub(r"%s?<lang>" % os.sep, '%(sep)s(?P<lang>[^%(sep)s]+)'
+        expr_re = re.sub(r"%s?<lang>" % os.sep, '%(sep)s([^%(sep)s]+)'
             % { 'sep': os.sep}, '.*%s$' % expr_re)
+    print expr_re
     expr_rec = re.compile(expr_re)
 
     # The path everything will be relative to
             f_path = os.path.join(root, f)
             match = expr_rec.match(f_path)
             if match:
-                lang = match.group('lang')
+                lang = match.group(1)
                 f_path = os.path.abspath(f_path)
                 if lang == source_language and not source_file:
                     source_file = f_path

File txclib/project.py

 
             expr_re = re.escape(file_filter)
             expr_re = re.sub(r"\\<lang\\>", '<lang>', expr_re)
-            expr_re = re.sub(r"<lang>", '(?P<lang>[^/]+)', '.*?%s$' % expr_re)
+            expr_re = re.sub(r"<lang>", '([^/]+)', '.*?%s$' % expr_re)
             expr_rec = re.compile(expr_re)
             for root, dirs, files in os.walk(self.root):
                 for f in files:
                     f_path = os.path.join(root, f).replace(os.path.sep, '/')
                     match = expr_rec.match(f_path)
                     if match:
-                        lang = match.group('lang')
+                        lang = match.group(1)
                         if lang != source_lang:
                             f_path = relpath(f_path, self.root)
                             tr_files.update({lang: f_path})