Skip to content

Commit 6a7a572

Browse files
committed
Purge legacy CLI aliases and compatibility shims
1 parent 5a44075 commit 6a7a572

File tree

12 files changed

+25
-124
lines changed

12 files changed

+25
-124
lines changed

geocompare/interfaces/cli.py

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,18 @@ def __init__(self):
4343
version=f"geocompare {__version__}",
4444
)
4545

46-
build_parser = subparsers.add_parser(
47-
"build",
48-
aliases=["createdb", "ingest", "c"],
49-
help="build data products from source files",
50-
)
46+
build_parser = subparsers.add_parser("build", help="build data products from source files")
5147
build_parser.add_argument("path", help="path to data files")
5248
build_parser.set_defaults(func=self.create_data_products)
5349

54-
query_parser = subparsers.add_parser(
55-
"query", aliases=["view", "show", "q", "v"], help="query and compare geographies"
56-
)
50+
query_parser = subparsers.add_parser("query", help="query and compare geographies")
5751
query_subparsers = query_parser.add_subparsers(
5852
help="enter geocompare query <command> -h for details",
5953
dest="query_command",
6054
required=True,
6155
)
6256

63-
search_parser = query_subparsers.add_parser(
64-
"search", aliases=["find", "lookup", "s"], help="search place names"
65-
)
57+
search_parser = query_subparsers.add_parser("search", help="search place names")
6658
search_parser.add_argument("query", help="search query")
6759
search_parser.add_argument("-n", type=int, default=15, help="number of results to display")
6860
search_parser.add_argument(
@@ -76,9 +68,7 @@ def __init__(self):
7668
)
7769
search_parser.set_defaults(func=self.display_label_search)
7870

79-
profile_parser = query_subparsers.add_parser(
80-
"profile", aliases=["dp"], help="show one demographic profile"
81-
)
71+
profile_parser = query_subparsers.add_parser("profile", help="show one demographic profile")
8272
profile_parser.add_argument("display_label", help="the exact place name")
8373
profile_parser.add_argument(
8474
"--profile-view",
@@ -88,16 +78,14 @@ def __init__(self):
8878
)
8979
profile_parser.set_defaults(func=self.get_dp)
9080

91-
similar_parser = query_subparsers.add_parser(
92-
"similar", aliases=["gv"], help="show nearest geovectors"
93-
)
81+
similar_parser = query_subparsers.add_parser("similar", help="show nearest geovectors")
9482
similar_parser.add_argument("display_label", help="the exact place name")
9583
self._add_context_args(similar_parser)
9684
similar_parser.add_argument("-n", type=int, default=15, help="number of rows to display")
9785
similar_parser.set_defaults(func=self.compare_geovectors)
9886

9987
similar_app_parser = query_subparsers.add_parser(
100-
"similar-app", aliases=["gva"], help="show nearest geovectors (appearance mode)"
88+
"similar-app", help="show nearest geovectors (appearance mode)"
10189
)
10290
similar_app_parser.add_argument("display_label", help="the exact place name")
10391
self._add_context_args(similar_app_parser)
@@ -106,32 +94,24 @@ def __init__(self):
10694
)
10795
similar_app_parser.set_defaults(func=self.compare_geovectors_app)
10896

109-
top_parser = query_subparsers.add_parser(
110-
"top", aliases=["hv", "highest"], help="show highest values by component"
111-
)
97+
top_parser = query_subparsers.add_parser("top", help="show highest values by component")
11298
self._add_rank_args(top_parser)
11399
top_parser.set_defaults(func=self.extreme_values)
114100

115-
bottom_parser = query_subparsers.add_parser(
116-
"bottom", aliases=["lv", "lowest"], help="show lowest values by component"
117-
)
101+
bottom_parser = query_subparsers.add_parser("bottom", help="show lowest values by component")
118102
self._add_rank_args(bottom_parser)
119103
bottom_parser.set_defaults(func=self.lowest_values)
120104

121105
nearest_parser = query_subparsers.add_parser(
122-
"nearest",
123-
aliases=["cg", "closest", "near"],
124-
help="show closest geographies by distance",
106+
"nearest", help="show closest geographies by distance"
125107
)
126108
nearest_parser.add_argument("display_label", help="the exact place name")
127109
self._add_filter_arg(nearest_parser)
128110
self._add_context_args(nearest_parser)
129111
nearest_parser.add_argument("-n", type=int, default=15, help="number of rows to display")
130112
nearest_parser.set_defaults(func=self.closest_geographies)
131113

132-
dist_parser = query_subparsers.add_parser(
133-
"distance", aliases=["d", "dist"], help="distance between two places"
134-
)
114+
dist_parser = query_subparsers.add_parser("distance", help="distance between two places")
135115
dist_parser.add_argument("display_label_1", help="first place")
136116
dist_parser.add_argument("display_label_2", help="second place")
137117
dist_parser.add_argument(
@@ -140,7 +120,7 @@ def __init__(self):
140120
dist_parser.set_defaults(func=self.distance)
141121

142122
resolve_parser = subparsers.add_parser(
143-
"resolve", aliases=["key", "id"], help="resolve a place string to canonical IDs"
123+
"resolve", help="resolve a place string to canonical IDs"
144124
)
145125
resolve_parser.add_argument("query", help="input place string to resolve")
146126
resolve_parser.add_argument("--state", help="optional state filter, e.g. ca")
@@ -158,9 +138,7 @@ def __init__(self):
158138
)
159139
resolve_parser.set_defaults(func=self.resolve_geography)
160140

161-
export_parser = subparsers.add_parser(
162-
"export", aliases=["tocsv", "csv", "e", "t"], help="export data as CSV"
163-
)
141+
export_parser = subparsers.add_parser("export", help="export data as CSV")
164142
export_subparsers = export_parser.add_subparsers(
165143
help="enter geocompare export <command> -h for details",
166144
dest="export_command",
@@ -179,7 +157,7 @@ def __init__(self):
179157
export_rows_parser.set_defaults(func=self.rows)
180158

181159
export_profile_parser = export_subparsers.add_parser(
182-
"profile", aliases=["dp"], help="export one demographic profile to CSV"
160+
"profile", help="export one demographic profile to CSV"
183161
)
184162
export_profile_parser.add_argument("display_label", help="the exact place name")
185163
export_profile_parser.add_argument(
@@ -208,23 +186,18 @@ def _add_rank_args(self, parser):
208186

209187
def _add_filter_arg(self, parser):
210188
parser.add_argument(
211-
"-f",
212-
"--geofilter",
189+
"-w",
213190
"--where",
214191
dest="geofilter",
215-
help=(
216-
"filter criteria; supports legacy 'comp:op:value' and modern "
217-
"'comp>=value' formats"
218-
),
192+
help="filter criteria in modern form (for example: population>=100000)",
219193
)
220194

221195
def _add_context_args(self, parser):
222196
parser.add_argument(
223-
"-c",
224-
"--context",
197+
"-s",
225198
"--scope",
226199
dest="context",
227-
help="legacy scope string (for example: places+ca, 050+06075:county, 94103)",
200+
help="scope string (for example: places+ca, 050+06075:county, 94103)",
228201
)
229202
parser.add_argument(
230203
"--universe",

geocompare/models/demographic_profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, db_row):
2323
self.sumlevel = db_row['SUMLEVEL']
2424
# self.key = db_row['KEY']
2525

26-
# CountyTools instance and county data
26+
# County lookup instance and county data
2727
ct = self._ct
2828
# County GEOIDs
2929
if self.sumlevel == '160': # Place

geocompare/models/geovector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(
2626
self.geoid = db_row['GEOID']
2727
self.name = db_row['NAME']
2828

29-
# CountyTools instance and county data
29+
# County lookup instance and county data
3030
ct = self._ct
3131
self.counties = []
3232
self.counties_display = []

geocompare/tools/CountyTools.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

geocompare/tools/KeyTools.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

geocompare/tools/StateTools.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

geocompare/tools/SummaryLevelTools.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

geocompare/tools/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
from geocompare.tools.county_key_index import CountyKeyIndex
22
from geocompare.tools.county_lookup import CountyLookup
3-
4-
# Backward-compatible aliases.
5-
from geocompare.tools.CountyTools import CountyTools
6-
from geocompare.tools.KeyTools import KeyTools
73
from geocompare.tools.numeric import parse_float, parse_int, parse_number, safe_divide
84
from geocompare.tools.state_lookup import StateLookup
9-
from geocompare.tools.StateTools import StateTools
105
from geocompare.tools.summary_level_parser import SummaryLevelParser
11-
from geocompare.tools.SummaryLevelTools import SummaryLevelTools
126

137
__all__ = [
148
"CountyLookup",
159
"CountyKeyIndex",
1610
"StateLookup",
1711
"SummaryLevelParser",
18-
"CountyTools",
19-
"KeyTools",
20-
"StateTools",
21-
"SummaryLevelTools",
2212
"parse_number",
2313
"parse_int",
2414
"parse_float",

geocompare/tools/query_syntax.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,6 @@ def parse_geofilter(geofilter: str) -> List[Dict[str, Optional[str]]]:
3636

3737

3838
def _parse_single_filter(raw: str) -> Dict[str, Optional[str]]:
39-
if ":" in raw:
40-
parts = [part.strip() for part in raw.split(":")]
41-
if len(parts) in (3, 4):
42-
comp = parts[0]
43-
operator_key = parts[1]
44-
value = parts[2]
45-
data_type = parts[3] if len(parts) == 4 else None
46-
47-
if operator_key in _VALID_OPERATOR_KEYS and data_type in (None, "c", "cc"):
48-
return {
49-
"comp": comp,
50-
"operator": operator_key,
51-
"value": value,
52-
"data_type": data_type,
53-
}
54-
5539
symbol_match = _SYMBOL_FILTER_RE.match(raw)
5640
if symbol_match:
5741
comp, operator_symbol, value, data_type = symbol_match.groups()
@@ -73,8 +57,8 @@ def _parse_single_filter(raw: str) -> Dict[str, Optional[str]]:
7357
}
7458

7559
raise ValueError(
76-
"filter: Invalid criteria. Use 'comp:op:value' or 'comp>=value' "
77-
"(operators: gt,gteq,eq,lteq,lt or >,>=,=,<=,<)."
60+
"filter: Invalid criteria. Use 'comp>=value' "
61+
"(operators: >,>=,=,<=,< with optional :c or :cc suffix)."
7862
)
7963

8064

@@ -88,7 +72,7 @@ def build_context(
8872
"""Build legacy context string from explicit scope options."""
8973
has_explicit_scope = any([universe, in_state, in_county, in_zcta])
9074
if context and has_explicit_scope:
91-
raise ValueError("Use either --context/--scope or explicit --universe/--in-* options.")
75+
raise ValueError("Use either --scope or explicit --universe/--in-* options.")
9276
if context:
9377
return context
9478

geocompare/tools/summary_level_parser.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ def is_summary_level_keyword(self, input_str: str) -> bool:
3737
def is_summary_level_code(self, input_str: str) -> bool:
3838
return input_str in self.code_to_keyword
3939

40-
# Backward-compatible names.
41-
def iskeyword(self, input_str: str) -> bool:
42-
return self.is_summary_level_keyword(input_str)
43-
44-
def iscode(self, input_str: str) -> bool:
45-
return self.is_summary_level_code(input_str)
46-
4740
def parse_context(self, context: str) -> Tuple[Optional[str], Optional[str], Optional[str]]:
4841
universe_sl = None
4942
group_sl = None

0 commit comments

Comments
 (0)