Identify the contents of `buf`
(self, buf)
| 92 | pass |
| 93 | |
| 94 | def from_buffer(self, buf): |
| 95 | """ |
| 96 | Identify the contents of `buf` |
| 97 | """ |
| 98 | with self.lock: |
| 99 | try: |
| 100 | # if we're on python3, convert buf to bytes |
| 101 | # otherwise this string is passed as wchar* |
| 102 | # which is not what libmagic expects |
| 103 | # NEXTBREAK: only take bytes |
| 104 | if type(buf) == str and str != bytes: |
| 105 | buf = buf.encode('utf-8', errors='replace') |
| 106 | return maybe_decode(magic_buffer(self.cookie, buf)) |
| 107 | except MagicException as e: |
| 108 | return self._handle509Bug(e) |
| 109 | |
| 110 | def from_file(self, filename): |
| 111 | # raise FileNotFoundException or IOError if the file does not exist |