X-Git-Url: https://source.tree.se/git?p=treecutter.git;a=blobdiff_plain;f=treecutter%2Fdirectory.py;fp=treecutter%2Fdirectory.py;h=e7508d94f8d22b3403d60dd85c695eacc6584179;hp=7519a6b27bd4b044ccb57986eaf9961b10eed846;hb=870b74488439f6c30974eb759d5032fc06cb8c14;hpb=bdecaa29bbb25b5e4ccc2b08d04577e780a149b9 diff --git a/treecutter/directory.py b/treecutter/directory.py index 7519a6b..e7508d9 100644 --- a/treecutter/directory.py +++ b/treecutter/directory.py @@ -3,12 +3,14 @@ import os import fnmatch from lxml import etree import treecutter.constants as const +import re class Directory(): """Class containing the state of the directory with articles""" def __init__(self): self._cwd = u'.' self._tree = [] + self._basepath = re.compile('[/\w\._-]*/\w+',re.UNICODE) def scan(self): for dirname, dirnames, filenames in os.walk(self._cwd): @@ -19,8 +21,8 @@ class Directory(): title = doc.xpath(u'/db:article/db:info/db:title',namespaces=const.XPATH) menu = doc.xpath(u'/db:article/db:info/db:titleabbrev',namespaces=const.XPATH) if title and menu: - base = file_.split('.')[1] - link = base.replace('index','') + base = self._basepath.match(file_).group() + link = base.replace('index','')[1:] self._tree.append(link) def set(self):