mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
0d9fbc1ad7
This version of SickBeard uses both TVDB and TVRage to search and gather it's series data from allowing you to now have access to and download shows that you couldn't before because of being locked into only what TheTVDB had to offer. Also this edition is based off the code we used in our XEM editon so it does come with scene numbering support as well as all the other features our XEM edition has to offer. Please before using this with your existing database (sickbeard.db) please make a backup copy of it and delete any other database files such as cache.db and failed.db if present, we HIGHLY recommend starting out with no database files at all to make this a fresh start but the choice is at your own risk! Enjoy!
73 lines
2.2 KiB
Python
73 lines
2.2 KiB
Python
"""
|
|
Very basic field: raw content with a size in byte. Use this class for
|
|
unknown content.
|
|
"""
|
|
|
|
from lib.hachoir_core.field import Field, FieldError
|
|
from lib.hachoir_core.tools import makePrintable
|
|
from lib.hachoir_core.bits import str2hex
|
|
from lib.hachoir_core import config
|
|
|
|
MAX_LENGTH = (2**64)
|
|
|
|
class RawBytes(Field):
|
|
"""
|
|
Byte vector of unknown content
|
|
|
|
@see: L{Bytes}
|
|
"""
|
|
static_size = staticmethod(lambda *args, **kw: args[1]*8)
|
|
|
|
def __init__(self, parent, name, length, description="Raw data"):
|
|
assert issubclass(parent.__class__, Field)
|
|
if not(0 < length <= MAX_LENGTH):
|
|
raise FieldError("Invalid RawBytes length (%s)!" % length)
|
|
Field.__init__(self, parent, name, length*8, description)
|
|
self._display = None
|
|
|
|
def _createDisplay(self, human):
|
|
max_bytes = config.max_byte_length
|
|
if type(self._getValue) is type(lambda: None):
|
|
display = self.value[:max_bytes]
|
|
else:
|
|
if self._display is None:
|
|
address = self.absolute_address
|
|
length = min(self._size / 8, max_bytes)
|
|
self._display = self._parent.stream.readBytes(address, length)
|
|
display = self._display
|
|
truncated = (8 * len(display) < self._size)
|
|
if human:
|
|
if truncated:
|
|
display += "(...)"
|
|
return makePrintable(display, "latin-1", quote='"', to_unicode=True)
|
|
else:
|
|
display = str2hex(display, format=r"\x%02x")
|
|
if truncated:
|
|
return '"%s(...)"' % display
|
|
else:
|
|
return '"%s"' % display
|
|
|
|
def createDisplay(self):
|
|
return self._createDisplay(True)
|
|
|
|
def createRawDisplay(self):
|
|
return self._createDisplay(False)
|
|
|
|
def hasValue(self):
|
|
return True
|
|
|
|
def createValue(self):
|
|
assert (self._size % 8) == 0
|
|
if self._display:
|
|
self._display = None
|
|
return self._parent.stream.readBytes(
|
|
self.absolute_address, self._size / 8)
|
|
|
|
class Bytes(RawBytes):
|
|
"""
|
|
Byte vector: can be used for magic number or GUID/UUID for example.
|
|
|
|
@see: L{RawBytes}
|
|
"""
|
|
pass
|
|
|