def save(self, path): self.config = CustomConfigParser(self.encoding) for name, a_filter in self.filters.items(): section_name = a_filter.PREFIX + (a_filter.filter_or and "OR_" or "AND_") + name if not self.config.has_section(section_name): self.config.add_section(section_name) for prop_name, value in a_filter.as_dict().items(): self.config.set(section_name, prop_name, value) DocSaverMixin.save(self, path)
def load(self, path): """fill document with information from .profile file""" # load config if not DocSaverMixin.load(self, path): return False # synchronize cache for section in self.config.sections(): props = self.config.items(section) for filter_class in self.FILTERS: name, new_filter = filter_class.from_str(section, props) if new_filter is None: continue else: self.filters[name] = new_filter break # add match all self._create_match_all()
def to_stream(self): """returns a file object containing values""" self._set_repositories() self._set_files() self._set_peers() return DocSaverMixin.to_stream(self)
def load(self, path): """fill document with information from .profile file""" result = DocSaverMixin.load(self, path) self.get_files() self.get_peers() return result
def save(self, path): """fill document with information from .profile file""" self._set_repositories() self._set_files() self._set_peers() DocSaverMixin.save(self, path)
def __init__(self, encoding=ENCODING): DocSaverMixin.__init__(self, encoding)