Python glob 模块,glob1() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用glob.glob1()

项目:filibuster    作者:LettError    | 项目源码 | 文件源码
def index(tagname):
    """Return the name of the submodule that tagname is defined in,
    as well as a list of modules and keys in which this tagname is used."""
    mods = glob.glob1(__path__[0], '*.py')
    keys = []
    usedin = {}

    for m in mods:
        if m[:2] == '__':
            continue
        modname = __name__ + '.' + m[:-3]
        path = string.split(modname, '.')
        module = __import__(modname)
        # find the deepest submodule
        for modname in path[1:]:
            module = getattr(module, modname)
        if hasattr(module, 'content'):
            c = module.content
            for k in c.keys():
                if k == tagname:
                    keys.append(m)
                for item in c[k]:
                    if string.find(item, tagname) !=  -1:
                        usedin[(m, k)] = 1
    return keys, usedin.keys()
项目:Sample-Code    作者:meigrafd    | 项目源码 | 文件源码
def logit(message):
    line = "["+ time.strftime("%d.%m.%Y %H:%M:%S") +"]  "+ message
    print line
    if Logging:
        if get_filesize(Logfile) >= MAXLOGSIZE:
            if LOGROTATE:
                print "["+ time.strftime("%d.%m.%Y %H:%M:%S") +"]  Rotating Logfile"
                file_count = len(glob.glob1(os.path.dirname(Logfile), os.path.basename(Logfile)+"*"))
                new_file_count = (file_count + 1)
                if file_count == 1:
                    extension = ".1"
                elif file_count > 1:
                    extension = "."+ str(new_file_count)
                os.rename(Logfile, Logfile + extension)
            else:
                os.remove(Logfile)
        with open(Logfile, 'a') as f:
            f.write(line +"\n")
项目:TACTIC-Handler    作者:listyque    | 项目源码 | 文件源码
def get_info_from_updates_folder(files_list=False):
    updates_dir = '{0}/updates'.format(env_mode.get_current_path())
    json_files = glob.glob1(updates_dir, '*.json')
    if files_list:
        return json_files
    updates_list = []
    for jf in json_files:
        if jf != 'versions.json':
            print '{0}/{1}'.format(updates_dir, jf)
            updates_list.append(read_json_from_path('{0}/{1}'.format(updates_dir, jf)))

    return updates_list
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
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
项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
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
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
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
项目:django    作者:alexsukhrin    | 项目源码 | 文件源码
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
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
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
项目:DjangoBlog    作者:0daybug    | 项目源码 | 文件源码
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
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def build_pdbzip():
    pdbexclude = ['kill_python.pdb', 'make_buildinfo.pdb',
                  'make_versioninfo.pdb']
    path = "python-%s%s-pdb.zip" % (full_current_version, msilib.arch_ext)
    pdbzip = zipfile.ZipFile(path, 'w')
    for f in glob.glob1(os.path.join(srcdir, PCBUILD), "*.pdb"):
        if f not in pdbexclude and not f.endswith('_d.pdb'):
            pdbzip.write(os.path.join(srcdir, PCBUILD, f), f)
    pdbzip.close()
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def build_pdbzip():
    pdbexclude = ['kill_python.pdb', 'make_buildinfo.pdb',
                  'make_versioninfo.pdb']
    path = "python-%s%s-pdb.zip" % (full_current_version, msilib.arch_ext)
    pdbzip = zipfile.ZipFile(path, 'w')
    for f in glob.glob1(os.path.join(srcdir, PCBUILD), "*.pdb"):
        if f not in pdbexclude and not f.endswith('_d.pdb'):
            pdbzip.write(os.path.join(srcdir, PCBUILD, f), f)
    pdbzip.close()
项目:tensorflow-layer-library    作者:bioinf-jku    | 项目源码 | 文件源码
def __resume_from_dir__(self, dir):
        # setup working directory
        working_dir = os.path.realpath(dir)
        self.timestamp = os.path.basename(working_dir)

        # Set up result folder structure
        results_path = "{}/results".format(working_dir, self.timestamp)

        # Set up tensorboard directory
        tensorboard = "{}/tensorboard".format(working_dir, self.timestamp)

        # set path to kill file (if this file exists abort run)
        kill_file_name = "ABORT_RUN"
        kill_file = os.path.join(working_dir, kill_file_name)
        if os.path.exists(kill_file):
            os.remove(kill_file)

        # create plot file to plot by default
        plot_file_name = "PLOT_ON"
        plot_file = os.path.join(working_dir, plot_file_name)

        if not (os.path.exists(results_path) or not os.path.exists(tensorboard)):
            raise Exception("can not resume from given directory")

        checkpoints = glob.glob1(results_path, "*.ckpt*")
        checkpoints = [checkpoint for checkpoint in checkpoints if
                       not (".meta" in checkpoint or ".index" in checkpoint)]
        checkpoints = natsorted(checkpoints)
        checkpoint = os.path.join(results_path, checkpoints[-1])

        if not os.path.exists(checkpoint):
            raise Exception("could not find checkpoint in given directory")

        if not checkpoint.endswith("ckpt"):
            checkpoint = checkpoint[:checkpoint.index(".ckpt.") + 5]

        return [working_dir, results_path, tensorboard, kill_file, plot_file, checkpoint]
项目:wanblog    作者:wanzifa    | 项目源码 | 文件源码
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
项目:tabmaster    作者:NicolasMinghetti    | 项目源码 | 文件源码
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
项目:trydjango18    作者:lucifer-yqh    | 项目源码 | 文件源码
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
项目:simplebot    作者:korneevm    | 项目源码 | 文件源码
def send_cat(bot, update, user_data):
    cat_list = glob1("cats", "*.jp*g")
    cat_pic = os.path.join('cats', random.choice(cat_list))
    chat_id = update.message.chat_id
    bot.send_photo(chat_id=chat_id, photo=open(cat_pic, 'rb'))
项目:simplebot    作者:korneevm    | 项目源码 | 文件源码
def send_cat(bot, update, user_data):
    cat_list = glob1("cats", "*.jp*g")
    cat_pic = os.path.join('cats', random.choice(cat_list))
    chat_id = update.message.chat_id
    bot.send_photo(chat_id=chat_id, photo=open(cat_pic, 'rb'))
项目:simplebot    作者:korneevm    | 项目源码 | 文件源码
def send_cat(bot, update, user_data):
    user = get_user(update.effective_user, user_data)
    cat_list = glob1("cats", "*.jp*g")
    cat_pic = os.path.join('cats', random.choice(cat_list))
    chat_id = update.message.chat_id
    bot.send_photo(chat_id=chat_id, photo=open(cat_pic, 'rb'))
项目:sc2_predictor    作者:hellno    | 项目源码 | 文件源码
def get_sample_count(path, classes):
    count = 0
    for name in class_names:
        count += len(glob.glob1(path + name + '/', '*.png'))
    return count
项目:trydjango18    作者:wei0104    | 项目源码 | 文件源码
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
项目:ims    作者:ims-team    | 项目源码 | 文件源码
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
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
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
项目:django-open-lecture    作者:DmLitov4    | 项目源码 | 文件源码
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
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def demo():
    import glob
    winDir=win32api.GetWindowsDirectory()
    for fileName in glob.glob1(winDir, '*.bmp')[:2]:
        bitmapTemplate.OpenDocumentFile(os.path.join(winDir, fileName))
项目:picasso    作者:jungmannlab    | 项目源码 | 文件源码
def loadTif(self):

        self.path = QtGui.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]').split(','))

            for i in range(0, self.tifCounter):
                self.table.setItem(i, 0, QtGui.QTableWidgetItem(self.tifFiles[i]))
项目:filibuster    作者:LettError    | 项目源码 | 文件源码
def content():
    """Return one dictionary that contains all dictionaries of the
    module. By making a function rather than part of the namespace,
    the content can be updated dynamically. Should not make any
    difference in speed for normal use."""

    global _contentCache

    if _contentCache is not None:
        return _contentCache

    # import each time by looking at the files
    mods = glob.glob1(__path__[0], '*.py')
    _contentCache = content = {}

    for m in mods:
        if m[:2] == '__':
            continue
        modname = __name__ + '.' + m[:-3]
        path = string.split(modname, '.')
        module = __import__(modname)
        # find the deepest submodule
        for modname in path[1:]:
            module = getattr(module, modname)
        if hasattr(module, 'content'):
            content.update(module.content)
            continue
        else:
            if DEBUG:
                print __name__, 'submodule ', module, 'misses a content dictionary.'
    return content
项目:travlr    作者:gauravkulkarni96    | 项目源码 | 文件源码
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
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def demo():
    import glob
    winDir=win32api.GetWindowsDirectory()
    for fileName in glob.glob1(winDir, '*.bmp')[:2]:
        bitmapTemplate.OpenDocumentFile(os.path.join(winDir, fileName))
项目:kaggle_amazon    作者:asanakoy    | 项目源码 | 文件源码
def get_last_checkpoint(model_dir):
    list_of_models = glob.glob1(model_dir, '*.hdf5')
    ckpt_epochs = [int(x.split('-')[-2]) for x in list_of_models]
    print ckpt_epochs
    latest_model_name = list_of_models[np.argsort(ckpt_epochs)[-1]]
    epoch_num = int(latest_model_name.split('-')[-2])
    print 'last snapshot:', latest_model_name
    print 'last epoch=', epoch_num
    return os.path.join(model_dir, latest_model_name), epoch_num
项目:logo-gen    作者:jellene4eva    | 项目源码 | 文件源码
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
项目:liberator    作者:libscie    | 项目源码 | 文件源码
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
项目:gmail_scanner    作者:brandonhub    | 项目源码 | 文件源码
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
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
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
项目:probesc    作者:bstaint    | 项目源码 | 文件源码
def find_modules(self, src_dir):
        ''' ?????? '''
        for fn in glob.glob1(src_dir, '[!_]*.py'):
            yield os.path.splitext(fn)[0]
项目:CSCE482-WordcloudPlus    作者:ggaytan00    | 项目源码 | 文件源码
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
项目:producthunt    作者:davidgengler    | 项目源码 | 文件源码
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
项目:django-rtc    作者:scifiswapnil    | 项目源码 | 文件源码
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
项目:pw_Houdini_VEX_Editor    作者:paulwinex    | 项目源码 | 文件源码
def theme_menu(self):
        actions = self.menuTheme.actions()
        for i in actions[2:]:
            self.menuTheme.removeAction(i)

        path = os.path.join(os.path.dirname(__file__), 'colors').replace('\\','/')
        files = glob.glob1(path, '*.json')
        for f in files:
            full = os.path.join(path, f).replace('\\','/')
            d = json.load(open(full))
            a = QAction(d['name'], self, triggered=lambda f=d['name']:self.set_theme(f))
            self.menuTheme.addAction(a)
项目:pw_Houdini_VEX_Editor    作者:paulwinex    | 项目源码 | 文件源码
def update_backup_menu(self):
        actions = self.backup_menu_act.actions()
        for i in actions[3:]:
            self.backup_menu_act.removeAction(i)

        backupdir = vex_settings.backup_folder()
        for b in glob.glob1(backupdir, '*.backup'):
            act = QAction(b, self)
            # act.setData(os.path.join(backupdir, b).replace('\\','/'))
            path = os.path.join(backupdir, b).replace('\\','/')
            act.triggered.connect(lambda x=path: self.restore_backup(x))
            self.backup_menu_act.addAction(act)
项目:pw_Houdini_VEX_Editor    作者:paulwinex    | 项目源码 | 文件源码
def get_themes(self):
        path = self.themes_path()
        themes = []
        for c in glob.glob1(path, '*.json'):
            try:
                data = json.load(open(os.path.join(path, c)))
            except:
                continue
            data['path'] = os.path.join(path, c).replace('\\','/')
            themes.append(data)
        return themes
项目:geekpoint    作者:Lujinghu    | 项目源码 | 文件源码
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
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
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
项目:LatinSounds_AppEnviaMail    作者:G3ek-aR    | 项目源码 | 文件源码
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
项目:DjangoZeroToHero    作者:RayParra    | 项目源码 | 文件源码
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
项目:Roboism    作者:markroxor    | 项目源码 | 文件源码
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
项目:django-wechat-api    作者:crazy-canux    | 项目源码 | 文件源码
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