Skip to content

Commit

Permalink
Added forgotten kwargs to RoadwayNetwork init
Browse files Browse the repository at this point in the history
+ some PEP8
  • Loading branch information
e-lo committed Mar 4, 2021
1 parent 37cd673 commit 6ed2240
Show file tree
Hide file tree
Showing 12 changed files with 355 additions and 313 deletions.
2 changes: 1 addition & 1 deletion network_wrangler/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setupLogging(
level: the level of logging that will be recorded
log_filename: the location of the log file that will get created to add the DEBUG log
log_to_console: if True, logging will go to the console at INFO level
"""
"""

if level is None:
WranglerLogger.setLevel(logging.DEBUG)
Expand Down
39 changes: 18 additions & 21 deletions network_wrangler/projectcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class ProjectCard(object):

def __init__(self, attribute_dictonary: dict):
"""
Constructor for Project Card object.
Constructor for Project Card object.
args:
attribute_dictonary: a nested dictionary of project card attributes.
attribute_dictonary: a nested dictionary of project card attributes.
"""
# add these first so they are first on write out
self.project = None
Expand All @@ -64,8 +64,8 @@ def read(card_filename: str, validate: bool = True):
Reads and validates a Project card
args:
card_filename: The path to the project card file.
validate: Boolean indicating if the project card should be validated. Defaults to True.
card_filename: The path to the project card file.
validate: Boolean indicating if the project card should be validated. Defaults to True.
Returns a Project Card object
"""
Expand Down Expand Up @@ -124,7 +124,7 @@ def read_yml(card_filename: str) -> dict:
Reads "normal" wrangler project cards defined in YAML.
Args:
card_filename: file location where the project card is.
card_filename: file location where the project card is.
Returns: Attribute Dictionary for Project Card
"""
Expand All @@ -141,8 +141,8 @@ def write(self, out_filename: str = None):
Writes project card dictionary to YAML file.
args:
out_filename: file location to write the project card object as yml.
If not provided, will write to current directory using the project name as the filename.
out_filename: file location to write the project card object as yml.
If not provided, will write to current directory using the project name as the filename.
"""
if not out_filename:
from network_wrangler.utils import make_slug
Expand All @@ -164,12 +164,11 @@ def write(self, out_filename: str = None):

@staticmethod
def validate_project_card_schema(
card_filename: str,
card_schema_filename: str = "project_card.json"
card_filename: str, card_schema_filename: str = "project_card.json"
) -> bool:
"""
Tests project card schema validity by evaluating if it conforms to the schemas
args:
card_filename: location of project card .yml file
card_schema_filename: location of project card schema to validate against. Defaults to project_card.json.
Expand All @@ -195,12 +194,16 @@ def validate_project_card_schema(
except ValidationError as exc:
WranglerLogger.error("Failed Project Card validation: Validation Error")
WranglerLogger.error("Project Card File Loc:{}".format(card_filename))
WranglerLogger.error("Project Card Schema Loc:{}".format(card_schema_filename))
WranglerLogger.error(
"Project Card Schema Loc:{}".format(card_schema_filename)
)
WranglerLogger.error(exc.message)

except SchemaError as exc:
WranglerLogger.error("Failed Project Card schema validation: Schema Error")
WranglerLogger.error("Project Card Schema Loc:{}".format(card_schema_filename))
WranglerLogger.error(
"Project Card Schema Loc:{}".format(card_schema_filename)
)
WranglerLogger.error(exc.message)

except yaml.YAMLError as exc:
Expand Down Expand Up @@ -233,18 +236,15 @@ def build_link_selection_query(

selection_keys = [k for l in selection["link"] for k, v in l.items()]

unique_link_ids_sel = list( set(unique_link_ids) & set(selection_keys) )
unique_link_ids_sel = list(set(unique_link_ids) & set(selection_keys))

for l in selection["link"]:
for key, value in l.items():

if key in ignore:
continue

if (
unique_link_ids_sel
and key not in unique_link_ids
):
if unique_link_ids_sel and key not in unique_link_ids:
continue

count = count + 1
Expand All @@ -269,10 +269,7 @@ def build_link_selection_query(
):
sel_query = sel_query + " and "

if (
unique_link_ids_sel
and count != len(unique_link_ids_sel)
):
if unique_link_ids_sel and count != len(unique_link_ids_sel):
sel_query = sel_query + " and "

if not unique_link_ids_sel:
Expand Down
Loading

0 comments on commit 6ed2240

Please sign in to comment.