5 import treecutter.constants as const
6 from treecutter.docbook import Docbook
10 """Class containing the state of the directory with articles"""
14 self._basepath = re.compile('[/\w\._-]*/[\w-]+',re.UNICODE)
17 for dirname, dirnames, filenames in os.walk(self._cwd):
18 for filename in filenames:
19 if fnmatch.fnmatch(filename, '*.xml'):
20 file_ = os.path.join(dirname,filename)
22 (title, menu) = doc.title()
23 draft = doc.status() == "draft"
24 level = doc.userlevel()
26 # doc = etree.parse(file_)
27 # title = doc.xpath(u'/db:article/db:info/db:title',namespaces=const.XPATH)
28 # menu = doc.xpath(u'/db:article/db:info/db:titleabbrev',namespaces=const.XPATH)
29 # draft = doc.xpath(u'/db:article[@status="draft"]',namespaces=const.XPATH)
30 if draft and draftflag:
32 if title and menu and not draft and level <= levelflag:
33 base = self._basepath.match(file_).group()
34 link = base.replace('index','')[1:]
35 self._tree.append(link)
38 return set(self._tree)