small fix to use f strings instead of '%'

This commit is contained in:
mrepetto 2019-09-18 13:58:36 -03:00
parent 78dfef04d3
commit f5ad848974

View file

@ -1,15 +1,14 @@
#!/usr/bin/python #!/usr/bin/python
import argparse
import json
import os import os
import sys import sys
import json
import warnings import warnings
import argparse from argparse import RawTextHelpFormatter
from dejavu import Dejavu from dejavu import Dejavu
from dejavu.recognize import FileRecognizer from dejavu.recognize import FileRecognizer, MicrophoneRecognizer
from dejavu.recognize import MicrophoneRecognizer
from argparse import RawTextHelpFormatter
warnings.filterwarnings("ignore") warnings.filterwarnings("ignore")
@ -17,14 +16,14 @@ DEFAULT_CONFIG_FILE = "dejavu.cnf.SAMPLE"
def init(configpath): def init(configpath):
""" """
Load config from a JSON file Load config from a JSON file
""" """
try: try:
with open(configpath) as f: with open(configpath) as f:
config = json.load(f) config = json.load(f)
except IOError as err: except IOError as err:
print(("Cannot open configuration: %s. Exiting" % (str(err)))) print(f"Cannot open configuration: {str(err)}. Exiting")
sys.exit(1) sys.exit(1)
# create a Dejavu instance # create a Dejavu instance
@ -59,7 +58,7 @@ if __name__ == '__main__':
config_file = args.config config_file = args.config
if config_file is None: if config_file is None:
config_file = DEFAULT_CONFIG_FILE config_file = DEFAULT_CONFIG_FILE
# print "Using default config file: %s" % (config_file) # print ("Using default config file: {config_file}")
djv = init(config_file) djv = init(config_file)
if args.fingerprint: if args.fingerprint:
@ -67,8 +66,7 @@ if __name__ == '__main__':
if len(args.fingerprint) == 2: if len(args.fingerprint) == 2:
directory = args.fingerprint[0] directory = args.fingerprint[0]
extension = args.fingerprint[1] extension = args.fingerprint[1]
print(("Fingerprinting all .%s files in the %s directory" print(f"Fingerprinting all .{extension} files in the {directory} directory")
% (extension, directory)))
djv.fingerprint_directory(directory, ["." + extension], 4) djv.fingerprint_directory(directory, ["." + extension], 4)
elif len(args.fingerprint) == 1: elif len(args.fingerprint) == 1: