def getPaths(self): documentationDirectoryPath = os.path.join(common.getRootFilePath(), 'documentation') self.documentationDirectoryPath = documentationDirectoryPath self.autogenDirectoryPath = os.path.join( documentationDirectoryPath, 'autogenerated', ) self.buildDirectoryPath = os.path.join( documentationDirectoryPath, 'build', ) self.doctreesDirectoryPath = os.path.join( self.buildDirectoryPath, 'doctrees', ) self.sourcesDirectoryPath = os.path.join( documentationDirectoryPath, 'source', ) self.buildDirectories = { 'html': os.path.join( self.buildDirectoryPath, 'html', ), 'latex': os.path.join( self.buildDirectoryPath, 'latex', ), # could reuse latex, but too much rewriting 'latexpdf': os.path.join( self.buildDirectoryPath, 'latex', ), }
def getPaths(self): documentationDirectoryPath = os.path.join(common.getRootFilePath(), 'documentation') self.documentationDirectoryPath = documentationDirectoryPath self.autogenDirectoryPath = os.path.join( documentationDirectoryPath, 'autogenerated', ) self.buildDirectoryPath = os.path.join( documentationDirectoryPath, 'build', ) self.doctreesDirectoryPath = os.path.join( self.buildDirectoryPath, 'doctrees', ) self.sourcesDirectoryPath = os.path.join( documentationDirectoryPath, 'source', ) self.buildDirectories = { 'html': os.path.join( self.buildDirectoryPath, 'html', ), 'latex': os.path.join( self.buildDirectoryPath, 'latex', ), # could reuse latex, but too much rewriting 'latexpdf': os.path.join( self.buildDirectoryPath, 'latex', ), }
def __init__(self): self.outputDirectory = None self.docBasePath = os.path.join(common.getRootFilePath(), 'documentation') self.docSourcePath = os.path.join(self.docBasePath, 'source') self.docGeneratedPath = os.path.join(self.docBasePath, 'autogenerated')
def getDirBuildHtml(): '''Return the html directory ''' from music21 import common parentDir = common.getRootFilePath() dirBuild = os.path.join(parentDir, 'documentation', 'build') dirBuildHtml = os.path.join(dirBuild, 'html') return dirBuildHtml
def getDirBuildHtml(): '''Return the html directory ''' from music21 import common parentDir = common.getRootFilePath() dirBuild = os.path.join(parentDir, 'documentation', 'build') dirBuildHtml = os.path.join(dirBuild, 'html') return dirBuildHtml
def __iter__(self): rootFilesystemPath = common.getRootFilePath() documentationPath = rootFilesystemPath / 'documentation' / 'source' for fileName in sorted(documentationPath.rglob('*.ipynb')): if fileName.parent.name.endswith('.ipynb_checkpoints'): continue if '-checkpoint' in fileName.name: continue yield fileName
def __iter__(self): rootFilesystemPath = common.getRootFilePath() documentationPath = rootFilesystemPath / 'documentation' /'source' for fileName in sorted(documentationPath.rglob('*.ipynb')): if fileName.parent.name.endswith('.ipynb_checkpoints'): continue if '-checkpoint' in fileName.name: continue yield fileName
def getDocumentationFiles(runOne=False): ''' returns a list of namedtuples for each module that should be run >>> from music21.test import testDocumentation >>> testDocumentation.getDocumentationFiles() [ModTuple(module='index.rst', fullModulePath='...music21/documentation/autogenerated/index.rst', moduleNoExtension='index', autoGen=False), ..., ModTuple(module='usersGuide_03_pitches.rst', fullModulePath='...music21/documentation/autogenerated/usersGuide/usersGuide_03_pitches.rst', moduleNoExtension='usersGuide_03_pitches', autoGen=True), ...] ''' from music21 import common music21basedir = common.getRootFilePath() builddocRstDir = os.path.join(music21basedir, 'documentation', 'source') if not os.path.exists(builddocRstDir): raise Music21Exception( "Cannot run tests on documentation because the rst files " + "in documentation/source do not exist") allModules = [] for root, unused_dirnames, filenames in os.walk(builddocRstDir): for module in filenames: fullModulePath = os.path.join(root, module) if not module.endswith('.rst'): continue if module.startswith('module'): # we have this already... continue if module in skipModules: continue if runOne is not False: if not module.endswith(runOne): continue with io.open(fullModulePath, 'r', encoding='utf-8') as f: incipit = f.read(1000) if 'AUTOMATICALLY GENERATED' in incipit: autoGen = True else: autoGen = False moduleNoExtension = module[:-4] modTuple = ModTuple(module, fullModulePath, moduleNoExtension, autoGen) allModules.append(modTuple) return allModules
def runOne(nbFile): us = environment.UserSettings() museScore = us['musescoreDirectPNGPath'] us['musescoreDirectPNGPath'] = '/skip' try: retVal = os.system('pytest --nbval ' + nbFile + ' --sanitize-with ' + common.getRootFilePath() + os.sep + 'documentation' + os.sep + 'docbuild' + os.sep + 'nbval-sanitize.cfg -q') except (Exception, KeyboardInterrupt): raise finally: us['musescoreDirectPNGPath'] = museScore return retVal
def runOne(nbFile): us = environment.UserSettings() museScore = us['musescoreDirectPNGPath'] us['musescoreDirectPNGPath'] = '/skip' try: retVal = os.system('pytest --nbval ' + nbFile + ' --sanitize-with ' + common.getRootFilePath() + os.sep + 'documentation' + os.sep + 'docbuild' + os.sep + 'nbval-sanitize.cfg -q') except (Exception, KeyboardInterrupt): raise finally: us['musescoreDirectPNGPath'] = museScore return retVal
def getDocumentationFiles(runOne=False): ''' returns a list of namedtuples for each module that should be run >>> from music21.test import testDocumentation >>> testDocumentation.getDocumentationFiles() [ModTuple(module='index.rst', fullModulePath='...music21/documentation/autogenerated/index.rst', moduleNoExtension='index', autoGen=False), ..., ModTuple(module='usersGuide_03_pitches.rst', fullModulePath='...music21/documentation/autogenerated/usersGuide/usersGuide_03_pitches.rst', moduleNoExtension='usersGuide_03_pitches', autoGen=True), ...] ''' from music21 import common music21basedir = common.getRootFilePath() builddocRstDir = os.path.join(music21basedir, 'documentation', 'source') if not os.path.exists(builddocRstDir): raise Music21Exception( "Cannot run tests on documentation because the rst files " + "in documentation/source do not exist") allModules = [] for root, unused_dirnames, filenames in os.walk(builddocRstDir): for module in filenames: fullModulePath = os.path.join(root, module) if not module.endswith('.rst'): continue if module.startswith('module'): # we have this already... continue if module in skipModules: continue if runOne is not False: if not module.endswith(runOne): continue with io.open(fullModulePath, 'r', encoding='utf-8') as f: incipit = f.read(1000) if 'AUTOMATICALLY GENERATED' in incipit: autoGen = True else: autoGen = False moduleNoExtension = module[:-4] modTuple = ModTuple(module, fullModulePath, moduleNoExtension, autoGen) allModules.append(modTuple) return allModules
def runAll(): sourcePath = common.getRootFilePath() + os.sep + 'documentation' + os.sep + 'source' for innerDir in ('about', 'developerReference', 'installing', 'usersGuide'): fullDir = sourcePath + os.sep + innerDir allFiles = os.listdir(fullDir) for f in allFiles: if not f.endswith('ipynb'): continue if f in skip: continue print(innerDir + os.sep + f) try: retVal = runOne(fullDir + os.sep + f) except KeyboardInterrupt: break if retVal == 512: return None
def __iter__(self): rootFilesystemPath = common.getRootFilePath() documentationPath = os.path.join( rootFilesystemPath, 'documentation', 'source', ) for pathParts in os.walk(documentationPath): directoryPath, fileNames = pathParts[0], pathParts[2] if directoryPath.endswith('.ipynb_checkpoints'): continue for fileName in fileNames: if '-checkpoint' in fileName: continue if fileName.endswith('.ipynb'): filePath = os.path.join( directoryPath, fileName, ) yield filePath
def __iter__(self): rootFilesystemPath = common.getRootFilePath() documentationPath = os.path.join( rootFilesystemPath, 'documentation', 'source', ) for pathParts in os.walk(documentationPath): directoryPath, fileNames = pathParts[0], pathParts[2] if directoryPath.endswith('.ipynb_checkpoints'): continue for fileName in fileNames: if '-checkpoint' in fileName: continue if fileName.endswith('.ipynb'): filePath = os.path.join( directoryPath, fileName, ) yield filePath
def runOne(nbFile): us = environment.UserSettings() museScore = us['musescoreDirectPNGPath'] us['musescoreDirectPNGPath'] = '/skip' + str(museScore) # this config file changes 0x39f3a0 to 0xADDRESS. sanitize_fn = str(common.getRootFilePath() / 'documentation' / 'docbuild' / 'nbval-sanitize.cfg') try: retVal = subprocess.run([ 'pytest', '--disable-pytest-warnings', '--nbval', str(nbFile), '--sanitize-with', sanitize_fn, '-q' ]) except (Exception, KeyboardInterrupt): raise finally: us['musescoreDirectPNGPath'] = museScore return retVal
def runAll(): sourcePath = common.getRootFilePath( ) + os.sep + 'documentation' + os.sep + 'source' for innerDir in ('about', 'developerReference', 'installing', 'usersGuide'): fullDir = sourcePath + os.sep + innerDir allFiles = os.listdir(fullDir) for f in allFiles: if not f.endswith('ipynb'): continue if f in skip: continue print(innerDir + os.sep + f) try: retVal = runOne(fullDir + os.sep + f) except KeyboardInterrupt: break if retVal == 512: return None
def runAll(): sourcePath = common.getRootFilePath() / 'documentation' / 'source' goodFiles = [] for innerDir in ('about', 'developerReference', 'installing', 'usersGuide'): fullDir = sourcePath / innerDir for f in sorted(fullDir.rglob('*.ipynb')): if f.name in skip: continue if 'checkpoint' in str(f): continue goodFiles.append(f) for f in goodFiles: print("Running: ", str(f)) try: retVal = runOne(f) except KeyboardInterrupt: break if retVal == 512: return None
def runAll(): sourcePath = common.getRootFilePath() / 'documentation' / 'source' goodFiles = [] for innerDir in ('about', 'developerReference', 'installing', 'usersGuide'): fullDir = sourcePath / innerDir for f in sorted(fullDir.rglob('*.ipynb')): if f.name in skip: continue if 'checkpoint' in str(f): continue goodFiles.append(f) for f in goodFiles: print("Running: ", str(f)) try: retVal = runOne(f) except KeyboardInterrupt: break if retVal == 512: return None
def __init__(self): self.outputDirectory = None self.docBasePath = os.path.join(common.getRootFilePath(), 'documentation') self.docSourcePath = os.path.join(self.docBasePath, 'source') self.docGeneratedPath = os.path.join(self.docBasePath, 'autogenerated')
def __init__(self): self.outputDirectory = None self.docBasePath = common.getRootFilePath() / 'documentation' self.docSourcePath = self.docBasePath / 'source' self.docGeneratedPath = self.docBasePath / 'autogenerated'
def __init__(self): self.outputDirectory = None self.docBasePath = common.getRootFilePath() / 'documentation' self.docSourcePath = self.docBasePath / 'source' self.docGeneratedPath = self.docBasePath / 'autogenerated'