X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=webber.py;h=9b3d0728baa2af88b79360fc1a0fddb0d8b16990;hb=62778c4dbb5f3f23e7cbfdbf7628975dd0b66ea6;hp=194ce5cf3e93e4667f7f79245842948a19d2d6e4;hpb=5b24964cda642526f6331573980b2cd6f254780b;p=webber.git diff --git a/webber.py b/webber.py index 194ce5c..9b3d072 100644 --- a/webber.py +++ b/webber.py @@ -63,6 +63,7 @@ class File(Holder): Holder.__init__(self, **kw) files[kw["rel_path"]] = self self.render = None + self.contents = None mtime = os.stat(self.path)[stat.ST_MTIME] self.mtime = mtime self.ctime = mtime @@ -80,7 +81,7 @@ class File(Holder): if read_keywords: s = s.strip() #print "kwd:", s - if s==terminate_line: + if s == terminate_line: read_keywords = False continue @@ -107,6 +108,16 @@ class File(Holder): continue #print "txt:", s.rstrip().encode("iso-8859-1") txt.append(s) + + # Warn about a bogus time entries + if self.mtime < self.ctime: + log('%s: modification time cannot be before creation time' % self.rel_path) + self.ctime = self.mtime + + # Warn about long titles / long linktitles + if len(self.linktitle) > 20: + log('%s: define a shorter linktitle' % self.rel_path) + self.contents = "".join(txt) @@ -251,7 +262,7 @@ def get_program_directory(): # 5... Debug # def log(s, level=4): - if level>4: + if level > 4: indent = " " * (level-4) else: indent = "" @@ -326,13 +337,16 @@ hooks = {} def load_plugins(): """Loads all plugins in the plugins directory.""" sys.path.append(os.path.join(get_program_directory(), "plugins")) + if cfg.has_key("plugin_dirs"): + for s in cfg.plugin_dirs: + sys.path.append(s) for s in cfg.plugins: #print "import:", s - #try: - exec "import %s" % s - #except: - # print "Could not import plugin '%s'" % s - # sys.exit(1) + try: + exec "import %s" % s + except: + print "Could not import plugin '%s'" % s + sys.exit(1) def set_hook(name, last=False): @@ -424,7 +438,7 @@ def iso_to_time(val): try: t = time.strptime(val, "%Y-%m-%d") except ValueError: - warning("%s: wrong ISO format in '%s'" % (self.rel_path, s)) + warning("wrong ISO format in '%s'" % val) return int(time.mktime(t)) @set_function("format_date") @@ -496,7 +510,7 @@ def walk_tree(dirpath): direc.inheritFrom(cfg) if not rel_path: rel_path = "." - log("reading directory %s" % rel_path, level=4) + log("reading directory %s" % rel_path, level=5) for s in os.listdir(dirpath): full_path = os.path.join(dirpath, s) @@ -519,6 +533,13 @@ def walk_tree(dirpath): if ok: #print "FILE", s rel_path = relpath(cfg.in_dir, full_path) + # Allow paths to be specified in exclude_files: + for e in cfg.exclude_files: + if fnmatch.fnmatch(rel_path, e): + log("ignoring file %s" % rel_path, level=7) + ok = False + break + if ok: log("reading file %s" % rel_path, level=5) file = File( path = full_path, @@ -591,11 +612,13 @@ def scan_files(): for s in files: file = files[s] - try: - # Just check if the file has contents - contents = file.contents - except: + if not file.has_key("contents"): continue +# try: +# # Just check if the file has contents +# contents = file.contents +# except: +# continue direc = directories[file.direc]