Mercurial > hg > decoupage
comparison decoupage/formatters.py @ 70:262fb90a54b4
make template loading lenient and other fixes; bump version
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 04 Aug 2012 15:55:52 -0700 |
parents | 4094bee13154 |
children | ebf3d3c39cb7 |
comparison
equal
deleted
inserted
replaced
69:9fac58348520 | 70:262fb90a54b4 |
---|---|
15 """ | 15 """ |
16 | 16 |
17 defaults = {} # default values for attrs to be set on the instance | 17 defaults = {} # default values for attrs to be set on the instance |
18 | 18 |
19 def __init__(self, string): | 19 def __init__(self, string): |
20 self._string = string | |
20 args = [ i.strip() for i in string.split(',')] | 21 args = [ i.strip() for i in string.split(',')] |
21 for index, arg in enumerate(args): | 22 for index, arg in enumerate(args): |
22 if '=' in arg: | 23 if '=' in arg: |
23 break | 24 break |
24 else: | 25 else: |
172 # XXX what about setting the page title? | 173 # XXX what about setting the page title? |
173 | 174 |
174 defaults = { 'separator': ':' } | 175 defaults = { 'separator': ':' } |
175 | 176 |
176 def __call__(self, request, data): | 177 def __call__(self, request, data): |
178 | |
179 # title webpage | |
180 title = self._string | |
181 if ':' in title: | |
182 _title, url = [i.strip() for i in title.split(':', 1)] | |
183 if '://' in url: | |
184 # XXX could also use urlparse | |
185 title = _title | |
186 data['link'] = url | |
187 data['title'] = title | |
188 | |
189 # title files | |
177 for f in data['files']: | 190 for f in data['files']: |
178 if f['description'] and self.separator in f['description']: | 191 if f['description'] and self.separator in f['description']: |
179 title, description = f['description'].split(self.separator, 1) | 192 title, description = f['description'].split(self.separator, 1) |
180 title = title.strip() | 193 title = title.strip() |
181 description = description.strip() | 194 description = description.strip() |