diff --git a/v0.3.1/404.html b/v0.3.1/404.html new file mode 100644 index 0000000..e4b269b --- /dev/null +++ b/v0.3.1/404.html @@ -0,0 +1,525 @@ + + + +
+ + + + + + + + + + + + + + +from projectcard.io import read_cards
+
+# Read in cards from a directory with the tag "Baseline 2030"
+project_cards = read_cards(directory, filter_tags=["Baseline2030"])
+
+# Iterate through a deck of cards for validity
+for project_name,card in project_cards.items():
+ print(f"{project_name}: {card.valid}")
+
+# Print out a summary of the card with the project name "4th Ave Busway"
+print(project_cards["4th Ave Busway"])
+
Project Card class for project card data schema.
+ + + +ProjectCard
+
+
+ ¶Representation of a Project Card.
+ + +Attributes:
+Name | +Type | +Description | +
---|---|---|
__dict__ |
+ + | +
+
+
+ Dictionary of project card attributes + |
+
project |
+ + | +
+
+
+ Name of project + |
+
dependencies |
+
+ dict
+ |
+
+
+
+ Dependencies of project + |
+
tags |
+
+ list[str]
+ |
+
+
+
+ Tags of project + |
+
notes |
+
+ str
+ |
+
+
+
+ Notes about project + |
+
valid |
+
+ bool
+ |
+
+
+
+ Boolean indicating if data conforms to project card data schema + |
+
facilities |
+
+ list[dict]
+ |
+
+
+
+ List of all facility objects in project card + |
+
facility |
+
+ Union[str, dict]
+ |
+
+
+
+ either singular facility in project card or the string “multiple” + |
+
all_property_changes |
+
+ Union[str, dict]
+ |
+
+
+
+ List of all property_changes objects in project card + |
+
property_changes |
+
+ Union[str, dict]
+ |
+
+
+
+ either singular property_changes in project card or the string “multiple” + |
+
change_types |
+
+ list[str]
+ |
+
+
+
+ List of all project types in project card + |
+
change_type |
+
+ str
+ |
+
+
+
+ either singular project type in project card or the string “multiple” + |
+
sub_projects |
+
+ str
+ |
+
+
+
+ list of sub_project objects + |
+
projectcard/projectcard.py
30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 |
|
all_transit_property_changes: list[dict]
+
+
+ property
+
+
+ ¶Return all transit property changes from project card.
+all_transit_routing_changes: list[dict]
+
+
+ property
+
+
+ ¶Return all transit routing changes from project card.
+change_type: str
+
+
+ property
+
+
+ ¶Return single change type if single project or “multiple” if >1 subproject.
+change_types: list[str]
+
+
+ property
+
+
+ ¶Returns list of all change types from project/subproject.
+facilities: list[dict]
+
+
+ property
+
+
+ ¶Return all facilities from project card as list of dicts.
+facility: Union[str, dict]
+
+
+ property
+
+
+ ¶Return facility part of project card or “multiple” if more than one.
+service: Union[str, dict]
+
+
+ property
+
+
+ ¶Return service part of from project card or “multiple” if more than one.
+services: list[dict]
+
+
+ property
+
+
+ ¶Return all services from project card as list of dicts.
+to_dict: dict
+
+
+ property
+
+
+ ¶Return dictionary of public project card attributes.
+transit_property_change: Union[str, dict]
+
+
+ property
+
+
+ ¶Return transit property change from project card or “multiple if more than one.
+transit_routing_change: Union[str, dict]
+
+
+ property
+
+
+ ¶Return transit routing change from project card.
+valid: bool
+
+
+ property
+
+
+ ¶Return True if project card is valid, False otherwise.
+__init__(attribute_dictonary, use_defaults=True)
+
+ ¶Constructor for ProjectCard object.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
attribute_dictonary |
+
+ dict
+ |
+
+
+
+ a nested dictionary of attributes + |
+ + required + | +
use_defaults |
+
+ bool
+ |
+
+
+
+ if True, will use default values for missing required attributes, +if exist in schema. Defaults to True. + |
+
+ True
+ |
+
projectcard/projectcard.py
__str__()
+
+ ¶SubProject
+
+
+ ¶Representation of a SubProject within a ProjectCard.
+ + +Attributes:
+Name | +Type | +Description | +
---|---|---|
parent_project |
+
+ ProjectCard
+ |
+
+
+
+ reference to parent ProjectCard object + |
+
type |
+
+ ProjectCard
+ |
+
+
+
+ project type + |
+
tags |
+
+ list[str]
+ |
+
+
+
+ reference to parent project card tags + |
+
dependencies |
+
+ dict
+ |
+
+
+
+ reference to parent project card’s dependencies + |
+
project |
+
+ str
+ |
+
+
+
+ reference to the name of the parent project card’s name + |
+
facility |
+
+ dict
+ |
+
+
+
+ facility selection dictionary + |
+
property_changes |
+
+ dict
+ |
+
+
+
+ property_changes dictionary + |
+
projectcard/projectcard.py
190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 |
|
change_type: str
+
+
+ property
+
+
+ ¶Return change type from subproject.
+dependencies: dict
+
+
+ property
+
+
+ ¶Return dependencies from parent project card.
+facility: dict
+
+
+ property
+
+
+ ¶Return facility dictionary from subproject.
+parent_project: ProjectCard
+
+
+ property
+
+
+ ¶Return parent project from parent project card.
+project: str
+
+
+ property
+
+
+ ¶Return project name from parent project card.
+tags: list[str]
+
+
+ property
+
+
+ ¶Return tags from parent project card.
+valid: bool
+
+
+ property
+
+
+ ¶Check if subproject is valid.
+__init__(sp_dictionary, parent_project)
+
+ ¶Constructor for SubProject object.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sp_dictionary |
+
+ dict
+ |
+
+
+
+ dictionary of sub-project attributes contained within “changes” +list of parent projet card + |
+ + required + | +
parent_project |
+
+ ProjectCard
+ |
+
+
+
+ ProjectCard object for parent project card + |
+ + required + | +
projectcard/projectcard.py
Functions for reading and writing project cards.
+ + + +dict_to_yaml_with_comments(d)
+
+ ¶Converts a dictionary to a YAML string with comments.
+ +projectcard/io.py
read_card(filepath, validate=False)
+
+ ¶Read single project card from a path and return project card object.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
filepath |
+
+ ProjectCardFilepath
+ |
+
+
+
+ file where the project card is. + |
+ + required + | +
validate |
+
+ bool
+ |
+
+
+
+ if True, will validate the project card schemea + |
+
+ False
+ |
+
projectcard/io.py
read_cards(filepath, filter_tags=None, recursive=False, base_path=DEFAULT_BASE_PATH, existing_projects=None)
+
+ ¶Reads collection of project card files by inferring the file type.
+Lowercases all keys, but then replaces any that need to be uppercased using the +REPLACE_KEYS mapping. Needed to keep “A” and “B” uppercased.
+If a path is given as a relative path, it will be resolved to an absolute path using +the base_path.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
filepath |
+
+ ProjectCardFilepaths
+ |
+
+
+
+ where the project card is. A single path, list of paths, +a directory, or a glob pattern. + |
+ + required + | +
filter_tags |
+
+ Optional[list[str]]
+ |
+
+
+
+ list of tags to filter by. + |
+
+ None
+ |
+
recursive |
+
+ bool
+ |
+
+
+
+ if True, will search recursively in subdirs. + |
+
+ False
+ |
+
base_path |
+
+ Path
+ |
+
+
+
+ base path to resolve relative paths from. Defaults to current working directory. + |
+
+ DEFAULT_BASE_PATH
+ |
+
existing_projects |
+
+ Optional[list[str]]
+ |
+
+
+
+ list of existing project names to check for uniqueness. + |
+
+ None
+ |
+
projectcard/io.py
write_card(project_card, filename=None)
+
+ ¶Writes project card dictionary to YAML file.
+ +projectcard/io.py
Validates ProjectCard JSON data against a JSON schema.
+ + + +package_schema(schema_path=PROJECTCARD_SCHEMA, outfile_path=None)
+
+ ¶Consolidates referenced schemas into a single schema and writes it out.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
schema_path |
+
+ Union[Path, str]
+ |
+
+
+
+ Schema to read int and package. Defaults to PROJECTCARD_SCHEMA which is + ROOTDIR / “schema” / “projectcard.json”. + |
+
+ PROJECTCARD_SCHEMA
+ |
+
outfile_path |
+
+ Optional[Union[Path, str]]
+ |
+
+
+
+ Where to write out packaged schema. Defaults +to schema_path.basepath.packaged.json + |
+
+ None
+ |
+
projectcard/validate.py
update_dict_with_schema_defaults(data, schema=PROJECTCARD_SCHEMA)
+
+ ¶Recursively update missing required properties with default values.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
data |
+
+ dict
+ |
+
+
+
+ The data dictionary to update. + |
+ + required + | +
schema |
+
+ Union[Path, dict]
+ |
+
+
+
+ The schema dictionary or path to the schema file. + |
+
+ PROJECTCARD_SCHEMA
+ |
+
Returns:
+Type | +Description | +
---|---|
+ dict
+ |
+
+
+
+ The updated data dictionary. + |
+
projectcard/validate.py
validate_card(jsondata, schema_path=PROJECTCARD_SCHEMA, parse_defaults=True)
+
+ ¶Validates json-like data to specified schema.
+If pycode
key exists, will evaluate it for basic runtime errors using Flake8.
+Note: will not flag any invalid use of RoadwayNetwork or TransitNetwork APIs.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
jsondata |
+
+ dict
+ |
+
+
+
+ json-like data to validate. + |
+ + required + | +
schema_path |
+
+ Path
+ |
+
+
+
+ path to schema to validate to. +Defaults to PROJECTCARD_SCHEMA which is +ROOTDIR / “schema” / “projectcard.json” + |
+
+ PROJECTCARD_SCHEMA
+ |
+
parse_defaults |
+
+ bool
+ |
+
+
+
+ if True, will use default values for missing required attributes. + |
+
+ True
+ |
+
Raises:
+Type | +Description | +
---|---|
+ ValidationError
+ |
+
+
+
+ If jsondata doesn’t conform to specified schema. + |
+
+ SchemaError
+ |
+
+
+
+ If schema itself is not valid. + |
+
projectcard/validate.py
validate_schema_file(schema_path=PROJECTCARD_SCHEMA)
+
+ ¶Validates that a schema file is a valid JSON-schema.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
schema_path |
+
+ Path
+ |
+
+
+
+ description. Defaults to PROJECTCARD_SCHEMA which is +ROOTDIR / “schema” / “projectcard.json”. + |
+
+ PROJECTCARD_SCHEMA
+ |
+
projectcard/validate.py