annotate decoupage/formats.py @ 49:ac693b8df32c

add idea of formats and json format
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 03 Nov 2010 08:18:50 -0700
parents
children a2f09d749a3f 0e2b9e0507c5
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']:
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 f['modified'] = f['modified'].ctime()
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 return 'application/json', json.dumps(data['files'])
ac693b8df32c add idea of formats and json format
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13