Relative imports to fix packaging issues

This commit is contained in:
Marc Harper 2015-10-20 09:40:08 -07:00
parent f2a4cb92d3
commit 9abb9b3d56
19 changed files with 152 additions and 121 deletions

View file

@ -19,20 +19,22 @@
from __future__ import print_function
from __future__ import unicode_literals
from localization import N_
from changes import FileDiff
import comment
import datetime
import filtering
import format
import interval
import multiprocessing
import re
import subprocess
import sys
import terminal
import threading
from . import changes
from . import comment
from . import filtering
from . import format
from . import interval
from .localization import N_
from . import terminal
NUM_THREADS = multiprocessing.cpu_count()
class BlameEntry(object):
@ -138,11 +140,11 @@ class Blame(object):
row = row.encode("latin-1", "replace")
row = row.decode("utf-8", "replace").strip("\"").strip("'").strip()
if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
if changes.FileDiff.is_valid_extension(row) and not filtering.set_filtered(changes.FileDiff.get_filename(row)):
blame_command = filter(None, ["git", "blame", "--line-porcelain", "-w"] + \
(["-C", "-C", "-M"] if hard else []) +
[interval.get_since(), interval.get_ref(), "--", row])
thread = BlameThread(useweeks, changes, blame_command, FileDiff.get_extension(row), self.blames, row.strip())
thread = BlameThread(useweeks, changes, blame_command, changes.FileDiff.get_extension(row), self.blames, row.strip())
thread.daemon = True
thread.start()

View file

@ -19,14 +19,16 @@
from __future__ import unicode_literals
import datetime
import extensions
import filtering
import interval
import multiprocessing
import os
import subprocess
import threading
from . import extensions
from . import filtering
from . import interval
CHANGES_PER_THREAD = 200
NUM_THREADS = multiprocessing.cpu_count()

View file

@ -18,14 +18,16 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import extensions
import filtering
import format
import interval
import optval
import os
import subprocess
from . import extensions
from . import filtering
from . import format
from . import interval
from . import optval
def __read_git_config__(repo, variable):
previous_directory = os.getcwd()
os.chdir(repo)

View file

@ -19,16 +19,18 @@
from __future__ import print_function
from __future__ import unicode_literals
import localization
import version
import base64
import basedir
import os
import terminal
import textwrap
import time
import zipfile
from . import basedir
from . import localization
from . import terminal
from . import version
__available_formats__ = ["html", "htmlembedded", "text", "xml"]
DEFAULT_FORMAT = __available_formats__[2]

View file

@ -20,35 +20,36 @@
from __future__ import print_function
from __future__ import unicode_literals
import localization
localization.init()
import sys
sys.path.append("gitinspector")
from output import outputable
from output.blameoutput import BlameOutput
from output.changesoutput import ChangesOutput
from output.extensionsoutput import ExtensionsOutput
from output.filteringoutput import FilteringOutput
from output.metricsoutput import MetricsOutput
from output.responsibilitiesoutput import ResponsibilitiesOutput
from output.timelineoutput import TimelineOutput
import atexit
import basedir
import changes
import clone
import config
import extensions
import filtering
import format
import help
import interval
import getopt
import os
import optval
import terminal
import version
import sys
from . import basedir
from . import changes
from . import clone
from . import config
from . import extensions
from . import filtering
from . import format
from . import help
from . import interval
from . import localization
from . import optval
from . import terminal
from . import version
from .output import outputable
from .output.blameoutput import BlameOutput
from .output.changesoutput import ChangesOutput
from .output.extensionsoutput import ExtensionsOutput
from .output.filteringoutput import FilteringOutput
from .output.metricsoutput import MetricsOutput
from .output.responsibilitiesoutput import ResponsibilitiesOutput
from .output.timelineoutput import TimelineOutput
localization.init()
class Runner(object):
def __init__(self):

View file

@ -18,12 +18,14 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import hashlib
try:
from urllib.parse import urlencode
except:
from urllib import urlencode
import format
import hashlib
from . import format
def get_url(email, size=20):
md5hash = hashlib.md5(email.encode("utf-8").lower().strip()).hexdigest()

View file

@ -19,10 +19,13 @@
from __future__ import print_function
from __future__ import unicode_literals
from extensions import DEFAULT_EXTENSIONS
from format import __available_formats__
import sys
from .extensions import DEFAULT_EXTENSIONS
from .format import __available_formats__
__doc__ = _("""Usage: {0} [OPTION]... [REPOSITORY]
List information about the repository in REPOSITORY. If no repository is
specified, the current directory is used. If multiple repositories are

View file

@ -20,11 +20,6 @@
from __future__ import print_function
from __future__ import unicode_literals
try:
import basedir
except:
import gitinspector.basedir as basedir
import gettext
import locale
import os
@ -32,6 +27,11 @@ import re
import sys
import time
try:
from . import basedir
except:
import gitinspector.basedir as basedir
__enabled__ = False
__installed__ = False
__translation__ = None

View file

@ -18,13 +18,15 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from changes import FileDiff
import comment
import filtering
import interval
import re
import subprocess
from . import changes
from . import comment
from . import filtering
from . import interval
__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}
@ -54,11 +56,11 @@ class MetricsLogic(object):
i = i.encode("latin-1", "replace")
i = i.decode("utf-8", "replace").strip("\"").strip("'").strip()
if FileDiff.is_valid_extension(i) and not filtering.set_filtered(FileDiff.get_filename(i)):
if changes.FileDiff.is_valid_extension(i) and not filtering.set_filtered(changes.FileDiff.get_filename(i)):
file_r = subprocess.Popen(["git", "show", interval.get_ref() + ":{0}".format(i.strip())],
bufsize=1, stdout=subprocess.PIPE).stdout.readlines()
extension = FileDiff.get_extension(i)
extension = changes.FileDiff.get_extension(i)
lines = MetricsLogic.get_eloc(file_r, extension)
cycc = MetricsLogic.get_cyclomatic_complexity(file_r, extension)

View file

@ -19,16 +19,19 @@
from __future__ import print_function
from __future__ import unicode_literals
from localization import N_
from .outputable import Outputable
import blame
import format
import gravatar
import json
import sys
import terminal
import textwrap
from .. import blame
from .. import format
from .. import gravatar
from ..localization import N_
from .. import terminal
from .outputable import Outputable
BLAME_INFO_TEXT = N_("Below are the number of rows from each author that have survived and are still "
"intact in the current revision")

View file

@ -19,15 +19,18 @@
from __future__ import print_function
from __future__ import unicode_literals
from localization import N_
from .outputable import Outputable
import changes
import format
import gravatar
import json
import terminal
import textwrap
from .. import changes
from .. import format
from .. import gravatar
from ..localization import N_
from .. import terminal
from .outputable import Outputable
HISTORICAL_INFO_TEXT = N_("The following historical commit information, by author, was found in the repository")
NO_COMMITED_FILES_TEXT = N_("No commited files with the specified extensions were found")

View file

@ -19,12 +19,16 @@
from __future__ import print_function
from __future__ import unicode_literals
import extensions
from localization import N_
from .outputable import Outputable
import terminal
import textwrap
from .. import extensions
from ..localization import N_
from .. import terminal
from .outputable import Outputable
EXTENSIONS_INFO_TEXT = N_("The extensions below were found in the repository history")
EXTENSIONS_MARKED_TEXT = N_("(extensions used during statistical analysis are marked)")

View file

@ -19,13 +19,14 @@
from __future__ import print_function
from __future__ import unicode_literals
from filtering import __filters__
from filtering import has_filtered
from localization import N_
from .outputable import Outputable
import terminal
import textwrap
from .. import filtering
from ..localization import N_
from .. import terminal
from .outputable import Outputable
FILTERING_INFO_TEXT = N_("The following files were excluded from the statistics due to the specified exclusion patterns")
FILTERING_AUTHOR_INFO_TEXT = N_("The following authors were excluded from the statistics due to the specified exclusion patterns")
FILTERING_EMAIL_INFO_TEXT = N_("The authors with the following emails were excluded from the statistics due to the specified " \
@ -47,12 +48,12 @@ class FilteringOutput(Outputable):
return filtering_xml
def output_html(self):
if has_filtered():
if filtering.has_filtered():
filtering_xml = "<div><div class=\"box\">"
FilteringOutput.__output_html_section__(_(FILTERING_INFO_TEXT), __filters__["file"][1])
FilteringOutput.__output_html_section__(_(FILTERING_AUTHOR_INFO_TEXT), __filters__["author"][1])
FilteringOutput.__output_html_section__(_(FILTERING_EMAIL_INFO_TEXT), __filters__["email"][1])
FilteringOutput.__output_html_section__(_(FILTERING_COMMIT_INFO_TEXT), __filters__["revision"][1])
FilteringOutput.__output_html_section__(_(FILTERING_INFO_TEXT), filtering.__filters__["file"][1])
FilteringOutput.__output_html_section__(_(FILTERING_AUTHOR_INFO_TEXT), filtering.__filters__["author"][1])
FilteringOutput.__output_html_section__(_(FILTERING_EMAIL_INFO_TEXT), filtering.__filters__["email"][1])
FilteringOutput.__output_html_section__(_(FILTERING_COMMIT_INFO_TEXT), filtering.__filters__["revision"][1])
filtering_xml += "</div></div>"
print(filtering_xml)
@ -67,10 +68,10 @@ class FilteringOutput(Outputable):
print("...%s" % i[-width+3:] if len(i) > width else i)
def output_text(self):
FilteringOutput.__output_text_section__(_(FILTERING_INFO_TEXT), __filters__["file"][1])
FilteringOutput.__output_text_section__(_(FILTERING_AUTHOR_INFO_TEXT), __filters__["author"][1])
FilteringOutput.__output_text_section__(_(FILTERING_EMAIL_INFO_TEXT), __filters__["email"][1])
FilteringOutput.__output_text_section__(_(FILTERING_COMMIT_INFO_TEXT), __filters__["revision"][1])
FilteringOutput.__output_text_section__(_(FILTERING_INFO_TEXT), filtering.__filters__["file"][1])
FilteringOutput.__output_text_section__(_(FILTERING_AUTHOR_INFO_TEXT), filtering.__filters__["author"][1])
FilteringOutput.__output_text_section__(_(FILTERING_EMAIL_INFO_TEXT), filtering.__filters__["email"][1])
FilteringOutput.__output_text_section__(_(FILTERING_COMMIT_INFO_TEXT), filtering.__filters__["revision"][1])
@staticmethod
def __output_xml_section__(info_string, filtered, container_tagname):
@ -86,10 +87,10 @@ class FilteringOutput(Outputable):
print("\t\t</{0}>".format(container_tagname))
def output_xml(self):
if has_filtered():
if filtering.has_filtered():
print("\t<filtering>")
FilteringOutput.__output_xml_section__(_(FILTERING_INFO_TEXT), __filters__["file"][1], "files")
FilteringOutput.__output_xml_section__(_(FILTERING_AUTHOR_INFO_TEXT), __filters__["author"][1], "authors")
FilteringOutput.__output_xml_section__(_(FILTERING_EMAIL_INFO_TEXT), __filters__["email"][1], "emails")
FilteringOutput.__output_xml_section__(_(FILTERING_COMMIT_INFO_TEXT), __filters__["revision"][1], "revision")
FilteringOutput.__output_xml_section__(_(FILTERING_INFO_TEXT), filtering.__filters__["file"][1], "files")
FilteringOutput.__output_xml_section__(_(FILTERING_AUTHOR_INFO_TEXT), filtering.__filters__["author"][1], "authors")
FilteringOutput.__output_xml_section__(_(FILTERING_EMAIL_INFO_TEXT), filtering.__filters__["email"][1], "emails")
FilteringOutput.__output_xml_section__(_(FILTERING_COMMIT_INFO_TEXT), filtering.__filters__["revision"][1], "revision")
print("\t</filtering>")

View file

@ -19,9 +19,10 @@
from __future__ import print_function
from __future__ import unicode_literals
from localization import N_
from ..localization import N_
from .. import metrics
from .outputable import Outputable
import metrics
ELOC_INFO_TEXT = N_("The following files are suspiciously big (in order of severity)")
CYCLOMATIC_COMPLEXITY_TEXT = N_("The following files have an elevated cyclomatic complexity (in order of severity)")

View file

@ -19,7 +19,7 @@
from __future__ import print_function
from __future__ import unicode_literals
import format
from .. import format
class Outputable(object):
def output_html(self):

View file

@ -19,16 +19,19 @@
from __future__ import print_function
from __future__ import unicode_literals
from localization import N_
from .outputable import Outputable
import blame
import changes
import format
import gravatar
import responsibilities as resp
import terminal
import textwrap
from .. import blame
from .. import changes
from .. import format
from .. import gravatar
from ..localization import N_
from .. import responsibilities as resp
from .. import terminal
from .outputable import Outputable
RESPONSIBILITIES_INFO_TEXT = N_("The following repsonsibilties, by author, were found in the current "
"revision of the repository (comments are exluded from the line count, "
"if possible)")

View file

@ -19,13 +19,15 @@
from __future__ import print_function
from __future__ import unicode_literals
from localization import N_
from .outputable import Outputable
import format
import gravatar
import terminal
import textwrap
import timeline
from .. import format
from .. import gravatar
from ..localization import N_
from .. import terminal
from .. import timeline
from .outputable import Outputable
TIMELINE_INFO_TEXT = N_("The following history timeline has been gathered from the repository")
MODIFIED_ROWS_TEXT = N_("Modified Rows:")

View file

@ -19,8 +19,9 @@
from __future__ import print_function
from __future__ import unicode_literals
import blame
import changes
from . import blame
from . import changes
class ResponsibiltyEntry(object):
blames = {}

View file

@ -20,12 +20,9 @@
from __future__ import print_function
from __future__ import unicode_literals
try:
import localization
localization.init()
except:
import gitinspector.localization
gitinspector.localization.init()
from . import localization
localization.init()
__version__ = "0.4.3dev"