X-Git-Url: https://source.tree.se/git?p=treecutter.git;a=blobdiff_plain;f=treecutter%2Fdirectory.py;fp=treecutter%2Fdirectory.py;h=d4a0973cbd6cb3eee76906a7f6babf56585a5955;hp=1b7a3e9f3ee6562ff9bfedd51ea0bdac409b1d7c;hb=86815abce0db2e449bc3b2cbc6790885f73d41d9;hpb=5ee26cbf373af8fe76d549f4f1cba1f240146a2b diff --git a/treecutter/directory.py b/treecutter/directory.py index 1b7a3e9..d4a0973 100644 --- a/treecutter/directory.py +++ b/treecutter/directory.py @@ -3,6 +3,7 @@ import os import fnmatch from lxml import etree import treecutter.constants as const +from treecutter.docbook import Docbook import re class Directory(): @@ -17,10 +18,18 @@ class Directory(): for filename in filenames: if fnmatch.fnmatch(filename, '*.xml'): file_ = os.path.join(dirname,filename) - doc = etree.parse(file_) - 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: + doc = Docbook(file_) + (title, menu) = doc.title() + draft = doc.status() == "draft" + level = doc.userlevel() + +# doc = etree.parse(file_) +# 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) +# draft = doc.xpath(u'/db:article[@status="draft"]',namespaces=const.XPATH) + if draft and draftflag: + draft = False + if title and menu and not draft and level <= levelflag: base = self._basepath.match(file_).group() link = base.replace('index','')[1:] self._tree.append(link)