mscxyz.Score¶
- class mscxyz.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.
Methods
__init__
(src)backup
()Make a copy of the MuseScore file.
change_path
([suffix, extension, filename])exists
()Get the version number of the MuseScore file.
new
([suffix, extension, filename])Read the MuseScore XML file as text.
reload
([save])Reload the MuseScore file.
save
([new_dest, mscore])Save the MuseScore file.
Attributes
The absolute path of the backup file.
The basename of the score file, for example:
score
.The name of the containing directory of the MuseScore file, for example:
/home/xyz/score_files
.The extension (
mscx
ormscz
) of the score file.The filename of the MuseScore file, for example:
score.mscz
.Whether the MuseScore file is uncompressed , i.e. it is a
*.mscx
file.The absolute path of the JSON file in which the metadata can be exported.
The revision number of the MuseScore program, for example:
eb8d33c
.The semantic version number of the MuseScore program, for example:
4.2.0
.Score files created with MuseScore 4 have a separate style file.
The major MuseScore version, for example
2
,3
or4
The absolute path of the MuseScore file, for example
/home/xyz/score.mscz
.The path of the uncompressed MuseScore file in XML format file.
The root element of the XML tree.
The MuseScore version as a floating point number, for example
2.03
,3.01
or4.20
.- path: Path¶
The absolute path of the MuseScore file, for example
/home/xyz/score.mscz
.
- zip_container: ZipContainer | None = 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 = 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 fields: FieldsManager¶
- new(suffix: Any | None = None, extension: str | None = None, filename: str | None = None) Score [source]¶
- 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.
- 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.