python类glob1()的实例源码

__init__.py 文件源码 项目:filibuster 作者: LettError 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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()
lueftersteuerung.py 文件源码 项目:Sample-Code 作者: meigrafd 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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")
update_functions.py 文件源码 项目:TACTIC-Handler 作者: listyque 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:CodingDojo 作者: ComputerSocietyUNB 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:NarshaTech 作者: KimJangHyeon 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:Scrum 作者: prakharchoudhary 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:django 作者: alexsukhrin 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:Gypsy 作者: benticarlos 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:DjangoBlog 作者: 0daybug 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
__init__.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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
msilib.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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
msi.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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()
__init__.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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
msilib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
msi.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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()
workingdir.py 文件源码 项目:tensorflow-layer-library 作者: bioinf-jku 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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]
filebased.py 文件源码 项目:wanblog 作者: wanzifa 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:tabmaster 作者: NicolasMinghetti 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:trydjango18 作者: lucifer-yqh 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
bot2.py 文件源码 项目:simplebot 作者: korneevm 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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'))
bot3.py 文件源码 项目:simplebot 作者: korneevm 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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'))
bot4.py 文件源码 项目:simplebot 作者: korneevm 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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'))
train-ingame-classifier.py 文件源码 项目:sc2_predictor 作者: hellno 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def get_sample_count(path, classes):
    count = 0
    for name in class_names:
        count += len(glob.glob1(path + name + '/', '*.png'))
    return count
filebased.py 文件源码 项目:trydjango18 作者: wei0104 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:ims 作者: ims-team 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:lifesoundtrack 作者: MTG 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
filebased.py 文件源码 项目:django-open-lecture 作者: DmLitov4 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
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
bitmap.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def demo():
    import glob
    winDir=win32api.GetWindowsDirectory()
    for fileName in glob.glob1(winDir, '*.bmp')[:2]:
        bitmapTemplate.OpenDocumentFile(os.path.join(winDir, fileName))
simulate.py 文件源码 项目:picasso 作者: jungmannlab 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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]))
__init__.py 文件源码 项目:filibuster 作者: LettError 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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


问题


面经


文章

微信
公众号

扫码关注公众号