remove hanging utils.py in root, and add GPL license header to all .py files
authorterom
Fri, 21 Dec 2007 20:49:04 +0000
changeset 14 4b5478da5850
parent 13 c229bcb1de41
child 15 0fe851a29bc6
remove hanging utils.py in root, and add GPL license header to all .py files
lib/folder.py
lib/helpers.py
lib/image.py
lib/log.py
lib/shorturl.py
lib/template.py
lib/utils.py
utils.py
--- a/lib/folder.py	Fri Dec 21 20:45:03 2007 +0000
+++ b/lib/folder.py	Fri Dec 21 20:49:04 2007 +0000
@@ -1,3 +1,23 @@
+# 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, os.path
 
 import settings, image, utils, helpers
--- a/lib/helpers.py	Fri Dec 21 20:45:03 2007 +0000
+++ b/lib/helpers.py	Fri Dec 21 20:49:04 2007 +0000
@@ -1,3 +1,23 @@
+# 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.
+#
+
 # template helper functions
 import urllib
 from formatbytes import formatbytes
--- a/lib/image.py	Fri Dec 21 20:45:03 2007 +0000
+++ b/lib/image.py	Fri Dec 21 20:49:04 2007 +0000
@@ -1,3 +1,23 @@
+# 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, os.path
 
 import PIL.Image
--- a/lib/log.py	Fri Dec 21 20:45:03 2007 +0000
+++ b/lib/log.py	Fri Dec 21 20:49:04 2007 +0000
@@ -1,3 +1,23 @@
+# 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 logging
 
 logging.basicConfig(
--- a/lib/shorturl.py	Fri Dec 21 20:45:03 2007 +0000
+++ b/lib/shorturl.py	Fri Dec 21 20:49:04 2007 +0000
@@ -1,3 +1,23 @@
+# 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 struct
 import base64
 import shelve
--- a/lib/template.py	Fri Dec 21 20:45:03 2007 +0000
+++ b/lib/template.py	Fri Dec 21 20:49:04 2007 +0000
@@ -1,3 +1,23 @@
+# 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 mako import exceptions
 from mako.lookup import TemplateLookup
 
--- a/lib/utils.py	Fri Dec 21 20:45:03 2007 +0000
+++ b/lib/utils.py	Fri Dec 21 20:49:04 2007 +0000
@@ -1,3 +1,23 @@
+# 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
 
 def readFile (path) :
--- a/utils.py	Fri Dec 21 20:45:03 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-###############################################################
-# Functions taken from pathutils.py Version 0.2.5 (2005/12/06), http://www.voidspace.org.uk/python/recipebook.shtml#utils
-# Copyright Michael Foord 2004
-# Released subject to the BSD License
-# Please see http://www.voidspace.org.uk/python/license.shtml
-
-###############################################################
-# formatbytes takes a filesize (as returned by os.getsize() )
-# and formats it for display in one of two ways !!
-
-# For information about bugfixes, updates and support, please join the Pythonutils mailing list.
-# http://groups.google.com/group/pythonutils/
-# Comments, suggestions and bug reports welcome.
-# Scripts maintained at http://www.voidspace.org.uk/python/index.shtml
-# E-mail fuzzyman@voidspace.org.uk
-
-def formatbytes(sizeint, configdict=None, **configs):
-    """
-    Given a file size as an integer, return a nicely formatted string that
-    represents the size. Has various options to control it's output.
-    
-    You can pass in a dictionary of arguments or keyword arguments. Keyword
-    arguments override the dictionary and there are sensible defaults for options
-    you don't set.
-    
-    Options and defaults are as follows :
-    
-    *    ``forcekb = False`` -         If set this forces the output to be in terms
-    of kilobytes and bytes only.
-    
-    *    ``largestonly = True`` -    If set, instead of outputting 
-        ``1 Mbytes, 307 Kbytes, 478 bytes`` it outputs using only the largest 
-        denominator - e.g. ``1.3 Mbytes`` or ``17.2 Kbytes``
-    
-    *    ``kiloname = 'Kbytes'`` -    The string to use for kilobytes
-    
-    *    ``meganame = 'Mbytes'`` - The string to use for Megabytes
-    
-    *    ``bytename = 'bytes'`` -     The string to use for bytes
-    
-    *    ``nospace = True`` -        If set it outputs ``1Mbytes, 307Kbytes``, 
-        notice there is no space.
-    
-    Example outputs : ::
-    
-        19Mbytes, 75Kbytes, 255bytes
-        2Kbytes, 0bytes
-        23.8Mbytes
-    
-    .. note::
-    
-        It currently uses the plural form even for singular.
-    """
-    defaultconfigs = {  'forcekb' : False,
-                        'largestonly' : True,
-                        'kiloname' : 'Kbytes',
-                        'meganame' : 'Mbytes',
-                        'bytename' : 'bytes',
-                        'nospace' : True}
-    if configdict is None:
-        configdict = {}
-    for entry in configs:
-        # keyword parameters override the dictionary passed in
-        configdict[entry] = configs[entry]
-    #
-    for keyword in defaultconfigs:
-        if not configdict.has_key(keyword):
-            configdict[keyword] = defaultconfigs[keyword]
-    #
-    if configdict['nospace']:
-        space = ''
-    else:
-        space = ' '
-    #
-    mb, kb, rb = bytedivider(sizeint)
-    if configdict['largestonly']:
-        if mb and not configdict['forcekb']:
-            return stringround(mb, kb)+ space + configdict['meganame']
-        elif kb or configdict['forcekb']:
-            if mb and configdict['forcekb']:
-                kb += 1024*mb
-            return stringround(kb, rb) + space+ configdict['kiloname']
-        else:
-            return str(rb) + space + configdict['bytename']
-    else:
-        outstr = ''
-        if mb and not configdict['forcekb']:
-            outstr = str(mb) + space + configdict['meganame'] +', '
-        if kb or configdict['forcekb'] or mb:
-            if configdict['forcekb']:
-                kb += 1024*mb 
-            outstr += str(kb) + space + configdict['kiloname'] +', '
-        return outstr + str(rb) + space + configdict['bytename']
-
-def stringround(main, rest):
-    """
-    Given a file size in either (mb, kb) or (kb, bytes) - round it
-    appropriately.
-    """
-    # divide an int by a float... get a float
-    value = main + rest/1024.0
-    return str(round(value, 1))
-
-def bytedivider(nbytes):
-    """
-    Given an integer (probably a long integer returned by os.getsize() )
-    it returns a tuple of (megabytes, kilobytes, bytes).
-    
-    This can be more easily converted into a formatted string to display the
-    size of the file.
-    """ 
-    mb, remainder = divmod(nbytes, 1048576)
-    kb, rb = divmod(remainder, 1024)
-    return (mb, kb, rb)
-
-