Mercurial > hg > decoupage
comparison decoupage/web.py @ 92:c5895d87c65e
lets get these ordered
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sat, 27 Dec 2014 10:49:58 -0800 |
parents | fca150947fb1 |
children | 21273cdb2047 |
comparison
equal
deleted
inserted
replaced
91:4a9c5cf9fec9 | 92:c5895d87c65e |
---|---|
1 """ | 1 """ |
2 decoupage: a dynamic file server | 2 decoupage: a dynamic file server |
3 """ | 3 """ |
4 | 4 |
5 # TODO: | 5 # TODO: |
6 | |
6 # handle files with `#`s like like `#index.ini` | 7 # handle files with `#`s like like `#index.ini` |
7 # -> http://k0s.org/portfolio/ideas/#index.ini# | 8 # -> http://k0s.org/portfolio/ideas/#index.ini# |
8 # | 9 # |
9 # oops. Handle it better | 10 # oops. Handle it better |
10 # - either # is a magic hide character | 11 # - either # is a magic hide character |
11 # - or you urlescape that guy | 12 # - or you urlescape that guy |
12 | 13 |
14 # OrderedDict | |
15 | |
13 import os | 16 import os |
14 import sys | 17 import sys |
15 | 18 |
19 from collections import OrderedDict | |
16 from contenttransformer.app import FileTypeTransformer | 20 from contenttransformer.app import FileTypeTransformer |
17 from contenttransformer.app import transformers | 21 from contenttransformer.app import transformers |
18 from datetime import datetime | 22 from datetime import datetime |
19 from formatters import formatters | 23 from formatters import formatters |
20 from genshi.builder import Markup | 24 from genshi.builder import Markup |
27 from pkg_resources import load_entry_point | 31 from pkg_resources import load_entry_point |
28 from pkg_resources import resource_filename | 32 from pkg_resources import resource_filename |
29 from webob import Request, Response, exc | 33 from webob import Request, Response, exc |
30 | 34 |
31 transformers = transformers() | 35 transformers = transformers() |
32 | |
33 string = (str, unicode) | 36 string = (str, unicode) |
34 | 37 |
35 class Decoupage(object): | 38 class Decoupage(object): |
36 | 39 |
37 ### class level variables | 40 ### class level variables |
242 | 245 |
243 | 246 |
244 ### internal methods | 247 ### internal methods |
245 | 248 |
246 def filedata(self, path, directory, conf=None): | 249 def filedata(self, path, directory, conf=None): |
247 conf = conf or {} | 250 conf = conf or OrderedDict() |
248 files = [] | 251 files = [] |
249 | 252 |
250 # get data for files | 253 # get data for files |
251 filenames = os.listdir(directory) | 254 filenames = os.listdir(directory) |
252 for i in filenames: | 255 for i in filenames: |
305 | 308 |
306 # return cached configuration | 309 # return cached configuration |
307 if hasattr(self, '_conf') and path_tuple in self._conf: | 310 if hasattr(self, '_conf') and path_tuple in self._conf: |
308 return self._conf[path_tuple] | 311 return self._conf[path_tuple] |
309 | 312 |
310 conf = {} | 313 conf = OrderedDict() |
311 | 314 |
312 # local configuration | 315 # local configuration |
313 ini_path = os.path.join(directory, 'index.ini') | 316 ini_path = os.path.join(directory, 'index.ini') |
314 if os.path.exists(ini_path): | 317 if os.path.exists(ini_path): |
315 _conf = ConfigMunger(ini_path).dict() | 318 _conf = ConfigMunger(ini_path).dict() |