X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=webber.py;h=dab4675b4193b117f76d2d0bde7da72c4293e573;hb=3518e3cb4158558d03162d2ccc4c31f4c6daf41f;hp=c46141c49f4db1509f658dba5b2964d088568ae1;hpb=bd023f0983dd000545a1c5d358841ea16c7aaccc;p=webber.git diff --git a/webber.py b/webber.py index c46141c..dab4675 100644 --- a/webber.py +++ b/webber.py @@ -50,7 +50,15 @@ class Directory(Holder): def __init__(self, **kw): Holder.__init__(self, **kw) - directories[kw["rel_path"]] = self + kw["rel_path"] = self + if self.rel_path == "": + self.rel_path = "." + directories[self.rel_path] = self + try: + self.load(os.path.join(self.abs_path, "directory.conf")) + #print self + except IOError: + pass files = {} @@ -139,6 +147,10 @@ def get_file_for(name): #print " via linktitle:", s _get_file_for_cache[name] = f return f + if f.title == name: + #print " via title:", s + _get_file_for_cache[name] = f + return f except: pass # Allow exact match as well @@ -207,8 +219,8 @@ def relpath(base_path, target): def get_link_from(source, dest): - #print "get_link_from", source, dest - #print source + if dest is None: + raise KeyError if not isinstance(source, File): source = get_file_for(source) if not source: @@ -217,7 +229,7 @@ def get_link_from(source, dest): if not isinstance(dest, File): dest = get_file_for(dest) if not dest: - print "NO DEST" + warning("unknown link from %s to %s" % (source.rel_path, dest)) return "." rel_path = relpath(directories[source.direc].abs_path, directories[dest.direc].abs_path) try: @@ -437,12 +449,14 @@ def iso_to_time(val): return int(time.mktime(t)) @set_function("format_date") -def format_date(timestamp): - return time.strftime(cfg.date_format, time.localtime(timestamp)) +def format_date(timestamp, format=None): + if not format: + format = cfg.date_format + return time.strftime(format, time.localtime(timestamp)) @set_function("get_time") -def get_time(): - return format_date(time.time()) +def get_time(format=None): + return format_date(time.time(), format) @set_function("get_current_file") def get_current_file(): @@ -511,7 +525,7 @@ def walk_tree(dirpath): full_path = os.path.join(dirpath, s) ok = True if os.path.isdir(full_path): - for e in cfg.exclude_dir: + for e in cfg.exclude_dirs: if fnmatch.fnmatchcase(s, e): log("ignoring directory %s" % s, level=7) ok = False @@ -769,7 +783,12 @@ def main(): # link contents of webber.ini into cfg and set some defaults, # then let plugins fixup things in cfg.* cfg.inheritFrom(options) - cfg.setDefault("exclude_dir", ["plugins"]) + cfg.setDefault("exclude_dirs", []) + cfg.setDefault("exclude_files", ["webber.conf", "directory.conf", "*.tmpl"]) + cfg.setDefault("copy_files", []) + cfg.setDefault("input_encoding", "iso-8859-1") + cfg.setDefault("output_encoding", "iso-8859-1") + cfg.setDefault("template", "default") run_hooks("checkconfig") run_hooks("start")