Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
python 2.7 fixes
  • Loading branch information
genaromadrid committed Jun 14, 2016
1 parent 9a6aaa3 commit 73886dc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 5 additions & 1 deletion mifiel/api_auth/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def build(self, method, url, body, content_md5=None, content_type=None, httpdate
if not body:
body = ''
if isinstance(body, str):
m.update(body.encode('ascii'))
try:
m.update(body.encode('ascii'))
# For Python 2.7
except(UnicodeDecodeError):
m.update(body)
else:
m.update(body)

Expand Down
9 changes: 7 additions & 2 deletions mifiel/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from mifiel import Response
import requests
from os.path import basename

class Base(object):
def __init__(self, client, path):
Expand All @@ -26,8 +25,14 @@ def url(self, path=None):
def process_request(self, method, url=None, data=None, files=None):
if not url:
url = self.url()

if method == 'post':
response = requests.post(url, auth=self.client.auth, data=data, files=files)
response = requests.post(
url=url,
auth=self.client.auth,
data=data,
files=files
)
elif method == 'put':
response = requests.put(url, auth=self.client.auth, json=data)
elif method == 'get':
Expand Down
2 changes: 1 addition & 1 deletion mifiel/certificate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from mifiel import Base

class Document(Base):
class Certificate(Base):
def __init__(self, client):
Base.__init__(self, client, 'keys')
7 changes: 5 additions & 2 deletions mifiel/document.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from mifiel import Base
import mimetypes
from os.path import basename

class Document(Base):
def __init__(self, client):
Expand All @@ -21,8 +22,10 @@ def create(client, signatories, file=None, dhash=None, callback_url=None):
sig_numbers = {}

for index, item in enumerate(signatories):
for key, val in item.iteritems():
sig_numbers.update({'signatories['+str(index)+']['+str(key)+']':val})
for key, val in item.items():
sig_numbers.update(
{'signatories[' + str(index) + '][' + str(key) + ']': val}
)

data = sig_numbers

Expand Down

0 comments on commit 73886dc

Please sign in to comment.