lib/utils.py
author terom
Fri, 21 Dec 2007 20:45:03 +0000
changeset 13 c229bcb1de41
parent 12 c2d8e9a754a1
child 14 4b5478da5850
permissions -rw-r--r--
image breadcrumb links back to page that said image is on
import os.path

def readFile (path) :
    fo = open(path, 'r')
    data = fo.read()
    fo.close()

    return data

def readTitleDescr (path) :
    """
        Read a title.txt or <imgname>.txt file
    """

    if os.path.exists(path) :
        content = readFile(path)

        if '---' in content :
            title, descr = content.split('---', 1)
        else :
            title, descr = content, ''

        return title.strip(), descr.strip()

    return "", ""

def url_join (*parts) :
    return '/'.join(parts)
 
from optparse import OptionParser
    
def optparse (options) :
    parser = OptionParser()
    
    
    parser.add_option