Consensus.utils module
Utility functions
This module contains helper functions that can be used alone or they are used by more than one of the classes.
where_clause_maker()
function is used to create a SQL where clause for downloading data from Esri servers.
read_lookup()
is used by the SmartLinker()
to build a graph and read_service_table()
is used by FeatureServer()
to select the right Esri service from a pickle file. Both the lookup and the pickle file are created during the lookup building.
- Consensus.utils.read_lookup(lookup_folder=None, server_name=None)
Read lookup table.
- Parameters:
lookup_folder (Path) –
pathlib.Path()
to the folder wherelookup.json
file is currently saved.server_name (str) – The name of the server. For
EsriConnector()
sub-classes, this is the same asself._name
.
- Returns:
Lookup table as a Pandas dataframe.
- Return type:
pd.DataFrame
- Consensus.utils.read_service_table(parent_path=PosixPath('/home/runner/work/Consensus/Consensus/Consensus'), esri_server=None)
Read service table pickle file.
- Parameters:
parent_path (Path) –
pathlib.Path()
to the folder where the Esri server pickle file is currently saved.esri_server (str) – The name of the Esri server. For instance, for Open Geography Portal, this would be Open_Geography_Portal. This can be output from any Esri server using the
_name
method.
- Return type:
Dict
[str
,Any
]- Returns:
Dict[str, Layer]
- Consensus.utils.where_clause_maker(values, column)
Create a SQL where clause for Esri ArcGIS servers based on a list of values in a column and that column’s name. You must also include the layer’s name.
- Parameters:
values (List) – A list of values in
column
to include in the where clause.column (str) – The column name to use in the where clause.
- Returns:
A SQL where clause.
- Return type:
str