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


Python glob.glob1方法代碼示例

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


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

示例1: collect_room

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def collect_room(building_name, room_name):
  room_dir = os.path.join(DATA_DIR, 'Stanford3dDataset_v1.2', building_name,
                          room_name, 'Annotations')
  files = glob.glob1(room_dir, '*.txt')
  files = sorted(files, key=lambda s: s.lower())
  vertexs = []; colors = [];
  for f in files:
    file_name = os.path.join(room_dir, f)
    logging.info('  %s', file_name)
    a = np.loadtxt(file_name)
    vertex = a[:,:3]*1.
    color = a[:,3:]*1
    color = color.astype(np.uint8)
    vertexs.append(vertex)
    colors.append(color)
  files = [f.split('.')[0] for f in files]
  out = {'vertexs': vertexs, 'colors': colors, 'names': files}
  return out 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:20,代碼來源:script_preprocess_annoations_S3DIS.py

示例2: have_similar_img

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def have_similar_img(base_img, comp_img_path, threshold=10):
    """
    Check whether comp_img_path have a image looks like base_img.
    """
    support_img_format = ['jpg', 'jpeg', 'gif', 'png', 'pmp']
    comp_images = []
    if os.path.isdir(comp_img_path):
        for ext in support_img_format:
            comp_images.extend([os.path.join(comp_img_path, x) for x in
                                glob.glob1(comp_img_path, '*.%s' % ext)])
    else:
        comp_images.append(comp_img_path)

    for img in comp_images:
        if img_similar(base_img, img, threshold):
            return True
    return False 
開發者ID:avocado-framework,項目名稱:avocado-vt,代碼行數:19,代碼來源:ppm_utils.py

示例3: import_shapers

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def import_shapers(logger):
    (_, zip_path) = tempfile.mkstemp()
    (_, http_message) = request.urlretrieve(url, zip_path)
    zip_file = ZipFile(zip_path)
    ex_dir = tempfile.mkdtemp()
    zip_file.extractall(ex_dir)
    shapefiles = glob.glob1(ex_dir, "*.shp")
    lm = LayerMapping(Parcel, "/data/shapefiles/M274TaxPar.shp", {
        "shape_leng": "SHAPE_Leng",
        "shape_area": "SHAPE_Area",
        "map_par_id": "MAP_PAR_ID",
        "loc_id": "LOC_ID",
        "poly_type": "POLY_TYPE",
        "map_no": "MAP_NO",
        "source": "SOURCE",
        "plan_id": "PLAN_ID",
        "last_edit": "LAST_EDIT",
        "town_id": "TOWN_ID",
        "shape": "POLYGON"
    }) 
開發者ID:codeforboston,項目名稱:cornerwise,代碼行數:22,代碼來源:cambridgema.py

示例4: table_water_level

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def table_water_level(lake, startdate, enddate, result_dir, output_file=None):
    # Grabs lake names from .txt files in the results folder.
    lakes = [i.split('.')[0] for i in glob.glob1(result_dir,'*txt')]

    # Compares lake names found from .txt files with the chosen lake. If a match is found, the parser is run.
    if lake in lakes:
        lake_dir = result_dir + os.sep + lake + '.txt'
        (features, dates, water, clouds) = parse_lake_results(lake_dir, startdate, enddate)

        # Error-catcher for situation where a date range is selected and no good points are available for plotting.
        if water == False:
            print "No good data points found in selected date range. Please try a larger date range and retry."
        # Table creating and saving block:
        else:
            # Error catching for invalid directories.
            if output_file == None:
                output_file = result_dir + '/' + lake + '.csv'
            with open(output_file, 'wb') as f:
                writer = csv.writer(f)
                writer.writerow(["Date", "Area (km^2)"])
                writer.writerows(izip(dates, water)) 
開發者ID:nasa,項目名稱:CrisisMappingToolkit,代碼行數:23,代碼來源:plot_water_levelui.py

示例5: plot_water_level

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def plot_water_level(lake, startdate, enddate, result_dir):
    # Grabs lake names from .txt files in the results folder.
    lakes = [i.split('.')[0] for i in glob.glob1(result_dir,'*txt')]

    # Compares lake names found from .txt files with the chosen lake. If a match is found, the parser is run.
    if lake in lakes:
        lake = result_dir + os.sep + lake + '.txt'
        (features, dates, water, clouds) = parse_lake_results(lake, startdate, enddate)

        # Error-catcher for situation where a date range is selected and no good points are available for plotting.
        if water == False:
            print "No good data points found in selected date range. Please try a larger date range."
        # plot_results(features, dates, water, clouds, None, 'results/mono_lake_elevation.txt')
        else:
            plot_results(features, dates, water, clouds)
            plt.show()

    # Notifies user if the data file for the selected lake has not been generated yet.
    else:
        print "Specified lake data file not found. Please retrieve data and try again." 
開發者ID:nasa,項目名稱:CrisisMappingToolkit,代碼行數:22,代碼來源:plot_water_levelui.py

示例6: checker

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def checker(folder, typ, infile, item, asset, start, end, cmin, cmax,outfile):
    print('Now Searching....')
    allasset = idl(infile = infile, item = item, asset = asset, start = start, end = end, cmin = cmin, cmax = cmax)
    sprefix = {'PSScene4Band': '_3B', 'REOrthoTile': '_R', 'PSScene3Band': '_3B', 'PSOrthoTile': '_BGRN'}
    sval = sprefix.get(item)
    if typ == 'image':
        filenames = glob.glob1(folder,"*.tif")
        l = []
        for items in filenames:
            l.append(items.split(sval)[0])
        print('Number of items not found locally: '+str(len(set(allasset)-set(l))))
        print('IDlist written to '+str(outfile)+' with '+str(len(set(allasset)-set(l))))
        with open(outfile, "w") as f:
            for s in list(set(allasset)-set(l)):
                f.write(str(s) +"\n")
    if typ=='metadata':
        filenames=glob.glob1(folder,"*.xml")
        l=[]
        for items in filenames:
            l.append(items.split(sval)[0])
        print('Number of items not found locally: '+str(len(set(allasset).difference(set(l)))))
        print('IDlist written to '+str(outfile)+' with '+str(len(set(allasset)-set(l)))+' ids')
        with open(outfile, "w") as f:
            for s in list(set(allasset)-set(l)):
                f.write(str(s) +"\n") 
開發者ID:tyson-swetnam,項目名稱:porder,代碼行數:27,代碼來源:diffcheck.py

示例7: load_building_meshes

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def load_building_meshes(self, building):
    dir_name = os.path.join(building['data_dir'], 'mesh', building['name'])
    mesh_file_name = glob.glob1(dir_name, '*.obj')[0]
    mesh_file_name_full = os.path.join(dir_name, mesh_file_name)
    logging.error('Loading building from obj file: %s', mesh_file_name_full)
    shape = renderer.Shape(mesh_file_name_full, load_materials=True, 
                           name_prefix=building['name']+'_')
    return [shape] 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:10,代碼來源:factory.py

示例8: _list_cache_files

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def _list_cache_files(self):
        """
        Get a list of paths to all the cache files. These are all the files
        in the root cache dir that end on the cache_suffix.
        """
        if not os.path.exists(self._dir):
            return []
        filelist = [os.path.join(self._dir, fname) for fname
                    in glob.glob1(self._dir, '*%s' % self.cache_suffix)]
        return filelist 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:12,代碼來源:filebased.py

示例9: demo

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def demo():
	import glob
	winDir=win32api.GetWindowsDirectory()
	for fileName in glob.glob1(winDir, '*.bmp')[:2]:
		bitmapTemplate.OpenDocumentFile(os.path.join(winDir, fileName)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:bitmap.py

示例10: glob

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def glob(self, pattern, exclude = None):
        """Add a list of files to the current component as specified in the
        glob pattern. Individual files can be excluded in the exclude list."""
        files = glob.glob1(self.absolute, pattern)
        for f in files:
            if exclude and f in exclude: continue
            self.add_file(f)
        return files 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:__init__.py

示例11: run

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def run(logger=None):
    shapefiles_dir = download_shapefiles(shapefile_url, logger)

    try:
        shapefile = os.path.join(
            shapefiles_dir, glob.glob1(shapefiles_dir, "M274TaxPar.shp")[0])
        assessor_data = os.path.join(
            shapefiles_dir, glob.glob1(shapefiles_dir, "M274Assess.dbf")[0])
        import_shapes(shapefile, logger)
        add_assessor_data(assessor_data, logger)
    finally:
        shutil.rmtree(shapefiles_dir) 
開發者ID:codeforboston,項目名稱:cornerwise,代碼行數:14,代碼來源:somervillema.py

示例12: get_new_file_name

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def get_new_file_name(path):
    video_counter = len(glob.glob1(path, "*.avi"))
    filename = "demo_%03d" % video_counter
    return path + time_stamped(filename) + ".avi" 
開發者ID:dronekit,項目名稱:visual-followme,代碼行數:6,代碼來源:file_utils.py

示例13: max_globs

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def max_globs():
    for f in range(MAX_GLOBS):
        tmpfile = tempfile.NamedTemporaryFile(prefix='tmp_', suffix='_glob', delete=False)
        tmpfile.close()
        with open(tmpfile.name, 'w') as fd:
            fd.write(DATA)
    yield tempfile.gettempdir()
    for fle in glob.glob1(tempfile.gettempdir(), "tmp_*_glob"):
        os.remove(tempfile.gettempdir() + "/" + fle)


# hack to find this source file and not the .pyc version of it 
開發者ID:RedHatInsights,項目名稱:insights-core,代碼行數:14,代碼來源:test_specs.py

示例14: pred_samples

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def pred_samples(runs_dir, data_dir, sess, image_shape, logits, keep_prob, input_image, print_speed=False):
    # Make folder for current run
    output_dir = os.path.join(runs_dir, str(time.time()))
    if os.path.exists(output_dir):
        shutil.rmtree(output_dir)
    os.makedirs(output_dir)

    # Run NN on test images and save them to HD
    print('Predicting images...')
    # start epoch training timer

    image_outputs = gen_output(
        sess, logits, keep_prob, input_image, data_dir, image_shape)

    counter = 0
    for name, image, speed_ in image_outputs:
        scipy.misc.imsave(os.path.join(output_dir, name), image)
        if print_speed is True:
            counter+=1
            print("Processing file: {0:05d},\tSpeed: {1:.2f} fps".format(counter, speed_))

        # sum_time += laptime

    # pngCounter = len(glob1(data_dir,'*.png'))

    print('All augmented images are saved to: {}.'.format(output_dir)) 
開發者ID:JunshengFu,項目名稱:semantic_segmentation,代碼行數:28,代碼來源:helper.py

示例15: loadTif

# 需要導入模塊: import glob [as 別名]
# 或者: from glob import glob1 [as 別名]
def loadTif(self):

        self.path = QtWidgets.QFileDialog.getExistingDirectory(
            self, "Select Directory"
        )
        if self.path:

            self.tifCounter = len(_glob.glob1(self.path, "*.tif"))
            self.tifFiles = _glob.glob(os.path.join(self.path, "*.tif"))

            self.table.setRowCount(int(self.tifCounter))
            self.table.setColumnCount(6)
            self.table.setHorizontalHeaderLabels(
                [
                    "FileName",
                    "Imager concentration[nM]",
                    "Integration time [ms]",
                    "Laserpower",
                    "Mean [Photons]",
                    "Std [Photons]",
                ]
            )

            for i in range(0, self.tifCounter):
                self.table.setItem(
                    i, 0, QtWidgets.QTableWidgetItem(self.tifFiles[i])
                ) 
開發者ID:jungmannlab,項目名稱:picasso,代碼行數:29,代碼來源:simulate.py


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