Skip to content

Commit

Permalink
Several pylint corrections
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Hracek <phracek@redhat.com>
  • Loading branch information
phracek committed Mar 11, 2015
1 parent e18d64a commit 5fc1bb9
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 72 deletions.
27 changes: 15 additions & 12 deletions rebasehelper/build_log_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,34 @@


class BuildLogAnalyzerMissingError(RuntimeError):
"""
Error indicating build.log is missing
"""

"""Error indicating build.log is missing"""

pass


class BuildLogAnalyzerMakeError(RuntimeError):
"""
Error indicating failure problem with building
"""

"""Error indicating failure problem with building"""

pass


class BuildLogAnalyzerPatchError(RuntimeError):
"""
Error indicating failure problem with building
"""

"""Error indicating failure problem with building"""
pass


class BuildLogAnalyzer(object):
"""
Class analyze the log provided by build programs
"""

"""Class analyze the log provided by build programs"""

log_dirname = ""

@classmethod
def parse_log(cls, dir_name, log_name):

"""
Function analyze the logs for specific section
:param log_name: Logfile name which is analyzed
Expand All @@ -65,6 +65,7 @@ def parse_log(cls, dir_name, log_name):

@classmethod
def _parse_build_log(cls, log_name):

"""
Function analyzes log files in our case build.log
:param log_name:
Expand Down Expand Up @@ -129,6 +130,7 @@ def _find_patch_error(cls, section):

@classmethod
def _get_files_from_string(cls, section):

"""
Function returns files from string
If row begins with / then it appends the rest of row to field
Expand All @@ -150,6 +152,7 @@ def _parse_mock_log(cls, log_name):

@classmethod
def _find_section(cls, lines, s_reg, e_reg=None):

"""
get string from substring
:param log_name: file_name to analyze
Expand Down
23 changes: 16 additions & 7 deletions rebasehelper/output_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def check_output_argument(output_tool):


class BaseOutputTool(object):
""" Class used for testing and other future stuff, ...
Each method should overwrite method like run_check

"""
Class used for testing and other future stuff, ...
Each method should overwrite method like run_check
"""

def print_summary(self, **kwargs):
Expand All @@ -59,7 +61,9 @@ def print_summary(self, **kwargs):

@register_output_tool
class TextOutputTool(BaseOutputTool):

""" Text output tool. """

PRINT = "text"

@classmethod
Expand Down Expand Up @@ -107,21 +111,23 @@ def print_rpms(cls, rpms, version):
message = "{0} package(s): are in directory {1} :"
if isinstance(srpm, str):
logger_output.info(message.format(type_rpm.upper(),
os.path.dirname(rpms.get(srpm, ""))))
os.path.dirname(rpms.get(srpm, ""))))
logger_output.info("- {0}".format(os.path.basename(srpm)))
else:
logger_output.info(message.format(type_rpm.upper(),
os.path.dirname(srpm[0])))
os.path.dirname(srpm[0])))
for pkg in srpm:
logger_output.info("- {0}".format(os.path.basename(pkg)))

@classmethod
def print_build_logs(cls, rpms, version):

"""
Function is used for printing rpm build logs
:param kwargs:
:return:
"""

if rpms.get('logs', None) is None:
return
logger_output.info('Available {0} logs:'.format(version))
Expand All @@ -131,10 +137,12 @@ def print_build_logs(cls, rpms, version):

@classmethod
def print_summary(cls, path):

"""
Function is used for printing summary informations
:return:
"""

# First of all we would like to print all
# summary information
OutputLogger.set_info_text("Summary output is also available in log:", path)
Expand All @@ -159,18 +167,19 @@ def print_summary(cls, path):

@classmethod
def print_pkgdiff_tool(cls):

"""
Function prints a summary information about pkgcomparetool
"""

for check, data in six.iteritems(OutputLogger.get_checkers()):
if data:
logger_output.info("{0}:\n{1}".format(check, data))


class OutputTool(object):
"""
Class representing printing the final results.
"""

"""Class representing printing the final results."""

def __init__(self, output_tool=None):
if output_tool is None:
Expand Down
43 changes: 25 additions & 18 deletions rebasehelper/patch_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
# Tomas Hozza <thozza@redhat.com>

import os
import six
from rebasehelper.logger import logger
from rebasehelper.utils import ConsoleHelper
from rebasehelper.utils import GitHelper, GitRebaseError
from rebasehelper.diff_helper import GenericDiff
from rebasehelper.exceptions import RebaseHelperError

#from git import Repo
#import git
Expand All @@ -40,32 +37,29 @@ def register_patch_tool(patch_tool):


class PatchBase(object):
""" Class used for using several patching command tools, ...
Each method should overwrite method like run_check

"""
Class used for using several patching command tools, ...
Each method should overwrite method like run_check
"""

helpers = {}

@classmethod
def match(cls, cmd):
"""
Method checks whether it is usefull patch method
"""
"""Method checks whether it is usefull patch method"""
return NotImplementedError()

@classmethod
def run_patch(cls, *args, **kwargs):
"""
Method will check all patches in relevant package
"""
"""Method will check all patches in relevant package"""
return NotImplementedError()

@register_patch_tool
class GitPatchTool(PatchBase):
"""
Class for git command used for patching old and new
sources
"""

"""Class for git command used for patching old and new sources"""

CMD = 'git'
source_dir = ""
old_sources = ""
Expand All @@ -85,6 +79,12 @@ def match(cls, cmd):

@staticmethod
def apply_patch(git_helper, patch_name):
"""
Function applies patches to old sources
It tries apply patch with am command and if it fails
then with command --apply
"""
logger.debug('Applying patch with am')

ret_code = git_helper.command_am(input_file=patch_name)
Expand Down Expand Up @@ -155,6 +155,9 @@ def _git_rebase(cls):

@staticmethod
def commit_patch(git_helper, patch_name):

"""Function commits patched files to git"""

logger.debug('Commit patch')
ret_code = git_helper.command_add_files(parameters=['--all'])
if int(ret_code) != 0:
Expand All @@ -164,9 +167,8 @@ def commit_patch(git_helper, patch_name):

@classmethod
def apply_old_patches(cls, patches):
"""
Function applies a patch to a old/new sources
"""

"""Function applies a patch to a old/new sources"""
for patch in patches:
patch_path = patch.get_path()
logger.info("Applying patch '{0}' to '{1}'".format(os.path.basename(patch_path),
Expand All @@ -179,13 +181,17 @@ def apply_old_patches(cls, patches):

@classmethod
def init_git(cls, directory):

""" Function initialize old and new Git repository"""

gh = GitHelper(directory)
ret_code = gh.command_init(directory)
gh.command_add_files('.')
gh.command_commit(message='Initial Commit')

@classmethod
def run_patch(cls, old_dir, new_dir, git_helper, patches, **kwargs):

"""
The function can be used for patching one
directory against another
Expand All @@ -207,6 +213,7 @@ def run_patch(cls, old_dir, new_dir, git_helper, patches, **kwargs):


class Patcher(object):

"""
Class representing a process of applying and generating rebased patch using specific tool.
"""
Expand Down

0 comments on commit 5fc1bb9

Please sign in to comment.