diff --git a/check_source/check_descriptions.py b/check_source/check_descriptions.py index 327d2c989426b01c0aa9bfcd438fe5ceaa96be9a..e384872521fceedaee2aadfd0a2222f8ec26c966 100644 --- a/check_source/check_descriptions.py +++ b/check_source/check_descriptions.py @@ -97,12 +97,13 @@ DUPLICATE_WHITELIST = ( ('OBJECT_OT_bake', 'OBJECT_OT_bake_image'), ('OBJECT_OT_duplicate_move', 'OBJECT_OT_duplicate_move_linked'), ('WM_OT_context_cycle_enum', 'WM_OT_context_toggle', 'WM_OT_context_toggle_enum'), - ('WM_OT_context_set_boolean', 'WM_OT_context_set_enum', 'WM_OT_context_set_float', 'WM_OT_context_set_int', 'WM_OT_context_set_string', 'WM_OT_context_set_value'), - ) + ('WM_OT_context_set_boolean', 'WM_OT_context_set_enum', 'WM_OT_context_set_float', + 'WM_OT_context_set_int', 'WM_OT_context_set_string', 'WM_OT_context_set_value'), +) DUPLICATE_IGNORE = { "", - } +} def check_duplicates(): diff --git a/check_source/check_spelling.py b/check_source/check_spelling.py index 50b0c42395307df33567646e39db0fd38a25794a..20700a210671f05f5bee065bb40ef7732f924c6c 100755 --- a/check_source/check_spelling.py +++ b/check_source/check_spelling.py @@ -48,9 +48,9 @@ import enchant dict_spelling = enchant.Dict("en_US") from check_spelling_c_config import ( - dict_custom, - dict_ignore, - ) + dict_custom, + dict_ignore, +) def words_from_text(text): @@ -124,7 +124,7 @@ class Comment: "text", "line", "type", - ) + ) def __init__(self, file, text, line, type): self.file = file @@ -185,10 +185,10 @@ def extract_c_comments(filepath): r"\param[in,out]", r"\param", r"\page", - ) + ) SKIP_COMMENTS = ( "BEGIN GPL LICENSE BLOCK", - ) + ) # http://doc.qt.nokia.com/qtcreator-2.4/creator-task-lists.html#task-list-file-format # file\tline\ttype\tdescription @@ -356,7 +356,7 @@ def spell_check_comments_recursive(dirpath): ".mm", ".osl", ".py", - }) + }) for filepath in source_list(dirpath, is_source): spell_check_comments(filepath) diff --git a/check_source/check_style_c.py b/check_source/check_style_c.py index 4097c0eaa03c93f2454a15665021ee87c6f5ba49..f00fe3eee670221ad2e79bae382ff63d98524985 100755 --- a/check_source/check_style_c.py +++ b/check_source/check_style_c.py @@ -79,7 +79,7 @@ class TokStore: "text", "line", "flag", - ) + ) def __init__(self, type, text, line): self.type = type @@ -350,6 +350,8 @@ def extract_cast(index): return (i_start, i_end) A = print + + def tk_range_find_by_type(index_start, index_end, type_, filter_tk=None): if index_start < index_end: for i in range(index_start, index_end + 1): @@ -396,14 +398,14 @@ def blender_check_kw_if(index_kw_start, index_kw, index_kw_end): # check for: if () # { # note: if the if statement is multi-line we allow it - if ((tokens[index_kw].line == tokens[index_kw_end].line) and + if ((tokens[index_kw].line == tokens[index_kw_end].line) and (tokens[index_kw].line == tokens[index_next].line - 1)): - if ((tokens[index_kw].line + 1 != tokens[index_next].line) and - (tk_range_find_by_type(index_kw + 1, index_next - 1, Token.Comment.Preproc, - filter_tk=lambda tk: tk.text in { - "if", "ifdef", "ifndef", "else", "elif", "endif"}) != -1) - ): + if ((tokens[index_kw].line + 1 != tokens[index_next].line) and + (tk_range_find_by_type(index_kw + 1, index_next - 1, Token.Comment.Preproc, + filter_tk=lambda tk: tk.text in { + "if", "ifdef", "ifndef", "else", "elif", "endif"}) != -1) + ): # allow this to go unnoticed pass else: @@ -430,12 +432,12 @@ def blender_check_kw_if(index_kw_start, index_kw, index_kw_end): # check for correct single line use & indentation if not (tokens[index_next].type == Token.Punctuation and tokens[index_next].text == ";"): if tokens[index_next].type == Token.Keyword and tokens[index_next].text in {"if", "while", "for"}: - ws_kw = extract_ws_indent(index_kw) - ws_end = extract_ws_indent(index_next) - if len(ws_kw) + 1 != len(ws_end): - warning("E200", "bad single line indent '%s (...) {'" % - tokens[index_kw].text, index_kw, index_next) - del ws_kw, ws_end + ws_kw = extract_ws_indent(index_kw) + ws_end = extract_ws_indent(index_next) + if len(ws_kw) + 1 != len(ws_end): + warning("E200", "bad single line indent '%s (...) {'" % + tokens[index_kw].text, index_kw, index_next) + del ws_kw, ws_end else: index_end = tk_advance_to_token(index_next, 1, ";", Token.Punctuation) if tokens[index_kw].line != tokens[index_end].line: @@ -501,7 +503,7 @@ def blender_check_kw_if(index_kw_start, index_kw, index_kw_end): # use startswith because there are function calls within 'if' checks sometimes. ws_indent_test = extract_to_linestart(i + 1) # print("indent: %r %s" % (ws_indent_test, tokens[i].text)) - #if ws_indent_test != ws_indent: + # if ws_indent_test != ws_indent: if ws_indent_test.startswith(ws_indent): pass @@ -540,7 +542,7 @@ def blender_check_kw_else(index_kw): # # check for this case since this is needed sometimes: # else { a = 1; } - if ((tokens[index_kw].line == tokens[i_next].line) and + if ((tokens[index_kw].line == tokens[i_next].line) and (tokens[index_kw + 1].type == Token.Text) and (len(tokens[index_kw + 1].text) > 1) and (tokens[index_kw + 1].text.isspace())): @@ -580,24 +582,24 @@ def blender_check_kw_else(index_kw): # else # #endif # if - if ((tokens[index_kw].line + 1 != tokens[i_next].line) and - any(True for i in range(index_kw + 1, i_next) - if (tokens[i].type == Token.Comment.Preproc and - tokens[i].text.lstrip("# \t").startswith(( - "if", "ifdef", "ifndef", - "else", "elif", "endif", + if ((tokens[index_kw].line + 1 != tokens[i_next].line) and + any(True for i in range(index_kw + 1, i_next) + if (tokens[i].type == Token.Comment.Preproc and + tokens[i].text.lstrip("# \t").startswith(( + "if", "ifdef", "ifndef", + "else", "elif", "endif", )) + ) ) - ) - ): + ): # allow this to go unnoticed pass - if ((tokens[index_kw].line + 1 != tokens[i_next].line) and - (tk_range_find_by_type(index_kw + 1, i_next - 1, Token.Comment.Preproc, - filter_tk=lambda tk: tk.text in { - "if", "ifdef", "ifndef", "else", "elif", "endif", }) != -1) - ): + if ((tokens[index_kw].line + 1 != tokens[i_next].line) and + (tk_range_find_by_type(index_kw + 1, i_next - 1, Token.Comment.Preproc, + filter_tk=lambda tk: tk.text in { + "if", "ifdef", "ifndef", "else", "elif", "endif", }) != -1) + ): # allow this to go unnoticed pass else: @@ -638,7 +640,7 @@ def blender_check_kw_switch(index_kw_start, index_kw, index_kw_end): "return": ws_switch_indent + "\t\t", "continue": ws_switch_indent + "\t\t", "goto": ws_switch_indent + "\t\t", - } + } index_final = tk_match_backet(index_next) @@ -697,7 +699,7 @@ def blender_check_kw_switch(index_kw_start, index_kw, index_kw_end): if tokens[i].text in { "/* fall-through */", "/* fall through */", "/* pass-through */", "/* pass through */", - }: + }: ok = True break @@ -715,7 +717,8 @@ def blender_check_kw_switch(index_kw_start, index_kw, index_kw_end): break else: ws_other_indent = extract_to_linestart(i) - ws_other_indent = ws_other_indent[:len(ws_other_indent) - len(ws_other_indent.lstrip())] + ws_other_indent = ws_other_indent[ + :len(ws_other_indent) - len(ws_other_indent.lstrip())] ws_test_other = ws_test[tokens[i].text] if ws_other_indent == ws_test_other: ok = True @@ -798,15 +801,15 @@ def blender_check_operator(index_start, index_end, op_text, is_cpp): # detect (-a) vs (a - b) index_prev = index_start - 1 if (tokens[index_prev].text.isspace() and - tokens[index_prev - 1].flag & IS_CAST): + tokens[index_prev - 1].flag & IS_CAST): index_prev -= 1 if tokens[index_prev].flag & IS_CAST: index_prev = tk_advance_flag(index_prev, -1, IS_CAST) - if (not tokens[index_prev].text.isspace() and + if (not tokens[index_prev].text.isspace() and tokens[index_prev].text not in {"[", "(", "{"}): warning("E130", "no space before operator '%s'" % op_text, index_start, index_end) - if (not tokens[index_end + 1].text.isspace() and + if (not tokens[index_end + 1].text.isspace() and tokens[index_end + 1].text not in {"]", ")", "}"}): # TODO, needs work to be useful # warning("E130", "no space after operator '%s'" % op_text, index_start, index_end) @@ -833,20 +836,20 @@ def blender_check_operator(index_start, index_end, op_text, is_cpp): index_prev = index_start - 1 if (tokens[index_prev].text.isspace() and - tokens[index_prev - 1].flag & IS_CAST): + tokens[index_prev - 1].flag & IS_CAST): index_prev -= 1 if tokens[index_prev].flag & IS_CAST: index_prev = tk_advance_flag(index_prev, -1, IS_CAST) # This check could be improved, its a bit fuzzy - if ((tokens[index_start - 1].flag & IS_CAST) or + if ((tokens[index_start - 1].flag & IS_CAST) or (tokens[index_start + 1].flag & IS_CAST)): # allow: # a = *(int *)b; # and: # b = (int *)*b; pass - elif ((tokens[index_start - 1].type in Token.Number) or + elif ((tokens[index_start - 1].type in Token.Number) or (tokens[index_start + 1].type in Token.Number)): warning("E130", "no space around operator '%s'" % op_text, index_start, index_end) elif not (tokens[index_start - 1].text.isspace() or tokens[index_start - 1].text in {"(", "[", "{"}): @@ -915,7 +918,7 @@ def blender_check_operator(index_start, index_end, op_text, is_cpp): if len(op_text) > 1: if op_text[0] == "*" and op_text[-1] == "*": - if ((not tokens[index_start - 1].text.isspace()) and + if ((not tokens[index_start - 1].text.isspace()) and (not tokens[index_start - 1].type == Token.Punctuation)): warning("E130", "no space before pointer operator '%s'" % op_text, index_start, index_end) if tokens[index_end + 1].text.isspace(): @@ -1332,13 +1335,13 @@ def scan_source(fp, code, args): else: col += len(tok.text.expandtabs(TAB_SIZE)) - #elif tok.type == Token.Name: + # elif tok.type == Token.Name: # print(tok.text) #print(ttype, type(ttype)) #print((ttype, value)) - #for ttype, value in la: + # for ttype, value in la: # #print(value, end="") @@ -1385,21 +1388,21 @@ def scan_source_recursive(dirpath, args): def create_parser(): parser = argparse.ArgumentParser( - description=( + description=( "Check C/C++ code for conformance with blenders style guide:\n" "http://wiki.blender.org/index.php/Dev:Doc/CodeStyle)") - ) + ) parser.add_argument( - "paths", - nargs='+', - help="list of files or directories to check", - ) + "paths", + nargs='+', + help="list of files or directories to check", + ) parser.add_argument( - "-l", - "--no-length-check", - action="store_true", - help="skip warnings for long lines", - ) + "-l", + "--no-length-check", + action="store_true", + help="skip warnings for long lines", + ) return parser diff --git a/check_source/check_style_c_config.py b/check_source/check_style_c_config.py index 42ee0b68897c3d0e6f23ea50684bd7233051d82e..8a9a3f659fdcb1316b2e97bdf1e8c3be1bf84f52 100644 --- a/check_source/check_style_c_config.py +++ b/check_source/check_style_c_config.py @@ -28,12 +28,12 @@ IGNORE = ( "source/blender/editors/space_logic/logic_buttons.c", "source/blender/editors/space_logic/logic_window.c", - + "source/blender/imbuf/intern/dds/DirectDrawSurface.cpp", "source/blender/opencl/intern/clew.c", "source/blender/opencl/intern/clew.h", - ) +) IGNORE_DIR = ( "source/blender/collada", @@ -41,7 +41,8 @@ IGNORE_DIR = ( "source/blender/editors/physics", "source/blender/editors/space_logic", "source/blender/freestyle", - ) +) -SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..", "..")))) +SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath( + os.path.join(os.path.dirname(__file__), "..", "..", "..")))) diff --git a/tests/check_source/check_style_c_test.py b/tests/check_source/check_style_c_test.py index c166038cbdd042860f376989223d1905e9f421af..631ad143f9847d825d444729a1f920f84c21d90f 100755 --- a/tests/check_source/check_style_c_test.py +++ b/tests/check_source/check_style_c_test.py @@ -6,10 +6,10 @@ import os import sys sys.path.append( - os.path.join( + os.path.join( os.path.dirname(__file__), "..", "..", "check_source", - )) + )) # ---- import unittest @@ -363,7 +363,7 @@ void func(void) "a = -(int)b + 1;"), ("a = 1+ (int *)*b;", "a = 1 + (int *)*b;"), - ) + ) for expr_fail, expr_ok in ab_test: code = FUNC_BEGIN + expr_fail + FUNC_END @@ -378,6 +378,7 @@ void func(void) class SourceCodeTestComplete(unittest.TestCase): """ Check we ran all tests. """ + def _test_complete(self): # -------------------------------------------------------------------- # Check we test all errors diff --git a/utils/blend2json.py b/utils/blend2json.py index 976c647ff772094eb035ac796957c5fc526e2dde..7a9736fc215c5bf6c0396d93df06b2083e6090f4 100755 --- a/utils/blend2json.py +++ b/utils/blend2json.py @@ -85,10 +85,10 @@ import re # Avoid maintaining multiple blendfile modules import sys sys.path.append(os.path.join( - os.path.dirname(__file__), - "..", "..", "..", - "release", "scripts", "addons", "io_blend_utils", "blend", - )) + os.path.dirname(__file__), + "..", "..", "..", + "release", "scripts", "addons", "io_blend_utils", "blend", +)) del sys import blendfile @@ -128,7 +128,7 @@ def list_to_json(lst, indent, indent_step, compact_output=False): ((',\n%s%s' % (indent, indent_step)).join( ('\n%s%s%s' % (indent, indent_step, l) if (i == 0 and l[0] in {'[', '{'}) else l) for i, l in enumerate(lst)) - ) + + ) + '\n%s]' % indent) @@ -354,32 +354,41 @@ def argparse_create(): parser = argparse.ArgumentParser(description=usage_text, epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument(dest="input", nargs="+", metavar='PATH', - help="Input .blend file(s)") - parser.add_argument("-o", "--output", dest="output", action="append", metavar='PATH', required=False, - help="Output .json file(s) (same path/name as input file(s) if not specified)") - parser.add_argument("-c", "--check-file", dest="check_file", default=False, action='store_true', required=False, - help=("Perform some basic validation checks over the .blend file")) - parser.add_argument("--compact-output", dest="compact_output", default=False, action='store_true', required=False, - help=("Output a very compact representation of blendfile (one line per block/DNAStruct)")) - parser.add_argument("--no-old-addresses", dest="no_address", default=False, action='store_true', required=False, - help=("Do not output old memory address of each block of data " - "(used as 'uuid' in .blend files, but change pretty noisily)")) - parser.add_argument("--no-fake-old-addresses", dest="use_fake_address", default=True, action='store_false', - required=False, - help=("Do not 'rewrite' old memory address of each block of data " - "(they are rewritten by default to some hash of their content, " - "to try to avoid too much diff noise between different but similar files)")) - parser.add_argument("--full-data", dest="full_data", - default=False, action='store_true', required=False, - help=("Also put in JSon file data itself " - "(WARNING! will generate *huge* verbose files - and is far from complete yet)")) - parser.add_argument("--full-dna", dest="full_dna", default=False, action='store_true', required=False, - help=("Also put in JSon file dna properties description (ignored when --compact-output is used)")) + parser.add_argument( + dest="input", nargs="+", metavar='PATH', + help="Input .blend file(s)") + parser.add_argument( + "-o", "--output", dest="output", action="append", metavar='PATH', required=False, + help="Output .json file(s) (same path/name as input file(s) if not specified)") + parser.add_argument( + "-c", "--check-file", dest="check_file", default=False, action='store_true', required=False, + help=("Perform some basic validation checks over the .blend file")) + parser.add_argument( + "--compact-output", dest="compact_output", default=False, action='store_true', required=False, + help=("Output a very compact representation of blendfile (one line per block/DNAStruct)")) + parser.add_argument( + "--no-old-addresses", dest="no_address", default=False, action='store_true', required=False, + help=("Do not output old memory address of each block of data " + "(used as 'uuid' in .blend files, but change pretty noisily)")) + parser.add_argument( + "--no-fake-old-addresses", dest="use_fake_address", default=True, action='store_false', + required=False, + help=("Do not 'rewrite' old memory address of each block of data " + "(they are rewritten by default to some hash of their content, " + "to try to avoid too much diff noise between different but similar files)")) + parser.add_argument( + "--full-data", dest="full_data", + default=False, action='store_true', required=False, + help=("Also put in JSon file data itself " + "(WARNING! will generate *huge* verbose files - and is far from complete yet)")) + parser.add_argument( + "--full-dna", dest="full_dna", default=False, action='store_true', required=False, + help=("Also put in JSon file dna properties description (ignored when --compact-output is used)")) group = parser.add_argument_group("Filters", FILTER_DOC) - group.add_argument("--filter-block", dest="block_filters", nargs=3, action='append', - help=("Filter to apply to BLOCKS (a.k.a. data itself)")) + group.add_argument( + "--filter-block", dest="block_filters", nargs=3, action='append', + help=("Filter to apply to BLOCKS (a.k.a. data itself)")) return parser diff --git a/utils/blender_update_themes.py b/utils/blender_update_themes.py index f9a4545db64319f17ef0624681e4b7fc1f33d7ce..d8b483ccdc2c7055945c34cefeb35ba25d8749af 100644 --- a/utils/blender_update_themes.py +++ b/utils/blender_update_themes.py @@ -34,7 +34,7 @@ def update(filepath): preset_xml_map = ( ("user_preferences.themes[0]", "Theme"), ("user_preferences.ui_styles[0]", "Theme"), - ) + ) rna_xml.xml_file_run(context, filepath, preset_xml_map) diff --git a/utils/credits_git_gen.py b/utils/credits_git_gen.py index f1049a89bec8fe3e9a7110273419b73985df8b53..3fcf704f6f9714f2eab9ff2ec1c646874e80133f 100755 --- a/utils/credits_git_gen.py +++ b/utils/credits_git_gen.py @@ -37,7 +37,7 @@ class CreditUser: "commit_total", "year_min", "year_max", - ) + ) def __init__(self): self.commit_total = 0 @@ -46,7 +46,7 @@ class CreditUser: class Credits: __slots__ = ( "users", - ) + ) def __init__(self): self.users = {} @@ -115,12 +115,14 @@ def argparse_create(): parser = argparse.ArgumentParser(description=usage_text, epilog=epilog) - parser.add_argument("--source", dest="source_dir", - metavar='PATH', required=True, - help="Path to git repository") - parser.add_argument("--range", dest="range_sha1", - metavar='SHA1_RANGE', required=True, - help="Range to use, eg: 169c95b8..HEAD") + parser.add_argument( + "--source", dest="source_dir", + metavar='PATH', required=True, + help="Path to git repository") + parser.add_argument( + "--range", dest="range_sha1", + metavar='SHA1_RANGE', required=True, + help="Range to use, eg: 169c95b8..HEAD") return parser @@ -137,7 +139,7 @@ def main(): b"blender/extern/", b"blender/intern/opennl/", b"blender/intern/moto/", - ) + ) if not any(f for f in c.files if not f.startswith(ignore_dir)): return False @@ -151,7 +153,7 @@ def main(): "<b>BioSkill GmbH</b> - H3D compatibility for X3D Exporter, " "OBJ Nurbs Import/Export", "<b>AutoCRC</b> - Improvements to fluid particles, vertex color baking", - ) + ) credits = Credits() # commit_range = "HEAD~10..HEAD" @@ -159,8 +161,8 @@ def main(): citer = GitCommitIter(args.source_dir, commit_range) credits.process((c for c in citer if is_credit_commit_valid(c))) credits.write("credits.html", - is_main_credits=True, - contrib_companies=contrib_companies) + is_main_credits=True, + contrib_companies=contrib_companies) print("Written: credits.html") diff --git a/utils/git_log.py b/utils/git_log.py index f738b5f12cca46d877a87ed7c3a604a727fa3854..dd2c91bc60c76bb475659e954a97754676046158 100644 --- a/utils/git_log.py +++ b/utils/git_log.py @@ -36,18 +36,18 @@ class GitCommit: "_body", "_files", "_files_status", - ) + ) def __init__(self, sha1, git_dir): self.sha1 = sha1 self._git_dir = git_dir self._author = \ - self._date = \ - self._body = \ - self._files = \ - self._files_status = \ - None + self._date = \ + self._body = \ + self._files = \ + self._files_status = \ + None def cache(self): """ Cache all properties @@ -68,13 +68,13 @@ class GitCommit: "-1", # only this rev self.sha1, "--format=" + format, - ) + args + ) + args # print(" ".join(cmd)) p = subprocess.Popen( cmd, stdout=subprocess.PIPE, - ) + ) return p.stdout.read() @property @@ -86,11 +86,11 @@ class GitCommit: "rev-parse", "--short", self.sha1, - ) + ) p = subprocess.Popen( cmd, stdout=subprocess.PIPE, - ) + ) return p.stdout.read().strip().decode('ascii') @property @@ -147,7 +147,7 @@ class GitCommitIter: "_git_dir", "_sha1_range", "_process", - ) + ) def __init__(self, path, sha1_range): self._path = path @@ -163,13 +163,13 @@ class GitCommitIter: "log", self._sha1_range, "--format=%H", - ) + ) # print(" ".join(cmd)) self._process = subprocess.Popen( cmd, stdout=subprocess.PIPE, - ) + ) return self def __next__(self): @@ -199,11 +199,11 @@ class GitRepo: "rev-parse", "--abbrev-ref", "HEAD", - ) + ) # print(" ".join(cmd)) p = subprocess.Popen( cmd, stdout=subprocess.PIPE, - ) + ) return p.stdout.read() diff --git a/utils/git_log_review_commits.py b/utils/git_log_review_commits.py index 6e3d3589b8e243c1ec853ce8404590c08738b011..03ea099e4df4a625f9cc63da05ff829dbab93074 100755 --- a/utils/git_log_review_commits.py +++ b/utils/git_log_review_commits.py @@ -37,6 +37,7 @@ class _Getch: Gets a single character from standard input. Does not echo to the screen. """ + def __init__(self): try: self.impl = _GetchWindows() @@ -48,6 +49,7 @@ class _Getch: class _GetchUnix: + def __init__(self): import tty import sys @@ -67,6 +69,7 @@ class _GetchUnix: class _GetchWindows: + def __init__(self): import msvcrt @@ -142,18 +145,22 @@ def argparse_create(): parser = argparse.ArgumentParser(description=usage_text, epilog=epilog) - parser.add_argument("--source", dest="source_dir", - metavar='PATH', required=True, - help="Path to git repository") - parser.add_argument("--range", dest="range_sha1", - metavar='SHA1_RANGE', required=True, - help="Range to use, eg: 169c95b8..HEAD") - parser.add_argument("--author", dest="author", - metavar='AUTHOR', type=str, required=False, - help=("Method to filter commits in ['BUGFIX', todo]")) - parser.add_argument("--filter", dest="filter_type", - metavar='FILTER', type=str, required=False, - help=("Method to filter commits in ['BUGFIX', todo]")) + parser.add_argument( + "--source", dest="source_dir", + metavar='PATH', required=True, + help="Path to git repository") + parser.add_argument( + "--range", dest="range_sha1", + metavar='SHA1_RANGE', required=True, + help="Range to use, eg: 169c95b8..HEAD") + parser.add_argument( + "--author", dest="author", + metavar='AUTHOR', type=str, required=False, + help=("Method to filter commits in ['BUGFIX', todo]")) + parser.add_argument( + "--filter", dest="filter_type", + metavar='FILTER', type=str, required=False, + help=("Method to filter commits in ['BUGFIX', todo]")) return parser diff --git a/utils/git_log_review_commits_advanced.py b/utils/git_log_review_commits_advanced.py index 7294b5e74d977ad7f103fbf9cf78e8e8d58c1cc4..7c256c2c77b11b847b29ce07d35465f2a1a9e500 100755 --- a/utils/git_log_review_commits_advanced.py +++ b/utils/git_log_review_commits_advanced.py @@ -58,10 +58,10 @@ IGNORE_END_LINE = "<!-- IGNORE_END -->" _cwd = os.getcwd() __doc__ = __doc__ + \ - "\nRaw GIT revisions files:\n\t* Accepted: %s\n\t* Rejected: %s\n\n" \ - "Basic pretty-printed accepted revisions: %s\n\nFull release notes wiki page: %s\n" \ - % (os.path.join(_cwd, ACCEPT_FILE), os.path.join(_cwd, REJECT_FILE), - os.path.join(_cwd, ACCEPT_PRETTY_FILE), os.path.join(_cwd, ACCEPT_RELEASELOG_FILE)) + "\nRaw GIT revisions files:\n\t* Accepted: %s\n\t* Rejected: %s\n\n" \ + "Basic pretty-printed accepted revisions: %s\n\nFull release notes wiki page: %s\n" \ + % (os.path.join(_cwd, ACCEPT_FILE), os.path.join(_cwd, REJECT_FILE), + os.path.join(_cwd, ACCEPT_PRETTY_FILE), os.path.join(_cwd, ACCEPT_RELEASELOG_FILE)) del _cwd @@ -70,6 +70,7 @@ class _Getch: Gets a single character from standard input. Does not echo to the screen. """ + def __init__(self): try: self.impl = _GetchWindows() @@ -81,6 +82,7 @@ class _Getch: class _GetchUnix: + def __init__(self): import tty import sys @@ -100,6 +102,7 @@ class _GetchUnix: class _GetchWindows: + def __init__(self): import msvcrt @@ -150,7 +153,7 @@ BUGFIX_CATEGORIES = ( "Grease Pencil", "Objects", "Dependency Graph", - ), + ), ), ("Data / Geometry", ( @@ -160,14 +163,14 @@ BUGFIX_CATEGORIES = ( "Meta Editing", "Modifiers", "Material / Texture", - ), + ), ), ("Physics / Simulations / Sculpt / Paint", ( "Particles", "Physics / Hair / Simulations", "Sculpting / Painting", - ), + ), ), ("Image / Video / Render", ( @@ -180,7 +183,7 @@ BUGFIX_CATEGORIES = ( "Render: Cycles", "Render: Freestyle", "Sequencer", - ), + ), ), ("UI / Spaces / Transform", ( @@ -190,11 +193,11 @@ BUGFIX_CATEGORIES = ( "Text Editor", "Transform", "User Interface", - ), + ), ), ("Game Engine", ( - ), + ), ), ("System / Misc", ( @@ -204,7 +207,7 @@ BUGFIX_CATEGORIES = ( "Other", "Python", "System", - ), + ), ), ) @@ -457,35 +460,44 @@ def argparse_create(): parser = argparse.ArgumentParser(description=usage_text, epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument("--source", dest="source_dir", - metavar='PATH', required=True, - help="Path to git repository") - parser.add_argument("--range", dest="range_sha1", - metavar='SHA1_RANGE', required=False, - help="Range to use, eg: 169c95b8..HEAD") - parser.add_argument("--author", dest="author", - metavar='AUTHOR', type=str, required=False, - help=("Author(s) to filter commits (")) - parser.add_argument("--filter", dest="filter_type", - metavar='FILTER', type=str, required=False, - help=("Method to filter commits in ['BUGFIX', 'NOISE']")) - parser.add_argument("--accept-pretty", dest="accept_pretty", - default=False, action='store_true', required=False, - help=("Also output pretty-printed accepted commits (nearly ready for WIKI release notes)")) - parser.add_argument("--accept-releaselog", dest="accept_releaselog", - default=False, action='store_true', required=False, - help=("Also output accepted commits as a wiki release log page (adds sorting by categories)")) - parser.add_argument("--blender-rev", dest="blender_rev", - default=None, required=False, - help=("Blender revision (only used to generate release notes page)")) - parser.add_argument("--blender-rstate", dest="blender_rstate", - default="alpha", required=False, - help=("Blender release state (like alpha, beta, rc1, final, corr_a, corr_b, etc.), " - "each revision will be tagged by given one")) - parser.add_argument("--blender-rstate-list", dest="blender_rstate_list", - default="", required=False, type=lambda s: s.split(","), - help=("Blender release state(s) to additionaly list in their own sections " - "(e.g. pass 'RC2' to list fixes between RC1 and RC2, ie tagged as RC2, etc.)")) + parser.add_argument( + "--source", dest="source_dir", + metavar='PATH', required=True, + help="Path to git repository") + parser.add_argument( + "--range", dest="range_sha1", + metavar='SHA1_RANGE', required=False, + help="Range to use, eg: 169c95b8..HEAD") + parser.add_argument( + "--author", dest="author", + metavar='AUTHOR', type=str, required=False, + help=("Author(s) to filter commits (")) + parser.add_argument( + "--filter", dest="filter_type", + metavar='FILTER', type=str, required=False, + help=("Method to filter commits in ['BUGFIX', 'NOISE']")) + parser.add_argument( + "--accept-pretty", dest="accept_pretty", + default=False, action='store_true', required=False, + help=("Also output pretty-printed accepted commits (nearly ready for WIKI release notes)")) + parser.add_argument( + "--accept-releaselog", dest="accept_releaselog", + default=False, action='store_true', required=False, + help=("Also output accepted commits as a wiki release log page (adds sorting by categories)")) + parser.add_argument( + "--blender-rev", dest="blender_rev", + default=None, required=False, + help=("Blender revision (only used to generate release notes page)")) + parser.add_argument( + "--blender-rstate", dest="blender_rstate", + default="alpha", required=False, + help=("Blender release state (like alpha, beta, rc1, final, corr_a, corr_b, etc.), " + "each revision will be tagged by given one")) + parser.add_argument( + "--blender-rstate-list", dest="blender_rstate_list", + default="", required=False, type=lambda s: s.split(","), + help=("Blender release state(s) to additionaly list in their own sections " + "(e.g. pass 'RC2' to list fixes between RC1 and RC2, ie tagged as RC2, etc.)")) return parser diff --git a/utils/make_cursor_gui.py b/utils/make_cursor_gui.py index 523a186e35778afd891e2c5c2be1a3deddb72d96..ab51c1ee06222a3475cecff0d924d0c3b0f5483b 100755 --- a/utils/make_cursor_gui.py +++ b/utils/make_cursor_gui.py @@ -4,17 +4,17 @@ # Oct. 30, 2003 from tkinter import ( - Button, - Canvas, - Checkbutton, - END, - Frame, - IntVar, - Label, - RIDGE, - Text, - Tk, - ) + Button, + Canvas, + Checkbutton, + END, + Frame, + IntVar, + Label, + RIDGE, + Text, + Tk, +) color = ("black", "white", "darkgreen", "gray") @@ -110,7 +110,7 @@ class App: self.state.append(2) oldstate = [] - #Insert scaling here + # Insert scaling here self.updatescrn() self.prev.config(width=self.size + 1, height=self.size + 1) diff --git a/utils_api/bpy_introspect_ui.py b/utils_api/bpy_introspect_ui.py index 782346b56291562c3141b68009e3087d84f60ce8..933485c9d15d6043813cbb8cd6756f0a07710681 100644 --- a/utils_api/bpy_introspect_ui.py +++ b/utils_api/bpy_introspect_ui.py @@ -183,6 +183,7 @@ def NewAttr(attr, attr_single): class BaseFakeUI: + def __init__(self): self.layout = NewAttr("self.layout", "layout") @@ -200,6 +201,7 @@ class Header(BaseFakeUI): class Menu(BaseFakeUI): + def draw_preset(self, context): pass diff --git a/utils_build/cmake-flags b/utils_build/cmake-flags index ab0955c63b3e13e1f7c7e3497f64b884d018955b..1c2af550c6981a1588046877b0b4ae82ba86f4c2 100755 --- a/utils_build/cmake-flags +++ b/utils_build/cmake-flags @@ -38,158 +38,158 @@ PRESETS = { "CMAKE_CXX_FLAGS": (("-fsanitize=address",), ()), "CMAKE_C_FLAGS": (("-fsanitize=address",), ()), "CMAKE_EXE_LINKER_FLAGS": (("-lasan",), ()), - }, + }, "sanitize_leak": { "CMAKE_CXX_FLAGS": (("-fsanitize=leak",), ()), "CMAKE_C_FLAGS": (("-fsanitize=leak",), ()), - }, + }, "sanitize_undefined": { "CMAKE_CXX_FLAGS": (("-fsanitize=undefined",), ()), "CMAKE_C_FLAGS": (("-fsanitize=undefined",), ()), - }, + }, "sanitize_thread": { "CMAKE_CXX_FLAGS": (("-fsanitize=thread",), ()), "CMAKE_C_FLAGS": (("-fsanitize=thread",), ()), - }, + }, # GCC5 "sanitize_float_divide_by_zero": { "CMAKE_CXX_FLAGS": (("-fsanitize=float-divide-by-zero",), ()), "CMAKE_C_FLAGS": (("-fsanitize=float-divide-by-zero",), ()), - }, + }, "sanitize_float_cast_overflow": { "CMAKE_CXX_FLAGS": (("-fsanitize=float-cast-overflow",), ()), "CMAKE_C_FLAGS": (("-fsanitize=float-cast-overflow",), ()), - }, + }, "sanitize_int_overflow": { "CMAKE_CXX_FLAGS": (("-fsanitize=signed-integer-overflow",), ()), "CMAKE_C_FLAGS": (("-fsanitize=signed-integer-overflow",), ()), - }, + }, "sanitize_bool": { "CMAKE_CXX_FLAGS": (("-fsanitize=bool",), ()), "CMAKE_C_FLAGS": (("-fsanitize=bool",), ()), - }, + }, "sanitize_enum": { "CMAKE_CXX_FLAGS": (("-fsanitize=enum",), ()), "CMAKE_C_FLAGS": (("-fsanitize=enum",), ()), - }, + }, "sanitize_bounds": { "CMAKE_CXX_FLAGS": (("-fsanitize=bounds",), ()), "CMAKE_C_FLAGS": (("-fsanitize=bounds",), ()), - }, + }, "sanitize_bounds_strict": { "CMAKE_CXX_FLAGS": (("-fsanitize=bounds-strict",), ()), "CMAKE_C_FLAGS": (("-fsanitize=bounds-strict",), ()), - }, + }, "sanitize_vla_bounds": { "CMAKE_CXX_FLAGS": (("-fsanitize=vla-bounds",), ()), "CMAKE_C_FLAGS": (("-fsanitize=vla-bounds",), ()), - }, + }, "sanitize_alignment": { "CMAKE_CXX_FLAGS": (("-fsanitize=alignment",), ()), "CMAKE_C_FLAGS": (("-fsanitize=alignment",), ()), - }, + }, "sanitize_object_size": { "CMAKE_CXX_FLAGS": (("-fsanitize=object-size",), ()), "CMAKE_C_FLAGS": (("-fsanitize=object-size",), ()), - }, + }, "sanitize_nonull_attribute": { "CMAKE_CXX_FLAGS": (("-fsanitize=nonnull-attribute",), ()), "CMAKE_C_FLAGS": (("-fsanitize=nonnull-attribute",), ()), - }, + }, "sanitize_returns_nonull_attribute": { "CMAKE_CXX_FLAGS": (("-fsanitize=returns-nonnull-attribute",), ()), "CMAKE_C_FLAGS": (("-fsanitize=returns-nonnull-attribute",), ()), - }, + }, "warn_all": { "CMAKE_CXX_FLAGS": (("-Wall",), ()), "CMAKE_C_FLAGS": (("-Wall",), ()), - }, + }, "warn_extra": { "CMAKE_CXX_FLAGS": (("-Wextra",), ()), "CMAKE_C_FLAGS": (("-Wextra",), ()), - }, + }, "warn_unused_macros": { "CMAKE_CXX_FLAGS": (("-Wunused-macros",), ()), "CMAKE_C_FLAGS": (("-Wunused-macros",), ()), - }, + }, "warn_undefined_macros": { "CMAKE_CXX_FLAGS": (("-Wundef",), ()), "CMAKE_C_FLAGS": (("-Wundef",), ()), - }, + }, "warn_unused_local_typedefs": { "CMAKE_CXX_FLAGS": (("-Wunused-local-typedefs",), ()), "CMAKE_C_FLAGS": (("-Wunused-local-typedefs",), ()), - }, + }, "warn_pointer_sign": { "CMAKE_CXX_FLAGS": (("",), ()), "CMAKE_C_FLAGS": (("-Wpointer-sign",), ()), - }, + }, "warn_sizeof_pointer_memaccess": { "CMAKE_CXX_FLAGS": (("-Wsizeof-pointer-memaccess",), ()), "CMAKE_C_FLAGS": (("-Wsizeof-pointer-memaccess",), ()), - }, + }, "warn_no_null": { "CMAKE_CXX_FLAGS": (("-Wnonnull",), ()), "CMAKE_C_FLAGS": (("-Wnonnull",), ()), - }, + }, "warn_init_self": { "CMAKE_CXX_FLAGS": (("-Winit-self",), ()), "CMAKE_C_FLAGS": (("-Winit-self",), ()), - }, + }, "warn_format": { "CMAKE_CXX_FLAGS": (("-Wformat=2", "-Wno-format-nonliteral", "-Wno-format-y2k"), ()), "CMAKE_C_FLAGS": (("-Wformat=2", "-Wno-format-nonliteral", "-Wno-format-y2k"), ()), - }, + }, "warn_format": { "CMAKE_CXX_FLAGS": (("-Wwrite-strings",), ()), "CMAKE_C_FLAGS": (("-Wwrite-strings",), ()), - }, + }, "warn_logical_op": { "CMAKE_CXX_FLAGS": (("-Wlogical-op",), ()), "CMAKE_C_FLAGS": (("-Wlogical-op",), ()), - }, + }, "warn_error": { "CMAKE_CXX_FLAGS": (("-Werror",), ()), "CMAKE_C_FLAGS": (("-Werror",), ()), - }, + }, "warn_shadow": { "CMAKE_CXX_FLAGS": (("-Wshadow", "-Wno-error=shadow"), ()), "CMAKE_C_FLAGS": (("-Wshadow", "-Wno-error=shadow"), ()), - }, + }, "warn_missing_include_dirs": { "CMAKE_CXX_FLAGS": (("-Wmissing-include-dirs",), ()), "CMAKE_C_FLAGS": (("-Wmissing-include-dirs",), ()), - }, + }, "warn_double_promotion": { "CMAKE_CXX_FLAGS": (("-Wdouble-promotion",), ()), "CMAKE_C_FLAGS": (("-Wdouble-promotion",), ()), - }, + }, "warn_declaration_after_statement": { "CMAKE_C_FLAGS": (("-Wdeclaration-after-statement",), ()), - }, + }, "warn_zero_as_null_pointer_constant": { "CMAKE_CXX_FLAGS": (("-Wzero-as-null-pointer-constant",), ()), - }, + }, "show_color": { "CMAKE_C_FLAGS": (("-fdiagnostics-color=always",), ()), "CMAKE_CXX_FLAGS": (("-fdiagnostics-color=always",), ()), - }, + }, # Optimize "optimize_whole_program": { "CMAKE_CXX_FLAGS": (("-flto",), ()), "CMAKE_C_FLAGS": (("-flto",), ()), "CMAKE_EXE_LINKER_FLAGS": (("-flto", "-fwhole-program",), ()), - }, + }, # Profile "profile_gprof": { "CMAKE_CXX_FLAGS": (("-pg",), ()), "CMAKE_C_FLAGS": (("-pg",), ()), "CMAKE_EXE_LINKER_FLAGS": (("-pg",), ()), - }, + }, } # ---------------------------------------------------------------------------- diff --git a/utils_ide/qtcreator/externaltools/qtc_assembler_preview.py b/utils_ide/qtcreator/externaltools/qtc_assembler_preview.py index 2c6fdb30ecd2c0973c80c64772e36d37164aadf2..b5552d354735f5522fb26e6e2a9dd6362ee41d51 100755 --- a/utils_ide/qtcreator/externaltools/qtc_assembler_preview.py +++ b/utils_ide/qtcreator/externaltools/qtc_assembler_preview.py @@ -21,6 +21,7 @@ SOURCE_FILE = sys.argv[-1] # TODO, support other compilers COMPILER_ID = 'GCC' + def find_arg(source, data): source_base = os.path.basename(source) for l in data: @@ -46,10 +47,11 @@ def find_arg(source, data): def find_build_args_ninja(source): make_exe = "ninja" - process = subprocess.Popen([make_exe, "-t", "commands"], - stdout=subprocess.PIPE, - cwd=BUILD_DIR, - ) + process = subprocess.Popen( + [make_exe, "-t", "commands"], + stdout=subprocess.PIPE, + cwd=BUILD_DIR, + ) while process.poll(): time.sleep(1) @@ -59,12 +61,14 @@ def find_build_args_ninja(source): data = out.decode("utf-8", errors="ignore").split("\n") return find_arg(source, data) + def find_build_args_make(source): make_exe = "make" - process = subprocess.Popen([make_exe, "--always-make", "--dry-run", "--keep-going", "VERBOSE=1"], - stdout=subprocess.PIPE, - cwd=BUILD_DIR, - ) + process = subprocess.Popen( + [make_exe, "--always-make", "--dry-run", "--keep-going", "VERBOSE=1"], + stdout=subprocess.PIPE, + cwd=BUILD_DIR, + ) while process.poll(): time.sleep(1) @@ -75,6 +79,7 @@ def find_build_args_make(source): data = out.decode("utf-8", errors="ignore").split("\n") return find_arg(source, data) + def main(): import re @@ -106,7 +111,7 @@ def main(): except ValueError: i = -1 if i != -1: - del arg_split[:i + 1] + del arg_split[:i + 1] if COMPILER_ID == 'GCC': # --- Switch debug for optimized --- @@ -129,19 +134,17 @@ def main(): # asan flags (re.compile(r"\-fsanitize=.*"), 1), - ): + ): if isinstance(arg, str): # exact string compare while arg in arg_split: i = arg_split.index(arg) - del arg_split[i : i + n] + del arg_split[i: i + n] else: # regex match for i in reversed(range(len(arg_split))): if arg.match(arg_split[i]): - del arg_split[i : i + n] - - + del arg_split[i: i + n] # add optimized args arg_split += ["-O3", "-fomit-frame-pointer", "-DNDEBUG", "-Wno-error"] diff --git a/utils_ide/qtcreator/externaltools/qtc_blender_diffusion.py b/utils_ide/qtcreator/externaltools/qtc_blender_diffusion.py index 915c949a030f39ec562218d6aab707e59585529f..26348506b37f3b9931cdcc49eb2e85fe2332e91d 100755 --- a/utils_ide/qtcreator/externaltools/qtc_blender_diffusion.py +++ b/utils_ide/qtcreator/externaltools/qtc_blender_diffusion.py @@ -17,14 +17,19 @@ SOURCE_ROW = sys.argv[-1] BASE_URL = "https://developer.blender.org/diffusion/B/browse" + def main(): dirname, filename = os.path.split(SOURCE_FILE) - process = subprocess.Popen(["git", "rev-parse", "--symbolic-full-name", "--abbrev-ref", "@{u}"], stdout=subprocess.PIPE, cwd=dirname, universal_newlines=True) + process = subprocess.Popen( + ["git", "rev-parse", "--symbolic-full-name", "--abbrev-ref", + "@{u}"], stdout=subprocess.PIPE, cwd=dirname, universal_newlines=True) output = process.communicate()[0] branchname = output.rstrip().rsplit('/', 1)[-1] - process = subprocess.Popen(["git", "rev-parse", "--show-toplevel"], stdout=subprocess.PIPE, cwd=dirname, universal_newlines=True) + process = subprocess.Popen( + ["git", "rev-parse", "--show-toplevel"], + stdout=subprocess.PIPE, cwd=dirname, universal_newlines=True) output = process.communicate()[0] toplevel = output.rstrip() filepath = os.path.relpath(SOURCE_FILE, toplevel) diff --git a/utils_ide/qtcreator/externaltools/qtc_doxy_file.py b/utils_ide/qtcreator/externaltools/qtc_doxy_file.py index bca773c4aad48108921eb0b3aff30c0e9e7485d2..7e1fd80c13f4ccc0cdf405dc8b03e0e67fa19602 100755 --- a/utils_ide/qtcreator/externaltools/qtc_doxy_file.py +++ b/utils_ide/qtcreator/externaltools/qtc_doxy_file.py @@ -12,6 +12,7 @@ import os import subprocess import tempfile + def find_gitroot(filepath_reference): path = filepath_reference path_prev = "" diff --git a/utils_ide/qtcreator/externaltools/qtc_project_update.py b/utils_ide/qtcreator/externaltools/qtc_project_update.py index 7ea5b8a4502193981cc1dd5c7af9adee7db142c1..d708f5aa2d6737ced20eb31ab935baff2c6e8f77 100755 --- a/utils_ide/qtcreator/externaltools/qtc_project_update.py +++ b/utils_ide/qtcreator/externaltools/qtc_project_update.py @@ -12,6 +12,7 @@ import os PROJECT_DIR = sys.argv[-1] + def cmake_find_source(path): import re match = re.compile(r"^CMAKE_HOME_DIRECTORY\b") @@ -28,8 +29,7 @@ cmd = ( "python", os.path.join(SOURCE_DIR, "build_files/cmake/cmake_qtcreator_project.py"), PROJECT_DIR, - ) +) print(cmd) os.system(" ".join(cmd)) - diff --git a/utils_ide/qtcreator/externaltools/qtc_select_surround.py b/utils_ide/qtcreator/externaltools/qtc_select_surround.py index 2c2af5f6fa28f45a78ec86c07524effcc29ce09a..3d1dd2a984fe298f32f43c174885163151d2507a 100755 --- a/utils_ide/qtcreator/externaltools/qtc_select_surround.py +++ b/utils_ide/qtcreator/externaltools/qtc_select_surround.py @@ -7,4 +7,3 @@ txt = sys.stdin.read() print("(", end="") print(txt, end="") print(")", end="") - diff --git a/utils_ide/qtcreator/externaltools/qtc_sort_paths.py b/utils_ide/qtcreator/externaltools/qtc_sort_paths.py index b2fee04f7d971d2d0c4f536b52cba1ee010f0ed4..f4d2609d91437adf0434cd9eaf7029d9655a435a 100755 --- a/utils_ide/qtcreator/externaltools/qtc_sort_paths.py +++ b/utils_ide/qtcreator/externaltools/qtc_sort_paths.py @@ -6,6 +6,7 @@ data = txt.split("\n") class PathCMP: + def __init__(self, path): path = path.strip()