diff options
| author | jvoisin | 2015-12-02 17:07:19 +0100 |
|---|---|---|
| committer | jvoisin | 2015-12-02 17:22:45 +0100 |
| commit | 80ece3001895ea13d50915a5215fd47e313bab4c (patch) | |
| tree | c5ede43867c5d7fe2af4178b34b0e6dc219f6aac /libmat/hachoir_editor/field.py | |
| parent | 3cf80e8b5d6faf410e9ad3aad77f23cf6418a587 (diff) | |
Remove hachoir from MAT.
This (huge) commit removes completely hachoir from MAT.
Audio files are now processed with mutagen, and images
with exiftool, since the main python imaging library (PIL)
isn't super-great to deal with metadata (and damaged/non-standard
files).
Package maintainer should change the dependencies to reflect this.
Diffstat (limited to 'libmat/hachoir_editor/field.py')
| -rw-r--r-- | libmat/hachoir_editor/field.py | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/libmat/hachoir_editor/field.py b/libmat/hachoir_editor/field.py deleted file mode 100644 index 6b1efe3..0000000 --- a/libmat/hachoir_editor/field.py +++ /dev/null | |||
| @@ -1,69 +0,0 @@ | |||
| 1 | from hachoir_core.error import HachoirError | ||
| 2 | from hachoir_core.field import joinPath, MissingField | ||
| 3 | |||
| 4 | class EditorError(HachoirError): | ||
| 5 | pass | ||
| 6 | |||
| 7 | class FakeField(object): | ||
| 8 | """ | ||
| 9 | This class have API looks similar to Field API, but objects don't contain | ||
| 10 | any value: all values are _computed_ by parent methods. | ||
| 11 | |||
| 12 | Example: FakeField(editor, "abc").size calls editor._getFieldSize("abc"). | ||
| 13 | """ | ||
| 14 | is_field_set = False | ||
| 15 | |||
| 16 | def __init__(self, parent, name): | ||
| 17 | self._parent = parent | ||
| 18 | self._name = name | ||
| 19 | |||
| 20 | def _getPath(self): | ||
| 21 | return joinPath(self._parent.path, self._name) | ||
| 22 | path = property(_getPath) | ||
| 23 | |||
| 24 | def _getName(self): | ||
| 25 | return self._name | ||
| 26 | name = property(_getName) | ||
| 27 | |||
| 28 | def _getAddress(self): | ||
| 29 | return self._parent._getFieldAddress(self._name) | ||
| 30 | address = property(_getAddress) | ||
| 31 | |||
| 32 | def _getSize(self): | ||
| 33 | return self._parent.input[self._name].size | ||
| 34 | size = property(_getSize) | ||
| 35 | |||
| 36 | def _getValue(self): | ||
| 37 | return self._parent.input[self._name].value | ||
| 38 | value = property(_getValue) | ||
| 39 | |||
| 40 | def createDisplay(self): | ||
| 41 | # TODO: Returns new value if field is altered | ||
| 42 | return self._parent.input[self._name].display | ||
| 43 | display = property(createDisplay) | ||
| 44 | |||
| 45 | def _getParent(self): | ||
| 46 | return self._parent | ||
| 47 | parent = property(_getParent) | ||
| 48 | |||
| 49 | def hasValue(self): | ||
| 50 | return self._parent.input[self._name].hasValue() | ||
| 51 | |||
| 52 | def __getitem__(self, key): | ||
| 53 | # TODO: Implement this function! | ||
| 54 | raise MissingField(self, key) | ||
| 55 | |||
| 56 | def _isAltered(self): | ||
| 57 | return False | ||
| 58 | is_altered = property(_isAltered) | ||
| 59 | |||
| 60 | def writeInto(self, output): | ||
| 61 | size = self.size | ||
| 62 | addr = self._parent._getFieldInputAddress(self._name) | ||
| 63 | input = self._parent.input | ||
| 64 | stream = input.stream | ||
| 65 | if size % 8: | ||
| 66 | output.copyBitsFrom(stream, addr, size, input.endian) | ||
| 67 | else: | ||
| 68 | output.copyBytesFrom(stream, addr, size//8) | ||
| 69 | |||
