Fixed pylint violations reported by a newer version of pylint.

This commit is contained in:
Adam Waldenberg 2015-10-12 03:15:30 +02:00
parent 34337dec17
commit 1f2f120389
12 changed files with 51 additions and 70 deletions

View File

@ -22,7 +22,7 @@ import subprocess
import sys
def get_basedir():
if hasattr(sys,'frozen'): # exists when running via py2exe
if hasattr(sys, "frozen"): # exists when running via py2exe
return sys.prefix
else:
return os.path.dirname(os.path.realpath(__file__))
@ -33,11 +33,11 @@ def get_basedir_git():
global __git_basedir__
if not __git_basedir__:
sp = subprocess.Popen(["git", "rev-parse", "--is-bare-repository"], bufsize=1,
bare_command = subprocess.Popen(["git", "rev-parse", "--is-bare-repository"], bufsize=1,
stdout=subprocess.PIPE, stderr=open(os.devnull, "w"))
isbare = sp.stdout.readlines()
sp.wait()
if sp.returncode != 0:
isbare = bare_command.stdout.readlines()
bare_command.wait()
if bare_command.returncode != 0:
sys.exit(_("Error processing git repository at \"%s\"." % os.getcwd()))
isbare = (isbare[0].decode("utf-8", "replace").strip() == "true")
absolute_path = None

View File

@ -35,7 +35,7 @@ import threading
NUM_THREADS = multiprocessing.cpu_count()
class BlameEntry:
class BlameEntry(object):
rows = 0
skew = 0 # Used when calculating average code age.
comments = 0
@ -125,7 +125,7 @@ class BlameThread(threading.Thread):
PROGRESS_TEXT = N_("Checking how many rows belong to each author (Progress): {0:.0f}%")
class Blame:
class Blame(object):
def __init__(self, hard, useweeks, changes):
self.blames = {}
ls_tree_r = subprocess.Popen(["git", "ls-tree", "--name-only", "-r", interval.get_ref()], bufsize=1,
@ -178,7 +178,7 @@ class Blame:
@staticmethod
def get_time(string):
time = re.search(" \(.*?(\d\d\d\d-\d\d-\d\d)", string)
time = re.search(r" \(.*?(\d\d\d\d-\d\d-\d\d)", string)
return time.group(1).strip()
def get_summed_blames(self):

View File

@ -33,7 +33,7 @@ NUM_THREADS = multiprocessing.cpu_count()
__thread_lock__ = threading.BoundedSemaphore(NUM_THREADS)
__changes_lock__ = threading.Lock()
class FileDiff:
class FileDiff(object):
def __init__(self, string):
commit_line = string.split("|")
@ -65,7 +65,7 @@ class FileDiff:
return True
return False
class Commit:
class Commit(object):
def __init__(self, string):
self.filediffs = []
commit_line = string.split("|")
@ -93,7 +93,7 @@ class Commit:
def is_commit_line(string):
return string.split("|").__len__() == 4
class AuthorInfo:
class AuthorInfo(object):
email = None
insertions = 0
deletions = 0
@ -169,7 +169,7 @@ class ChangesThread(threading.Thread):
__changes_lock__.release() # ...to here.
__thread_lock__.release() # Lock controlling the number of threads running
class Changes:
class Changes(object):
authors = {}
authors_dateinfo = {}
authors_by_email = {}

View File

@ -19,18 +19,18 @@
from __future__ import unicode_literals
__comment_begining__ = { "java": "/*", "c": "/*", "cc": "/*", "cpp": "/*", "cs": "/*", "h": "/*", "hh": "/*", "hpp": "/*",
"hs": "{-", "html": "<!--", "php": "/*", "py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*",
"jspx": "<!--", "scala": "/*", "sql": "/*", "tex": "\\begin{comment}", "xhtml": "<!--",
"xml": "<!--", "ml": "(*", "mli": "(*" }
__comment_begining__ = {"java": "/*", "c": "/*", "cc": "/*", "cpp": "/*", "cs": "/*", "h": "/*", "hh": "/*", "hpp": "/*",
"hs": "{-", "html": "<!--", "php": "/*", "py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*",
"jspx": "<!--", "scala": "/*", "sql": "/*", "tex": "\\begin{comment}", "xhtml": "<!--",
"xml": "<!--", "ml": "(*", "mli": "(*"}
__comment_end__ = { "java": "*/", "c": "*/", "cc": "*/", "cpp": "*/", "cs": "*/", "h": "*/", "hh": "*/", "hpp": "*/", "hs": "-}",
"html": "-->", "php": "/*", "py": "\"\"\"", "glsl": "*/", "rb": "=end", "js": "*/", "jspx": "-->",
"scala": "*/", "sql": "*/", "tex": "\\end{comment}", "xhtml": "-->", "xml": "-->", "ml": "*)", "mli": "*)" }
__comment_end__ = {"java": "*/", "c": "*/", "cc": "*/", "cpp": "*/", "cs": "*/", "h": "*/", "hh": "*/", "hpp": "*/", "hs": "-}",
"html": "-->", "php": "/*", "py": "\"\"\"", "glsl": "*/", "rb": "=end", "js": "*/", "jspx": "-->",
"scala": "*/", "sql": "*/", "tex": "\\end{comment}", "xhtml": "-->", "xml": "-->", "ml": "*)", "mli": "*)"}
__comment__ = { "java": "//", "c": "//", "cc": "//", "cpp": "//", "cs": "//", "h": "//", "hh": "//", "hpp": "//", "hs": "--",
"pl": "#", "php": "//", "py": "#", "glsl": "//", "rb": "#", "js": "//", "scala": "//", "sql": "--", "tex": "%",
"ada": "--", "ads": "--", "adb": "--", "pot": "#", "po": "#" }
__comment__ = {"java": "//", "c": "//", "cc": "//", "cpp": "//", "cs": "//", "h": "//", "hh": "//", "hpp": "//", "hs": "--",
"pl": "#", "php": "//", "py": "#", "glsl": "//", "rb": "#", "js": "//", "scala": "//", "sql": "--", "tex": "%",
"ada": "--", "ads": "--", "adb": "--", "pot": "#", "po": "#"}
__comment_markers_must_be_at_begining__ = {"tex": True}

View File

@ -17,12 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from __future__ import unicode_literals
import re
import subprocess
import terminal
import textwrap
__filters__ = {"file": [set(), set()], "author": [set(), set()], "email": [set(), set()], "revision": [set(), set()],
"message" : [set(), None]}

View File

@ -84,23 +84,23 @@ def output_header():
else:
jquery_js = " src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js\">"
print(html_header.format(title = _("Repository statistics for {0}").format(os.path.basename(basedir.get_basedir_git())),
jquery = jquery_js,
jquery_tablesorter = tablesorter_js,
jquery_flot = flot_js,
jquery_flot_pie = pie_js,
jquery_flot_resize = resize_js,
logo = logo.decode("utf-8", "replace"),
logo_text = _("The output has been generated by {0} {1}. The statistical analysis tool"
print(html_header.format(title=_("Repository statistics for {0}").format(os.path.basename(basedir.get_basedir_git())),
jquery=jquery_js,
jquery_tablesorter=tablesorter_js,
jquery_flot=flot_js,
jquery_flot_pie=pie_js,
jquery_flot_resize=resize_js,
logo=logo.decode("utf-8", "replace"),
logo_text=_("The output has been generated by {0} {1}. The statistical analysis tool"
" for git repositories.").format(
"<a href=\"https://github.com/ejwa/gitinspector\">gitinspector</a>",
version.__version__),
repo_text = _("Statistical information for the repository '{0}' was gathered on {1}.").format(
repo_text=_("Statistical information for the repository '{0}' was gathered on {1}.").format(
os.path.basename(basedir. get_basedir_git()), localization.get_date()),
show_minor_authors = _("Show minor authors"),
hide_minor_authors = _("Hide minor authors"),
show_minor_rows = _("Show rows with minor work"),
hide_minor_rows = _("Hide rows with minor work")))
show_minor_authors=_("Show minor authors"),
hide_minor_authors=_("Hide minor authors"),
show_minor_rows=_("Show rows with minor work"),
hide_minor_rows=_("Hide rows with minor work")))
elif __selected_format__ == "xml":
print("<gitinspector>")
print("\t<version>" + version.__version__ + "</version>")

View File

@ -33,7 +33,6 @@ from output.responsibilitiesoutput import ResponsibilitiesOutput
from output.timelineoutput import TimelineOutput
import atexit
import basedir
import blame
import changes
import clone
import config
@ -43,16 +42,13 @@ import format
import help
import interval
import getopt
import metrics
import os
import optval
import responsibilities
import sys
import terminal
import timeline
import version
class Runner:
class Runner(object):
def __init__(self):
self.hard = False
self.include_metrics = False

View File

@ -77,10 +77,10 @@ def init():
def check_compatibility(version):
if isinstance(__translation__, gettext.GNUTranslations):
header_pattern = re.compile ("^([^:\n]+): *(.*?) *$", re.MULTILINE)
header_pattern = re.compile("^([^:\n]+): *(.*?) *$", re.MULTILINE)
header_entries = dict(header_pattern.findall(_("")))
if (header_entries["Project-Id-Version"] != "gitinspector {0}".format(version)):
if header_entries["Project-Id-Version"] != "gitinspector {0}".format(version):
print("WARNING: The translation for your system locale is not up to date with the current gitinspector "
"version. The current maintainer of this locale is {0}.".format(header_entries["Last-Translator"]),
file=sys.stderr)

View File

@ -17,10 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from __future__ import unicode_literals
from localization import N_
from outputable import Outputable
from changes import FileDiff
import comment
import filtering
@ -31,19 +28,19 @@ import subprocess
__metric_eloc__ = {"java": 500, "c": 500, "cpp": 500, "cs": 500, "h": 300, "hpp": 300, "php": 500, "py": 500, "glsl": 1000,
"rb": 500, "js": 500, "sql": 1000, "xml": 1000}
__metric_cc_tokens__ = [[["java", "js", "c", "cc", "cpp"], ["else", "for\s+\(.*\)", "if\s+\(.*\)", "case\s+\w+:",
"default:", "while\s+\(.*\)"],
__metric_cc_tokens__ = [[["java", "js", "c", "cc", "cpp"], ["else", r"for\s+\(.*\)", r"if\s+\(.*\)", r"case\s+\w+:",
"default:", r"while\s+\(.*\)"],
["assert", "break", "continue", "return"]],
[["cs"], ["else", "for\s+\(.*\)", "foreach\s+\(.*\)", "goto\s+\w+:", "if\s+\(.*\)", "case\s+\w+:",
"default:", "while\s+\(.*\)"],
[["cs"], ["else", r"for\s+\(.*\)", r"foreach\s+\(.*\)", r"goto\s+\w+:", r"if\s+\(.*\)", r"case\s+\w+:",
"default:", r"while\s+\(.*\)"],
["assert", "break", "continue", "return"]],
[["py"], ["^\s+elif .*:$", "^\s+else:$", "^\s+for .*:", "^\s+if .*:$", "^\s+while .*:$"],
["^\s+assert", "break", "continue", "return"]]]
[["py"], [r"^\s+elif .*:$", r"^\s+else:$", r"^\s+for .*:", r"^\s+if .*:$", r"^\s+while .*:$"],
[r"^\s+assert", "break", "continue", "return"]]]
METRIC_CYCLOMATIC_COMPLEXITY_THRESHOLD = 50
METRIC_CYCLOMATIC_COMPLEXITY_DENSITY_THRESHOLD = 0.75
class MetricsLogic:
class MetricsLogic(object):
def __init__(self):
self.eloc = {}
self.cyclomatic_complexity = {}

View File

@ -21,21 +21,17 @@ from __future__ import print_function
from __future__ import unicode_literals
import blame
import changes
import format
import gravatar
import terminal
import textwrap
class ResponsibiltyEntry:
class ResponsibiltyEntry(object):
blames = {}
class Responsibilities:
class Responsibilities(object):
@staticmethod
def get(hard, useweeks, author_name):
author_blames = {}
for i in blame.get(hard, useweeks, changes.get(hard)).blames.items():
if (author_name == i[0][0]):
if author_name == i[0][0]:
total_rows = i[1].rows - i[1].comments
if total_rows > 0:
author_blames[i[0][1]] = total_rows

View File

@ -24,8 +24,8 @@ import platform
import sys
import unicodedata
__bold__ = "\033[1m"
__normal__ = "\033[0;0m"
__bold__ = "\033[1m"
__normal__ = "\033[0;0m"
DEFAULT_TERMINAL_SIZE = (80, 25)

View File

@ -17,15 +17,10 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from __future__ import unicode_literals
import datetime
import format
import gravatar
import terminal
import textwrap
class TimelineData:
class TimelineData(object):
def __init__(self, changes, useweeks):
authordateinfo_list = sorted(changes.get_authordateinfo_list().items())
self.changes = changes