metawards.WardInfos¶
-
class
metawards.
WardInfos
(wards: List[metawards._wardinfo.WardInfo] = <factory>, _index: Dict[metawards._wardinfo.WardInfo, int] = None)[source]¶ Simple class that holds a list of WardInfo objects, and provides useful search functions over that list. This prevents me from cluttering up the interface of Network
-
__init__
(wards: List[metawards._wardinfo.WardInfo] = <factory>, _index: Dict[metawards._wardinfo.WardInfo, int] = None) → None¶
Methods
__init__
(wards, _index, int] = None)contains
(info)Return whether or not this contains the passed WardInfo find
(name, authority, region, match, …)Generic search function that will search using any or all of the terms provided. index
(info)Return the index of the passed ‘info’ object if it is in this list. reindex
()Rebuild the WardInfo index. -
__contains__
(info: metawards._wardinfo.WardInfo) → bool[source]¶ Return whether or not this contains the passed WardInfo
-
__setitem__
(i: int, info: metawards._wardinfo.WardInfo) → None[source]¶ Set the ith WardInfo equal to ‘info’.
-
contains
(info: metawards._wardinfo.WardInfo) → bool[source]¶ Return whether or not this contains the passed WardInfo
-
find
(name: str = None, authority: str = None, region: str = None, match: bool = False, match_authority_and_region: bool = False, include_alternates: bool = True)[source]¶ Generic search function that will search using any or all of the terms provided. This returns a list of indicies of wards that match the search
Parameters: - name (str or regexp) – Name or code of the ward to search. You can also include the authority adn region by separating usign “/”, e.g. “Clifton/Bristol”.
- authority (str or regexp) – Name or code of the authority to search
- region (str or regexp) – Name or code of the region to search
- match (bool(False)) – Use a regular expression match for the ward rather than a search. This forces the match to be at the start of the string
- match_authority_and_region (bool(False)) – Use a regular expression match for the authority and region rather than a search. This forces the match to be at the start of the string
- include_alternates (bool(True)) – Whether or not to include alternative names and codes when searching for the ward
-
index
(info: metawards._wardinfo.WardInfo) → int[source]¶ Return the index of the passed ‘info’ object if it is in this list. If not, then a ValueError exception is raised. Note that only the first matching WardInfo will be returned
-
reindex
()[source]¶ Rebuild the WardInfo index. You must call this function after you have modified the list of WardInfo objects, as otherwise this will fall out of date. Note that this will be automatically called the first time you use the “contains” or “index” functions
-
wards
= None¶ The list of WardInfo objects, one for each ward in order
-