本文整理汇总了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
示例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)
示例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")
示例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")]
示例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
示例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"
)
示例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
示例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
示例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