Skip to content

Commit

Permalink
Only parse schema once
Browse files Browse the repository at this point in the history
  • Loading branch information
tillywoodfield committed Jul 17, 2024
1 parent 483943c commit 400666a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions iatidata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ def create_activities_table():
)


@functools.lru_cache
def get_activities_schema() -> xmlschema.XMLSchema10:
return xmlschema.XMLSchema(
str(
pathlib.Path()
/ "__iatikitcache__/standard/schemas/203/iati-activities-schema.xsd"
)
)


def get_standard(refresh=False):
if not (pathlib.Path() / "__iatikitcache__").is_dir() or refresh:
logger.info("Downloading standard")
Expand Down Expand Up @@ -238,12 +248,7 @@ def parse_activities_from_dataset(
return

transform = etree.XSLT(etree.parse(str(this_dir / "iati-activities.xsl")))
schema = xmlschema.XMLSchema(
str(
pathlib.Path()
/ "__iatikitcache__/standard/schemas/203/iati-activities-schema.xsd"
)
)
schema = get_activities_schema()

schema_dict = get_sorted_schema_dict()

Expand Down

0 comments on commit 400666a

Please sign in to comment.