GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — beedo/models.py at master · Soopro/beedo Expand file tree/ Copy pathmodels.pyMore file actions 52 lines (45 loc) · 1.47 KB / Copy pathmodels.pyFile metadata and controls52 lines (45 loc) · 1.47 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 # coding=utf8 from __future__ import absolute_import import os import yaml import urllib class Entry(dict): path = '' def __init__(self, data, path): self.path = path super(Entry, self).__init__(data) def save(self): _file = self._data_encode(dict(self)) _file = {k.capitalize(): v for k, v in _file.iteritems()} if os.path.isfile(self.path): os.remove(self.path) with open(self.path, 'w') as yaml_file: yaml.safe_dump(_file, yaml_file, default_flow_style=False, indent=2, allow_unicode=True) return self['_id'] def delete(self): if os.path.isfile(self.path): os.remove(self.path) return self['_id'] def _data_encode(self, x): if isinstance(x, dict): return {k.lower(): self._data_encode(v) for k, v in x.iteritems()} elif isinstance(x, list): return list([self._data_encode(i) for i in x]) elif isinstance(x, unicode): return urllib.unquote(x.encode('utf-8')) elif isinstance(x, str): return urllib.unquote(x) elif isinstance(x, (int, float, bool)) or x is None: return x else: try: x = urllib.unquote(str(x)) except Exception as e: print e pass return x |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |