X-Git-Url: https://source.tree.se/git?p=treecutter.git;a=blobdiff_plain;f=treecutter%2Flink.py;fp=treecutter%2Flink.py;h=f482c0bf2f9bd4299c395dba7852a89a26314820;hp=69ee9b1cfcd58e951c8b35aecbb7fbcf3deacebb;hb=870b74488439f6c30974eb759d5032fc06cb8c14;hpb=bdecaa29bbb25b5e4ccc2b08d04577e780a149b9 diff --git a/treecutter/link.py b/treecutter/link.py index 69ee9b1..f482c0b 100644 --- a/treecutter/link.py +++ b/treecutter/link.py @@ -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):