removed --name option from 'transcribe list' to keep things simple, made code neater for helpers.get_transcription_jobs

This commit is contained in:
2019-03-06 23:28:46 -05:00
parent 2767f2ff55
commit 956c70fee1
2 changed files with 14 additions and 10 deletions

View File

@@ -88,14 +88,11 @@ def get_transcription_jobs(
status=status)
if jobs:
if name:
exact_match_jobs = []
for job in jobs:
if job['name'] == name:
exact_match_jobs.append(job)
if not exact_match_jobs:
jobs = get_exact_name_matches(jobs, name)
# this is because AWS Transcribe doesn't have exact file
# search
if not jobs:
continue
else:
jobs = exact_match_jobs
all_jobs[stt_name] = jobs
if name and len(all_jobs) == 0:
@@ -104,6 +101,14 @@ def get_transcription_jobs(
return all_jobs
def get_exact_name_matches(jobs, name):
exact_match_jobs = []
for job in jobs:
if job['name'] == name:
exact_match_jobs.append(job)
return exact_match_jobs
def get_transcription_jobs_dict():
jobs = get_transcription_jobs()
return {

View File

@@ -44,15 +44,14 @@ def get(name, save, pretty):
@cli.command()
@click.option('--service', type=str, help="STT service name")
@click.option('-n', '--name', type=str, help="transcription job name")
@click.option('--status', type=str, help="completed | failed | in_progress")
def list(service, name, status):
def list(service, status):
"""Lists available STT services."""
if service is not None and service not in vendors.SERVICES:
raise click.ClickException(f'no such service: {service}')
try:
all_jobs = get_transcription_jobs(service, name, status)
all_jobs = get_transcription_jobs(service_name=service, status=status)
except exceptions.ConfigError as e:
raise click.ClickException(str(e))
else: