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


Python Difference.from_text_readers方法代码示例

本文整理汇总了Python中diffoscope.difference.Difference.from_text_readers方法的典型用法代码示例。如果您正苦于以下问题:Python Difference.from_text_readers方法的具体用法?Python Difference.from_text_readers怎么用?Python Difference.from_text_readers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在diffoscope.difference.Difference的用法示例。


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

示例1: compare_details

# 需要导入模块: from diffoscope.difference import Difference [as 别名]
# 或者: from diffoscope.difference.Difference import from_text_readers [as 别名]
 def compare_details(self, other, source=None):
     differences = []
     differences.append(Difference.from_text_readers(list_libarchive(self.path),
                                                     list_libarchive(other.path),
                                                     self.path, other.path, source="file list"))
     differences.extend(_compare_elf_data(self.path, other.path))
     return differences
开发者ID:satyamz,项目名称:diffoscope,代码行数:9,代码来源:elf.py

示例2: compare

# 需要导入模块: from diffoscope.difference import Difference [as 别名]
# 或者: from diffoscope.difference.Difference import from_text_readers [as 别名]
 def compare(self, other, source=None):
     my_encoding = self.encoding or 'utf-8'
     other_encoding = other.encoding or 'utf-8'
     try:
         with codecs.open(self.path, 'r', encoding=my_encoding) as my_content, \
              codecs.open(other.path, 'r', encoding=other_encoding) as other_content:
             difference = Difference.from_text_readers(my_content, other_content, self.name, other.name, source)
             if my_encoding != other_encoding:
                 if difference is None:
                     difference = Difference(None, self.path, other.path, source)
                 difference.add_details([Difference.from_text(my_encoding, other_encoding, None, None, source='encoding')])
             return difference
     except (LookupError, UnicodeDecodeError):
         # unknown or misdetected encoding
         return self.compare_bytes(other, source)
开发者ID:pombredanne,项目名称:diffoscope-1,代码行数:17,代码来源:text.py

示例3: compare

# 需要导入模块: from diffoscope.difference import Difference [as 别名]
# 或者: from diffoscope.difference.Difference import from_text_readers [as 别名]
 def compare(self, other, source=None):
     logger.debug('my_content %s', self.path)
     with open(self.path) as my_content, \
          open(other.path) as other_content:
         return Difference.from_text_readers(my_content, other_content, self.name, other.name, source=source, comment="symlink")
开发者ID:satyamz,项目名称:diffoscope,代码行数:7,代码来源:symlink.py

示例4: compare_details

# 需要导入模块: from diffoscope.difference import Difference [as 别名]
# 或者: from diffoscope.difference.Difference import from_text_readers [as 别名]
 def compare_details(self, other, source=None):
     return [Difference.from_text_readers(list_libarchive(self.path),
                                     list_libarchive(other.path),
                                     self.path, other.path, source="file list")]
开发者ID:satyamz,项目名称:diffoscope,代码行数:6,代码来源:deb.py

示例5: StaticLibFile

# 需要导入模块: from diffoscope.difference import Difference [as 别名]
# 或者: from diffoscope.difference.Difference import from_text_readers [as 别名]
    The command line `ar` tool is not used any more so remove it from the
    required tools.

--- diffoscope/comparators/elf.py.orig	2016-01-31 06:32:02 UTC
+++ diffoscope/comparators/elf.py
@@ -24,8 +24,9 @@ import subprocess
 from diffoscope import tool_required, OutputParsingError
 from diffoscope import logger
 from diffoscope.comparators.binary import File
+from diffoscope.comparators.libarchive import list_libarchive
 from diffoscope.comparators.deb import DebFile, get_build_id_map
-from diffoscope.comparators.utils import get_ar_content, Command, Container
+from diffoscope.comparators.utils import Command, Container
 from diffoscope.difference import Difference
 
 
@@ -415,10 +416,8 @@ class StaticLibFile(File):
 
     def compare_details(self, other, source=None):
         differences = []
-        # look up differences in metadata
-        content1 = get_ar_content(self.path)
-        content2 = get_ar_content(other.path)
-        differences.append(Difference.from_text(
-                               content1, content2, self.path, other.path, source="metadata"))
+        differences.append(Difference.from_text_readers(list_libarchive(self.path),
+                                                        list_libarchive(other.path),
+                                                        self.path, other.path, source="file list"))
         differences.extend(_compare_elf_data(self.path, other.path))
         return differences
开发者ID:lexqbit,项目名称:freebsd-ports,代码行数:32,代码来源:patch-diffoscope_comparators_elf.py

示例6: compare

# 需要导入模块: from diffoscope.difference import Difference [as 别名]
# 或者: from diffoscope.difference.Difference import from_text_readers [as 别名]
 def compare(self, other, source=None):
     with open(self.path) as my_content, open(other.path) as other_content:
         return Difference.from_text_readers(
             my_content, other_content, self.name, other.name, source=source, comment="device"
         )
开发者ID:pombredanne,项目名称:diffoscope-1,代码行数:7,代码来源:device.py

示例7: test_too_long_diff_block_lines

# 需要导入模块: from diffoscope.difference import Difference [as 别名]
# 或者: from diffoscope.difference.Difference import from_text_readers [as 别名]
def test_too_long_diff_block_lines(monkeypatch):
    monkeypatch.setattr(Config, 'max_diff_block_lines', 10)
    too_long_text_a = StringIO("a\n" * 21)
    too_long_text_b = StringIO("b\n" * 21)
    difference = Difference.from_text_readers(too_long_text_a, too_long_text_b, 'a', 'b')
    assert '[ 11 lines removed ]' in difference.unified_diff
开发者ID:pombredanne,项目名称:diffoscope-1,代码行数:8,代码来源:test_difference.py

示例8: test_too_much_input_for_diff

# 需要导入模块: from diffoscope.difference import Difference [as 别名]
# 或者: from diffoscope.difference.Difference import from_text_readers [as 别名]
def test_too_much_input_for_diff(monkeypatch):
    monkeypatch.setattr(Config, 'max_diff_input_lines', 20)
    too_long_text_a = StringIO("a\n" * 21)
    too_long_text_b = StringIO("b\n" * 21)
    difference = Difference.from_text_readers(too_long_text_a, too_long_text_b, 'a', 'b')
    assert '[ Too much input for diff ]' in difference.unified_diff 
开发者ID:pombredanne,项目名称:diffoscope-1,代码行数:8,代码来源:test_difference.py

示例9: test_too_much_input_for_diff

# 需要导入模块: from diffoscope.difference import Difference [as 别名]
# 或者: from diffoscope.difference.Difference import from_text_readers [as 别名]
def test_too_much_input_for_diff(monkeypatch):
    monkeypatch.setattr(Config, "max_diff_input_lines", 20)
    too_long_text_a = StringIO("a\n" * 21)
    too_long_text_b = StringIO("b\n" * 21)
    difference = Difference.from_text_readers(too_long_text_a, too_long_text_b, "a", "b")
    assert "[ Too much input for diff " in difference.unified_diff
开发者ID:anthraxx,项目名称:diffoscope,代码行数:8,代码来源:test_difference.py


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