Skip to main content

AssemblyLine.al_courts

Package for a very simple / MVP list of courts that is mostly signature compatible w/ MACourts for now

ALCourt Objects

class ALCourt(Court)

Object representing a court in Massachusetts. TODO: it could be interesting to store a jurisdiction on a court. But this is non-trivial. Should it be geo boundaries? A list of cities? A list of counties? Instead, we use a function on the CourtList object that filters courts by address and can use any of those three features of the court to do the filtering.

short_label

Returns a string that represents a nice, disambiguated label for the court. This may not match the court's name. If the name omits city, we append city name to the court name. This is good for a drop-down selection list.

Returns:

  • str - string representing the court's name, with city if needed to disambiguate

short_label_and_address

Returns a markdown formatted string with the name and address of the court. More concise version without description; suitable for a responsive case.

Returns:

  • str - string representing the court's name and address

short_description

Returns a Markdown formatted string that includes the disambiguated name and the description of the court, for inclusion in the results page with radio buttons.

Returns:

  • str - string representing the court's name and description

from_row

Loads data from a single Pandas Dataframe into the current court object. Note: It will try to convert column names that don't make valid attributes. Best practice is to use good attribute names (no spaces) that don't interfere with existing attributes or methods of DAObject

Arguments:

  • df_row - Pandas Series object
  • ensure_lat_long - bool, whether to use Google Maps to geocode the address if we don't have coordinates

geolocate

Use Google Maps to geocode the court's address and store the result in the location attribute.

Deprecated: use geocode() instead.

geocode

Use Google Maps to geocode the court's address and store the result in the location attribute.

ALCourtLoader Objects

class ALCourtLoader(DAObject)

Object to hold some methods surrounding loading/filtering courts.

Built around Pandas dataframe.

Attributes:

  • filename str - Path to the file containing court information.
  • converters Dict[str, Callable] - A dictionary of functions to apply to columns in the dataframe.

all_courts

Return a list of all courts in the spreadsheet.

Returns:

List[Dict[int, str]]: List of all ALCourt instances without filtering.

unique_column_values

Retrieve a set of unique values present in a specified dataframe column.

Arguments:

  • column_name str - The name of the column in the dataframe.

Returns:

  • Set[str] - A set containing unique values from the specified column. Returns an empty set if an error occurs.

county_list

Get a set of all unique names for the specified column in the given spreadsheet. Typically used to get a list of all possible counties that have a court.

Arguments:

  • column_name str - The name of the column in the dataframe.

Returns:

  • Set[str] - A list of all unique values in the specified row in the given spreadsheet

county_has_one_court

Returns True if there is only one court associated with the specified county in the spreadsheet. Returns False otherwise.

Arguments:

  • county_name str - The name of the county to check.
  • county_column str - The name of the column in the dataframe that contains the county names. Defaults to "address_county".

Returns:

  • bool - True if there is only one court associated with the specified county in the spreadsheet.

county_court

Return the first court matching the county name. Should only be used when you know there is exactly one match

Arguments:

  • intrinsicName str - The intrinsic name you want the newly returned object to have (used for DA namespace searching).
  • county_name str - The name of the county to check.
  • county_column str - The name of the column in the dataframe that contains the county names. Defaults to "address_county".

Returns:

  • ALCourt - The first court matching the county name.

matching_courts_in_county

Retrieve a list of all courts in the specified county.

This function fetches courts suitable for displaying as a drop-down or radio button list in Docassemble. The results are dictionaries where the key is the index in the dataframe, useful for retrieving the court's full details later using the as_court() method.

Arguments:

  • county_name str - Name of the county.
  • county_column str, optional - Column heading which contains county name. Defaults to "address_county".
  • display_column str, optional - Column heading used for display in the drop-down. Defaults to "name".
  • search_string Optional[str], optional - A keyword to filter the list of results. Defaults to None.
  • search_columns Optional[Union[List[str], str]], optional - Columns to aggregate and search across with the search_string in a case-insensitive manner. Defaults to None.

Returns:

List[Dict[int, str]]: List of dictionaries representing matching courts.

filter_courts

Return a filtered subset of courts represented as a list of dictionaries.

Each dictionary has the format {index: name}, where "index" refers to the dataframe index and "name" is determined by the display_column.

Arguments:

  • court_types Optional[Union[List[str], str]] - Exact string match or matches used to filter results (inclusive). Examples include "District" or ["Municipal","Superior"].
  • column str, optional - Column heading to search. Defaults to "department".
  • display_column str, optional - Column heading used for display in the drop-down. Defaults to "name".
  • search_string Optional[str], optional - A keyword to filter the list of results. Defaults to None.
  • search_columns Optional[Union[List[str], str]], optional - Columns to aggregate and search across with the search_string in a case-insensitive manner. Defaults to None.

Returns:

List[Dict[int, str]]: List of dictionaries representing filtered courts.

as_court

Retrieve the court at the specified index as an ALCourt object.

Arguments:

  • intrinsicName str - The intrinsic name you want to assign to the returned object (used for DA namespace searching).
  • index Union[int, str] - The index position of the court in the dataframe.
  • ensure_lat_long bool, optional - Whether to ensure the presence of latitude and longitude data. Defaults to True.

Returns:

  • ALCourt - An ALCourt object initialized with data from the specified index.