diff --git a/check_source/check_cmake_consistency.py b/check_source/check_cmake_consistency.py index d4972924530f38f2be4ee57bfd37676b35f04c2a..c34b07d8bdd3acba158cc4c0a3d40d93a4dcb3e5 100755 --- a/check_source/check_cmake_consistency.py +++ b/check_source/check_cmake_consistency.py @@ -216,7 +216,6 @@ def cmake_get_src(f: str) -> None: f_rel_key = f_rel_key.replace(os.sep, "/") local_ignore_source_missing = global_ignore_source_missing.get(f_rel_key, []) - for l, line_number in tokens: # Replace directories. l = l.replace("${CMAKE_SOURCE_DIR}", SOURCE_DIR) diff --git a/check_source/check_licenses.py b/check_source/check_licenses.py index 09a94dbcfa473fc5fb3336f18a4aee19657df4a6..c05b5345da7f08e0fc6110164a9dd44d8732d292 100644 --- a/check_source/check_licenses.py +++ b/check_source/check_licenses.py @@ -245,7 +245,7 @@ def check_contents(filepath: str, text: str) -> None: print("Comment Block:", filepath, "failed to find comment end") return comment_end += 2 - comment_block = text[comment_beg + 2 : comment_end - 2] + comment_block = text[comment_beg + 2: comment_end - 2] comment_block = "\n".join( [l.removeprefix(" *") for l in comment_block.split("\n")] ) diff --git a/check_source/check_spelling.py b/check_source/check_spelling.py index 46e8122ade56b35a201b104262abc6361542d0d4..4e3fc02e03f326351984c123f72d592121a9cce6 100755 --- a/check_source/check_spelling.py +++ b/check_source/check_spelling.py @@ -73,11 +73,11 @@ files_ignore = { # ----------------------------------------------------------------------------- # Dictionary Utilities + def dictionary_create(): # type: ignore import enchant # type: ignore dict_spelling = enchant.Dict("en_US") - # Don't add ignore to the dictionary, since they will be suggested. for w in dict_custom: # Also, don't use `add(w)`, this will manipulate users personal dictionaries. diff --git a/check_source/check_unused_defines.py b/check_source/check_unused_defines.py index d815fd61b9480d35e6773d215842e5caa4bca41c..f7a7bed545d397f7b3b7dd27c598a6449c4440fd 100755 --- a/check_source/check_unused_defines.py +++ b/check_source/check_unused_defines.py @@ -33,22 +33,25 @@ defines = {} import re re_words = re.compile("[A-Za-z_][A-Za-z_0-9]*") -re_defines = re.compile("^\s*#define\s+([A-Za-z_][A-Za-z_0-9]*)", re.MULTILINE) +re_defines = re.compile("^\\s*#define\\s+([A-Za-z_][A-Za-z_0-9]*)", re.MULTILINE) # From # https://stackoverflow.com/a/18381470/432509 + + def remove_comments(string): pattern = r"(\".*?\"|\'.*?\')|(/\*.*?\*/|//[^\r\n]*$)" # first group captures quoted strings (double or single) # second group captures comments (//single-line or /* multi-line */) - regex = re.compile(pattern, re.MULTILINE|re.DOTALL) + regex = re.compile(pattern, re.MULTILINE | re.DOTALL) + def _replacer(match): # if the 2nd group (capturing comments) is not None, # it means we have captured a non-quoted (real) comment string. if match.group(2) is not None: - return "" # so we will return empty to remove the comment + return "" # so we will return empty to remove the comment else: # otherwise, we will return the 1st group - return match.group(1) # capture + return match.group(1) # capture return regex.sub(_replacer, string) @@ -67,6 +70,7 @@ def extract_terms(fn, data_src): # Don't edit the file. return None + run( directories=[os.path.join(SOURCE_DIR, d) for d in SOURCE_DIRS], is_text=lambda fn: fn.endswith(SOURCE_EXT), diff --git a/modules/blendfile.py b/modules/blendfile.py index fc1fbc13a67cfebeb8b6d5de4d6e662abb699c50..5842f2ea5313bfd18ed9c315848bc3d1309e7366 100644 --- a/modules/blendfile.py +++ b/modules/blendfile.py @@ -449,13 +449,14 @@ class BlendFileBlock: for index in range(dna_name.array_size): for f in struct.fields: yield from self.get_recursive_iter( - (index, f.dna_name.name_only), path_full, - default, None, use_nil, use_str, 0) + (index, f.dna_name.name_only), path_full, + default, None, use_nil, use_str, 0) else: for f in struct.fields: yield from self.get_recursive_iter( - f.dna_name.name_only, path_full, - default, None, use_nil, use_str, 0) + f.dna_name.name_only, path_full, + default, None, use_nil, use_str, 0) + def items_recursive_iter(self, use_nil=True): for k in self.keys(): yield from self.get_recursive_iter(k, use_nil=use_nil, use_str=False) diff --git a/utils/blender_keyconfig_export_permutations.py b/utils/blender_keyconfig_export_permutations.py index ae928d105c6ae086d6e23ab43cf992906573dc36..f199822dadaf09f956486d794f2abfd6bc67f16e 100755 --- a/utils/blender_keyconfig_export_permutations.py +++ b/utils/blender_keyconfig_export_permutations.py @@ -126,7 +126,7 @@ def permutation_as_filename(preset, values): return quote( preset + "_" + ".".join([ "-".join((str(key), str(val))) - for key, val in values + for key, val in values ]), # Needed so forward slashes aren't included in the resulting name. safe="", diff --git a/utils/blender_merge_format_changes.py b/utils/blender_merge_format_changes.py index 8813a32e8efaa8c16c6dc2b80a0ff9c61cef3e91..b4a43b61f7de96bf1e3abe0d441eeffb6c6e5cbe 100755 --- a/utils/blender_merge_format_changes.py +++ b/utils/blender_merge_format_changes.py @@ -11,12 +11,14 @@ format_commits = ( 'e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1', '91a9cd0a94000047248598394c41ac30f893f147', '3076d95ba441cd32706a27d18922a30f8fd28b8a', - ) +) pre_format_commit = format_commits[0] + '~1' + def get_string(cmd): return subprocess.run(cmd, stdout=subprocess.PIPE).stdout.decode('utf8').strip() + # Parse arguments. mode = None base_branch = 'master' @@ -73,7 +75,7 @@ if mode == 'rebase': mode_cmd = 'rebase' else: branch = get_string(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) - mode_cmd = 'merge --no-edit -m "Merge \'' + base_branch + '\' into \'' + branch + '\'"'; + mode_cmd = 'merge --no-edit -m "Merge \'' + base_branch + '\' into \'' + branch + '\'"' # Rebase up to the clang-format commit. code = os.system('git merge-base --is-ancestor ' + pre_format_commit + ' HEAD') diff --git a/utils/blender_theme_as_c.py b/utils/blender_theme_as_c.py index 32acb941ca5db0f4c9103d5dd62606242b78d67f..16a7c13c3f4fd1f8cc8b1ec9d7bd3ece1b122a78 100755 --- a/utils/blender_theme_as_c.py +++ b/utils/blender_theme_as_c.py @@ -60,6 +60,7 @@ def repr_f32(f): return "%.*f" % (i, f_test) return f_str + import os # Avoid maintaining multiple blendfile modules diff --git a/utils/cycles_commits_sync.py b/utils/cycles_commits_sync.py index 12b08df797d835f764b67030842d4204d0336857..0a0e1509452b51cf8a7aa068bc9cb5310baac390 100755 --- a/utils/cycles_commits_sync.py +++ b/utils/cycles_commits_sync.py @@ -18,8 +18,8 @@ IGNORE_HASHES = { } # Start revisions from both repositories. -CYCLES_START_COMMIT = b"b941eccba81bbb1309a0eb4977fc3a77796f4ada" # blender-v2.92 -BLENDER_START_COMMIT = b"02948a2cab44f74ed101fc1b2ad9fe4431123e85" # v2.92 +CYCLES_START_COMMIT = b"b941eccba81bbb1309a0eb4977fc3a77796f4ada" # blender-v2.92 +BLENDER_START_COMMIT = b"02948a2cab44f74ed101fc1b2ad9fe4431123e85" # v2.92 # Prefix which is common for all the subjects. GIT_SUBJECT_COMMON_PREFIX = b"Subject: [PATCH] " diff --git a/utils/cycles_timeit.py b/utils/cycles_timeit.py index 660cae44a8d258b6b30fdd62b057b691ec05c3dd..b16594e9a6fd82be0e49318456932dc334425214 100755 --- a/utils/cycles_timeit.py +++ b/utils/cycles_timeit.py @@ -126,7 +126,7 @@ def benchmarkFile(blender, blendfile, stats): re_path_tracing = re.compile(".*Path Tracing Tile ([0-9]+)/([0-9]+)$") re_total_render_time = re.compile(r".*Total render time: ([0-9]+(\.[0-9]+)?)") re_render_time_no_sync = re.compile( - ".*Render time \(without synchronization\): ([0-9]+(\.[0-9]+)?)") + ".*Render time \\(without synchronization\\): ([0-9]+(\\.[0-9]+)?)") re_pipeline_time = re.compile(r"Time: ([0-9:\.]+) \(Saving: ([0-9:\.]+)\)") # Prepare output folder. # TODO(sergey): Use some proper output folder. diff --git a/utils_maintenance/c_struct_clean.py b/utils_maintenance/c_struct_clean.py index 80988888b4f079344a343df6784f06ea373ced51..8e20adb12492317b7b22edd380c44dd8847d75ba 100755 --- a/utils_maintenance/c_struct_clean.py +++ b/utils_maintenance/c_struct_clean.py @@ -71,6 +71,7 @@ def clean_structs(fn: str, data_src: str) -> Optional[str]: return data_dst return None + run( directories=[os.path.join(SOURCE_DIR, d) for d in SOURCE_DIRS], is_text=lambda fn: fn.endswith(SOURCE_EXT), diff --git a/utils_maintenance/modules/batch_edit_text.py b/utils_maintenance/modules/batch_edit_text.py index cffaec8b5d06a483994deff9508be00fd303227e..c2760f6b1b232e9893cca54da6e4c1d4eb79fcce 100644 --- a/utils_maintenance/modules/batch_edit_text.py +++ b/utils_maintenance/modules/batch_edit_text.py @@ -15,6 +15,7 @@ TextOpFn = Callable[ Optional[str] ] + def operation_wrap(args: Tuple[str, TextOpFn]) -> None: fn, text_operation = args with open(fn, "r", encoding="utf-8") as f: @@ -27,7 +28,9 @@ def operation_wrap(args: Tuple[str, TextOpFn]) -> None: with open(fn, "w", encoding="utf-8") as f: f.write(data_dst) -def run(*, + +def run( + *, directories: Sequence[str], is_text: Callable[[str], bool], text_operation: TextOpFn,