Skip to content

Commit

Permalink
Fix up logic
Browse files Browse the repository at this point in the history
  • Loading branch information
wsanchez committed Jan 22, 2025
1 parent 29a4088 commit 67a21a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
20 changes: 12 additions & 8 deletions src/transmissions/indexer/_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Patterns:

_pattern_2017: Pattern[str] | None = None
_pattern_2023: Pattern[str] | None = None
_pattern_2024: Pattern[str] | None = None

@classmethod
def pattern_2017(cls) -> Pattern:
Expand Down Expand Up @@ -152,8 +153,8 @@ def pattern_2024(cls) -> Pattern:
"2024-08-29 04-54-33 BRC 911 ALT All Call- 'Radio' called 'All'.wav"
"2024-08-28 10-40-47 A-1 Group Call- 'Security 03' called 'Security'.wav"

if cls._pattern_2023 is None:
cls._pattern_2023 = regex(
if cls._pattern_2024 is None:
cls._pattern_2024 = regex(
r"^"
r"(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})"
r" (?P<hour>\d{2})-(?P<minute>\d{2})-(?P<second>\d{2})"
Expand All @@ -167,7 +168,7 @@ def pattern_2024(cls) -> Pattern:
r".*"
r"\.wav$"
)
return cls._pattern_2023
return cls._pattern_2024


@mutable(kw_only=True)
Expand Down Expand Up @@ -239,10 +240,10 @@ def _transmissionFromFile(self, path: Path) -> Transmission | None:
elif path.name.startswith("2024-"):
match = Patterns.pattern_2024().match(path.name)
else:
match = None
raise InvalidFileError(f"No matching pattern for {path}")

if match is None:
raise InvalidFileError(f"Skipping file {path}")
raise InvalidFileError(f"Pattern failed for {path}")

def getValue(*names: str, default: str | None = None) -> str:
for name in names:
Expand Down Expand Up @@ -480,14 +481,17 @@ async def _ensureTransmission(
if transmission.station != existingTransmission.station:
self.log.error(
"Duplicate transmissions with different "
"stations {station1} and {station2}",
"stations {station1} and {station2} at "
"file paths {path1} and {path2}",
station1=existingTransmission.station,
station2=transmission.station,
path1=existingTransmission.path,
path2=transmission.path,
)
return
if transmission.path != existingTransmission.path:
self.log.error(
"Duplicate transmissions with different "
self.log.info(
"Duplicate transmissions with different content at "
"file paths {path1} and {path2}",
path1=existingTransmission.path,
path2=transmission.path,
Expand Down
2 changes: 1 addition & 1 deletion src/transmissions/model/_transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def key(self) -> Key:

def __str__(self) -> str:
return (
f"{self.startTime} ({self.duration})"
f"{self.eventID} {self.startTime} ({self.duration})"
f" [{self.system}: {self.channel}]"
f" {self.station}: {self.transcription}"
)
6 changes: 3 additions & 3 deletions src/transmissions/run/_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ async def app(store: TXDataStore) -> None:
@main.command()
@click.argument(
"file",
type=ClickPath(exists=True, dir_okay=False, path_type=Path),
type=ClickPath(path_type=Path),
nargs=-1,
)
@pass_context
Expand All @@ -297,7 +297,7 @@ async def app(_store: TXDataStore) -> None:
sourcePath = _sourcePath.resolve()

# If filePath isn't in sourcePath, it isn't in event
if filePath.parts[: len(sourcePath.parts)] == sourcePath.parts:
if filePath.parts[: len(sourcePath.parts)] != sourcePath.parts:
continue

indexer = Indexer(event=event, root=sourcePath)
Expand All @@ -324,7 +324,7 @@ async def app(store: TXDataStore) -> None:
@main.command()
@option(
"--search",
help="Filter output with the given serach query.",
help="Filter output with the given search query.",
type=str,
metavar="<query>",
prompt=False,
Expand Down

0 comments on commit 67a21a0

Please sign in to comment.