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): # 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 == u"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): log.debug(u'get_attributes: {0}'.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() return self._resource_map_resolver.get_attributes( object_tree_root, path)
def get_attributes(self, object_tree_root, path): log.debug( u'get_attributes: {0}'.format(util.string_from_path_elements(path)) ) # All items rendered by the ObjectTree Resolver are folders. Anything else is # deferred to one of the child resolvers. # To determine where the path transitions from the object_tree to the # controlled hierarchy, we check for the controlled hierarchy root names. # This means that those names are reserved. They can not be used as # object_tree folder names by the user. try: object_tree_folder = self._object_tree.get_folder(path, object_tree_root) except ONEDriveException: pass else: return attributes.Attributes(is_dir=True) #if len(path) > 0: # if path[-1] == self._get_help_name(): # return attributes.Attributes(size=self._folderHelpSize(object_tree_folder), # is_dir=False) # If the path is not to a object_tree folder root, a valid path must go to a # controlled hierarchy root or subfolder THROUGH a object_tree folder root. In # that case, the first path element that matches the reserved name of one of # the controlled hierarchy roots becomes the separator between the two # sections and determines which resolver to use for the tail section of the # path. object_tree_path, root_name, controlled_path = self._split_path_by_reserved_name( path ) # If the object_tree_path is not valid now and is not the readme file, then # the path is invalid. try: object_tree_folder = self._object_tree.get_folder( object_tree_path, object_tree_root ) except ONEDriveException: raise onedrive_exceptions.PathException(u'Invalid folder') if self._is_readme_file([root_name]): return self._get_readme_file_attributes(object_tree_path) # Now have all information required for gathering information about all the # objects in the object_tree folder and dispatching to a controlled hierarchy # resolver. #object_tree_folder = ObjectTreeFolderObjects(self._object_tree, object_tree_folder) return self._resolvers[root_name].get_attributes( object_tree_folder, controlled_path )
def _get_readme_file_attributes(self): return attributes.Attributes(size=len(self._readme_txt), is_dir=False)
def _get_readme_file_attributes(self, object_tree_path): return attributes.Attributes( size=len(self._generate_readme_text(object_tree_path)), is_dir=False )
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): return attributes.Attributes(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_attributes(self, object_tree_root, path): return attributes.Attributes(0, is_dir=True)
def _get_attributes(self, path): if self._is_readme_file(path): return self._get_readme_file_attributes() return attributes.Attributes(0, is_dir=True)
def _get_search_fields_file_attributes(self, record): return attributes.Attributes(size=len( self._generate_search_fields_text(record)), is_dir=False)