def _get_attributes(self, object_tree_folder, path): if path == ['readme.txt']: return attributes.Attributes(len(self._readme_txt)) merged_region_tree = self._get_merged_region_tree(object_tree_folder) region_tree_item, unconsumed_path = self._get_region_tree_item_and_unconsumed_path( merged_region_tree, path) if self._region_tree_item_is_pid(region_tree_item): try: return self._resource_map_resolver.get_attributes( object_tree_folder, [region_tree_item] + unconsumed_path) except onedrive_exceptions.NoResultException: pass return attributes.Attributes(0, is_dir=True)
def get_attributes(self, object_tree_root, path): log.debug('get_attributes: {}'.format(util.string_from_path_elements(path))) if not path: return attributes.Attributes(is_dir=True) if self._is_readme_file(path): return self._get_readme_file_attributes() self._object_tree.add_object_to_cache(path[-1]) return self._resource_map_resolver.get_attributes(object_tree_root, path)
def _get_attributes(self, object_tree_root, path): # d1_object handles two levels: # /pid # /pid/pid.ext # /pid/system.xml # /pid/search_fields.txt # The parent resolver must not strip the PID off the path. assert len(path) pid = path[0] try: record = self._object_tree.get_object_record(pid) except onedrive_exceptions.ONEDriveException: self._raise_invalid_path() # This resolver does not call out to any other resolvers. # Any path that is deeper than two levels, and any path that is one level, # but does not reference one of the fixed filenames is invalid. # Any path that is 1 level is a pid folder. We return the size of the # science object as the size of this folder. This is only indicative of the # actual size of the folder since the folder contains other objects as well. # But the filesystem drivers and clients do not seem to mind. On Linux, the # size of a folder is rarely taken into account since it indicates the # amount of disk space used for storing the folder record (an entirely # filesystem dependent size). if len(path) == 1: return attributes.Attributes(is_dir=True, size=record["size"], date=record["dateUploaded"]) elif len(path) == 2: filename = path[1] if filename == self._get_search_fields_filename(): return self._get_search_fields_file_attributes(record) elif filename == self._get_pid_filename(pid, record): return attributes.Attributes(size=record["size"], date=record["dateUploaded"]) elif filename == "system.xml": sys_meta_xml = self._object_tree.get_system_metadata(pid) return attributes.Attributes(size=len(sys_meta_xml), date=record["dateUploaded"]) self._raise_invalid_path()
def _get_attributes(self, object_tree_root, path): return attributes.Attributes(0, is_dir=True)
def _get_attributes(self, path): return attributes.Attributes(0, is_dir=True)
def _get_attributes(self, object_tree_root, path): return attributes.Attributes(self._get_resource_map_size(path[0]), is_dir=True)
def _get_attributes(self, path): if self._is_root(path): return attributes.Attributes(is_dir=True) return self._dispatch_get_attributes(path)
def _get_search_fields_file_attributes(self, record): return attributes.Attributes(size=len( self._generate_search_fields_text(record)), is_dir=False)
def _get_readme_file_attributes(self): return attributes.Attributes(size=len(self._readme_txt), is_dir=False)