terom@12: import os.path terom@12: terom@12: def readFile (path) : terom@12: fo = open(path, 'r') terom@12: data = fo.read() terom@12: fo.close() terom@12: terom@12: return data terom@12: terom@12: def readTitleDescr (path) : terom@12: """ terom@12: Read a title.txt or .txt file terom@12: """ terom@12: terom@12: if os.path.exists(path) : terom@12: content = readFile(path) terom@12: terom@12: if '---' in content : terom@12: title, descr = content.split('---', 1) terom@12: else : terom@12: title, descr = content, '' terom@12: terom@12: return title.strip(), descr.strip() terom@12: terom@12: return "", "" terom@12: terom@12: def url_join (*parts) : terom@12: return '/'.join(parts) terom@12: terom@12: from optparse import OptionParser terom@12: terom@12: def optparse (options) : terom@12: parser = OptionParser() terom@12: terom@12: terom@12: parser.add_option terom@12: terom@12: