terom@14: # DeGAL - A pretty simple web image gallery terom@14: # Copyright (C) 2007 Tero Marttila terom@14: # http://marttila.de/~terom/degal/ terom@14: # terom@14: # This program is free software; you can redistribute it and/or modify terom@14: # it under the terms of the GNU General Public License as published by terom@14: # the Free Software Foundation; either version 2 of the License, or terom@14: # (at your option) any later version. terom@14: # terom@14: # This program is distributed in the hope that it will be useful, terom@14: # but WITHOUT ANY WARRANTY; without even the implied warranty of terom@14: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terom@14: # GNU General Public License for more details. terom@14: # terom@14: # You should have received a copy of the GNU General Public License terom@14: # along with this program; if not, write to the terom@14: # Free Software Foundation, Inc., terom@14: # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. terom@14: # terom@14: 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@15: terom@15: def path_join (*parts) : terom@15: return os.path.join(*[part for part in parts if part is not None]) 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: