changeset 88:c382bdd01751

directory indicator
author Jeff Hammel <k0scist@gmail.com>
date Sun, 12 Jan 2014 19:20:16 -0800
parents ced29a73c561
children fca150947fb1
files decoupage/cli.py decoupage/formatters.py setup.py
diffstat 3 files changed, 26 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/decoupage/cli.py	Tue Dec 31 02:01:17 2013 -0800
+++ b/decoupage/cli.py	Sun Jan 12 19:20:16 2014 -0800
@@ -13,7 +13,7 @@
 import socket
 import sys
 
-from .formatters import Datestamp, Sort, Up
+from .formatters import Datestamp, Sort, Up, DirectoryIndicator
 from .web import Decoupage
 from wsgiref import simple_server
 
@@ -27,7 +27,10 @@
         Decoupage.__init__(self, **kwargs)
         # default formatters
         # TODO: make configurable
-        self._formatters = [Sort(), Up('..'), Datestamp('modified: %m %d, %Y')]
+        self._formatters = [Sort(),
+                            DirectoryIndicator('/'),
+                            Up('..'),
+                            Datestamp('modified: %m %d, %Y')]
     def get_formatters(self, path):
         return self._formatters
 
--- a/decoupage/formatters.py	Tue Dec 31 02:01:17 2013 -0800
+++ b/decoupage/formatters.py	Sun Jan 12 19:20:16 2014 -0800
@@ -137,6 +137,20 @@
             files.append(file_hash.get(f, None))
         files = [ i for i in files if i is not None ]
 
+class DirectoryIndicator(FormatterBase):
+    """indicate a directory"""
+    indicator = '/'
+    def __init__(self, indicator):
+        self.indicator = indicator.strip() or self.indicator
+    def __call__(self, request, data):
+        for f in data['files']:
+            if f.get('type') == 'directory':
+                title = f.get('title')
+                if title is not None:
+                    f['title'] = '%s %s' % (title, self.indicator)
+                else:
+                    description = f.get('description') or f['name']
+                    f['description'] = '%s %s' % (description, self.indicator)
 
 class FilenameDescription(FormatterBase):
     """
@@ -144,6 +158,7 @@
     the file extension (if any) will be dropped and
     spaces will be substituted for underscores
     """
+
     # TODO : deal with CamelCaseFilenames
 
     separators = ['_', '-'] # space substitute separators
@@ -238,7 +253,6 @@
     fatal = False
     defaults = {'separator': ';'}
 
-
     def __call__(self, request, data):
         for f in data['files']:
             if f['description'] and self.separator in f['description']:
@@ -314,7 +328,8 @@
     def __call__(self, request, data):
         data['include'] = self.include
 
-###
+
+### general purpose functions for formatters
 
 def formatters():
     formatters = {}
--- a/setup.py	Tue Dec 31 02:01:17 2013 -0800
+++ b/setup.py	Sun Jan 12 19:20:16 2014 -0800
@@ -1,4 +1,4 @@
-from setuptools import setup, find_packages
+from setuptools import setup
 
 # use README as long_description
 try:
@@ -6,7 +6,7 @@
 except IOError:
     description = ''
 
-version = '0.13.0'
+version = '0.13.1'
 
 setup(name='decoupage',
       version=version,
@@ -17,7 +17,7 @@
       author_email='k0scist@gmail.com',
       url='http://k0s.org/hg/decoupage',
       license="GPL",
-      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
+      packages=['decoupage'],
       include_package_data=True,
       zip_safe=False,
       install_requires=[
@@ -49,6 +49,7 @@
       all = decoupage.formatters:All
       css = decoupage.formatters:CSS
       datestamp = decoupage.formatters:Datestamp
+      directory = decoupage.formatters:DirectoryIndicator
       describe = decoupage.formatters:FilenameDescription
       icon = decoupage.formatters:Favicon
       ignore = decoupage.formatters:Ignore