Commits

jm  committed 2ff8e51

* urwid & fat parser: handle broken links.
* parser: Revert default 'offset' parameter of createParser to None.

  • Participants
  • Parent commits e3c9ec3

Comments (0)

Files changed (3)

File hachoir-parser/hachoir_parser/file_system/fat.py

 
     def createValue(self):
         field = InodeGen(self["/"], self.parent, self._getTargetPath())(self)
-        self._display = field.path
-        return Link.createValue(self)
+        if field:
+            self._display = field.path
+            return Link.createValue(self)
 
     def createDisplay(self):
         return "/%s[0]" % self._getTargetPath()

File hachoir-parser/hachoir_parser/guess.py

 
 ### Choose parser for a file ###################################################
 
-def createParser(filename, force_mime=None, offset=0, size=None, real_filename=None):
+def createParser(filename, force_mime=None, offset=None, size=None, real_filename=None):
     """
     Create a parser from a file or returns None on error.
 
     # Create input stream
     stream = FileInputStream(filename, real_filename)
     if offset or size:
-        offset *= 8
         if size:
             size *= 8
-        stream = InputSubStream(stream, offset, size)
+        stream = InputSubStream(stream, 8 * max(0, offset), size)
 
     # Create field set
     if real_filename:

File hachoir-urwid/hachoir_urwid/urwid_ui.py

                     self.event = False
                     root.refresh()
                     assert not self.event
-                self.set_focus(self.fromField(root, target.path))
+                if target:
+                    self.set_focus(self.fromField(root, target.path))
         elif key == ' ':
             if self.focus.parent and self.focus.field.size != 0:
                 raise NewTab_Stream(self.focus.field)