aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/parsers.py
diff options
context:
space:
mode:
authorTom Christie2012-01-21 18:33:34 +0000
committerTom Christie2012-01-21 18:33:34 +0000
commitdea4a45ec72d0bd3cfeeb9382f177eb2fc3b0e14 (patch)
tree99c9824ee53d6e57546eceb3551546cf72585c85 /djangorestframework/parsers.py
parenta851294d052174b53531fdf90b22ddac8738e374 (diff)
downloaddjango-rest-framework-dea4a45ec72d0bd3cfeeb9382f177eb2fc3b0e14.tar.bz2
pep8/pyflakes cleanup
Diffstat (limited to 'djangorestframework/parsers.py')
-rw-r--r--djangorestframework/parsers.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/djangorestframework/parsers.py b/djangorestframework/parsers.py
index 8fd1acbc..c8a014ae 100644
--- a/djangorestframework/parsers.py
+++ b/djangorestframework/parsers.py
@@ -115,6 +115,7 @@ if yaml:
else:
YAMLParser = None
+
class PlainTextParser(BaseParser):
"""
Plain text parser.
@@ -194,11 +195,11 @@ class XMLParser(BaseParser):
def _xml_convert(self, element):
"""
- convert the xml `element` into the corresponding python object
+ convert the xml `element` into the corresponding python object
"""
-
+
children = element.getchildren()
-
+
if len(children) == 0:
return self._type_convert(element.text)
else:
@@ -206,14 +207,14 @@ class XMLParser(BaseParser):
if children[0].tag == "list-item":
data = []
for child in children:
- data.append(self._xml_convert(child))
- else:
+ data.append(self._xml_convert(child))
+ else:
data = {}
for child in children:
data[child.tag] = self._xml_convert(child)
return data
-
+
def _type_convert(self, value):
"""
Converts the value returned by the XMl parse into the equivalent
@@ -223,7 +224,7 @@ class XMLParser(BaseParser):
return value
try:
- return datetime.datetime.strptime(value,'%Y-%m-%d %H:%M:%S')
+ return datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S')
except ValueError:
pass
@@ -240,11 +241,12 @@ class XMLParser(BaseParser):
return value
-DEFAULT_PARSERS = ( JSONParser,
- FormParser,
- MultiPartParser,
- XMLParser
- )
+DEFAULT_PARSERS = (
+ JSONParser,
+ FormParser,
+ MultiPartParser,
+ XMLParser
+)
if YAMLParser:
- DEFAULT_PARSERS += ( YAMLParser, )
+ DEFAULT_PARSERS += (YAMLParser,)