Skip to content

Commit 3093192

Browse files
refactor: Fix minor linting issues (#89)
1 parent fd3c64b commit 3093192

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

build-checks.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def checkCSVcolumnCount():
2121
reader = csv.reader(open(f, "r"))
2222
for row in reader:
2323
if not len(row) == 6:
24-
print("{}: Insufficient columns of data - {}".format(filename, row))
24+
print(f"{filename}: Insufficient columns of data - {row}")
2525
missing_csv_field = True
2626
continue
2727

@@ -30,6 +30,7 @@ def checkCSVcolumnCount():
3030
else:
3131
return 0
3232

33+
3334
def checkFilenameLengths():
3435
print("SOUNDS: Checking file name lengths ...")
3536
invalid_filename_found = False
@@ -38,12 +39,12 @@ def checkFilenameLengths():
3839
path = os.path.join(dirpath, fn)
3940
if path.split(os.path.sep)[2] == "SYSTEM":
4041
if len(os.path.splitext(fn)[0]) > 8:
41-
print("Filename too long for a SYSTEM file: {}".format(path))
42+
print(f"Filename too long for a SYSTEM file: {path}")
4243
invalid_filename_found = True
4344
elif path.split(os.path.sep)[2] == "SCRIPTS":
4445
continue
4546
elif len(os.path.splitext(fn)[0]) > 6:
46-
print("Filename too long for a non-SYSTEM file: {}".format(path))
47+
print(f"Filename too long for a non-SYSTEM file: {path}")
4748
invalid_filename_found = True
4849

4950
if invalid_filename_found:
@@ -60,7 +61,7 @@ def checkNoZeroByteFiles():
6061
for fn in files:
6162
path = os.path.join(root, fn)
6263
if os.stat(path).st_size == 0:
63-
print("Zero byte file: {}".format(path))
64+
print(f"Zero byte file: {path}")
6465
zero_byte_file_found = True
6566

6667
if zero_byte_file_found:
@@ -76,14 +77,15 @@ def validateSoundsJson():
7677
try:
7778
json.load(f)
7879
except ValueError as err:
79-
print("JSON not valid: {}".format(str(err)))
80+
print(f"JSON not valid: {str(err)}")
8081
invalid_json_found = True
8182

8283
if invalid_json_found:
8384
return 1
8485
else:
8586
return 0
8687

88+
8789
def checkForDuplicateStringID():
8890
print("VOICES: Check for duplicate StringIDs ...")
8991
duplicate_found = False
@@ -111,7 +113,7 @@ def checkForDuplicateStringID():
111113
else:
112114
StringID = row[0]
113115
if StringID in StringID_count.keys():
114-
print('{}: {} is duplicated'.format(f, StringID))
116+
print(f'{f}: {StringID} is duplicated')
115117
StringID_count[StringID] = StringID_count[StringID] + 1
116118
duplicate_found = True
117119
else:

voice-gen.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import re
66
import sys
77
import time
8-
import subprocess
98
from pathlib import Path
109

1110
try:
@@ -17,7 +16,6 @@
1716
https://docs.microsoft.com/azure/cognitive-services/speech-service/quickstart-text-to-speech-python for
1817
installation instructions.
1918
""")
20-
import sys
2119
sys.exit(1)
2220

2321

@@ -125,7 +123,7 @@ def main() -> None:
125123

126124
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
127125

128-
if not(os.path.isfile(csv_file)):
126+
if not os.path.isfile(csv_file):
129127
print("Error: voice file not found")
130128
sys.exit(1)
131129

@@ -181,11 +179,9 @@ def main() -> None:
181179
# If failed, show error, remove empty/corrupt file and halt
182180
if result.reason == speechsdk.ResultReason.Canceled:
183181
cancellation_details = result.cancellation_details
184-
print("Speech synthesis canceled: {}".format(
185-
cancellation_details.reason))
182+
print(f"Speech synthesis canceled: {cancellation_details.reason}")
186183
if cancellation_details.reason == speechsdk.CancellationReason.Error:
187-
print("Error details: {}".format(
188-
cancellation_details.error_details))
184+
print(f"Error details: {cancellation_details.error_details}")
189185
if os.path.isfile(outdir + os.sep + filename):
190186
os.remove(outdir + os.sep + filename)
191187
sys.exit(1)

0 commit comments

Comments
 (0)