Return a bytes representation or raise a KeyError.
(self, key)
| 1046 | return msg |
| 1047 | |
| 1048 | def get_bytes(self, key): |
| 1049 | """Return a bytes representation or raise a KeyError.""" |
| 1050 | try: |
| 1051 | if self._locked: |
| 1052 | f = open(os.path.join(self._path, str(key)), 'rb+') |
| 1053 | else: |
| 1054 | f = open(os.path.join(self._path, str(key)), 'rb') |
| 1055 | except OSError as e: |
| 1056 | if e.errno == errno.ENOENT: |
| 1057 | raise KeyError('No message with key: %s' % key) |
| 1058 | else: |
| 1059 | raise |
| 1060 | with f: |
| 1061 | if self._locked: |
| 1062 | _lock_file(f) |
| 1063 | try: |
| 1064 | return f.read().replace(linesep, b'\n') |
| 1065 | finally: |
| 1066 | if self._locked: |
| 1067 | _unlock_file(f) |
| 1068 | |
| 1069 | def get_file(self, key): |
| 1070 | """Return a file-like representation or raise a KeyError.""" |
nothing calls this directly
no test coverage detected