music21.common.pathTools¶
Functions¶
-
music21.common.pathTools.
cleanpath
(path)¶ Normalizes the path by expanding ~user on Unix, ${var} environmental vars (is this a good idea?), expanding %name% on Windows, normalizing path names (Windows turns backslashes to forward slashes, and finally if that file is not an absolute path, turns it from a relative path to an absolute path.
-
music21.common.pathTools.
getCorpusContentDirs
()¶ Get all dirs that are found in the corpus that contain content; that is, exclude dirs that have code or other resources.
>>> fp = common.getCorpusContentDirs() >>> fp # this test will be fragile, depending on composition of dirs ['airdsAirs', 'bach', 'beethoven', 'ciconia', 'corelli', 'cpebach', 'demos', 'essenFolksong', 'handel', 'haydn', 'josquin', 'leadSheet', 'luca', 'miscFolk', 'monteverdi', 'mozart', 'oneills1850', 'palestrina', 'ryansMammoth', 'schoenberg', 'schumann', 'schumann_clara', 'theoryExercises', 'trecento', 'verdi', 'weber']
Make sure that all corpus data has a directoryInformation tag in CoreCorpus.
>>> cc = corpus.corpora.CoreCorpus() >>> failed = [] >>> di = [d.directoryName for d in cc.directoryInformation] >>> for f in fp: ... if f not in di: ... failed.append(f) >>> failed []
-
music21.common.pathTools.
getCorpusFilePath
()¶ Get the stored music21 directory that contains the corpus metadata cache.
>>> fp = common.getCorpusFilePath() >>> fp.endswith('music21/corpus') or fp.endswith(r'music21\corpus') True
-
music21.common.pathTools.
getMetadataCacheFilePath
()¶ Get the stored music21 directory that contains the corpus metadata cache.
>>> fp = common.getMetadataCacheFilePath() >>> fp.endswith('corpus/_metadataCache') or fp.endswith(r'corpus\_metadataCache') True
Return type: str
-
music21.common.pathTools.
getPackageData
()¶ Return a list of package data in the format specified by setup.py. This creates a very inclusive list of all data types.
-
music21.common.pathTools.
getPackageDir
(fpMusic21=None, relative=True, remapSep='.', packageOnly=True)¶ Manually get all directories in the music21 package, including the top level directory. This is used in setup.py.
If relative is True, relative paths will be returned.
If remapSep is set to anything other than None, the path separator will be replaced.
If packageOnly is true, only directories with __init__.py files are collected.
-
music21.common.pathTools.
getSourceFilePath
()¶ Get the music21 directory that contains source files such as note.py, etc.. This is not the same as the outermost package development directory.
Return type: str
-
music21.common.pathTools.
relativepath
(path, start=None)¶ A cross-platform wrapper for os.path.relpath(), which returns path if under Windows, otherwise returns the relative path of path.
This avoids problems under Windows when the current working directory is on a different drive letter from path.
Return type: str