#!/usr/bin/python """flav2theme Converts Blosxom [http://www.blosxom.com/] flavour templates [http://www.blosxom.com/documentation/users/flavour.html] to single file theme templates compatible with the theme plugin [http://www.blosxom.com/plugins/general/theme.htm]. Concatenates the standard content_type, head, date, story, and foot components in order, followed by any additional components (e.g. writeback.flavour) supplied. Usage: python flav2theme.py /path/to/flavour/files/*.flavour_to_convert > page E.g. Create a Theme template out of content_type.html, head.html, date.html, story.html, foot.html, and any other html template files, all living at /Library/WebServer/Documents/Blosxom and save that template to a file called page. python flav2theme.py /Library/WebServer/Documents/Blosxom/*.html > page """ __version__ = "0+1i" __author__ = "Rael Dornfest [http://raelity.org/] " __copyright__ = "Copyright 2003 Rael Dornfest" __license__ = "http://creativecommons.org/licenses/by/1.0/" import re if __name__ == '__main__': import sys, os if sys.argv[1:]: files = sys.argv[1:] components = {} for file in files: component, flavour = os.path.splitext(os.path.basename(file)) flavourfh = open(file, 'r') components[component] = flavourfh.read() flavourfh.close() if components[component][-1:] == '\n': components[component] = components[component][:-1] page = "\n\n" % (flavour, components.get("content_type")) if components.has_key("content_type"): del components["content_type"] for c in ['head', 'date', 'story', 'foot']: try: page = page + "\n%s\n" % (c, components[c]) del components[c] except: pass for c in components.keys(): page = page + "\n%s\n" % (c, components[c]) print page else: print "Usage: python flav2theme.py /path/to/flavour/files/*.flavour_to_convert > page"