Mercurial > hg > decoupage
annotate decoupage/formats.py @ 55:47acf12d01e1
merge commit
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 18 Nov 2010 08:19:06 -0800 |
parents | 0e2b9e0507c5 a2f09d749a3f |
children | 884e6c805208 |
rev | line source |
---|---|
54
0e2b9e0507c5
add documentation for formats and a stub
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
1 """ |
0e2b9e0507c5
add documentation for formats and a stub
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
2 pluggable formats for directory listings |
0e2b9e0507c5
add documentation for formats and a stub
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
3 """ |
0e2b9e0507c5
add documentation for formats and a stub
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
4 |
49
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 try: |
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 import json as json |
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 except ImportError: |
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 import simplejson as json |
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 |
54
0e2b9e0507c5
add documentation for formats and a stub
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
10 # TODO: convert this to a class |
49
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 def format_json(data): |
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 |
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 # fix datetime |
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 for f in data['files']: |
52
a2f09d749a3f
work towards refactor letting links (and maybe other things in the future) dwell in a decoupage namespace
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
15 if 'modified' in f: |
a2f09d749a3f
work towards refactor letting links (and maybe other things in the future) dwell in a decoupage namespace
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
16 f['modified'] = f['modified'].ctime() |
49
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 |
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 return 'application/json', json.dumps(data['files']) |
ac693b8df32c
add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 |
54
0e2b9e0507c5
add documentation for formats and a stub
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
20 class RSS(object): |
0e2b9e0507c5
add documentation for formats and a stub
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
21 |
0e2b9e0507c5
add documentation for formats and a stub
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
22 def __init__(self, n=10): |
0e2b9e0507c5
add documentation for formats and a stub
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
23 pass |