annotate decoupage/formats.py @ 52:a2f09d749a3f

work towards refactor letting links (and maybe other things in the future) dwell in a decoupage namespace
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 16 Nov 2010 21:14:25 -0800
parents ac693b8df32c
children 47acf12d01e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 try:
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 import json as json
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 except ImportError:
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 import simplejson as json
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 def format_json(data):
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 # fix datetime
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 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
10 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
11 f['modified'] = f['modified'].ctime()
49
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 return 'application/json', json.dumps(data['files'])
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14