Skip to content

Commit 332a704

Browse files
committed
Format headers with .format() instead of string concatenation
1 parent de4e6a4 commit 332a704

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

zencoder/core.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
import httplib2
33
from urllib import urlencode
44

5-
# Library version. Should probably be rewritten to match the version in setup.py
6-
lib_version = 0.5;
7-
85
# Note: I've seen this pattern for dealing with json in different versions of
96
# python in a lot of modules -- if there's a better way, I'd love to use it.
107
try:
@@ -61,15 +58,16 @@ def headers(self):
6158
""" Returns default headers, by setting the Content-Type and Accepts
6259
headers.
6360
"""
64-
if self.as_xml:
65-
content_type = 'xml'
66-
else :
67-
content_type = 'json'
61+
content_type = 'xml' if self.as_xml else 'json'
62+
63+
headers = {
64+
'Content-Type': 'application/{0}'.format(content_type),
65+
'Accepts': 'application/{0}'.format(content_type),
66+
'Zencoder-Api-Key': self.api_key,
67+
'User-Agent': 'zencoder-py'
68+
}
6869

69-
return {'Content-Type': 'application/' + content_type,
70-
'Accepts': 'application/' + content_type,
71-
'User-Agent': 'Zencoder-Py v' + str(lib_version),
72-
'Zencoder-Api-Key': self.api_key}
70+
return headers
7371

7472
def encode(self, data):
7573
"""

0 commit comments

Comments
 (0)