AssemblyLine.al_general
safe_subdivision_type
Returns the subdivision type for the country with the given country code. If no subdivision type is found, returns None.
Arguments:
country_code
str - The ISO-3166-1 alpha-2 code for the country.
Returns:
Optional[str]
- The subdivision type for the country with the given country code.
ALAddress Objects
class ALAddress(Address)
This class is used to store addresses. The ALAddress class extends the Address
class with the address_fields()
method and "smarter"
handling of the unit attribute when printing a formatted address.
Attributes:
address
str - The street where the person lives.unit
str - The unit number where the person lives.city
str - The city where the person lives.state
str - The state where the person lives.zip
str - The zip code where the person lives.country
str - The country where the person lives.impounded
Optional[bool] - Whether the address is impounded.
address_fields
Return a YAML structure representing the list of fields for the object's address.
Optionally, allow the user to specify they do not have an address. When using
allow_no_address=True
, ensure to trigger the question with users[0].address.has_no_address
rather than users[0].address.address
. If show_if
is used, it will not be applied when
allow_no_address
is also used. Ensure country_code
adheres to ISO-3166-1 alpha-2 code standard.
NOTE: This function is stateful under specific conditions. Refer to the conditions mentioned below.
Arguments:
country_code
Optional[str] - ISO-3166-1 alpha-2 code of the country. Defaults to None.default_state
Optional[str] - Default state to set. Defaults to None.show_country
bool - Whether to display the country field. Defaults to False.show_county
bool - Whether to display the county field. Defaults to False.show_if
Union[str, Dict[str, str], None] - Condition to display each field. Defaults to None.allow_no_address
bool - Allow users to specify they don't have an address. Defaults to False.ask_if_impounded
Optional[bool] - Whether to ask if the address is impounded. Defaults to False.maxlengths
Optional[Dict[str, int]] - A dictionary of field names and their maximum lengths. Defaults to None.
Returns:
List[Dict[str, Any]]: A list of dictionaries representing address fields.
Notes:
- The function will set the
country
attribute of the Address tocountry_code
under these circumstances:
- The
country_code
parameter is used. - The
show_country
parameter is not used. country_code
differs from the value returned byget_country()
.
- Link to ISO-3166-1 alpha-2 codes: Officially assigned code elements.
formatted_unit
Returns the unit, formatted appropriately.
Arguments:
language
str, optional - The language in which to format the unit. Defaults to None (which uses system language).require
bool, optional - A flag indicating whether the unit is required. If set to True, the function will raise an error if the unit attribute does not exist. Defaults to False.bare
bool, optional - A flag indicating whether to add the word 'Unit' before the unit number. If set to True, the function will not add 'Unit' regardless of other conditions. Defaults to False.
Returns:
str: The formatted unit. If the unit attribute does not exist and require is set to False, this will be an empty string. If the unit attribute exists and is not None or an empty string, the function will return the unit number, possibly prefixed with 'Unit'. If the unit attribute exists and is None or an empty string, the function will return an empty string.
block
Returns a one-line formatted address, primarily for geocoding.
Arguments:
language
str, optional - Language for the address format.international
bool - If True, formats the address as an international address. Defaults to False.show_country
bool, optional - If True, includes the country in the formatted address. If None, decides based on the country attribute.bare
bool - If True, excludes certain formatting elements. Defaults to False.long_state
bool - If True, uses the full state name. Defaults to False.show_impounded
bool - If True, shows the address even if impounded. Defaults to False.
Returns:
str
- The one-line formatted address.
line_one
Returns the first line of the address, including the unit number if it exists.
Arguments:
language
str, optional - Language for the address format.bare
bool - If True, excludes certain formatting elements. Defaults to False.show_impounded
bool - If True, shows the address even if impounded. Defaults to False.
Returns:
str
- The first line of the address.
line_two
Returns the second line of the address, including city, state, and postal code.
Arguments:
language
str, optional - Language for the address format.long_state
bool - If True, uses the full state name. Defaults to False.show_impounded
bool - If True, shows the address even if impounded. Defaults to False.
Returns:
str
- The second line of the address.
on_one_line
Returns a one-line formatted address.
Arguments:
include_unit
bool - If True, includes the unit in the formatted address. Defaults to True.omit_default_country
bool - If True, doesn't show the Docassemble default country in the formatted address. Defaults to True.language
str, optional - Language for the address format.show_country
bool, optional - If True, includes the country in the formatted address. If None, decides based on the country attribute.bare
bool - If True, excludes certain formatting elements. Defaults to False.long_state
bool - If True, uses the full state name. Defaults to False.show_impounded
bool - If True, shows the address even if impounded. Defaults to False.
Returns:
str
- The one-line formatted address.
normalized_address
Try geocoding the address, returning the normalized version if successful.
If geocoding is successful, the method returns the "long" normalized version
of the address. All methods, such as my_address.normalized_address().block()
, are
still available on the returned object. However, note that the returned object will
be a standard Address object, not an ALAddress object. If geocoding fails, it returns
the version of the address as entered by the user.
Warning: currently the normalized address will not be redacted if the address is impounded.
Returns:
Union[Address, "ALAddress"]: Normalized address if geocoding is successful, otherwise the original address.
state_name
Returns the full state name based on the state abbreviation.
If a country_code
is provided, it will override the country attribute of the Address
object. Otherwise, the method uses, in order:
- The country code associated with the Address object, and then
- The country set in the global config for the server.
Arguments:
country_code
str, optional - ISO-3166-1 alpha-2 code to override the country attribute of the Address object. For valid codes, refer to: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements
Returns:
str
- The full state name corresponding to the state abbreviation. If an error occurs or the full name cannot be determined, returns the state abbreviation.
ALAddressList Objects
class ALAddressList(DAList)
A class to store a list of ALAddress objects.
Extends the DAList class and specifically caters to ALAddress objects. It provides methods to initialize the list and get a string representation of the list in a formatted manner.
init
Standard DAObject init method.
Arguments:
*pargs
- Positional arguments**kwargs
- Keyword arguments
__str__
Provide a string representation of the ALAddressList.
This method returns the addresses in the list formatted in a comma-separated manner using the on_one_line method of ALAddress.
Returns:
str
- Formatted string of all addresses in the list.
ALNameList Objects
class ALNameList(DAList)
A class to store a list of IndividualName objects.
Extends the DAList class and is tailored for IndividualName objects.
init
Standard DAObject init method.
Arguments:
*pargs
- Positional arguments**kwargs
- Keyword arguments
__str__
Provide a string representation of the ALNameList.
Returns:
str
- Formatted string of all names in the list.
ALPeopleList Objects
class ALPeopleList(DAList)
Class to store a list of ALIndividual objects, representing people.
For example, defendants, plaintiffs, or children.
init
Standard DAObject init method.
Arguments:
*pargs
- Positional arguments**kwargs
- Keyword arguments
names_and_addresses_on_one_line
Provide names and addresses of individuals on one line.
Arguments:
comma_string
str, optional - The string to use between name-address pairs. Defaults to '; '.bare
bool, optional - If True, prevents appending the word "Unit" to the unit attribute. Defaults to False.
Returns:
str
- Formatted string of names followed by addresses.
familiar
Provide a list of familiar forms of names of individuals.
Arguments:
**kwargs
- Keyword arguments to pass to the familiar method.
Returns:
str
- Formatted string of familiar names.
familiar_or
Provide a list of familiar forms of names of individuals separated by 'or'.
Arguments:
**kwargs
- Keyword arguments to pass to the familiar method.
Returns:
str
- Formatted string of familiar names separated by 'or'.
short_list
Return a subset of the list, truncated with 'et. al.' if it exceeds a given limit.
Arguments:
limit
int - The maximum number of items to display before truncating.truncate_string
str, optional - The string to append when truncating. Defaults to ', et. al.'.
Returns:
str
- Formatted string of names, truncated if needed.
full_names
Return a formatted list of full names of individuals.
Arguments:
comma_string
str, optional - The string to use between names. Defaults to ','.and_string
str, optional - The string to use before the last name in the list. Defaults to 'and'.
Returns:
str
- Formatted string of full names.
pronoun_reflexive
Returns the appropriate reflexive pronoun for the list of people, depending
on the person
keyword argument and the number of items in the list.
If the list is singular, return the reflexive pronoun for the first item in the list. If it is plural, return the appropriate plural reflexive pronoun (e.g., "themselves")
Arguments:
**kwargs
- Additional keyword arguments that are defined upstream.- person (Optional[[Union[str,int]]): Whether to use a first, second, or third person pronoun. Can be one of 1/"1p", 2/"2p", or 3/"3p" (default is 3). See upstream documentation for more information.
- default (Optional[str]): The default word to use if the pronoun is not defined, e.g. "the agent". If not defined, the default term is the user's name.
Returns:
str
- The reflexive pronoun for the list.
ALIndividual Objects
class ALIndividual(Individual)
Used to represent an Individual on the assembly line project.
This class extends the Individual class and adds more tailored attributes and methods relevant for the assembly line project. Specifically, it has attributes for previous addresses, other addresses, mailing addresses, previous names, aliases, and a preferred name.
Attributes:
previous_addresses
ALAddressList - List of previous addresses.other_addresses
ALAddressList - List of other addresses.mailing_address
ALAddress - Current mailing address.service_address
ALAddress - Service address.previous_names
ALNameList - List of previous names.aliases
ALNameList - List of aliases.preferred_name
IndividualName - The preferred name.
Notes:
Objects as attributes should not be passed directly to the constructor due to
initialization requirements in the Docassemble framework. See the init
method.
init
Standard DAObject init method.
Arguments:
*pargs
- Positional arguments**kwargs
- Keyword arguments
signature_if_final
Returns the individual's signature if i
is "final", which usually means we are assembling the final version of the document (as opposed to a preview).
Arguments:
i
str - The condition which, if set to "final", returns the signature.
Returns:
Union[DAFile, str]: The signature if the condition is met, otherwise an empty string.
phone_numbers
Fetches and formats the phone numbers of the individual.
Arguments:
country
str, optional - The country for phone number formatting. Defaults to the country of the docassemble server.show_impounded
bool - If True, shows the phone numbers even if impounded. Defaults to False.
Returns:
str
- Formatted string of phone numbers.
contact_methods
Generates a formatted string of all provided contact methods.
Returns:
str
- A formatted string indicating the available methods to contact the individual.
merge_letters
If the Individual has a child_letters attribute, add the new letters to the existing list
Avoid using. Only used in 209A.
Arguments:
new_letters
str - The new letters to add to the existing list of letters