Skip to content

Fixed multiword city names causing a ValueError#39

Merged
classabbyamp merged 1 commit intomiaowware:masterfrom
ussjoin:callook-multiword-cities
Aug 5, 2025
Merged

Fixed multiword city names causing a ValueError#39
classabbyamp merged 1 commit intomiaowware:masterfrom
ussjoin:callook-multiword-cities

Conversation

@ussjoin
Copy link
Copy Markdown
Contributor

@ussjoin ussjoin commented Jun 7, 2025

Description

Replaced the (elegant) replace-and-split line2 line with a less-elegant set of lines that additionally handle multiword city names.

Fixes #38

Type of change

  • Bug fix

How has this been tested?

from callsignlookuptools import CallookSyncClient, CallsignLookupError

callook_lookup = CallookSyncClient()

for callsign in ["W3UNX","WB0BK","KJ7ZHG","NA6JD","W9BLN","AK6FK","K1FIE", "W1AW"]:
  lookup_result = callook_lookup.search(callsign)
  print(lookup_result.address.city)

Test cases chosen because (except for W1AW, which is just there for a one-word control) these were some of the callsigns I was getting crashes on, when building a "send my giant pile of QSOs at once" tool for my ham radio club's pro-vaccine event. Had I gotten off my butt and tried to send the QSL cards in a more timely fashion, I would have submitted this bugfix earlier, so my apologies for that.

Checklist

  • Issue exists for PR
  • Code reviewed by the author
  • Code documented (comments or other documentation)
  • Changes tested
  • All tests pass (see DEVELOPING.md, if it exists)
  • CHANGELOG.md updated if needed (I don't think this merits a CHANGELOG notice)
  • Informative commit messages
  • Descriptive PR title

@classabbyamp
Copy link
Copy Markdown
Member

how about:

zip, state, *city = model_data.address.line2.replace(",", "").split(" ")[::-1]
city = " ".join(city[::-1])

@ussjoin
Copy link
Copy Markdown
Contributor Author

ussjoin commented Jun 8, 2025

@classabbyamp Well, today I learned a new operator (or rather, learned that the colon slicing operator can be a three-part syntax). Thank you! My test code shown in the description confirms your code works as well as mine, so I've updated the MR with your suggestion.

@thadigus
Copy link
Copy Markdown

thadigus commented Aug 5, 2025

@ussjoin Thanks for your fix! Do we know if this repo is still maintained? We're having the same issue over here in Van Wert, Ohio!

@classabbyamp
Copy link
Copy Markdown
Member

still maintained, just busy. will try to apply this patch soon

@thadigus
Copy link
Copy Markdown

thadigus commented Aug 5, 2025

Awesome, the W8FY club thanks you very much for maintaining such a helpful tool for our community @classabbyamp

classabbyamp
classabbyamp previously approved these changes Aug 5, 2025
@classabbyamp classabbyamp force-pushed the callook-multiword-cities branch from 9746e0f to 1fad17f Compare August 5, 2025 17:52
@classabbyamp
Copy link
Copy Markdown
Member

squashed and rebased to run CI

@classabbyamp classabbyamp merged commit 27d6385 into miaowware:master Aug 5, 2025
16 checks passed
@classabbyamp
Copy link
Copy Markdown
Member

released in 1.1.2: https://pypi.org/project/callsignlookuptools/

@ussjoin
Copy link
Copy Markdown
Contributor Author

ussjoin commented Aug 7, 2025

Thank you very much @classabbyamp!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Callook ValueError on multiword city names

4 participants