Skip to content

Commit 41dd2e2

Browse files
jirhikerCopilot
andauthored
Update services/well_inventory_csv.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 9f66270 commit 41dd2e2

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

services/well_inventory_csv.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,27 @@ def _extract_autogen_prefix(well_id: str | None) -> str | None:
6565
with optional whitespace around ``-`` (e.g., ``ABC -xxxx`` -> ``ABC-``)
6666
- blank value (uses default ``NM-`` prefix)
6767
"""
68+
# Normalize input
6869
value = (well_id or "").strip()
70+
71+
# Blank / missing value -> use default prefix
6972
if not value:
7073
return AUTOGEN_DEFAULT_PREFIX
7174

75+
# Direct prefix form, e.g. "XY-" or "ABC-"
7276
if AUTOGEN_PREFIX_REGEX.match(value):
77+
# Ensure normalized trailing dash and uppercase
78+
prefix = value[:-1].upper()
79+
return f"{prefix}-"
80+
81+
# Token form, e.g. "WL-XXXX", "SAC-xxxx", with optional spaces around "-"
82+
m = AUTOGEN_TOKEN_REGEX.match(value)
83+
if m:
84+
prefix = m.group("prefix").upper()
85+
return f"{prefix}-"
86+
87+
# Unsupported pattern: not an auto-generation placeholder
88+
return None
7389
return value
7490

7591
token_match = AUTOGEN_TOKEN_REGEX.match(value)

0 commit comments

Comments
 (0)