Exemplo n.º 1
0
    def __init__(self, rev=None, options=None, vc=None, cwd=None):
        self._init_options(options, cwd=cwd)

        from pep8radius.vcs import VersionControl
        if vc is None:
            vc = VersionControl.which()
        elif isinstance(vc, basestring):
            vc = VersionControl.from_string(vc)
        else:
            assert (issubclass(vc, VersionControl))
        self.vc = vc(cwd=self.cwd)

        self.root = self.vc.root
        self.rev = self.vc.branch_point(rev)
        # Note: This may raise a CalledProcessError, if it does it means
        # that there's been an error with the version control command.
        filenames = self.vc.get_filenames_diff(self)
        self.filenames_diff = self._clean_filenames(filenames)
Exemplo n.º 2
0
    def __init__(self, rev=None, options=None, vc=None, cwd=None):
        self._init_options(options, cwd=cwd)

        from pep8radius.vcs import VersionControl
        if vc is None:
            vc = VersionControl.which()
        elif isinstance(vc, basestring):
            vc = VersionControl.from_string(vc)
        else:
            assert(issubclass(vc, VersionControl))
        self.vc = vc(cwd=self.cwd)

        self.root = self.vc.root
        self.rev = self.vc.branch_point(rev)
        # Note: This may raise a CalledProcessError, if it does it means
        # that there's been an error with the version control command.
        filenames = self.vc.get_filenames_diff(self)
        self.filenames_diff = self._clean_filenames(filenames)
Exemplo n.º 3
0
def apply_config_defaults(parser, args, root):
    """Update the parser's defaults from either the arguments' config_arg or
    the config files given in config_files(root)."""
    if root is None:
        try:
            from pep8radius.vcs import VersionControl
            root = VersionControl.which().root_dir()
        except NotImplementedError:
            pass  # don't update local, could be using as module

    config = SafeConfigParser()
    config.read(args.global_config)
    if root and not args.ignore_local_config:
        config.read(local_config_files(root))

    try:
        defaults = dict((k.lstrip('-').replace('-', '_'), v)
                        for k, v in config.items("pep8"))
        parser.set_defaults(**defaults)
    except NoSectionError:
        pass  # just do nothing, potentially this could raise ?
    return parser
Exemplo n.º 4
0
def apply_config_defaults(parser, args, root):
    """Update the parser's defaults from either the arguments' config_arg or
    the config files given in config_files(root)."""
    if root is None:
        try:
            from pep8radius.vcs import VersionControl
            root = VersionControl.which().root_dir()
        except NotImplementedError:
            pass  # don't update local, could be using as module

    config = SafeConfigParser()
    config.read(args.global_config)
    if root and not args.ignore_local_config:
        config.read(local_config_files(root))

    try:
        defaults = dict((k.lstrip('-').replace('-', '_'), v)
                        for k, v in config.items("pep8"))
        parser.set_defaults(**defaults)
    except NoSectionError:
        pass  # just do nothing, potentially this could raise ?
    return parser