language: added full translation support
[treecutter.git] / treecutter / directory.py
index d4a0973cbd6cb3eee76906a7f6babf56585a5955..88390bb0ef9039a19f98878d2ecf121842edb51e 100644 (file)
@@ -5,15 +5,27 @@ from lxml import etree
 import treecutter.constants as const
 from treecutter.docbook import Docbook
 import re
+from itertools import chain
 
 class Directory():
     """Class containing the state of the directory with articles"""
     def __init__(self):
         self._cwd = u'.'
+        self._translations = []
         self._tree = []
         self._basepath = re.compile('[/\w\._-]*/[\w-]+',re.UNICODE)
 
-    def scan(self):
+    def translations(self, directory):
+        paths = (self._cwd, directory)
+        for dirname, dirnames, filenames in chain.from_iterable(os.walk(path) for path in paths):
+            for filename in filenames:
+                if fnmatch.fnmatch(filename, '*.xlf'):
+                    file_ = os.path.join(dirname,filename)
+                    self._translations.append(file_)
+        return self._translations
+
+
+    def scan(self, draftflag, levelflag):
         for dirname, dirnames, filenames in os.walk(self._cwd):
             for filename in filenames:
                 if fnmatch.fnmatch(filename, '*.xml'):