Path

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.segments" { graph [label="abjad.segments"]; node [color=1]; "abjad.segments.Path.Path" [URL="../api/abjad/segments/Path.html#abjad.segments.Path.Path", color=black, fontcolor=white, label=Path, target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph cluster_pathlib { graph [label=pathlib]; node [color=3]; "pathlib.Path" [URL="https://docs.python.org/3.6/library/pathlib.html#pathlib.Path", label=Path, target=_top]; "pathlib.PosixPath" [URL="https://docs.python.org/3.6/library/pathlib.html#pathlib.PosixPath", label="Posix\nPath", target=_top]; "pathlib.PurePath" [URL="https://docs.python.org/3.6/library/pathlib.html#pathlib.PurePath", label="Pure\nPath", target=_top]; "pathlib.PurePosixPath" [URL="https://docs.python.org/3.6/library/pathlib.html#pathlib.PurePosixPath", label="Pure\nPosix\nPath", target=_top]; "pathlib.Path" -> "pathlib.PosixPath"; "pathlib.PurePath" -> "pathlib.Path"; "pathlib.PurePath" -> "pathlib.PurePosixPath"; "pathlib.PurePosixPath" -> "pathlib.PosixPath"; } "builtins.object" -> "pathlib.PurePath"; "pathlib.PosixPath" -> "abjad.segments.Path.Path"; }

class abjad.segments.Path.Path

Path in an Abjad score package.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.materials
Path*('/path/to/scores/my_score/my_score/materials')
>>> path.materials('instruments')
Path*('/path/to/scores/my_score/my_score/materials/instruments')
>>> path.materials('instruments').is_material()
True

Attributes Summary

__call__ Calls path on names.
__new__ Construct a PurePath from one or several strings and or existing PurePath objects.
__repr__ Gets interpreter representation of path.
__rtruediv__ Joins path to argument.
__truediv__ Joins argument to path.
activate Activates tag in path.
add_buildspace_metadatum Adds metadatum with name and value into buildspace metadata with optional document_name.
add_metadatum Adds metadatum.
build Gets build directory.
builds Gets builds directory.
coerce Coerces asset name.
contents Gets contents directory.
count Counts tag in path.
deactivate Deactivates tag in path.
distribution Gets distribution directory.
etc Gets etc directory.
extern Externalizes LilyPond file parsable chunks.
get_asset_type Gets asset identifier.
get_files_ending_with Gets files in path ending with name.
get_identifier Gets identifier.
get_measure_profile_metadata Gets measure profile metadata.
get_metadata Gets __metadata__.py file in path.
get_metadatum Gets metadatum.
get_name_predicate Gets name predicate.
get_next_package Gets next package.
get_next_score Gets next score.
get_part_identifier Gets part identifier in layout.py only.
get_preamble_partial_score Gets preamble time signatures.
get_preamble_time_signatures Gets preamble time signatures.
get_previous_package Gets previous package.
get_previous_score Gets previous score.
get_time_signature_metadata Gets time signature metadata for buildspace directory.
get_title Gets score title.
global_rest_identifier Gets global rest identifier.
global_rest_identifiers Gets global rest identifiers.
global_skip_identifiers Gets global skip identifiers.
instrument_to_staff_identifiers Changes instrument to staff identifiers dictionary.
is__assets Is true when path is _assets directory.
is__segments Is true when path is _segments directory.
is_build Is true when path is build directory.
is_builds Is true when path is builds directory.
is_buildspace Is true when path is buildspace.
is_contents Is true when path is contents directory.
is_distribution Is true when path is distribution directory.
is_etc Is true when path is etc directory.
is_external Is true when path is not a score package path.
is_illustrationspace Is true when path is any of material, materials, segment or segments directories.
is_introduction_segment Is true when path is segment with name like _, _1, _2, ….
is_library Is true when path is composer library tools directory.
is_material Is true when path is material directory.
is_material_or_segment Is true when path is material directory or segment directory.
is_materials Is true when path is materials directory.
is_materials_or_segments Is true when path is materials directory or segments directory.
is_part Is true when directory is part directory.
is_parts Is true when directory is parts directory.
is_score_build Is true when directory is score build directory.
is_score_package_path Is true when path is package path.
is_scores Is true when path is scores directory.
is_segment Is true when path is segment directory.
is_segment_name Is true when string is canonical segment name.
is_segments Is true when path is segments directory.
is_stylesheets Is true when path is stylesheets directory.
is_test Is true when path is test directory.
is_tools Is true when path is tools directory.
is_wrapper Is true when path is wrapper directory
list_paths Lists paths ordered by view (if any).
list_secondary_paths Lists secondary paths.
materials Gets materials directory.
part_to_identifiers Changes part to (part container) identifiers (using container_to_part_assignment dictionary).
remove Removes path if it exists.
remove_metadatum Removes metadatum.
score_skeleton Makes score skeleton.
scores Gets scores directory.
segment_number_to_path Changes segment number to path.
segments Gets segments directory.
stylesheets Gets stylesheets directory.
test Gets test directory.
to_part Changes path to part.
tools Gets tools directory.
trim Trims path.
update_order_dependent_segment_metadata Updates order-dependent segment metadata.
with_name Gets path with name.
with_parent Gets path with parent name.
with_score Gets path with score name.
wrapper Gets wrapper directory.
write_metadata_py Writes metadata to __metadata__.py in current directory.

Special methods

(PurePath).__bytes__()

Return the bytes representation of the path. This is only recommended to use under Unix.

__call__(*names)

Calls path on names.

Return type:Path
(Path).__enter__()
(PurePath).__eq__(other)

Return self==value.

(Path).__exit__(t, v, tb)
(PurePath).__fspath__()
(PurePath).__ge__(other)

Return self>=value.

(PurePath).__gt__(other)

Return self>value.

(PurePath).__hash__()

Return hash(self).

(PurePath).__le__(other)

Return self<=value.

(PurePath).__lt__(other)

Return self<value.

static __new__(class_, *arguments, scores=None)

Construct a PurePath from one or several strings and or existing PurePath objects. The strings and path objects are combined so as to yield a canonicalized path, which is incorporated into the new PurePath object.

__repr__()

Gets interpreter representation of path.

Return type:str
__rtruediv__(argument)

Joins path to argument.

Returns new path.

(PurePath).__str__()

Return the string representation of the path, suitable for passing to system calls.

__truediv__(argument)

Joins argument to path.

Returns new path.


Methods

(Path).absolute()

Return an absolute version of this path. This function works even if the path doesn’t point to anything.

No normalization is done, i.e. all ‘.’ and ‘..’ will be kept along. Use resolve() to get the canonical path to a file.

activate(tag, indent=0, message_zero=False, name=None, undo=False)

Activates tag in path.

Case 0: path is a non-LilyPond file. Method does nothing.

Case 1: path is a LilyPond (.ily, .ly) file starting with illustration, layout or segment. Method activates tag in file.

Case 2: path is a directory. Method descends directory recursively and activates tag in LilyPond files given in case 1.

Returns triple.

First item in triple is count of deactivated tags activated by method.

Second item in pair is count of already-active tags skipped by method.

Third item in pair is list of canonical string messages that explain what happened.

Return type:Tuple[int, int, List[String]]
add_buildspace_metadatum(name, value, document_name=None)

Adds metadatum with name and value into buildspace metadata with optional document_name.

Return type:None
add_metadatum(name, value)

Adds metadatum.

Return type:None
(PurePath).as_posix()

Return the string representation of the path with forward (/) slashes.

(PurePath).as_uri()

Return the path as a ‘file’ URI.

(Path).chmod(mode)

Change the permissions of the path, like os.chmod().

coerce(name, suffix=None)

Coerces asset name.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )

In build directory:

>>> path.builds('letter').coerce('back cover.tex')
'back cover.tex'
>>> path.builds('letter').coerce('Back Cover.tex')
'Back Cover.tex'
>>> path.builds('letter').coerce('BACK_COVER.tex')
'BACK_COVER.tex'
>>> path.builds('letter').coerce('new music.ly')
'new music.ly'
>>> path.builds('letter').coerce('New Music.ly')
'New Music.ly'
>>> path.builds('letter').coerce('NEW_MUSIC.ly')
'NEW_MUSIC.ly'
>>> path.builds('letter').coerce('page_layout.py')
'page_layout.py'
>>> path.builds('letter').coerce('Page Layout.py')
'Page Layout.py'
>>> path.builds('letter').coerce('PAGE_LAYOUT.py')
'PAGE_LAYOUT.py'

In builds directory:

>>> path.builds.coerce('letter_landscape')
'letter-landscape'
>>> path.builds.coerce('letter landscape')
'letter-landscape'
>>> path.builds.coerce('Letter Landscape')
'letter-landscape'

In contents directory:

>>> path.contents.coerce('ETC')
'etc'

In distribution directory:

>>> path.distribution.coerce('program notes.txt')
'program-notes.txt'
>>> path.distribution.coerce('Program Notes.txt')
'program-notes.txt'
>>> path.distribution.coerce('PROGRAM_NOTES.txt')
'program-notes.txt'

In etc directory:

>>> path.etc.coerce('material sketches.md')
'material-sketches.md'
>>> path.etc.coerce('Material Sketches.md')
'material-sketches.md'
>>> path.etc.coerce('MATERIAL_SKETCHES.md')
'material-sketches.md'

In scores directory:

>>> path.scores.coerce('Green Score')
'green_score'

In segment directory:

>>> path.segments.coerce('_')
'_'
>>> path.segments.coerce('A')
'A'
>>> path.segments.coerce('A1')
'A1'
>>> path.segments.coerce('A99')
'A99'
>>> path.segments.coerce('segment_01')
'segment_01'
>>> path.segments.coerce('segment 01')
'segment_01'
>>> path.segments.coerce('Segment 01')
'segment_01'
>>> path.segments.coerce('SEGMENT 01')
'segment_01'

In stylesheets directory:

>>> path.stylesheets.coerce('segment stylesheet')
'segment-stylesheet.ily'
>>> path.stylesheets.coerce('Segment Stylesheet')
'segment-stylesheet.ily'
>>> path.stylesheets.coerce('SEGMENT_STYLESHEET')
'segment-stylesheet.ily'

Does not coerce in unknown directory:

>>> path = abjad.Path(
...     '/unknown/path',
...     )
>>> path.coerce('custom-script')
'custom-script'
>>> path.coerce('custom_script')
'custom_script'
>>> path.coerce('CUSTOM_SCRIPT')
'CUSTOM_SCRIPT'

Returns string.

count(tag)

Counts tag in path.

Returns two pairs.

Pair 1 gives (active tags, activate lines).

Pair 2 gives (deactivated tags, deactivated lines).

Return type:Tuple[Tuple[int, int], Tuple[int, int]]
deactivate(tag, indent=0, message_zero=False, name=None)

Deactivates tag in path.

Return type:Tuple[int, int, List[String]]
(Path).exists()

Whether this path exists.

(Path).expanduser()

Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)

extern(include_path=None, score_path=None)

Externalizes LilyPond file parsable chunks.

Produces skeleton score file and include file.

Overwrites path with skeleton score when score_path is none.

Writes include file to path with .ily suffix when include_path is none.

Return type:None
get_asset_type()

Gets asset identifier.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.builds.get_asset_type()
'directory'
>>> path.contents.get_asset_type()
'directory'
>>> path.distribution.get_asset_type()
'file'
>>> path.etc.get_asset_type()
'file'
>>> path.materials.get_asset_type()
'package'
>>> path.scores.get_asset_type()
'package'
>>> path.segments.get_asset_type()
'package'
>>> path.stylesheets.get_asset_type()
'file'
>>> path.test.get_asset_type()
'file'
>>> path.tools.get_asset_type()
'file'
>>> path.wrapper.get_asset_type()
'asset'

With external path:

>>> abjad.Path('/path/to/external').get_asset_type()
'asset'
Return type:str
get_files_ending_with(name)

Gets files in path ending with name.

Return type:List[Path]
get_identifier()

Gets identifier.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.contents.get_identifier()
'(untitled score)'
>>> path.materials('tempi').get_identifier()
'tempi'
>>> path.materials().get_identifier()
'materials'
>>> path.segments('segment_01').get_identifier()
'segment_01'
>>> path.segments().get_identifier()
'segments'
>>> path.wrapper().get_identifier()
'(untitled score)'

Returns title when path is contents directory.

Returns name metadatum when name metadatum exists.

Returns path name otherwise.

Return type:str
get_measure_profile_metadata()

Gets measure profile metadata.

Reads segment metadata when path is segment.

Reads score metadata when path is not segment.

Returns triple of three metadata: first measure number; measure count; list of fermata measure numbers.

Return type:Tuple[int, int, list]
get_metadata()

Gets __metadata__.py file in path.

Return type:OrderedDict
get_metadatum(metadatum_name, default=None)

Gets metadatum.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.contents.get_metadatum('foo') is None
True
Return type:Any
get_name_predicate()

Gets name predicate.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.builds.get_name_predicate()
<function String.is_build_directory_name at ...>
>>> path.contents.get_name_predicate()
<function String.is_package_name at ...>
>>> path.materials.get_name_predicate()
<function String.is_package_name at ...>
>>> path.materials('tempi').get_name_predicate()
<function String.is_lowercase_file_name at ...>
>>> path.scores.get_name_predicate()
<function String.is_package_name at ...>
>>> path.segments.get_name_predicate()
<function String.is_segment_name at ...>
>>> path.segments('segment_01').get_name_predicate()
<function String.is_lowercase_file_name at ...>
>>> path.wrapper.get_name_predicate() is None
True
Return type:Optional[Callable]
get_next_package(cyclic=False)

Gets next package.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.get_next_package() is None
True
Return type:Optional[Path]
get_next_score(cyclic=False)

Gets next score.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.get_next_score() is None
True
Return type:Optional[Path]
get_part_identifier()

Gets part identifier in layout.py only.

Return type:Optional[str]
get_preamble_partial_score()

Gets preamble time signatures.

Return type:bool
get_preamble_time_signatures()

Gets preamble time signatures.

Return type:Optional[List[str]]
get_previous_package(cyclic=False)

Gets previous package.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.get_previous_package() is None
True
Return type:Optional[Path]
get_previous_score(cyclic=False)

Gets previous score.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.get_previous_score() is None
True
Return type:Optional[Path]
get_time_signature_metadata()

Gets time signature metadata for buildspace directory.

Return type:List[TimeSignature]
get_title(year=True)

Gets score title.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.get_title()
'(untitled score)'

Returns string.

(Path).glob(pattern)

Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given pattern.

global_rest_identifiers()

Gets global rest identifiers.

Return type:List[String]
global_skip_identifiers()

Gets global skip identifiers.

Return type:List[String]
(Path).group()

Return the group name of the file gid.

instrument_to_staff_identifiers(instrument)

Changes instrument to staff identifiers dictionary.

Return type:OrderedDict
is__assets()

Is true when path is _assets directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path = path('build', '_assets')
>>> path.is__assets()
True
Return type:bool
is__segments()

Is true when path is _segments directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score/builds/letter/_segments',
...     scores='/path/to/scores',
...     )
>>> path.is__segments()
True
Return type:bool
(PurePath).is_absolute()

True if the path is absolute (has both a root and, if applicable, a drive).

(Path).is_block_device()

Whether this path is a block device.

is_build()

Is true when path is build directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.builds('letter').is_build()
True
Return type:bool
is_builds()

Is true when path is builds directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.builds.is_builds()
True
Return type:bool
is_buildspace()

Is true when path is buildspace.

  • build
  • builds
  • segment
  • segments
  • _segments
Return type:bool
(Path).is_char_device()

Whether this path is a character device.

is_contents()

Is true when path is contents directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.contents.is_contents()
True
Return type:bool
(Path).is_dir()

Whether this path is a directory.

is_distribution()

Is true when path is distribution directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.distribution.is_distribution()
True
Return type:bool
is_etc()

Is true when path is etc directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.etc.is_etc()
True
Return type:bool
is_external()

Is true when path is not a score package path.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.builds.is_external()
False
>>> path.contents.is_external()
False
>>> path.wrapper.is_external()
False
>>> path.scores.is_external()
True
>>> abjad.Path('/path/to/location').is_external()
True
Return type:bool
(Path).is_fifo()

Whether this path is a FIFO.

(Path).is_file()

Whether this path is a regular file (also True for symlinks pointing to regular files).

is_illustrationspace()

Is true when path is any of material, materials, segment or segments directories.

Returns true or false.

Return type:bool
is_introduction_segment()

Is true when path is segment with name like _, _1, _2, ….

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.segments('_').is_introduction_segment()
True
>>> path.segments('_1').is_introduction_segment()
True
>>> path.segments('_99').is_introduction_segment()
True
>>> path.segments('_1A').is_introduction_segment()
False
>>> path.segments('1').is_introduction_segment()
False
>>> path.segments('A').is_introduction_segment()
False
Return type:bool
is_library()

Is true when path is composer library tools directory.

Return type:bool
is_material()

Is true when path is material directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.materials('tempi').is_material()
True
Return type:bool
is_material_or_segment()

Is true when path is material directory or segment directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.materials.is_material_or_segment()
False
>>> path.materials('tempi').is_material_or_segment()
True
>>> path.segments.is_material_or_segment()
False
>>> path.segments('A').is_material_or_segment()
True
Return type:bool
is_materials()

Is true when path is materials directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.materials.is_materials()
True
Return type:bool
is_materials_or_segments()

Is true when path is materials directory or segments directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.materials.is_materials_or_segments()
True
>>> path.materials('tempi').is_materials_or_segments()
False
>>> path.segments.is_materials_or_segments()
True
>>> path.segments('A').is_materials_or_segments()
False
Return type:bool
is_part()

Is true when directory is part directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.builds.is_part()
False
>>> path.builds('arch-a-parts').is_part()
False
Return type:bool
is_parts()

Is true when directory is parts directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.builds.is_parts()
False
>>> path.builds('arch-a-score').is_parts()
False
Return type:bool
(PurePath).is_reserved()

Return True if the path contains one of the special names reserved by the system, if any.

is_score_build()

Is true when directory is score build directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.builds.is_score_build()
False
>>> path.builds('arch-a-score').is_score_build()
True
Return type:bool
is_score_package_path(prototype=())

Is true when path is package path.

External path returns false:

>>> abjad.Path('/path/to/location').is_score_package_path()
False

Scores directory returns false:

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.scores.is_score_package_path()
False

Package paths return true:

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.wrapper.is_score_package_path()
True
>>> path.contents.is_score_package_path()
True
>>> path.stylesheets.is_score_package_path()
True
>>> path('build', '_assets').is_score_package_path()
True
Return type:bool
is_scores()

Is true when path is scores directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.scores.is_scores()
True
Return type:bool
is_segment()

Is true when path is segment directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.segments('segment_01').is_segment()
True

REGRESSION. Abjad segments directory is excluded:

>>> path = abjad.Path(
...     '/path/to/abjad/abjad/segments',
...     )
>>> path /= 'segment_01'
>>> path.is_segment()
False
Return type:bool
is_segments()

Is true when path is segments directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.segments.is_segments()
True

Excludes Abjad segments directory:

>>> path = abjad.Path(
...     '/path/to/abjad/abjad/segments',
...     )
>>> path.is_segments()
False
Return type:bool
(Path).is_socket()

Whether this path is a socket.

is_stylesheets()

Is true when path is stylesheets directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.stylesheets.is_stylesheets()
True
Return type:bool

Whether this path is a symbolic link.

is_test()

Is true when path is test directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.test.is_test()
True
Return type:bool
is_tools()

Is true when path is tools directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.tools.is_tools()
True
Return type:bool
is_wrapper()

Is true when path is wrapper directory

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.wrapper.is_wrapper()
True
Return type:bool
(Path).iterdir()

Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’.

(PurePath).joinpath(*args)

Combine this path with one or several arguments, and return a new path representing either a subpath (if all arguments are relative paths) or a totally different path (if one of the arguments is anchored).

(Path).lchmod(mode)

Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.

list_paths()

Lists paths ordered by view (if any).

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.list_paths()
[]

Returns list.

list_secondary_paths()

Lists secondary paths.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.list_secondary_paths()
[]

Returns list.

(Path).lstat()

Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.

(PurePath).match(path_pattern)

Return True if this path matches the given pattern.

(Path).mkdir(mode=511, parents=False, exist_ok=False)

Create a new directory at this given path.

(Path).open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)

Open the file pointed by this path and return a file object, as the built-in open() function does.

(Path).owner()

Return the login name of the file owner.

part_to_identifiers(part, container_to_part_assignment)

Changes part to (part container) identifiers (using container_to_part_assignment dictionary).

Return type:Union[str, List[str]]
(Path).read_bytes()

Open the file in bytes mode, read it, and close the file.

(Path).read_text(encoding=None, errors=None)

Open the file in text mode, read it, and close the file.

(PurePath).relative_to(*other)

Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not a subpath of the other path), raise ValueError.

remove()

Removes path if it exists.

Returns none.

remove_metadatum(name)

Removes metadatum.

Returns none.

(Path).rename(target)

Rename this path to the given path.

(Path).replace(target)

Rename this path to the given path, clobbering the existing destination if it exists.

(Path).resolve(strict=False)

Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows).

(Path).rglob(pattern)

Recursively yield all existing files (of any kind, including directories) matching the given pattern, anywhere in this subtree.

(Path).rmdir()

Remove this directory. The directory must be empty.

(Path).samefile(other_path)

Return whether other_path is the same or not as this file (as returned by os.path.samefile()).

score_skeleton()

Makes score skeleton.

Only works when score template defines skeleton() method.

Return type:Optional[Score]
segment_number_to_path(number)

Changes segment number to path.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.segment_number_to_path(1)

Returns path.

(Path).stat()

Return the result of the stat() system call on this path, like os.stat() does.

Make this path a symlink pointing to the given path. Note the order of arguments (self, target) is the reverse of os.symlink’s.

to_part()

Changes path to part.

Return type:Part
(Path).touch(mode=438, exist_ok=True)

Create this file with the given access mode, if it doesn’t exist.

trim()

Trims path.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.contents.trim()
'/path/to/scores/my_score/my_score'
>>> path.segments.trim()
'my_score/segments'
>>> path.segments('segment_01').trim()
'my_score/segments/segment_01'
>>> path.materials.trim()
'my_score/materials'
>>> path.materials('tempi').trim()
'my_score/materials/tempi'
Return type:str

Remove this file or link. If the path is a directory, use rmdir() instead.

update_order_dependent_segment_metadata()

Updates order-dependent segment metadata.

Returns none.

with_name(name)

Gets path with name.

Returns path.

with_parent(name)

Gets path with parent name.

Returns path.

with_score(name)

Gets path with score name.

Returns path.

(PurePath).with_suffix(suffix)

Return a new path with the file suffix changed (or added, if none).

(Path).write_bytes(data)

Open the file in bytes mode, write to it, and close the file.

write_metadata_py(metadata)

Writes metadata to __metadata__.py in current directory.

Returns none.

(Path).write_text(data, encoding=None, errors=None)

Open the file in text mode, write to it, and close the file.


Class & static methods

classmethod (Path).cwd()

Return a new path pointing to the current working directory (as returned by os.getcwd()).

static global_rest_identifier(segment_name)

Gets global rest identifier.

>>> abjad.Path.global_rest_identifier('_')
'i_GlobalRests'
>>> abjad.Path.global_rest_identifier('_1')
'i_a_GlobalRests'
>>> abjad.Path.global_rest_identifier('_2')
'i_b_GlobalRests'
>>> abjad.Path.global_rest_identifier('A')
'A_GlobalRests'
>>> abjad.Path.global_rest_identifier('A1')
'A_a_GlobalRests'
>>> abjad.Path.global_rest_identifier('A2')
'A_b_GlobalRests'
Return type:String
classmethod (Path).home()

Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).

static is_segment_name(string)

Is true when string is canonical segment name.

>>> abjad.Path.is_segment_name('_')
True
>>> abjad.Path.is_segment_name('_1')
True
>>> abjad.Path.is_segment_name('_2')
True
>>> abjad.Path.is_segment_name('_99')
True
>>> abjad.Path.is_segment_name('A')
True
>>> abjad.Path.is_segment_name('A1')
True
>>> abjad.Path.is_segment_name('A2')
True
>>> abjad.Path.is_segment_name('A99')
True
>>> abjad.Path.is_segment_name('B')
True
>>> abjad.Path.is_segment_name('B1')
True
>>> abjad.Path.is_segment_name('B2')
True
>>> abjad.Path.is_segment_name('B99')
True
>>> abjad.Path.is_segment_name('AA')
True
>>> abjad.Path.is_segment_name('AA1')
True
>>> abjad.Path.is_segment_name('AA2')
True
>>> abjad.Path.is_segment_name('AA99')
True
>>> abjad.Path.is_segment_name('AB')
True
>>> abjad.Path.is_segment_name('AB1')
True
>>> abjad.Path.is_segment_name('AB2')
True
>>> abjad.Path.is_segment_name('AB99')
True
>>> abjad.Path.is_segment_name('__')
False
>>> abjad.Path.is_segment_name('1')
False
>>> abjad.Path.is_segment_name('a')
False
>>> abjad.Path.is_segment_name('b')
False
>>> abjad.Path.is_segment_name('aa')
False
>>> abjad.Path.is_segment_name('ab')
False
>>> abjad.Path.is_segment_name('AAA')
False
Return type:bool

Read-only properties

(PurePath).anchor

The concatenation of the drive and root, or ‘’.

build

Gets build directory.

Directory must be build directory, _segments direcotry or part directory.

>>> build = abjad.Path(
...     '/path/to/scores/my_score/my_score/builds/letter-score',
...     scores='/path/to/scores',
...     )

Works when path is build directory:

>>> build.build
Path*('/path/to/scores/my_score/my_score/builds/letter-score')

Works when path is _segments directory:

>>> (build / '_segments').build
Path('/path/to/scores/my_score/my_score/builds/letter-score')

Works when path is _assets directory:

>>> (build / '_assets').build
Path('/path/to/scores/my_score/my_score/builds/letter-score')

Works when path is parts directory:

>>> parts = abjad.Path(
...     '/path/to/scores/my_score/my_score/builds/letter-parts',
...     scores='/path/to/scores',
...     )
>>> parts.build
Path*('/path/to/scores/my_score/my_score/builds/letter-parts')

Works when path is part directory:

>>> (parts / 'bass-clarinet-part').build
Path*('/path/to/scores/my_score/my_score/builds/letter-parts/bass-clarinet-part')

Works when path is file in part directory:

>>> (parts / 'bass-clarinet-part' / 'layout.ly').build
Path('/path/to/scores/my_score/my_score/builds/letter-parts/bass-clarinet-part')
Return type:Optional[Path]
builds

Gets builds directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.builds
Path*('/path/to/scores/my_score/my_score/builds')
>>> path.builds('letter')
Path*('/path/to/scores/my_score/my_score/builds/letter')
Return type:Optional[Path]
contents

Gets contents directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.contents
Path*('/path/to/scores/my_score/my_score')
>>> path.contents('etc', 'notes.txt')
Path*('/path/to/scores/my_score/my_score/etc/notes.txt')
distribution

Gets distribution directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.distribution
Path*('/path/to/scores/my_score/my_score/distribution')
>>> path.distribution('score.pdf')
Path*('/path/to/scores/my_score/my_score/distribution/score.pdf')
Return type:Optional[Path]
(PurePath).drive

The drive prefix (letter or UNC path), if any.

etc

Gets etc directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.etc
Path*('/path/to/scores/my_score/my_score/etc')
>>> path.etc('notes.txt')
Path*('/path/to/scores/my_score/my_score/etc/notes.txt')
Return type:Optional[Path]
materials

Gets materials directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.materials
Path*('/path/to/scores/my_score/my_score/materials')
>>> path.materials('instruments')
Path*('/path/to/scores/my_score/my_score/materials/instruments')
Return type:Optional[Path]
(PurePath).name

The final path component, if any.

(PurePath).parent

The logical parent of the path.

(PurePath).parents

A sequence of this path’s logical parents.

(PurePath).parts

An object providing sequence-like access to the components in the filesystem path.

(PurePath).root

The root of the path, if any.

scores

Gets scores directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.scores
Path*('/path/to/scores')
>>> path.scores('red_score', 'red_score')
Path*('/path/to/scores/red_score/red_score')
Return type:Optional[Path]
segments

Gets segments directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.segments
Path*('/path/to/scores/my_score/my_score/segments')
>>> path.segments('segment_01')
Path*('/path/to/scores/my_score/my_score/segments/segment_01')
Return type:Optional[Path]
(PurePath).stem

The final path component, minus its last suffix.

stylesheets

Gets stylesheets directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.stylesheets
Path*('/path/to/scores/my_score/my_score/stylesheets')
>>> path.stylesheets('stylesheet.ily')
Path*('/path/to/scores/my_score/my_score/stylesheets/stylesheet.ily')
Return type:Optional[Path]
(PurePath).suffix

The final component’s last suffix, if any.

(PurePath).suffixes

A list of the final component’s suffixes, if any.

test

Gets test directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.test
Path*('/path/to/scores/my_score/my_score/test')
>>> path.test('test_materials.py')
Path*('/path/to/scores/my_score/my_score/test/test_materials.py')
Return type:Optional[Path]
tools

Gets tools directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.tools
Path*('/path/to/scores/my_score/my_score/tools')
>>> path.tools('SegmentMaker.py')
Path*('/path/to/scores/my_score/my_score/tools/SegmentMaker.py')
Return type:Optional[Path]
wrapper

Gets wrapper directory.

>>> path = abjad.Path(
...     '/path/to/scores/my_score/my_score',
...     scores='/path/to/scores',
...     )
>>> path.wrapper
Path*('/path/to/scores/my_score')
>>> path.wrapper('my_score', 'etc')
Path*('/path/to/scores/my_score/my_score/etc')
Return type:Optional[Path]