當前位置: 首頁>>代碼示例>>Python>>正文


Python glob2.glob方法代碼示例

本文整理匯總了Python中glob2.glob方法的典型用法代碼示例。如果您正苦於以下問題:Python glob2.glob方法的具體用法?Python glob2.glob怎麽用?Python glob2.glob使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在glob2的用法示例。


在下文中一共展示了glob2.glob方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_mod_data

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def create_mod_data(mod_paths):

    module_data = {}
    # load mod paths
    for m in mod_paths:
        if os.path.isdir(m):
            files = glob2.glob(os.path.join(m, "**/*.py"))
            pkg_root = os.path.abspath(os.path.dirname(m))
        else:
            pkg_root = os.path.abspath(os.path.dirname(m))
            files = [m]
        for f in files:
            f = os.path.abspath(f)
            mod_str = open(f, 'rb').read()

            dest_filename = f[len(pkg_root)+1:].replace(os.sep, "/")
            module_data[dest_filename] = bytes_to_b64str(mod_str)

    return module_data 
開發者ID:pywren,項目名稱:pywren,代碼行數:21,代碼來源:util.py

示例2: getFiles

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def getFiles(inputElement, extensions = PC_FILE_FORMATS, recursive = False):
    """ Get the list of files with certain extensions contained in the folder (and possible
subfolders) given by inputElement. If inputElement is directly a file it
returns a list with only one element, the given file """
    # If extensions is not a list but a string we converted to a list
    if type(extensions) == str:
        extensions = [extensions,]
    # If input element is file, return it
    if(os.path.isfile(inputElement)):
        fname,fext = os.path.splitext(inputElement)
        return [inputElement] if fext.lower() in extensions else []
    # Else, use recursive globbing
    files = []
    globpath = os.path.join(inputElement,'**') if recursive else inputElement
    for ext in extensions:
        files.extend(glob2.glob(os.path.join(globpath,'*.' + ext)))
        files.extend(glob2.glob(os.path.join(globpath,'*.' + ext.upper())))
    return list(set(files)) 
開發者ID:NLeSC,項目名稱:Massive-PotreeConverter,代碼行數:20,代碼來源:utils.py

示例3: _reset_filelist

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def _reset_filelist(self):
        sample_set = self.sample_set
        datatype = self.datatype
        print(datatype)
        print(sample_set)
        print(self.train_dir)
        if sample_set == 'train':
            if datatype == 'detail_data':
                self.filelist = glob2.glob(self.train_dir + '/**/*_rgb.npy')
                random.shuffle(self.filelist)
        if sample_set == 'valid':
            if datatype == 'detail_data':
                self.filelist = glob2.glob(self.valid_dir + '/**/*_rgb.npy')
                random.shuffle(self.filelist)
        if sample_set == 'test':
            if datatype == 'detail_data':
                self.filelist = glob2.glob(self.test_dir + '/**/*_rgb.npy')
                random.shuffle(self.filelist)
        self.currentindex = 0
        self.datanum = len(self.filelist) 
開發者ID:sfu-gruvi-3dv,項目名稱:deep_human,代碼行數:22,代碼來源:detail_hooker.py

示例4: list_files_in

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def list_files_in(directory, ignore_git_folder, ignore_file):
    '''Receives a path to a directory and returns
    paths to all files along with each mimetype'''
    file_list = []
    for root, dirs, files in os.walk(directory):
        for file in files:
            file_list.append(os.path.join(root, file))

    file_list = set(file_list)

    glob_rules = []

    if ignore_git_folder:
            glob_rules.append('.git/**')

    #Check if ignore file was provided
    if ignore_file is not None:
        glob_rules += parse_ignore_file(ignore_file)

    if len(glob_rules):
        glob_matches = match_glob_rules_in_directory(glob_rules, directory)
        #Remove files in file_list that matched any glob rule
        file_list = file_list - glob_matches

    return file_list 
開發者ID:dssg,項目名稱:repo-scraper,代碼行數:27,代碼來源:filesystem.py

示例5: __init__

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def __init__(self, panels_path, ocr_file, ad_path, dims, max_panels, max_boxes, max_words, max_vocab_size, h5path):

        self.panels_path = panels_path
        # self.images_path = images_path

        # self.n_pages = glob2.glob(join(self.images_path, '*', '*.jpg')) 
        # takes a really long time

        self.ocr_file = ocr_file
        self.dev_idx, self.test_idx, self.n_pages = self.compute_fold_starts()

        self.n_pages -= self.subtract_ad_pages(ad_path)

        self.dims = dims
        self.h5path = h5path
        self.max_panels = max_panels
        self.max_boxes = max_boxes
        self.max_words = max_words
        self.max_vocab_size = max_vocab_size
        self.dump_vocabulary('./data/comics_vocab.p') 
開發者ID:miyyer,項目名稱:comics,代碼行數:22,代碼來源:create_hdf5.py

示例6: _RmGlob

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def _RmGlob(file_wildcard, root, include_hidden):
  """Removes files matching 'file_wildcard' in root and its subdirectories, if
  any exists.

  An exception is thrown if root doesn't exist."""
  wildcard = os.path.join(os.path.realpath(root), file_wildcard)
  for item in glob2.glob(wildcard, include_hidden=include_hidden):
    try:
      os.remove(item)
    except OSError, e:
      if e.errno != errno.ENOENT:
        raise 
開發者ID:luci,項目名稱:recipes-py,代碼行數:14,代碼來源:fileutil.py

示例7: _Glob

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def _Glob(base, pattern, include_hidden):
  base = os.path.realpath(base)
  hits = glob2.glob(os.path.join(base, pattern), include_hidden=include_hidden)
  if hits:
    print('\n'.join(sorted((os.path.relpath(hit, start=base) for hit in hits)))) 
開發者ID:luci,項目名稱:recipes-py,代碼行數:7,代碼來源:fileutil.py

示例8: get_module_string

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def get_module_string(tests_path):
    path = get_module_path()
    tests_path = os.path.abspath(os.path.join(path, os.path.pardir, tests_path))
    test_files = glob2.glob(tests_path)
    relative_test_files = [get_ws_relative_route(test_file) for test_file in test_files]
    module_strings = [".".join(test_file)[:-3] for test_file in relative_test_files]
    return module_strings 
開發者ID:bq,項目名稱:web2board,代碼行數:9,代碼來源:TestRunner.py

示例9: find_files

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def find_files(path, patterns):
    if not isinstance(patterns, (list, tuple, set)):
        patterns = [patterns]
    files = []
    for pattern in patterns:
        files += glob2.glob(path + os.sep + pattern)
    return list(set(files)) 
開發者ID:bq,項目名稱:web2board,代碼行數:9,代碼來源:utils.py

示例10: list_serial_ports

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def list_serial_ports(ports_filter=None):
    ports = list(serial.tools.list_ports.comports())
    if ports_filter is not None:
        ports = filter(ports_filter, ports)
    if is_mac():
        ports = ports + [[x] for x in glob('/dev/tty.*') if x not in map(lambda x: x[0], ports)]
    return list(ports) 
開發者ID:bq,項目名稱:web2board,代碼行數:9,代碼來源:utils.py

示例11: test_maps

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def test_maps():
    sample_dir = os.path.join(os.path.dirname(__file__), "mapfiles")
    pth = sample_dir + r'/**/*.map'
    mapfiles = glob2.glob(pth)
    mapfiles = [f for f in mapfiles if "basemaps" not in f]

    for fn in mapfiles:
        logging.info("Processing {}".format(fn))
        fn = os.path.join(sample_dir, fn)
        pr = cProfile.Profile()
        pr.enable()
        output(fn)
        pr.disable()
        # pr.print_stats(sort='time') 
開發者ID:geographika,項目名稱:mappyfile,代碼行數:16,代碼來源:test_map_collection.py

示例12: live

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def live():
    """Run livereload server"""
    from livereload import Server

    server = Server(app)

    map(server.watch, glob2.glob("application/pages/**/*.*"))  # pages
    map(server.watch, glob2.glob("application/macros/**/*.html"))  # macros
    map(server.watch, glob2.glob("application/static/**/*.*"))  # public assets

    server.serve(port=PORT) 
開發者ID:Akagi201,項目名稱:learning-python,代碼行數:13,代碼來源:manage.py

示例13: copy_runtime

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def copy_runtime(tgt_dir):
    files = glob(os.path.join(pywren.SOURCE_DIR, "jobrunner/*.py"))
    for f in files:
        shutil.copy(f, os.path.join(tgt_dir, os.path.basename(f))) 
開發者ID:pywren,項目名稱:pywren,代碼行數:6,代碼來源:standalone.py

示例14: LoadModules

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def LoadModules(self):
        # loop and assign key and name
        warnings.filterwarnings('ignore', '.*Parent module*',)
        x = 1
        for name in glob2.glob('Modules/**/*.py'):
            if name.endswith(".py") and ("__init__" not in name):
                loaded_modules = imp.load_source(
                    name.replace("/", ".").rstrip('.py'), name)
                self.Modules[name] = loaded_modules
                self.Dmodules[x] = loaded_modules
                x += 1
        # print self.Dmodules
        # print self.Modules 
開發者ID:SimplySecurity,項目名稱:SimplyTemplate,代碼行數:15,代碼來源:TaskController.py

示例15: produce_normal_file

# 需要導入模塊: import glob2 [as 別名]
# 或者: from glob2 import glob [as 別名]
def produce_normal_file(data_dir):
    filelist = glob2.glob(data_dir + '/**/*_rgb.png')
    print('Total {} images'.format(len(filelist)))

    for curidx in range(len(filelist)):
        if curidx % 100 ==0:
            print('Processing image number', curidx)
        name = filelist[curidx]
        frameindex = name[-12:-8]
        # name = '/home/sicong/detail_data/data/3/0235_rgb.png'
        try:
            img_full = io.imread(name)
        except:
            continue
        depth_full = io.imread(name[0:-8] + '_depth.png')
        depthcount = np.sum(depth_full > 100)
        if depthcount < 100 * 100:
            continue
        rot = 0
        scale = util.getScale_detail(depth_full)
        center = util.getCenter_detail(depth_full)
        if (center[0] < 1 or center[1] < 1 or center[1] > img_full.shape[0] or center[0] > img_full.shape[1]):
            continue

        ori_mask = depth_full > 100
        pcd = PointCloud(np.expand_dims(depth_full, 0), np.expand_dims(ori_mask, 0))
        ori_normal = pcd.get_normal().squeeze(0)
        gt_normal = util_detail.cropfor3d(ori_normal, center, scale, rot, 256, 'nearest')
        gt_normal = normal_util.normalize(gt_normal)
        normal_file_name = name[0:-8] + '_normal.npy'
        np.save(normal_file_name, gt_normal) 
開發者ID:sfu-gruvi-3dv,項目名稱:deep_human,代碼行數:33,代碼來源:produce_normal_file.py


注:本文中的glob2.glob方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。