def get_repositories(self): """return list of repos""" # lazy initialisation repos = FileSharingMixin.get_repositories(self) if len(repos) > 0: return repos # full init repos = self.init_repos() for repo in repos: # create repo with out checking validity of path. # checking might be needed at loading only => checked=False FileSharingMixin.add_repository(self, repo, checked=False) return FileSharingMixin.get_repositories(self)
def get_files(self): """returns {root: Container}""" # lazy initialisation if self.files != {}: return FileSharingMixin.get_files(self) # full init for repo in self.init_repos(): try: self.files[repo] = create_container(repo, checked=False) except AssertionError: display_status("non valid repo '%s'"% repo) # if no valid repo found, does not try any further... if self.files == {}: return self.files for option in self.config.options(SECTION_FILE): # get share & tag try: o_description = self.config.get(SECTION_FILE, option) o_file, o_share, o_size, o_tag = o_description.split(',', 3) o_file = (o_file == 'F') and True or False o_share = (o_share == SHARED_TAG) o_tag = force_unicode(o_tag) o_size = int(o_size) except (ValueError, ConfigParser.NoSectionError, ConfigParser.NoOptionError), err: log("option '%s' not well formated: %s"% (o_description, err)) o_file, o_share, o_tag, o_size = False, False, DEFAULT_TAG, 0 # add container try: file_container = o_file and self.get_file(option) \ or self.get_container(option) file_container.share(o_share) file_container.tag(o_tag) file_container.size = o_size except KeyError: log("non valid file '%s'"% option)
def import_document(self, other_document): """copy data from another document into self""" CachePersonalMixin.import_document(self, other_document) FileSharingMixin.import_document(self, other_document) ContactsMixin.import_document(self, other_document)
def __init__(self): CachePersonalMixin.__init__(self) FileSharingMixin.__init__(self) ContactsMixin.__init__(self) SaverMixin.__init__(self)
def reset_files(self): """empty all information concerning files""" FileSharingMixin.reset_files(self) self.config.remove_section(SECTION_FILE) self.config.add_section(SECTION_FILE)
def __init__(self): self.config.add_section(SECTION_FILE) FileSharingMixin.__init__(self)