Skip to content
Commits on Source (5)
......@@ -234,9 +234,15 @@ class File(object, metaclass=abc.ABCMeta):
if hasattr(self, '_other_file'):
return self._other_file.__class__.CONTAINER_CLASS(self)
return None
def type_name(klass):
return "{}.{}".format(klass.__module__, klass.__name__)
if not hasattr(self, '_as_container'):
logger.debug(
'instantiating %s for %s', self.__class__.CONTAINER_CLASS, self
'Instantiating a %s for %s',
type_name(self.__class__.CONTAINER_CLASS),
self.name,
)
try:
self._as_container = self.__class__.CONTAINER_CLASS(self)
......@@ -244,8 +250,8 @@ class File(object, metaclass=abc.ABCMeta):
return None
logger.debug(
"Returning a %s for %s",
self._as_container.__class__.__name__,
self,
type_name(self._as_container.__class__),
self.name,
)
return self._as_container
......@@ -467,10 +473,10 @@ class File(object, metaclass=abc.ABCMeta):
re.sub(
r'^',
' ',
val.decode('utf-8'),
val.decode('utf-8').strip(),
flags=re.MULTILINE,
),
).strip()
)
# Truncate output
max_len = 250
......
......@@ -37,7 +37,7 @@ def try_recognize(file, cls, recognizes):
return False
# Found a match; perform type magic
logger.debug("Using %s for %s", cls.__name__, file.name)
logger.debug("Using %s.%s for %s", cls.__module__, cls.__name__, file.name)
new_cls = type(cls.__name__, (cls, type(file)), {})
file.__class__ = new_cls
......
......@@ -190,7 +190,9 @@ def run_diff(fifo1, fifo2, end_nl_q1, end_nl_q2):
)
if not parser.success and p.returncode not in (0, 1):
raise subprocess.CalledProcessError(p.returncode, cmd, output=diff)
raise subprocess.CalledProcessError(
p.returncode, cmd, output=parser.diff.encode('utf-8')
)
if p.returncode == 0:
return None
......
......@@ -102,7 +102,7 @@ def from_command(command):
'\n[…]' if len(command.stdout) > 1 else '',
)
raise subprocess.CalledProcessError(
returncode, command.cmdline(), output=output
returncode, command.cmdline(), output=output.encode('utf-8')
)
return end_nl
......