当前位置: 首页>>代码示例>>Python>>正文


Python diff.DiffCollection类代码示例

本文整理汇总了Python中lintreview.diff.DiffCollection的典型用法代码示例。如果您正苦于以下问题:Python DiffCollection类的具体用法?Python DiffCollection怎么用?Python DiffCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DiffCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_files__one_file

 def test_get_files__one_file(self):
     changes = DiffCollection(self.one_file)
     result = changes.get_files()
     expected = [
         "View/Helper/AssetCompressHelper.php"
     ]
     eq_(expected, result)
开发者ID:colindecarlo,项目名称:lint-review,代码行数:7,代码来源:test_diff.py

示例2: test_get_files__two_files__ignore_pattern

 def test_get_files__two_files__ignore_pattern(self):
     changes = DiffCollection(self.two_files)
     expected = [
         "Console/Command/Task/AssetBuildTask.php",
     ]
     ignore = ['Test/**']
     result = changes.get_files(ignore_patterns=ignore)
     self.assertEqual(expected, result)
开发者ID:markstory,项目名称:lint-review,代码行数:8,代码来源:test_diff.py

示例3: test_get_files__two_files

 def test_get_files__two_files(self):
     changes = DiffCollection(self.two_files)
     result = changes.get_files()
     expected = [
         "Console/Command/Task/AssetBuildTask.php",
         "Test/test_files/View/Parse/single.ctp",
     ]
     eq_(expected, result)
开发者ID:colindecarlo,项目名称:lint-review,代码行数:8,代码来源:test_diff.py

示例4: test_has_line_changed__single_line

    def test_has_line_changed__single_line(self):
        filename = 'some.js'
        pull_file = create_pull_files(self.single_line_add_json)
        changes = DiffCollection(pull_file)

        self.assertTrue(changes.has_line_changed(filename, 1))
        self.assertFalse(changes.has_line_changed(filename, 0))
        self.assertFalse(changes.has_line_changed(filename, 2))
开发者ID:markstory,项目名称:lint-review,代码行数:8,代码来源:test_diff.py

示例5: test_get_files__ignore_pattern__multiple_wildcard

 def test_get_files__ignore_pattern__multiple_wildcard(self):
     data = load_fixture('multiple_wildcard_pull_request.json')
     changes = DiffCollection(create_pull_files(data))
     expected = [
         "buildpacks/buildpack-ruby/tests/ruby-sinatra/test_web.rb",
     ]
     ignore = ['buildpacks/*/tests/*/test.sh']
     result = changes.get_files(ignore_patterns=ignore)
     self.assertEqual(expected, result)
开发者ID:markstory,项目名称:lint-review,代码行数:9,代码来源:test_diff.py

示例6: test_get_files__two_files__append_base

    def test_get_files__two_files__append_base(self):
        changes = DiffCollection(self.two_files)
        expected = [
            "/some/path/Console/Command/Task/AssetBuildTask.php",
            "/some/path/Test/test_files/View/Parse/single.ctp",
        ]
        result = changes.get_files(append_base="/some/path/")
        eq_(expected, result)

        result = changes.get_files(append_base="/some/path")
        eq_(expected, result)
开发者ID:colindecarlo,项目名称:lint-review,代码行数:11,代码来源:test_diff.py

示例7: test_add__with_diff_containing_block_offset

    def test_add__with_diff_containing_block_offset(self):
        res = Resource.loads(self.block_offset)
        changes = DiffCollection(res)

        problems = Problems(changes=changes)
        line_num = 32
        problems.add('somefile.py', line_num, 'Not good')
        eq_(1, len(problems))

        result = problems.all('somefile.py')
        eq_(changes.line_position('somefile.py', line_num), result[0].position,
            'Offset should be transformed to match value in changes')
开发者ID:hutchic,项目名称:lint-review,代码行数:12,代码来源:test_review.py

示例8: test_has_line_changed__two_files

    def test_has_line_changed__two_files(self):
        changes = DiffCollection(self.two_files)
        filename = 'Console/Command/Task/AssetBuildTask.php'

        # True for additions
        self.assertTrue(changes.has_line_changed(filename, 117))
        self.assertTrue(changes.has_line_changed(filename, 119))

        # Should return false if the line was a deletion
        self.assertFalse(changes.has_line_changed(filename, 148))

        # Should return false for unchanged
        self.assertFalse(changes.has_line_changed(filename, 145))
开发者ID:colindecarlo,项目名称:lint-review,代码行数:13,代码来源:test_diff.py

示例9: Processor

class Processor(object):

    def __init__(self, client, number, head, target_path):
        self._client = client
        self._number = number
        self._head = head
        self._target_path = target_path
        self._changes = None
        self._problems = Problems(target_path)
        self._review = Review(client, number)

    def load_changes(self):
        log.info('Loading pull request patches from github.')
        files = self._client.pull_requests.list_files(self._number)
        pull_request_patches = files.all()
        self._changes = DiffCollection(pull_request_patches)
        self._problems.set_changes(self._changes)

    def run_tools(self, review_config):
        if self._changes is None:
            raise RuntimeError('No loaded changes, cannot run tools. '
                               'Try calling load_changes first.')
        files_to_check = self._changes.get_files(
            append_base=self._target_path,
            ignore_patterns=review_config.ignore_patterns())
        tools.run(
            review_config,
            self._problems,
            files_to_check,
            self._target_path)

    def publish(self, wait_time=0):
        self._problems.limit_to_changes()
        self._review.publish(self._problems, self._head, wait_time)
开发者ID:kevinjqiu,项目名称:lint-review,代码行数:34,代码来源:processor.py

示例10: test_add__with_diff_containing_block_offset

    def test_add__with_diff_containing_block_offset(self):
        res = [
            PullFile(f, self.session) for f in json.loads(self.block_offset)
        ]
        changes = DiffCollection(res)

        problems = Problems(changes=changes)
        line_num = 32
        problems.add('somefile.py', line_num, 'Not good')
        self.assertEqual(1, len(problems))

        result = problems.all('somefile.py')
        first_result = result[0]
        self.assertIsInstance(first_result, Comment)
        self.assertEqual(
            changes.line_position('somefile.py', line_num),
            first_result.position,
            'Offset should be transformed to match value in changes'
        )
开发者ID:markstory,项目名称:lint-review,代码行数:19,代码来源:test_review.py

示例11: Processor

class Processor(object):

    _client = None
    _number = None
    _head = None
    _target_path = None
    _changes = None
    _problems = None
    _review = None
    _config = None

    def __init__(self, client, number, head, target_path, config=None):
        self._client = client
        self._number = number
        self._head = head
        self._target_path = target_path
        self._problems = Problems(target_path)
        self._review = Review(client, number)

        if config is None:
            config = {}
        self._config = config

    def load_changes(self):
        log.info('Loading pull request patches from github.')
        files = self._client.pull_requests.list_files(self._number)
        pull_request_patches = files.all()
        self._changes = DiffCollection(pull_request_patches)
        self._problems.set_changes(self._changes)

    def run_tools(self, review_config):
        if self._changes is None:
            raise RuntimeError('No loaded changes, cannot run tools. '
                               'Try calling load_changes first.')
        files_to_check = self._changes.get_files(
            append_base=self._target_path,
            ignore_patterns=review_config.ignore_patterns())
        commits_to_check = self.get_commits(self._number)
        tools.run(
            review_config,
            self._problems,
            files_to_check,
            commits_to_check,
            self._target_path)

    def publish(self):
        self._problems.limit_to_changes()
        self._review.publish(
            self._problems,
            self._head,
            self._config.get('SUMMARY_THRESHOLD'))

    def get_commits(self, number):
        return self._client.pull_requests.list_commits(number).all()
开发者ID:f3ndot,项目名称:lint-review,代码行数:54,代码来源:processor.py

示例12: Processor

class Processor(object):

    _repository = None
    _pull_request = None
    _target_path = None
    _changes = None
    _problems = None
    _review = None
    _config = None

    def __init__(self, repository, pull_request, target_path, config=None):
        config = config if config else {}
        self._config = config
        self._repository = repository
        self._pull_request = pull_request
        self._target_path = target_path
        self._problems = Problems(target_path)
        self._review = Review(repository, pull_request, config)

    def load_changes(self):
        log.info('Loading pull request patches from github.')
        files = self._pull_request.files()
        self._changes = DiffCollection(files)
        self._problems.set_changes(self._changes)

    def run_tools(self, review_config):
        if self._changes is None:
            raise RuntimeError('No loaded changes, cannot run tools. '
                               'Try calling load_changes first.')
        files_to_check = self._changes.get_files(
            append_base=self._target_path,
            ignore_patterns=review_config.ignore_patterns())
        commits_to_check = self._pull_request.commits()
        log.debug("_problems before tools: %s" % len(self._problems))
        self._problems = tools.run(
            review_config,
            self._problems,
            files_to_check,
            commits_to_check,
            self._target_path)
        log.debug("_problems after tools: %s" % len(self._problems))


    def publish(self):
        self._problems.limit_to_changes()
        self._review.publish(
            self._problems,
            self._pull_request.head,
            self._config.get('SUMMARY_THRESHOLD'))
开发者ID:vrutkovs,项目名称:lint-review,代码行数:49,代码来源:processor.py

示例13: test_has_line_changed__no_file

 def test_has_line_changed__no_file(self):
     changes = DiffCollection(self.two_files)
     self.assertFalse(changes.has_line_changed('derp', 99))
开发者ID:colindecarlo,项目名称:lint-review,代码行数:3,代码来源:test_diff.py

示例14: load_changes

 def load_changes(self):
     log.info('Loading pull request patches from github.')
     files = self._client.pull_requests.list_files(self._number)
     pull_request_patches = files.all()
     self._changes = DiffCollection(pull_request_patches)
     self._problems.set_changes(self._changes)
开发者ID:f3ndot,项目名称:lint-review,代码行数:6,代码来源:processor.py

示例15: load_changes

 def load_changes(self):
     log.info('Loading pull request patches from github.')
     files = list(self._repository.pull_request(self._number).files())
     self._changes = DiffCollection(files)
     self._problems.set_changes(self._changes)
开发者ID:coras-io,项目名称:lint-review,代码行数:5,代码来源:processor.py


注:本文中的lintreview.diff.DiffCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。