From 4f786458f6b3a9070623fddf316736474478e656 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 12 Sep 2021 12:01:57 +0200 Subject: [PATCH 1/2] Flake8: Invalid escape sequence 'l' This is a real error, not just a style issue. --- pdf_build_src/process_markdowns.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pdf_build_src/process_markdowns.py b/pdf_build_src/process_markdowns.py index a1e5bfd38e..e80671315f 100644 --- a/pdf_build_src/process_markdowns.py +++ b/pdf_build_src/process_markdowns.py @@ -401,9 +401,9 @@ def edit_titlepage(): with open('cover.tex', 'r') as file: data = file.readlines() - data[-1] = ("\\textsc{\large "+version_number+"}" + + data[-1] = ("\\textsc{\\large "+version_number+"}" + "\\\\[0.5cm]" + - "{\large " + + "{\\large " + build_date + "}" + "\\\\[2cm]" + From 3bcda384a8d7030b36e471a7891c9fdba93b94f1 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 12 Sep 2021 12:11:30 +0200 Subject: [PATCH 2/2] Flake8: fix style errors --- pdf_build_src/process_markdowns.py | 20 ++++---- tools/examplecode/example.py | 1 + tools/no-bad-latin.py | 73 +++++++++++++++--------------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/pdf_build_src/process_markdowns.py b/pdf_build_src/process_markdowns.py index e80671315f..ef7fdd79de 100644 --- a/pdf_build_src/process_markdowns.py +++ b/pdf_build_src/process_markdowns.py @@ -36,11 +36,11 @@ def copy_src(): target_path = "src_copy" # make new directory - mkdir_cmd = "mkdir "+target_path + mkdir_cmd = "mkdir " + target_path run_shell_cmd(mkdir_cmd) # copy contents of src directory - copy_cmd = "cp -R "+src_path+" "+target_path + copy_cmd = "cp -R " + src_path + " " + target_path run_shell_cmd(copy_cmd) @@ -66,7 +66,7 @@ def copy_images(root_path): for each in subdir_list: if each != root_path: - run_shell_cmd("cp -R "+each+"/images"+" "+root_path+"/images/") + run_shell_cmd("cp -R " + each + "/images" + " " + root_path + "/images/") def extract_header_string(): @@ -91,13 +91,13 @@ def add_header(): header = " ".join([title, version_number, build_date]) # creating a header string with latest version number and date - header_string = (r"\fancyhead[L]{ " + header + " }") + header_string = r"\fancyhead[L]{ " + header + " }" with open('header.tex', 'r') as file: data = file.readlines() # insert the header, note that you have to add a newline - data[4] = header_string+'\n' + data[4] = header_string + '\n' # re-write header.tex file with new header string with open('header.tex', 'w') as file: @@ -321,12 +321,12 @@ def correct_tables(root_path, debug=False): table_mode = True # Keep track of the line number where the table starts - start_line = line_nb-1 + start_line = line_nb - 1 print(' * Detected table starting line {}'.format(start_line)) # Extract for each row (header and the one containing dashes) # the content of each column and strip to remove extra whitespace - header_row = [c.strip() for c in re.split(r'(?= start_line and i < end_line: - new_content.append('|'.join(table[count])+' \n') + new_content.append('|'.join(table[count]) + ' \n') count += 1 elif i == end_line: - new_content.append('|'.join(table[count])+' \n\n') + new_content.append('|'.join(table[count]) + ' \n\n') count += 1 print(' - Appended corrected table lines to the new markdown content') else: @@ -401,7 +401,7 @@ def edit_titlepage(): with open('cover.tex', 'r') as file: data = file.readlines() - data[-1] = ("\\textsc{\\large "+version_number+"}" + + data[-1] = ("\\textsc{\\large " + version_number + "}" + "\\\\[0.5cm]" + "{\\large " + build_date + diff --git a/tools/examplecode/example.py b/tools/examplecode/example.py index 6ba3a67934..95be6c19c1 100644 --- a/tools/examplecode/example.py +++ b/tools/examplecode/example.py @@ -9,6 +9,7 @@ import os + class DirectoryTree: def __init__(self, filetree, use_pipe=True): self._generator = _TreeGenerator(filetree, use_pipe) diff --git a/tools/no-bad-latin.py b/tools/no-bad-latin.py index b553a9815f..74c362d01c 100755 --- a/tools/no-bad-latin.py +++ b/tools/no-bad-latin.py @@ -33,14 +33,14 @@ def parse_args(): def remove_comments(text_string): """Function to omit html comment identifiers in a text string using - regular expression matches + regular expression matches - Arguments: - text_string {string} -- The text to be matched + Arguments: + text_string {string} -- The text to be matched - Returns: - {string} -- The input text string with html comments removed - """ + Returns: + {string} -- The input text string with html comments removed + """ p = re.sub("(?s)", "", text_string) return p @@ -48,28 +48,28 @@ def remove_comments(text_string): def get_lines(text_string, sub_string): """Get individual lines in a text file - Arguments: - text_string {string} -- The text string to test - sub_string {string} -- The conditional string to perform splitting on + Arguments: + text_string {string} -- The text string to test + sub_string {string} -- The conditional string to perform splitting on - Returns: - {list} -- A list of split strings - """ + Returns: + {list} -- A list of split strings + """ lines = [line for line in text_string.split("\n") if sub_string in line] return lines def construct_error_message(files_dict): """Function to construct an error message pointing out where bad latin - phrases appear in lines of text + phrases appear in lines of text - Arguments: - files_dict {dictionary} -- Dictionary of failing files containing the - bad latin phrases and offending lines + Arguments: + files_dict {dictionary} -- Dictionary of failing files containing the + bad latin phrases and offending lines - Returns: - {string} -- The error message to be raised - """ + Returns: + {string} -- The error message to be raised + """ error_message = ["Bad latin found in the following files:\n"] for file in files_dict.keys(): @@ -82,32 +82,31 @@ def construct_error_message(files_dict): def read_and_check_files(files): """Function to read in files, remove html comments and check for bad latin - phrases + phrases - Arguments: - files {list} -- List of filenames to be checked + Arguments: + files {list} -- List of filenames to be checked - Returns: - {dict} -- Dictionary: Top level keys are absolute filepaths to files - that failed the check. Each of these has two keys: - 'latin_type' containing the unwanted latin phrase, and 'line' - containing the offending line. - """ + Returns: + {dict} -- Dictionary: Top level keys are absolute filepaths to files + that failed the check. Each of these has two keys: + 'latin_type' containing the unwanted latin phrase, and 'line' + containing the offending line. + """ failing_files = {} bad_latin = [ "i.e.", "i.e ", " ie ", "e.g.", "e.g ", "e.t.c.", " etc", "et cetera" - ] + ] for filename in files: if os.path.basename(filename) in IGNORE_LIST: pass else: try: - with open( - os.path.join(ABSOLUTE_HERE, filename), encoding="utf8", - errors="ignore") as f: + with open(os.path.join(ABSOLUTE_HERE, filename), + encoding="utf8", errors="ignore") as f: text = f.read() text = remove_comments(text) @@ -128,12 +127,12 @@ def read_and_check_files(files): def get_all_files(directory=os.path.join(ABSOLUTE_HERE, "src")): """Get a list of files to be checked. Ignores images, javascript, css files. - Keyword Arguments: - directory {string} -- The directory containing the files to check + Keyword Arguments: + directory {string} -- The directory containing the files to check - Returns: - {list} -- List of files to check - """ + Returns: + {list} -- List of files to check + """ files = [] filetypes_to_ignore = (".png", ".jpg", ".js", ".css")