Submodule score
¶
A class that represents one MuseScore file.
- class mscxyz.score.Score(src: str | Path)[source]
Bases:
object
This class holds basic file properties of the MuseScore score file.
- Parameters:
src – The relative (or absolute) path of a MuseScore file.
- path: Path
The absolute path of the MuseScore file, for example
/home/xyz/score.mscz
.
- zip_container: ZipContainer | None
- xml_file: str
The path of the uncompressed MuseScore file in XML format file. This path may be located in the temporary directory.
- xml: XmlManipulator
- xml_root: _Element
The root element of the XML tree. It is the
<museScore version="X.X">
Tag. See the lxml API.
- version: float
The MuseScore version as a floating point number, for example
2.03
,3.01
or4.20
.
- style_file: Path | None
Score files created with MuseScore 4 have a separate style file.
- property xml_string: str
- property version_major: int
The major MuseScore version, for example
2
,3
or4
- property program_version: str
The semantic version number of the MuseScore program, for example:
4.2.0
.<programVersion>4.2.0</programVersion>
- property program_revision: str
The revision number of the MuseScore program, for example:
eb8d33c
.<programRevision>eb8d33c</programRevision>
- property backup_file: Path
The absolute path of the backup file. The string
_bak
is appended to the file name before the extension.
- property json_file: Path
The absolute path of the JSON file in which the metadata can be exported.
- property dirname: str
The name of the containing directory of the MuseScore file, for example:
/home/xyz/score_files
.
- property filename: str
The filename of the MuseScore file, for example:
score.mscz
.
- property basename: str
The basename of the score file, for example:
score
.
- property extension: str
The extension (
mscx
ormscz
) of the score file.
- property is_uncompressed: bool
Whether the MuseScore file is uncompressed , i.e. it is a
*.mscx
file
- change_path(suffix: Any | None = None, extension: str | None = None, filename: str | None = None) Path [source]
- property export: Export
- property fields: FieldsManager
- property lyrics: Lyrics
- property meta: Meta
- property style: Style
- make_snapshot() None [source]
- new(suffix: Any | None = None, extension: str | None = None, filename: str | None = None) Score [source]
- exists() bool [source]
- backup() None [source]
Make a copy of the MuseScore file.
- get_version() float [source]
Get the version number of the MuseScore file.
- Returns:
The version number as a float.
- Raises:
ValueError – If the version number cannot be retrieved.
- print_diff() None [source]
- save(new_dest: str = '', mscore: bool = False) None [source]
Save the MuseScore file.
- Parameters:
new_dest – Save the MuseScore file under a new name.
mscore – Save the MuseScore file by opening it with the MuseScore executable and save it there.
- read_as_text() str [source]
Read the MuseScore XML file as text.
- Returns:
The content of the MuseScore XML file as text.