Skip to content

Commit

Permalink
Ran black
Browse files Browse the repository at this point in the history
  • Loading branch information
elliott authored and elliott committed Dec 30, 2020
1 parent 35557f4 commit fb6323e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 17 deletions.
4 changes: 3 additions & 1 deletion bin/bop_custom
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ if __name__ == "__main__":
default=False,
)

parser.add_argument("-o", "--output", help="Output file", action="store", default=None)
parser.add_argument(
"-o", "--output", help="Output file", action="store", default=None
)

args = parser.parse_args()

Expand Down
4 changes: 3 additions & 1 deletion bin/bop_download_data
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ if __name__ == "__main__":
action="store_true",
default=False,
)
parser.add_argument("-o", "--output", help="Ouptut Path", action="store", default=None)
parser.add_argument(
"-o", "--output", help="Ouptut Path", action="store", default=None
)

args = parser.parse_args()
timestamp = datetime.datetime.now().strftime("%Y%m%d")
Expand Down
14 changes: 8 additions & 6 deletions lib/bankofparliament/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def convert_commons_members_interests(self):
target="House of Commons",
text=["Member of the House of Commons"],
link=DATA_PARLIAMENT_LINK_URL.format(member["@Member_Id"], "contact"),
amount=self.get_house_of_commons_salary()
amount=self.get_house_of_commons_salary(),
)

# government relationship
Expand Down Expand Up @@ -245,7 +245,7 @@ def convert_lords_members_interests(self):
target="House of Lords",
text=["Member of the House of Lords"],
link=DATA_PARLIAMENT_LINK_URL.format(member["@Member_Id"], "contact"),
amount=self.get_house_of_lords_salary(member)
amount=self.get_house_of_lords_salary(member),
)

# government relationship
Expand Down Expand Up @@ -321,9 +321,7 @@ def convert_spads(self):
relationship_type="advisor_to",
source=name,
target=resolved_employer,
text=[
"An advisor to {}".format(resolved_employer)
],
text=["An advisor to {}".format(resolved_employer)],
link=SPADS_URL,
)
self.add_relationship(
Expand Down Expand Up @@ -422,7 +420,11 @@ def add_government_relationship(self, member):
source=member["DisplayAs"],
relationship_type="member_of",
target="Her Majesty's Government",
text=["Employed as {} for Her Majesty's Government".format(post["Name"])],
text=[
"Employed as {} for Her Majesty's Government".format(
post["Name"]
)
],
amount=self.get_government_salary(post),
link=DATA_PARLIAMENT_LINK_URL.format(
member["@Member_Id"], "contact"
Expand Down
11 changes: 9 additions & 2 deletions lib/bankofparliament/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

# local libs
from .utils import get_request
from .constants import DATA_PARLIAMENT_QUERY_URL, THEYWORKFORYOU_QUERY_URL, HEADERS, SPADS_URL
from .constants import (
DATA_PARLIAMENT_QUERY_URL,
THEYWORKFORYOU_QUERY_URL,
HEADERS,
SPADS_URL,
)

# third party libs
import scraperwiki
Expand Down Expand Up @@ -82,7 +87,9 @@ def get_spads_pdf(self):
else:
self.logger.warning("Failed to download special advisors pdf")
else:
self.logger.debug("Special advisors pdf already downloaded: {}".format(self.spads_path))
self.logger.debug(
"Special advisors pdf already downloaded: {}".format(self.spads_path)
)

def get_theyworkforyou_quota(self):
"""Log the current theyworkforyou api quota"""
Expand Down
17 changes: 13 additions & 4 deletions lib/bankofparliament/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def merge_entities(self, entities, new):
new_name = new_entity["name"]
new_aliases = new_entity["aliases"].lower().split(";")

filt = (entities["name"] == new_name)
filt = entities["name"] == new_name
existing_entities = entities.loc[filt]

if len(existing_entities):
Expand All @@ -98,7 +98,9 @@ def merge_entities(self, entities, new):
new_entities.append(new_entity.to_dict())

if len(new_entities):
entities = pandas.concat([entities, pandas.DataFrame(new_entities)], ignore_index=True)
entities = pandas.concat(
[entities, pandas.DataFrame(new_entities)], ignore_index=True
)

return entities

Expand Down Expand Up @@ -127,12 +129,19 @@ def extract_entities_from_relationships(self):
)
continue

if relationship["source"] == "UNKNOWN" and relationship["target"] == "UNKNOWN":
if (
relationship["source"] == "UNKNOWN"
and relationship["target"] == "UNKNOWN"
):
# family lobbyist
resolved_source = self.get_target_from_previous_relationship(index)
if resolved_source:
relationship["source"] = resolved_source
relationship["text"] = relationship["text"].lower().replace(resolved_source.lower(), "")
relationship["text"] = (
relationship["text"]
.lower()
.replace(resolved_source.lower(), "")
)

elif relationship["source"] == "UNKNOWN":
resolved_source = self.get_missing_source_entity(relationship)
Expand Down
4 changes: 3 additions & 1 deletion lib/bankofparliament/graphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
class GraphDB:
"""Generates neo4j database"""

def __init__(self, host, port, user, password, entities, relationships, limit, logger):
def __init__(
self, host, port, user, password, entities, relationships, limit, logger
):
"""Initialise the neo4j graphdb class"""
self.logger = logger
self.host = host
Expand Down
1 change: 0 additions & 1 deletion lib/bankofparliament/relationships/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ def find_alias_from_text(
)
return entity


alias_entity_types = (
alias_entity_types if alias_entity_types else self.ALIAS_ENTITY_TYPES
)
Expand Down
4 changes: 3 additions & 1 deletion lib/bankofparliament/relationships/relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ def solve(self):

elif self.entity_type == "union":
entity = self.find_alias_from_text(
text=entry, alias_entity_types=["union", "person"], prefered_entity_types=["union"] # accounting for bug
text=entry,
alias_entity_types=["union", "person"],
prefered_entity_types=["union"], # accounting for bug
)
if entity:
self.extracted_entities.append(entity)
Expand Down

0 comments on commit fb6323e

Please sign in to comment.