write the setup.py and move executables to 'scripts/' (for now, 'bin' might be better) use-distutils
authorTero Marttila <terom@fixme.fi>
Wed, 03 Jun 2009 18:59:46 +0300
branchuse-distutils
changeset 40 373392025533
parent 39 5591342ec2c9
child 41 3b1579a7bffb
write the setup.py and move executables to 'scripts/' (for now, 'bin' might be better)
README
degal
detool
scripts/degal
scripts/detool
scripts/lib
setup.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README	Wed Jun 03 18:59:46 2009 +0300
@@ -0,0 +1,1 @@
+XXX: write me
--- a/degal	Wed Jun 03 18:39:43 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)
--- a/detool	Wed Jun 03 18:39:43 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 <command> [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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/degal	Wed Jun 03 18:59:46 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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/detool	Wed Jun 03 18:59:46 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 <command> [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
--- a/scripts/lib	Wed Jun 03 18:39:43 2009 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-../lib/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.py	Wed Jun 03 18:59:46 2009 +0300
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+from distutils.core import setup
+
+setup(
+    # metadata
+    name            = "Degal",
+    version         = "0.1",
+    description     = "Image gallery script",
+    author          = "Tero Marttila",
+    author_email    = "terom@fixme.fi",
+    url             = "http://projects.qmsk.net/degal",
+    
+    # dependencies
+    requires        = [
+        "mako",
+        
+    ],
+
+    # manifest
+    packages        = [
+        'degal'
+    ],
+
+    scripts         = [
+        'scripts/degal'
+    ],
+)