From 241f5bb73a9eac8f1e5008e83f9059a8b1dfef86 Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Tue, 15 Jul 2008 00:43:06 +0200 Subject: [PATCH] General cleanups in bug.py Main changes are renaming variables with camelCase names to dashed_form names and refactoring extractKwargs to use a list of options to be extracted. Updated the sample config file to match the rename changes. --- src/git_stats/bug.py | 45 +++++++++++++++++++++++++++------------------ src/git_stats/config | 6 +++--- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/git_stats/bug.py b/src/git_stats/bug.py index 66e59df..0537ec9 100644 --- a/src/git_stats/bug.py +++ b/src/git_stats/bug.py @@ -63,7 +63,7 @@ class CommitInfo: return res def aggregateType(options): - """ + """Uses the specified options to get type information for many commits """ git = Repo(".").git @@ -110,9 +110,9 @@ def determineType(target, branch_map, parent_list, debug=False, - branchFilter=None, - msgFilter=None, - diffFilter=None, + branch_filter=None, + msg_filter=None, + diff_filter=None, pretty_names={}, raw_diffs={}, parsed_diffs={}, @@ -122,12 +122,13 @@ def determineType(target, Args: commit: The commit to determine the type of. debug: Whether to include debug information. - branchFilter: Type=fix if a commit belongs to any of these branches. - msgFilter: Type=fix if the commit log msg matches this filter. - diffFilter: Type=fix if the commit diff matches this filter. + branch_filter: Type=fix if a commit belongs to any of these branches. + msg_filter: Type=fix if the commit log msg matches this filter. + diff_filter: Type=fix if the commit diff matches this filter. raw_diffs: A dictionary with commits and their raw diffs. parsed_diffs: A dictionary with commits and their parsed diffs. touched_files: A dictionary with files and the commits that touched them. + pretty_names: A dictionary with commits and their names """ branches = branch.belongsTo(target, @@ -140,25 +141,25 @@ def determineType(target, parsed_diffs=parsed_diffs, touched_files=touched_files) - msg_matches = msgFilter and commit.commitmsgMatches(target, msgFilter) - diff_matches = diffFilter and commit.commitdiffMatches( target, - diffFilter, + msg_matches = msg_filter and commit.commitmsgMatches(target, msg_filter) + diff_matches = diff_filter and commit.commitdiffMatches( target, + diff_filter, raw_diffs=raw_diffs) result = CommitInfo(target) - if branchFilter in branches: - match = set(branchFilter).intersection(set(branches)) + if branch_filter in branches: + match = set(branch_filter).intersection(set(branches)) result.branches = match if reverts: result.reverts = reverts if msg_matches: - result.msg_matches = msgFilter + result.msg_matches = msg_filter if diff_matches: - result.diff_matches = diffFilter + result.diff_matches = diff_filter return result @@ -173,10 +174,18 @@ def extractKwargs(options): kwargs = {} - kwargs["debug"] = options.debug or opts.get("debug", False) - kwargs["msgFilter"] = options.message_filter or opts.get("msgFilter", None) - kwargs["diffFilter"] = options.diff_filter or opts.get("diffFilter", None) - kwargs["branchFilter"] = options.branch_filter or opts.get("branchFilter", None) + options_list = ["debug", + "msg_filter", + "diff_filter", + "branch_filter"] + + for opt in options_list: + if getattr(options, opt, None) == None: + val = opts.get(opt, None) + else: + val = getattr(options, opt) + + kwargs[opt] = val return kwargs diff --git a/src/git_stats/config b/src/git_stats/config index 8a60262..eac31eb 100644 --- a/src/git_stats/config +++ b/src/git_stats/config @@ -1,5 +1,5 @@ [GitStats] - branchFilter = maint - msgFilter = Bug-introduced-in - diffFilter = test_expect_failure + branch_filter = maint + msg_filter = Bug-introduced-in + diff_filter = test_expect_failure -- 2.11.4.GIT