当前位置: 首页>>代码示例>>Python>>正文


Python Util.listdir方法代码示例

本文整理汇总了Python中util.Util.listdir方法的典型用法代码示例。如果您正苦于以下问题:Python Util.listdir方法的具体用法?Python Util.listdir怎么用?Python Util.listdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在util.Util的用法示例。


在下文中一共展示了Util.listdir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_tree

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import listdir [as 别名]
  def get_tree(self, data_path):
    '''
    '''

    if not data_path:
      data_path = Constants.DEFAULT_DATA_FOLDER

    dir_content = sorted(Util.listdir(data_path))

    dir_listing = []

    for c in dir_content:

      full_url = os.path.join(data_path, c)

      # if not os.path.isdir(full_url):
      #   continue

      entry = {}
      entry['label'] = c
      entry['full_url'] = full_url
      entry['id'] = os.path.join(data_path, c)
      entry['load_on_demand'] = True

      dir_listing.append(entry)

    return dir_listing
开发者ID:fasrc,项目名称:mbeam,代码行数:29,代码来源:manager.py

示例2: from_directory

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import listdir [as 别名]
    def from_directory(
            directory,
            calculate_bounding_box=False,
            index_subdirs=True):
        '''
        Loads a section from a directory without loading any images.

        If the directory does not seem to be a section or is not ready,
        return None.
        '''

        if index_subdirs:

            fovs = []

            for f in Util.listdir(directory):
                fov_path = os.path.join(directory, f)

                # if not os.path.isdir(fov_path):
                #   # fovs always reside in directories
                #   continue

                fov = FoV.from_directory(fov_path, calculate_bounding_box)
                if fov:
                    fovs.append(fov)

        else:

            fovs = None

        # Read the LUTS file in the directory, if one exists
        # Should either be None or a mapping of a tile filename to its base64 luts string
        luts64_map = None
        if settings.LUTS_FILE_SUFFIX is not None:
            #section_dir_name = os.path.split(directory)[-1]
            #luts_fname = os.path.join(directory, '{}{}'.format(section_dir_name, settings.LUTS_FILE_SUFFIX))
            luts_fname = ''
            # Assuming there is only a single file with that prefix, use it
            all_dir_files = scandir.scandir(directory)
            for entry in all_dir_files:
                if entry.name.endswith(settings.LUTS_FILE_SUFFIX):
                    luts_fname = os.path.join(directory, entry.name)
                    break
            if os.path.exists(luts_fname):
                # print "Using LUTS file: {}".format(luts_fname)
                data = None
                with open(luts_fname, 'r') as f:
                    data = f.readlines()
                # Map between a file name and its luts base64 string
                luts64_map = {}
                for line in data:
                    tile_full_name, b64_str = line.split('\t')
                    tile_fname = tile_full_name.split('\\')[-1].lower() # Assuming Zeiss microscope system will always stay in windows
                    b64_str = b64_str[:-2] # Remove \r\n from the end of the string
                    luts64_map[tile_fname] = b64_str
                

        section = Section(directory, fovs, calculate_bounding_box, luts64_map)
        return section
开发者ID:Rhoana,项目名称:mb,代码行数:61,代码来源:section.py

示例3: index_fovs

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import listdir [as 别名]
    def index_fovs(self):
        '''
        '''
        fovs = []

        for f in Util.listdir(self._directory):
            fov_path = os.path.join(self._directory, f)

            # if not os.path.isdir(fov_path):
            #   # fovs always reside in directories
            #   continue

            fov = FoV.from_directory(fov_path, self._calculate_bounding_box)
            if fov:
                fovs.append(fov)

        self._fovs = fovs
开发者ID:Rhoana,项目名称:mb,代码行数:19,代码来源:section.py

示例4: from_directory

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import listdir [as 别名]
  def from_directory(directory, calculate_bounding_box=False):
    '''
    Loads a scan from a directory without loading any images.
    '''

    sections = []

    for i,s in enumerate(Util.listdir(directory)):
      section_path = os.path.join(directory, s)

      # if not os.path.isdir(section_path):
      #   # sections always reside in directories
      #   continue

      index_subdirs = i == 0

      section = Section.from_directory(section_path, calculate_bounding_box, index_subdirs)
      sections.append(section)

    scan = Scan(directory, sections)
    
    return scan
开发者ID:fasrc,项目名称:mbeam,代码行数:24,代码来源:scan.py


注:本文中的util.Util.listdir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。