path: adding support for . in directoies
[treecutter.git] / treecutter / link.py
index 69ee9b1cfcd58e951c8b35aecbb7fbcf3deacebb..f482c0bf2f9bd4299c395dba7852a89a26314820 100644 (file)
@@ -1,4 +1,5 @@
 #!/usr/bin/python
+import re
 import glob
 from treecutter.page import Page
 
@@ -8,6 +9,7 @@ class Link():
         self._link = link
         # find the representations of the link.
         self._pages = []
+        self._langregexp = re.compile('.*\.(\w\w)\.xml')
         path = link
         if self._link[-1] == '/':
             path = path+'index'
@@ -20,10 +22,9 @@ class Link():
 
     def _scan_languages(self,path):
         lang = []
-        for l in  glob.glob('.'+path+'*'):
-            ls = l.split('.')
-            if len(ls) > 3 and ls[3] == 'xml':
-                lang.append((ls[2],l))
+        for l in  glob.glob('.'+path+'*.xml'):
+            langcode = self._langregexp.search(l).group(1)
+            lang.append((langcode,l))
         return lang
 
     def link(self):