Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4a2f187

Browse files
author
Alex Schworer
committed
Allow for the JSON module to be configured.
Set `ZENCODER_PY_JSON_MODULE` to `simplejson` to use simplejson insteadof the built-in json module.
1 parent7a853f3 commit4a2f187

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

‎README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ client = Zencoder('API_KEY')
2828
client= Zencoder()
2929
```
3030

31+
####Configuring the JSON Module
32+
33+
By default, zencoder-py uses the built-in`json` module, but you can optionally configure it to use`simplejson` by setting the`ZENCODER_PY_JSON_MODULE` environment variable to`simplejson`. Note that zencoder-py will not install either module, it must already be installed.
34+
3135
##[Jobs](https://app.zencoder.com/docs/api/jobs)
3236

3337
Create a[new job](https://app.zencoder.com/docs/api/jobs/create).

‎zencoder/core.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22
importrequests
33
fromdatetimeimportdatetime
44

5-
# Note: I've seen this pattern for dealing with json in different versions of
6-
# python in a lot of modules -- if there's a better way, I'd love to use it.
7-
try:
8-
# python 2.6 and greater
9-
importjson
10-
exceptImportError:
11-
try:
12-
# python 2.5
13-
importsimplejson
14-
json=simplejson
15-
exceptImportError:
16-
# if we're in django or Google AppEngine land
17-
# use this as a last resort
18-
fromdjango.utilsimportsimplejson
19-
json=simplejson
5+
json_module=os.environ.get('ZENCODER_PY_JSON_MODULE','json')
6+
valid_json_modules= ('json','simplejson')
7+
ifjson_modulenotinvalid_json_modules:
8+
msg='ZENCODER_PY_JSON_MODULE=%s is not supported. Supported JSON modules: %s'% (json_module,', '.join(valid_json_modules))
9+
raiseRuntimeError(msg)
10+
11+
json=__import__(json_module)
2012

2113
__version__='0.6.5'
2214

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp