# HG changeset patch # User Tero Marttila # Date 1244043572 -10800 # Node ID 2e9fdb080ad64e8578e283f8742fcefba63c8905 # Parent 64a0168a6f50138b0bf1bd9a6967e455726871ba rename executable scripts to remove .py extension diff -r 64a0168a6f50 -r 2e9fdb080ad6 degal --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/degal Wed Jun 03 18:39:32 2009 +0300 @@ -0,0 +1,60 @@ +#!/usr/bin/env python2.5 +# +# DeGAL - A pretty simple web image gallery +# Copyright (C) 2007 Tero Marttila +# http://marttila.de/~terom/degal/ +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +import os.path, os +from optparse import OptionParser + +from lib import folder, shorturl, log + +def main (dir='.', targets=()) : + root_filter = {} + + for target in targets : + f = root_filter + for path_part in target.split('/') : + if path_part : + if path_part not in f : + f[path_part] = {} + + f = f[path_part] + + log.title("Indexing %s...", dir) + root = folder.Folder(dir) + root.index(root_filter) + log.up() + + log.title("Syncing ShortURLs...") + shorturl.updateDB(root) + log.up() + + log.title("Rendering updated dirs...") + root.render() + log.up() + +if __name__ == '__main__' : + parser = OptionParser(usage="usage: %prog [options] ... [target ...]") + + parser.add_option("-d", "--dir", dest="dir", help="look for images in DIR and write the HTML there", metavar="DIR", default=".") + + options, filter_targets = parser.parse_args() + + main(options.dir, filter_targets) diff -r 64a0168a6f50 -r 2e9fdb080ad6 degal.py --- a/degal.py Wed Jun 03 18:36:26 2009 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -#!/usr/bin/env python2.5 -# -# DeGAL - A pretty simple web image gallery -# Copyright (C) 2007 Tero Marttila -# http://marttila.de/~terom/degal/ -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the -# Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -import os.path, os -from optparse import OptionParser - -from lib import folder, shorturl, log - -def main (dir='.', targets=()) : - root_filter = {} - - for target in targets : - f = root_filter - for path_part in target.split('/') : - if path_part : - if path_part not in f : - f[path_part] = {} - - f = f[path_part] - - log.title("Indexing %s...", dir) - root = folder.Folder(dir) - root.index(root_filter) - log.up() - - log.title("Syncing ShortURLs...") - shorturl.updateDB(root) - log.up() - - log.title("Rendering updated dirs...") - root.render() - log.up() - -if __name__ == '__main__' : - parser = OptionParser(usage="usage: %prog [options] ... [target ...]") - - parser.add_option("-d", "--dir", dest="dir", help="look for images in DIR and write the HTML there", metavar="DIR", default=".") - - options, filter_targets = parser.parse_args() - - main(options.dir, filter_targets) diff -r 64a0168a6f50 -r 2e9fdb080ad6 detool --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/detool Wed Jun 03 18:39:32 2009 +0300 @@ -0,0 +1,106 @@ +#!/usr/bin/env python2.4 +# +# DeGAL - A pretty simple web image gallery +# Copyright (C) 2007 Tero Marttila +# http://marttila.de/~terom/degal/ +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +from lib import settings +from lib.log import misc as log +from lib.utils import path_join +import os, os.path, logging + +def move (options, args) : + if len(args) < 2 : + raise Exception("Must give one or more source files, and a destination dir") + + dest = args.pop(-1) + srcs = args + + if not os.path.isdir(dest) : + raise Exception("Given destination '%s' is not a directory" % dest) + + for subdir in (settings.THUMB_DIR, settings.PREVIEW_DIR) : + path = os.path.join(dest, subdir) + + if not os.path.exists(path) : + log.info("mkdir %s" % path) + os.mkdir(path) + + for src in srcs : + if not os.path.isfile(src) : + raise Exception("Given source file '%s' is not a valid file" % src) + + for (pre, post) in ( + (None, None), + (settings.THUMB_DIR, None), + (settings.PREVIEW_DIR, None), + (None, '.html'), + ) : + dir, fname = os.path.split(src) + + if post : + fname += post + + src_path = path_join(dir, pre, fname) + dst_path = path_join(dest, pre, fname) + + if os.path.isfile(src_path) : + if not options.overwite and os.path.exists(dst_path) : + log.warning("%s exists; skipping %s" % (dst_path, src_path)) + log.info("%s -> %s" % (src_path, dst_path)) + os.rename(src_path, dst_path) + +def help (options, args) : + print "Available commands:" + + for name, func in COMMANDS.iteritems() : + print "\t%s" % name + +COMMANDS = dict( + move = move, + mv = move, + help = help, +) + +if __name__ == '__main__' : + from optparse import OptionParser + + parser = OptionParser(usage="usage: %prog [options] [args ...]", version=settings.VERSION) + + parser.add_option("-q", "--quiet", dest="verbose", default=True) + parser.add_option("-i", "--careful", dest="overwrite", help="Do not overwrite files", default=True) + + options, args = parser.parse_args() + + if options.verbose : + log.setLevel(logging.INFO) + else : + log.setLevel(logging.ERROR) + + if not args : + parser.error("Must supply a command. See `detool.py help` for a list of commands") + + command = args.pop(0).lower() + + if command not in COMMANDS : + parser.error("Unknown command '%s'. Try `detool.py help`" % command) + + func = COMMANDS[command] + + func(options, args) \ No newline at end of file diff -r 64a0168a6f50 -r 2e9fdb080ad6 detool.py --- a/detool.py Wed Jun 03 18:36:26 2009 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -#!/usr/bin/env python2.4 -# -# DeGAL - A pretty simple web image gallery -# Copyright (C) 2007 Tero Marttila -# http://marttila.de/~terom/degal/ -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the -# Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -from lib import settings -from lib.log import misc as log -from lib.utils import path_join -import os, os.path, logging - -def move (options, args) : - if len(args) < 2 : - raise Exception("Must give one or more source files, and a destination dir") - - dest = args.pop(-1) - srcs = args - - if not os.path.isdir(dest) : - raise Exception("Given destination '%s' is not a directory" % dest) - - for subdir in (settings.THUMB_DIR, settings.PREVIEW_DIR) : - path = os.path.join(dest, subdir) - - if not os.path.exists(path) : - log.info("mkdir %s" % path) - os.mkdir(path) - - for src in srcs : - if not os.path.isfile(src) : - raise Exception("Given source file '%s' is not a valid file" % src) - - for (pre, post) in ( - (None, None), - (settings.THUMB_DIR, None), - (settings.PREVIEW_DIR, None), - (None, '.html'), - ) : - dir, fname = os.path.split(src) - - if post : - fname += post - - src_path = path_join(dir, pre, fname) - dst_path = path_join(dest, pre, fname) - - if os.path.isfile(src_path) : - if not options.overwite and os.path.exists(dst_path) : - log.warning("%s exists; skipping %s" % (dst_path, src_path)) - log.info("%s -> %s" % (src_path, dst_path)) - os.rename(src_path, dst_path) - -def help (options, args) : - print "Available commands:" - - for name, func in COMMANDS.iteritems() : - print "\t%s" % name - -COMMANDS = dict( - move = move, - mv = move, - help = help, -) - -if __name__ == '__main__' : - from optparse import OptionParser - - parser = OptionParser(usage="usage: %prog [options] [args ...]", version=settings.VERSION) - - parser.add_option("-q", "--quiet", dest="verbose", default=True) - parser.add_option("-i", "--careful", dest="overwrite", help="Do not overwrite files", default=True) - - options, args = parser.parse_args() - - if options.verbose : - log.setLevel(logging.INFO) - else : - log.setLevel(logging.ERROR) - - if not args : - parser.error("Must supply a command. See `detool.py help` for a list of commands") - - command = args.pop(0).lower() - - if command not in COMMANDS : - parser.error("Unknown command '%s'. Try `detool.py help`" % command) - - func = COMMANDS[command] - - func(options, args) \ No newline at end of file