Skip to content

Commit

Permalink
[#2477] Fix a bunch of whitespace and indentation issues
Browse files Browse the repository at this point in the history
    find akvo/ -name "*.py" |grep -v __init__.py|grep -v migration|xargs \
    autopep8 -i --select \
    E221,E241,E251,E271,E272,E115,E122,E123,E124,E125,E126,E127,E128,E231,E203,E225,E226,W291,E228,E201,E202,W293
  • Loading branch information
punchagan committed Dec 5, 2016
1 parent 8b080f1 commit 56e4c28
Show file tree
Hide file tree
Showing 54 changed files with 366 additions and 366 deletions.
4 changes: 2 additions & 2 deletions akvo/iati/checks/fields/crs_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def crs_add(project):
str(flag.pk)))

if not crs.loan_status_year and (crs.loan_status_currency or crs.loan_status_value_date or
crs.interest_received is not None or crs.principal_outstanding is not None or
crs.principal_arrears is not None or crs.interest_arrears is not None):
crs.interest_received is not None or crs.principal_outstanding is not None or
crs.principal_arrears is not None or crs.interest_arrears is not None):
all_checks_passed = False
checks.append((u'error', u'CRS (id: %s) has no loan status year specified' %
str(crs.pk)))
Expand Down
4 changes: 2 additions & 2 deletions akvo/iati/imports/mappers/Cordaid/financials.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def get_budget(self, budget_from):
activity = self.parent_elem
budget_item_data = dict(project=self.project,
label=BudgetItemLabel.objects.get(label='Total'),
other_extra = '',)
other_extra='',)

budget = budget_item_data['budget'] = activity.find(
'budget[@{}="{}"]'.format(akvo_ns('budget-from'), budget_from))
'budget[@{}="{}"]'.format(akvo_ns('budget-from'), budget_from))

if budget is not None:
budget_item_data['type'] = self.get_attrib(budget, 'type', 'type')
Expand Down
10 changes: 5 additions & 5 deletions akvo/iati/imports/mappers/Cordaid/partnerships.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Partnerships(Partnerships):

def __init__(self, iati_import_job, parent_elem, project, globals, related_obj=None):
super(Partnerships, self).__init__(
iati_import_job, parent_elem, project, globals, related_obj)
iati_import_job, parent_elem, project, globals, related_obj)
self._imported_partnerships = []
self._changes = []

Expand All @@ -52,7 +52,7 @@ def add_funding_partner(self, budget_from):
:return:
"""
assert budget_from == "Cordaid" or budget_from == "Others", (
"akvo:budget-from value incorrect: {}".format(budget_from))
"akvo:budget-from value incorrect: {}".format(budget_from))

budget_items = BudgetItems(self.iati_import_job, self.parent_elem, self.project,
self.globals)
Expand Down Expand Up @@ -99,8 +99,8 @@ def do_import(self):
self.add_funding_partner(OTHERS)

self._changes += self.delete_objects(
self.project.partnerships.filter(
iati_organisation_role__lt=Partnership.AKVO_SPONSOR_PARTNER),
self._imported_partnerships, 'partnership')
self.project.partnerships.filter(
iati_organisation_role__lt=Partnership.AKVO_SPONSOR_PARTNER),
self._imported_partnerships, 'partnership')

return self._changes
4 changes: 2 additions & 2 deletions akvo/iati/imports/mappers/CordaidZip/financials.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def get_budget(self, budget_from):
activity = self.parent_elem
budget_item_data = dict(project=self.project,
label=BudgetItemLabel.objects.get(label='Total'),
other_extra = '',)
other_extra='',)

budget = budget_item_data['budget'] = activity.find(
'budget[@{}="{}"]'.format(akvo_ns('budget-from'), budget_from))
'budget[@{}="{}"]'.format(akvo_ns('budget-from'), budget_from))

if budget is not None:
budget_item_data['type'] = self.get_attrib(budget, 'type', 'type')
Expand Down
8 changes: 4 additions & 4 deletions akvo/iati/imports/mappers/CordaidZip/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def do_import(self):

photo_id = self.get_attrib(self.parent_elem, akvo_ns('photo-id'), 'current_image')
current_image = file_from_zip_archive(
self.iati_import_job.iati_xml_file, "out_proj/{}.jpg".format(photo_id))
self.iati_import_job.iati_xml_file, "out_proj/{}.jpg".format(photo_id))
if current_image:
tmp_file = NamedTemporaryFile()
for line in current_image.readlines():
Expand All @@ -43,18 +43,18 @@ def do_import(self):
new_file = File(tmp_file)
if not same_data(old_file, new_file):
filename = model_and_instance_based_filename(
'Project', self.project.pk, 'current_image', 'image.jpg')
'Project', self.project.pk, 'current_image', 'image.jpg')
new_file.seek(0)
self.project.current_image.save(filename, new_file)
changes += ['current_image']

current_image_caption = self.get_attrib(
self.parent_elem, akvo_ns('image-caption'), 'current_image_caption')
self.parent_elem, akvo_ns('image-caption'), 'current_image_caption')
if current_image_caption:
changes += self.update_project_field('current_image_caption', current_image_caption)

current_image_credit = self.get_attrib(
self.parent_elem, akvo_ns('photo-credit'), 'current_image_credit')
self.parent_elem, akvo_ns('photo-credit'), 'current_image_credit')
if current_image_credit:
changes += self.update_project_field('current_image_credit', current_image_credit)

Expand Down
24 changes: 12 additions & 12 deletions akvo/iati/imports/mappers/CordaidZip/organisations.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class InternalOrganisationIDs(ImportMapper):
def __init__(self, iati_import_job, parent_elem, project, globals,
related_obj=None):
super(InternalOrganisationIDs, self).__init__(
iati_import_job, parent_elem, project, globals, related_obj)
iati_import_job, parent_elem, project, globals, related_obj)
self.model = InternalOrganisationID

def do_import(self):
Expand All @@ -40,7 +40,7 @@ class Organisations(ImportMapper):
def __init__(self, iati_import_job, parent_elem, project, globals,
related_obj=None):
super(Organisations, self).__init__(
iati_import_job, parent_elem, project, globals, related_obj)
iati_import_job, parent_elem, project, globals, related_obj)
self.model = Organisation
# HACK: "fix" globals so we get the straight text from elements
self.globals['version'] = '1'
Expand Down Expand Up @@ -92,7 +92,7 @@ def do_import(self):
"""

ioids = InternalOrganisationIDs(
self.iati_import_job, self.parent_elem, self.project, self.globals)
self.iati_import_job, self.parent_elem, self.project, self.globals)
identifier = ioids.get_child_element_text(ioids.parent_elem, 'org_id', 'identifier')
if identifier:
try:
Expand All @@ -107,18 +107,18 @@ def do_import(self):
owner = referenced_org.content_owner
if owner and owner != self.globals['cordaid']:
raise NotOwnedOrganisationException(
"Organisation {}, ID {}, is content owned by {}, ID {}. "
"Can't edit the data.".format(
referenced_org.name, referenced_org.pk,
owner.name, owner.pk
))
"Organisation {}, ID {}, is content owned by {}, ID {}. "
"Can't edit the data.".format(
referenced_org.name, referenced_org.pk,
owner.name, owner.pk
))

org_fields = {}
org_fields['long_name'] = self.get_child_element_text(
self.parent_elem, 'name', 'long_name').strip()
self.parent_elem, 'name', 'long_name').strip()
org_fields['name'] = org_fields['long_name'][:25]
org_fields['new_organisation_type'] = int(self.get_child_element_text(
self.parent_elem, 'iati_organisation_type', 'new_organisation_type', 22))
self.parent_elem, 'iati_organisation_type', 'new_organisation_type', 22))
org_fields['iati_org_id'] = self.get_child_element_text(
self.parent_elem, 'iati_org_id', 'iati_org_id')
org_fields['description'] = self.get_child_element_text(
Expand All @@ -136,8 +136,8 @@ def do_import(self):
organisation.save()
changes, created = None, True
internal_id = InternalOrganisationID.objects.create(
recording_org=self.globals['cordaid'], referenced_org=organisation,
identifier=identifier)
recording_org=self.globals['cordaid'], referenced_org=organisation,
identifier=identifier)

self.set_logo(organisation, identifier)
return organisation, changes, created
10 changes: 5 additions & 5 deletions akvo/iati/imports/mappers/CordaidZip/partnerships.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Partnerships(Partnerships):

def __init__(self, iati_import_job, parent_elem, project, globals, related_obj=None):
super(Partnerships, self).__init__(
iati_import_job, parent_elem, project, globals, related_obj)
iati_import_job, parent_elem, project, globals, related_obj)
self._imported_partnerships = []
self._changes = []

Expand Down Expand Up @@ -49,7 +49,7 @@ def add_funding_partner(self, budget_from):
from . import CORDAID_ORG_ID, OTHERS_ORG_ID, CORDAID

assert budget_from == "Cordaid" or budget_from == "Others", (
"akvo:budget-from value incorrect: {}".format(budget_from))
"akvo:budget-from value incorrect: {}".format(budget_from))

budget_items = BudgetItems(self.iati_import_job, self.parent_elem, self.project,
self.globals)
Expand Down Expand Up @@ -98,8 +98,8 @@ def do_import(self):
self.add_funding_partner(OTHERS)

self._changes += self.delete_objects(
self.project.partnerships.filter(
iati_organisation_role__lt=Partnership.AKVO_SPONSOR_PARTNER),
self._imported_partnerships, 'partnership')
self.project.partnerships.filter(
iati_organisation_role__lt=Partnership.AKVO_SPONSOR_PARTNER),
self._imported_partnerships, 'partnership')

return self._changes
4 changes: 2 additions & 2 deletions akvo/iati/imports/mappers/classifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ def do_import(self):
)
if created:
changes.append(
u'added policy marker (id: {}): {}'.format(policy_marker.pk, policy_marker))
u'added policy marker (id: {}): {}'.format(policy_marker.pk, policy_marker))
imported_markers.append(policy_marker)

changes += self.delete_objects(
self.project.policy_markers, imported_markers, 'policy marker')
self.project.policy_markers, imported_markers, 'policy marker')
return changes
6 changes: 3 additions & 3 deletions akvo/iati/imports/mappers/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Contacts(ImportMapper):
def __init__(self, iati_import_job, parent_elem, project, globals,
related_obj=None):
super(Contacts, self).__init__(
iati_import_job, parent_elem, project, globals)
iati_import_job, parent_elem, project, globals)
self.model = ProjectContact

def do_import(self):
Expand Down Expand Up @@ -42,7 +42,7 @@ def do_import(self):
email = contact.findtext('email', default='').strip()
website = contact.findtext('website', default='').strip()
mailing_address = self.get_child_element_text(
contact, 'mailing-address', 'mailing_address')
contact, 'mailing-address', 'mailing_address')

project_contact, created = ProjectContact.objects.get_or_create(
project=self.project,
Expand All @@ -58,7 +58,7 @@ def do_import(self):
)
if created:
changes.append(
u'added contact (id: {}): {}'.format(project_contact.pk, project_contact))
u'added contact (id: {}): {}'.format(project_contact.pk, project_contact))
imported_contacts.append(project_contact)

changes += self.delete_objects(self.project.contacts, imported_contacts, 'contact')
Expand Down
10 changes: 5 additions & 5 deletions akvo/iati/imports/mappers/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class Dates(ImportMapper):
def do_import(self):
if self.globals['version'][0] == '1':
date_element = self.parent_elem.find(
"activity-date[@type='{}']".format(self.ver_1_date_type))
"activity-date[@type='{}']".format(self.ver_1_date_type))
else:
date_element = self.parent_elem.find(
"activity-date[@type='{}']".format(self.ver_2_date_type))
"activity-date[@type='{}']".format(self.ver_2_date_type))
date = self.get_date(date_element, 'iso-date', self.date_field) if date_element else None
return self.update_project_field(self.date_field, date)

Expand All @@ -24,7 +24,7 @@ class PlannedStartDate(Dates):
def __init__(self, iati_import_job, parent_elem, project, globals,
related_obj=None):
super(PlannedStartDate, self).__init__(
iati_import_job, parent_elem, project, globals)
iati_import_job, parent_elem, project, globals)
self.ver_1_date_type = 'start-planned'
self.ver_2_date_type = '1'
self.date_field = 'date_start_planned'
Expand All @@ -34,7 +34,7 @@ class ActualStartDate(Dates):
def __init__(self, iati_import_job, parent_elem, project, globals,
related_obj=None):
super(ActualStartDate, self).__init__(
iati_import_job, parent_elem, project, globals)
iati_import_job, parent_elem, project, globals)
self.ver_1_date_type = 'start-actual'
self.ver_2_date_type = '2'
self.date_field = 'date_start_actual'
Expand All @@ -44,7 +44,7 @@ class PlannedEndDate(Dates):
def __init__(self, iati_import_job, parent_elem, project, globals,
related_obj=None):
super(PlannedEndDate, self).__init__(
iati_import_job, parent_elem, project, globals)
iati_import_job, parent_elem, project, globals)
self.ver_1_date_type = 'end-planned'
self.ver_2_date_type = '3'
self.date_field = 'date_end_planned'
Expand Down
16 changes: 8 additions & 8 deletions akvo/iati/imports/mappers/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def do_import(self):
"""

project_scope = self.get_child_elem_attrib(
self.parent_elem, 'activity-scope', 'code', 'project_scope')
self.parent_elem, 'activity-scope', 'code', 'project_scope')

return self.update_project_field('project_scope', project_scope)

Expand Down Expand Up @@ -103,7 +103,7 @@ def do_import(self):
"""

default_flow_type = self.get_child_elem_attrib(
self.parent_elem, 'default-flow-type', 'code', 'default_flow_type')
self.parent_elem, 'default-flow-type', 'code', 'default_flow_type')

return self.update_project_field('default_flow_type', default_flow_type)

Expand All @@ -120,7 +120,7 @@ def do_import(self):
"""

default_finance_type = self.get_child_elem_attrib(
self.parent_elem, 'default-finance-type', 'code', 'default_finance_type')
self.parent_elem, 'default-finance-type', 'code', 'default_finance_type')

return self.update_project_field('default_finance_type', default_finance_type)

Expand All @@ -136,7 +136,7 @@ def do_import(self):
"""

default_aid_type = self.get_child_elem_attrib(
self.parent_elem, 'default-aid-type', 'code', 'default_aid_type')
self.parent_elem, 'default-aid-type', 'code', 'default_aid_type')

return self.update_project_field('default_aid_type', default_aid_type)

Expand All @@ -153,7 +153,7 @@ def do_import(self):
"""

default_tied_status = self.get_child_elem_attrib(
self.parent_elem, 'default-tied-status', 'code', 'default_tied_status')
self.parent_elem, 'default-tied-status', 'code', 'default_tied_status')

return self.update_project_field('default_tied_status', default_tied_status)

Expand All @@ -169,7 +169,7 @@ def do_import(self):
"""

iati_status = self.get_child_elem_attrib(
self.parent_elem, 'activity-status', 'code', 'status')
self.parent_elem, 'activity-status', 'code', 'status')

if not iati_status:
self.add_log('activity-status@code', 'iati_status', 'invalid status code')
Expand All @@ -183,7 +183,7 @@ class Conditions(ImportMapper):
def __init__(self, iati_import_job, parent_elem, project, globals,
related_obj=None):
super(Conditions, self).__init__(
iati_import_job, parent_elem, project, globals)
iati_import_job, parent_elem, project, globals)
self.model = ProjectCondition

def do_import(self):
Expand Down Expand Up @@ -211,7 +211,7 @@ def do_import(self):
)
if created:
changes.append(u'added condition (id: {}): {}'.format(
project_condition.pk, project_condition))
project_condition.pk, project_condition))
imported_conditions.append(project_condition)

changes += self.delete_objects(self.project.conditions, imported_conditions, 'condition')
Expand Down
Loading

0 comments on commit 56e4c28

Please sign in to comment.