Skip to content

Commit

Permalink
remove load_anchored_holdings function
Browse files Browse the repository at this point in the history
use load_holdings instead
  • Loading branch information
mscarey committed Oct 9, 2021
1 parent 62e1756 commit e6af6fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 43 deletions.
40 changes: 3 additions & 37 deletions authorityspoke/io/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
from authorityspoke.io.name_index import Mentioned


def load_anchored_holdings(
def load_holdings(
filename: Optional[str] = None,
directory: Optional[pathlib.Path] = None,
filepath: Optional[pathlib.Path] = None,
) -> Dict[str, Union[Dict[str, RawFactor], Dict[str, RawEnactment], List[RawHolding]]]:
) -> List[RawHolding]:
r"""
Load list of records from YAML or JSON to create :class:`.Holding`\s with text selectors.
Expand Down Expand Up @@ -62,40 +62,6 @@ def load_anchored_holdings(
return holdings


def load_holdings(
filename: Optional[str] = None,
directory: Optional[pathlib.Path] = None,
filepath: Optional[pathlib.Path] = None,
) -> Dict[str, Union[Dict[str, RawFactor], Dict[str, RawEnactment], List[RawHolding]]]:
r"""
Load a list of records from JSON to create :class:`.Holding`\s.
:param filename:
the name of the JSON file to look in for :class:`Holding`
data in the format that lists ``mentioned_factors``
followed by a list of holdings.
:param directory:
the path of the directory containing the JSON file.
:param filepath:
Complete path to the XML file representing the :class:`.Code`,
including filename.
:returns:
a list of :class:`Holding`\s from a JSON file in the
``example_data/holdings`` subdirectory, from a JSON
file.
"""
holdings = load_anchored_holdings(
filename=filename, directory=directory, filepath=filepath
)

if isinstance(holdings, Dict):
return holdings["holdings"]
return holdings


def read_holdings_from_file(
filename: Optional[str] = None,
directory: Optional[pathlib.Path] = None,
Expand Down Expand Up @@ -156,7 +122,7 @@ def read_anchored_holdings_from_file(
>>> print(result.holdings[0].outputs[0])
the fact that <Mazza-Alaluf> operated <Turismo Costa Brava> without an appropriate money transmitting license in a State where such operation was punishable as a misdemeanor or a felony under State law
"""
raw_holdings = load_anchored_holdings(
raw_holdings = load_holdings(
filename=filename, directory=directory, filepath=filepath
)
return readers.read_holdings_with_anchors(raw_holdings, client=client)
Expand Down
8 changes: 2 additions & 6 deletions tests/io/test_holding.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
from authorityspoke.procedures import Procedure
from authorityspoke.io import loaders, readers, name_index
from authorityspoke.io.fake_enactments import FakeClient
from authorityspoke.io.loaders import (
load_holdings,
read_holdings_from_file,
load_anchored_holdings,
)
from authorityspoke.io.loaders import load_holdings, read_holdings_from_file
from authorityspoke.io import filepaths, text_expansion
from authorityspoke.rules import Rule

Expand Down Expand Up @@ -211,7 +207,7 @@ def test_read_holdings_and_then_get_anchors(self, make_response):
impossible to get text anchors.
"""
mock_client = FakeClient(responses=make_response)
raw_holdings = load_anchored_holdings(f"holding_oracle.yaml")
raw_holdings = load_holdings(f"holding_oracle.yaml")
loaded = readers.read_holdings_with_anchors(raw_holdings, client=mock_client)

assert isinstance(loaded.holdings[0], HoldingWithAnchors)
Expand Down

0 comments on commit e6af6fd

Please sign in to comment.