Skip to content

Commit 1dfda97

Browse files
committed
PEP8
1 parent 437b7a6 commit 1dfda97

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

github3/converters.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
#
4-
# author: David Medina
3+
54
from .core import Converter
65

6+
77
class Rawlizer(Converter):
88
""" Raw converter """
99

@@ -16,6 +16,7 @@ def loads(self, raw_resource):
1616
def dumps(self):
1717
pass
1818

19+
1920
class Json(Converter):
2021
""" Json converter """
2122

@@ -32,6 +33,7 @@ def loads(self, raw_resource):
3233
def dumps(self):
3334
pass
3435

36+
3537
class Modelizer(Converter):
3638
""" Own model converter """
3739

@@ -52,18 +54,18 @@ def inject(self, model):
5254
self.model = model
5355

5456
def _parse_map(self, model, raw_resource):
55-
if getattr(raw_resource, 'items', False):
57+
if hasattr(raw_resource, 'items'):
5658
return Modelizer(model).loads(raw_resource)
5759

5860
def _parse_collection_map(self, model, raw_resources):
5961
# Dict of resources (Ex: Gist file)
60-
if getattr(raw_resources, 'items', False):
62+
if hasattr(raw_resources, 'items'):
6163
dict_map = {}
6264
for key, raw_resource in raw_resources.items():
6365
dict_map[key] = Modelizer(model).loads(raw_resource)
6466
return dict_map
6567
# list of resources
66-
elif getattr(raw_resources, '__iter__', False):
68+
elif hasattr(raw_resources, '__iter__'):
6769
return [Modelizer(model).loads(raw_resource)
6870
for raw_resource in raw_resources]
6971

@@ -74,24 +76,24 @@ def loads(self, raw_resource):
7476
self.__class__.__name__)
7577
idl = self.model.idl()
7678
attrs.update(
77-
{attr: raw_resource[attr] for attr in idl.get('strs',())
79+
{attr: raw_resource[attr] for attr in idl.get('strs', ())
7880
if attr in raw_resource})
7981
attrs.update(
80-
{attr: raw_resource[attr] for attr in idl.get('ints',())
82+
{attr: raw_resource[attr] for attr in idl.get('ints', ())
8183
if attr in raw_resource})
8284
attrs.update(
8385
{attr: self._parse_date(raw_resource[attr])
84-
for attr in idl.get('dates',()) if attr in raw_resource})
86+
for attr in idl.get('dates', ()) if attr in raw_resource})
8587
attrs.update(
86-
{attr: raw_resource[attr] for attr in idl.get('bools',())
88+
{attr: raw_resource[attr] for attr in idl.get('bools', ())
8789
if attr in raw_resource})
8890
attrs.update(
8991
{attr: self._parse_map(model, raw_resource[attr])
90-
for attr, model in idl.get('maps',{}).items()
92+
for attr, model in idl.get('maps', {}).items()
9193
if attr in raw_resource})
9294
attrs.update(
9395
{attr: self._parse_collection_map(model, raw_resource[attr])
94-
for attr, model in idl.get('collection_maps',{}).items()
96+
for attr, model in idl.get('collection_maps', {}).items()
9597
if attr in raw_resource})
9698

9799
return self.model(attrs)

0 commit comments

Comments
 (0)