• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python common.relativepath函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中music21.common.relativepath函数的典型用法代码示例。如果您正苦于以下问题:Python relativepath函数的具体用法?Python relativepath怎么用?Python relativepath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: write

 def write(self, filePath, rst): #
     '''
     Write ``rst`` (a unicode string) to ``filePath``, 
     only overwriting an existing file if the content differs.
     '''
     shouldWrite = True
     if os.path.exists(filePath):
         oldRst = common.readFileEncodingSafe(filePath, firstGuess='utf-8')
         if rst == oldRst:
             shouldWrite = False
         else:
             pass
             ## uncomment for  help in figuring out why a file keeps being different...
             #import difflib
             #print(common.relativepath(filePath))
             #print('\n'.join(difflib.ndiff(rst.split('\n'), oldRst.split('\n'))))
             
     if shouldWrite:
         with io.open(filePath, 'w', encoding='utf-8') as f:
             try:
                 f.write(rst)
             except UnicodeEncodeError as uee:
                 six.raise_from(DocumentationWritersException("Could not write %s with rst:\n%s" % (filePath, rst)), uee)
         print('\tWROTE   {0}'.format(common.relativepath(filePath)))
     else:
         print('\tSKIPPED {0}'.format(common.relativepath(filePath)))
开发者ID:folkengine,项目名称:music21,代码行数:26,代码来源:writers.py


示例2: __iter__

 def __iter__(self):
     import music21
     rootFilesystemPath = music21.__path__[0]
     for directoryPath, directoryNames, fileNames in os.walk(
         rootFilesystemPath):
         directoryNamesToRemove = []
         for directoryName in directoryNames:
             if directoryName in self._ignoredDirectoryNames:
                 directoryNamesToRemove.append(directoryName)
         for directoryName in directoryNamesToRemove:
             directoryNames.remove(directoryName)
         if '__init__.py' in fileNames:
             strippedPath = directoryPath.partition(rootFilesystemPath)[2]
             pathParts = [x for x in strippedPath.split(os.path.sep) if x]
             pathParts.insert(0, 'music21')
             packagesystemPath = '.'.join(pathParts)
             try:
                 module = __import__(packagesystemPath, fromlist=['*'])
                 if getattr(module, '_DOC_IGNORE_MODULE_OR_PACKAGE', False):
                     # Skip examining any other file or directory below
                     # this directory.
                     if self.verbose:
                         print('\tIGNORED {0}/*'.format(
                             common.relativepath(directoryPath)))
                     directoryNames[:] = []
                     continue
             except ImportError:
                 pass
         for fileName in fileNames:
             if fileName in self._ignoredFileNames:
                 continue
             if not fileName.endswith('.py'):
                 continue
             if fileName.startswith('_') and not fileName.startswith('__'):
                 continue
             filePath = os.path.join(directoryPath, fileName)
             strippedPath = filePath.partition(rootFilesystemPath)[2]
             pathParts = [x for x in os.path.splitext(
                 strippedPath)[0].split(os.path.sep)[1:] if x]
             pathParts = ['music21'] + pathParts
             packagesystemPath = '.'.join(pathParts)
             try:
                 module = __import__(packagesystemPath, fromlist=['*'])
                 if getattr(module, '_DOC_IGNORE_MODULE_OR_PACKAGE',
                     False):
                     if self.verbose:
                         print('\tIGNORED {0}'.format(
                             common.relativepath(filePath)))
                     continue
                 yield module
             except ImportError:
                 pass
     raise StopIteration
开发者ID:Wajih-O,项目名称:music21,代码行数:53,代码来源:iterators.py


示例3: run

 def run(self):
     from music21 import documentation # @UnresolvedImport
     ipythonNotebookFilePaths = [x for x in
         documentation.IPythonNotebookIterator()]
     for ipythonNotebookFilePath in ipythonNotebookFilePaths:
         nbConvertReturnCode = self.convertOneNotebook(ipythonNotebookFilePath)
         if nbConvertReturnCode is True:
             self.cleanupNotebookAssets(ipythonNotebookFilePath)
             print('\tWROTE   {0}'.format(common.relativepath(
                 ipythonNotebookFilePath)))
         else:
             print('\tSKIPPED {0}'.format(common.relativepath(
                 ipythonNotebookFilePath)))
开发者ID:antoniopessotti,项目名称:music21,代码行数:13,代码来源:writers.py


示例4: run

 def run(self):
     for ipythonNotebookFilePath in self.ipythonNotebookFilePaths:
         nbConvertReturnCode = self.convertOneNotebook(ipythonNotebookFilePath)
         if nbConvertReturnCode is True:
             self.cleanupNotebookAssets(ipythonNotebookFilePath)
             print('\tWROTE   {0}'.format(common.relativepath(
                 ipythonNotebookFilePath)))
         else:
             print('\tSKIPPED {0}'.format(common.relativepath(
                 ipythonNotebookFilePath)))
     
             # do not print anything for skipped -checkpoint files
     self.writeIndexRst()
开发者ID:folkengine,项目名称:music21,代码行数:13,代码来源:writers.py


示例5: cleanFilePath

 def cleanFilePath(self):
     corpusPath = os.path.abspath(common.getCorpusFilePath())
     if self.filePath.startswith(corpusPath):
         cleanFilePath = common.relativepath(self.filePath, corpusPath)
     else:
         cleanFilePath = self.filePath
     return cleanFilePath
开发者ID:Joshk920,项目名称:music21,代码行数:7,代码来源:caching.py


示例6: _parseNonOpus

 def _parseNonOpus(self, parsedObject):
     from music21 import metadata
     try:
         corpusPath = metadata.MetadataBundle.corpusPathToKey(
             self.cleanFilePath)
         if parsedObject.metadata is not None:
             richMetadata = metadata.RichMetadata()
             richMetadata.merge(parsedObject.metadata)
             richMetadata.update(parsedObject)  # update based on Stream
             environLocal.printDebug(
                 'updateMetadataCache: storing: {0}'.format(corpusPath))
             metadataEntry = metadata.MetadataEntry(
                 sourcePath=self.cleanFilePath,
                 metadataPayload=richMetadata,
                 )
             self.results.append(metadataEntry)
         else:
             environLocal.printDebug(
                 'addFromPaths: got stream without metadata, '
                 'creating stub: {0}'.format(
                     common.relativepath(self.cleanFilePath)))
             metadataEntry = metadata.MetadataEntry(
                 sourcePath=self.cleanFilePath,
                 metadataPayload=None,
                 )
             self.results.append(metadataEntry)
     except Exception:
         environLocal.printDebug('Had a problem with extracting metadata '
         'for {0}, piece ignored'.format(self.filePath))
         environLocal.printDebug(traceback.format_exc())
开发者ID:Joshk920,项目名称:music21,代码行数:30,代码来源:caching.py


示例7: write

 def write(self, filePath, rst): #
     '''
     Write ``rst`` (a unicode string) to ``filePath``, 
     only overwriting an existing file if the content differs.
     '''
     shouldWrite = True
     if os.path.exists(filePath):
         oldRst = common.readFileEncodingSafe(filePath, firstGuess='utf-8')
         if rst == oldRst:
             shouldWrite = False
     if shouldWrite:
         with open(filePath, 'w') as f:
             f.write(rst)
         print('\tWROTE   {0}'.format(common.relativepath(filePath)))
     else:
         print('\tSKIPPED {0}'.format(common.relativepath(filePath)))
开发者ID:Wajih-O,项目名称:music21,代码行数:16,代码来源:writers.py


示例8: write

 def write(self, filePath, rst): #
     '''
     Write ``lines`` to ``filePath``, only overwriting an existing file
     if the content differs.
     '''
     shouldWrite = True
     if os.path.exists(filePath):
         with open(filePath, 'r') as f:
             oldRst = f.read()
         if rst == oldRst:
             shouldWrite = False
     if shouldWrite:
         with open(filePath, 'w') as f:
             f.write(rst)
         print '\tWROTE   {0}'.format(common.relativepath(filePath))
     else:
         print '\tSKIPPED {0}'.format(common.relativepath(filePath))
开发者ID:Grahack,项目名称:music21,代码行数:17,代码来源:writers.py


示例9: write

 def write(self, filePath, rst): #
     '''
     Write ``rst`` (a unicode string) to ``filePath``, 
     only overwriting an existing file if the content differs.
     '''
     shouldWrite = True
     if os.path.exists(filePath):
         oldRst = common.readFileEncodingSafe(filePath, firstGuess='utf-8')
         if rst == oldRst:
             shouldWrite = False
     if shouldWrite:
         with codecs.open(filePath, 'w', 'utf-8') as f:
             try:
                 f.write(rst)
             except UnicodeEncodeError as uee:
                 six.raise_from(DocumentationWritersException("Could not write %s with rst:\n%s" % (filePath, rst)), uee)
         print('\tWROTE   {0}'.format(common.relativepath(filePath)))
     else:
         print('\tSKIPPED {0}'.format(common.relativepath(filePath)))
开发者ID:antoniopessotti,项目名称:music21,代码行数:19,代码来源:writers.py


示例10: run

    def run(self):
        excludedFiles = ['.ipynb', '__pycache__', '.pyc', '.gitignore', 'conf.py', '.DS_Store']
        for subPath in sorted(self.docSourcePath.rglob('*')):
            if subPath.is_dir():
                self.setupOutputDirectory(self.sourceToAutogenerated(subPath))
                continue

            runIt = True
            for ex in excludedFiles:
                if subPath.name.endswith(ex):
                    runIt = False
            if runIt is False:
                continue

            outputFilePath = self.sourceToAutogenerated(subPath)
            if (outputFilePath.exists()
                    and outputFilePath.stat().st_mtime > subPath.stat().st_mtime):
                print('\tSKIPPED {0}'.format(common.relativepath(outputFilePath)))
            else:
                shutil.copyfile(str(subPath), str(outputFilePath))
                print('\tWROTE   {0}'.format(common.relativepath(outputFilePath)))
开发者ID:cuthbertLab,项目名称:music21,代码行数:21,代码来源:writers.py


示例11: _main

def _main(target):
    from music21 import documentation  # @UnresolvedImport

    documentationDirectoryPath = documentation.__path__[0]
    sourceDirectoryPath = os.path.join(documentationDirectoryPath, "source")
    buildDirectoryPath = os.path.join(documentationDirectoryPath, "build")
    doctreesDirectoryPath = os.path.join(buildDirectoryPath, "doctrees")
    buildDirectories = {
        "html": os.path.join(buildDirectoryPath, "html"),
        "latex": os.path.join(buildDirectoryPath, "latex"),
        "latexpdf": os.path.join(buildDirectoryPath, "latex"),
    }
    if target in buildDirectories:
        print "WRITING DOCUMENTATION FILES"
        documentation.ModuleReferenceReSTWriter()()
        documentation.CorpusReferenceReSTWriter()()
        documentation.IPythonNotebookReSTWriter()()
        sphinxOptions = ["sphinx"]
        sphinxOptions.extend(("-b", target))
        sphinxOptions.extend(("-d", doctreesDirectoryPath))
        sphinxOptions.append(sourceDirectoryPath)
        sphinxOptions.append(buildDirectories[target])
        # sphinx.main() returns 0 on success, 1 on failure.
        # If the docs fail to build, we should not try to open a web browser.
        if sphinx.main(sphinxOptions):
            return
        if target == "html":
            launchPath = os.path.join(buildDirectories[target], "index.html")
            # TODO: Test launching web browsers under Windows.
            if launchPath.startswith("/"):
                launchPath = "file://" + launchPath
            webbrowser.open(launchPath)
    elif target == "clean":
        print "CLEANING AUTOGENERATED DOCUMENTATION"
        documentation.CorpusReferenceCleaner()()
        documentation.ModuleReferenceCleaner()()
        documentation.IPythonNotebookCleaner()()
        for name in os.listdir(buildDirectoryPath):
            if name.startswith("."):
                continue
            path = os.path.join(buildDirectoryPath, name)
            shutil.rmtree(path)
            print "\tCLEANED {0}".format(common.relativepath(path))
    elif target == "help":
        _print_usage()
    else:
        print "Unsupported documentation target {!r}".format(target)
        print
        _print_usage()
开发者ID:rafaelalmeida,项目名称:music21,代码行数:49,代码来源:make.py


示例12: argRun

def argRun():
    parser = argparse.ArgumentParser(
        description='Run pylint on music21 according to style guide.')
    parser.add_argument('files', metavar='filename', type=str, nargs='*',
                        help='Files to parse (default nearly all)')
    parser.add_argument('--strict', action='store_true',
                        help='Run the file in strict mode')
    args = parser.parse_args()
    #print(args.files)
    #print(args.strict)
    files = args.files if args.files else None
    if files:
        sfp = common.getSourceFilePath()
        files = [common.relativepath(f, sfp) for f in files]
    main(files, args.strict)
开发者ID:willingc,项目名称:music21,代码行数:15,代码来源:testLint.py


示例13: removeFile

 def removeFile(self, filePath):
     if os.path.exists(filePath):
         print('\tCLEANED {0}'.format(common.relativepath(filePath)))
         os.remove(filePath)
开发者ID:Wajih-O,项目名称:music21,代码行数:4,代码来源:cleaners.py


示例14: main

def main(target):
    from music21 import documentation # @UnresolvedImport
    documentationDirectoryPath = documentation.__path__[0]
    sourceDirectoryPath = os.path.join(
        documentationDirectoryPath,
        'source',
        )
    buildDirectoryPath = os.path.join(
        documentationDirectoryPath,
        'build',
        )
    doctreesDirectoryPath = os.path.join(
        buildDirectoryPath,
        'doctrees',
        )
    buildDirectories = {
        'html': os.path.join(
            buildDirectoryPath,
            'html',
            ),
        'latex': os.path.join(
            buildDirectoryPath,
            'latex',
            ),
        'latexpdf': os.path.join(
            buildDirectoryPath,
            'latex',
            ),
    }
    if target in buildDirectories:
        print('WRITING DOCUMENTATION FILES')
        documentation.ModuleReferenceReSTWriter().run()
        documentation.CorpusReferenceReSTWriter().run()
        try:
            documentation.IPythonNotebookReSTWriter().run()
        except OSError:
            raise ImportError('IPythonNotebookReSTWriter crashed; most likely cause: no pandoc installed: https://github.com/jgm/pandoc/releases')
        sphinxOptions = ['sphinx']
        sphinxOptions.extend(('-b', target))
        sphinxOptions.extend(('-d', doctreesDirectoryPath))
        sphinxOptions.append(sourceDirectoryPath)
        sphinxOptions.append(buildDirectories[target])
        # sphinx.main() returns 0 on success, 1 on failure.
        # If the docs fail to build, we should not try to open a web browser.
        if sphinx.main(sphinxOptions):
            return
        if target == 'html':
            launchPath = os.path.join(
                buildDirectories[target],
                'index.html',
                )
            # TODO: Test launching web browsers under Windows.
            if launchPath.startswith('/'):
                launchPath = 'file://' + launchPath
            webbrowser.open(launchPath)
    elif target == 'clean':
        print('CLEANING AUTOGENERATED DOCUMENTATION')
        documentation.CorpusReferenceCleaner().run()
        documentation.ModuleReferenceCleaner().run()
        documentation.IPythonNotebookCleaner().run()
        for name in os.listdir(buildDirectoryPath):
            if name.startswith('.'):
                continue
            path = os.path.join(
                buildDirectoryPath,
                name,
                )
            shutil.rmtree(path)
            print('\tCLEANED {0}'.format(common.relativepath(path)))
    elif target == 'help':
        _print_usage()
    else:
        print('Unsupported documentation target {!r}\n'.format(target))
        _print_usage()
开发者ID:Wajih-O,项目名称:music21,代码行数:74,代码来源:make.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.unwrapWeakref函数代码示例发布时间:2022-05-27
下一篇:
Python common.opFrac函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap