Other submodules
mscxyz.cli module
Wrapper for the command line interface.
- class mscxyz.cli.LineWrapRawTextHelpFormatter(prog: str)[source]
Bases:
RawDescriptionHelpFormatter
- mscxyz.cli.get_args(cli_args: Sequence[str] | None = None) DefaultArguments[source]
mscxyz.export module
- mscxyz.export.extensions
Supported file extensions for export in MuseScore version 4.
- class mscxyz.export.Export(score: Score)[source]
Bases:
object- to_extension(extension: str = 'pdf') Path[source]
Export the score to the specifed file type.
- Parameters:
extension – The extension (default: pdf)
- Returns:
The path of the exported file.
mscxyz.fields module
Provide fields ($variable) for the path templates.
- class mscxyz.fields.Field(name: 'str', description: 'str', attr_path: 'str', verbosity: 'int' = 1, color: 'Color' = 'white', readonly: 'bool' = False)[source]
Bases:
object- name: str
namewill become$namein the path templates
- description: str
Some description text for the documentation.
- attr_path: str
meta.titleaccessesscore.meta.title
- verbosity: int
Verbosity level indicating if the field should be displayed in the debug output.
- color: Literal['black', 'grey', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'light_grey', 'dark_grey', 'light_red', 'light_green', 'light_yellow', 'light_blue', 'light_magenta', 'light_cyan', 'white']
The color of the field in the debug output.
- readonly: bool
- class mscxyz.fields.FieldsManager(score: Score)[source]
Bases:
object- fields
- pre: dict[str, FieldValue]
The state of the field values at initialization, stored as a dictionary.
- property names: tuple[str, ...]
- diff(args: DefaultArguments) None[source]
mscxyz.rename module
Rename MuseScore files
- mscxyz.rename.rename(score: Score, path_template: str) None[source]
Rename a MuseScore file based on a path template and metadata fields.
- Parameters:
score – A Score object containing the file path and metadata fields
path_template – A template string for generating the target filename
- Example:
>>> score = Score(path='song.mscx') >>> rename(score, '{composer}/{title}')
mscxyz.settings module
This submodule provides default parameters for args. Here is the
args object stored from argparse. It can be accessed by the other
submodules using the function get_args().
- class mscxyz.settings.DefaultArguments[source]
Bases:
object- general_config_file: str | None
- general_backup: bool
- general_dry_run: bool
- general_catch_errors: bool
- general_mscore: bool
- general_executable: str | None
- export_extension: str | None
- export_compress: bool
- export_remove_origin: bool
- info_verbose: int
- info_color: bool
- info_diff: bool
- info_print_xml: bool
- help_markdown: bool
- help_rst: bool
- lyrics_extract: str | None
- lyrics_fix: bool
- lyrics_remap: str | None
- meta_clean: str | None
- meta_delete: bool
- meta_dist: list[tuple[str, str]] | None
- meta_log: list[str] | None
- meta_json: bool
- meta_sync: bool
- meta_set: list[tuple[str, str]] | None
- meta_metatag: list[tuple[str, str]] | None
- meta_vbox: list[tuple[str, str]] | None
- meta_combined: list[tuple[str, str]] | None
- meta_title: str | None
- meta_subtitle: str | None
- meta_composer: str | None
- meta_lyricist: str | None
- meta_instrument_excerpt: str | None
- rename_rename: str | None
- rename_target: str | None
- rename_only_filename: bool
- rename_alphanum: bool
- rename_ascii: bool
- rename_no_whitespace
- rename_skip: str | None
- rename_list_fields: bool
- rename_list_functions: bool
- selection_list: bool
- selection_glob: str
- selection_mscz: bool
- selection_mscx: bool
- style_value: list[tuple[str, str]]
- style_clean: bool
- style_file: TextIOWrapper | None
- style_styles_v3: bool
- style_styles_v4: bool
- style_reset_small_staffs: bool
- style_list_fonts: bool
- style_text_font: str | None
- style_title_font: str | None
- style_musical_symbol_font: str | None
- style_musical_text_font: str | None
- style_staff_space: float | None
- style_page_size: tuple[str, str] | None
- style_page_size_a4: bool
- style_page_size_letter: bool
- style_margin: str | None
- style_show_header: bool | None
- style_header_first_page: bool | None
- style_different_odd_even_header: bool | None
- style_header_all: tuple[str, str, str] | None
- style_header_odd_even: tuple[str, str, str, str, str, str] | None
- style_clear_header: bool
- style_lyrics_font_size: float | None
- style_lyrics_min_distance: float | None
- path: list[PathOrStr]
- mscxyz.settings.get_args() DefaultArguments[source]
Get the
argsobject (theargparseobject) which is stored in the .settings.py submodule for all other submodules.- Returns:
the
argparseobject
- mscxyz.settings.set_args(new_args: DefaultArguments) DefaultArguments[source]
Set the
argsobject (theargparseobject) which is stored in the .settings.py submodule for all other submodules to import.
- mscxyz.settings.reset_args() DefaultArguments[source]
Reset the
argsobject (theargparseobject) which is stored in the .settings.py submodule for all other submodules to import.
- mscxyz.settings.parse_config_ini(relpath: str | None = None) ConfigParser | None[source]
Parse the configuration file. The file format is INI. The default location is
/etc/mscxyz.ini.
- mscxyz.settings.merge_config_into_args(config: ConfigParser, args: DefaultArguments) DefaultArguments[source]
- mscxyz.settings.parse_args(parser: ArgumentParser, cli_args: Sequence[str] | None = None) DefaultArguments[source]
mscxyz.utils module
A collection of useful utility functions
- mscxyz.utils.list_path(src: PathLike[str] | str | Path | list[PathLike[str] | str | Path], extension: Literal['mscz', 'mscx', 'both'] = 'both', glob: str | None = None) Generator[Path, None, None][source]
List all scores in path.
- Parameters:
src – A directory to search for files or a file path or multiple directories or paths.
extension – Possible values: “both”, “mscz” or “mscx”.
glob – A glob string, see fnmatch
- mscxyz.utils.list_zero_alphabet() List[str][source]
Build a list: 0, a, b, c etc.
- mscxyz.utils.get_musescore_bin() str[source]
Check the existance of the executable mscore
- Returns:
Path of the executable.
- mscxyz.utils.execute_musescore(cli_args: list[str]) Popen[Any][source]
- Parameters:
cli_args – Command line arguments to call the mscore binary with.
- mscxyz.utils.re_open(input_file: str) None[source]
Open and save a MuseScore file with the
mscorebinary under the same file path.- Parameters:
input_file – The path (relative or absolute) of a MuseScore file.
- mscxyz.utils.round_float(value: str | int | float) float[source]
- class mscxyz.utils.Dimension(value: str)[source]
Bases:
object- value: float
- unit: Literal['mm', 'in']
- static parse(dimension: str) tuple[float, Literal['mm', 'in']][source]
- static convert(value: float, from_unit: Literal['mm', 'in'], to_unit: Literal['mm', 'in']) float[source]
- to(unit: Literal['mm', 'in']) float[source]
- mscxyz.utils.colorize(text: str, color: Literal['black', 'grey', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'light_grey', 'dark_grey', 'light_red', 'light_green', 'light_yellow', 'light_blue', 'light_magenta', 'light_cyan', 'white'] | None = None, on_color: Literal['on_black', 'on_grey', 'on_red', 'on_green', 'on_yellow', 'on_blue', 'on_magenta', 'on_cyan', 'on_light_grey', 'on_dark_grey', 'on_light_red', 'on_light_green', 'on_light_yellow', 'on_light_blue', 'on_light_magenta', 'on_light_cyan', 'on_white'] | None = None) str[source]
Wrapper function around
termcolor.colored()to easily turn off and on colorized terminal output on the command line.
- class mscxyz.utils.PathChanger(path: str | Path)[source]
Bases:
object- path: Path
- property extension: str
- property base: str
- new() PathChanger[source]
- change_extension(new_extension: str) Path[source]
- add_suffix(suffix: Any) Path[source]
- change(suffix: Any | None = None, extension: str | None = None, filename: str | None = None) Path[source]
- mscxyz.utils.change_path(path: str | Path, suffix: Any | None = None, extension: str | None = None) Path[source]
- class mscxyz.utils.ZipContainer(abspath: str | Path)[source]
Bases:
objectContainer for the file paths of the different files in an unzipped MuseScore file
<?xml version="1.0" encoding="UTF-8"?> <container> <rootfiles> <rootfile full-path="score_style.mss"/> <rootfile full-path="test.mscx"/> <rootfile full-path="Thumbnails/thumbnail.png"/> <rootfile full-path="audiosettings.json"/> <rootfile full-path="viewsettings.json"/> </rootfiles> </container>
- tmp_dir: Path
Absolute path of the temporary directory where the unzipped files are stored
- xml_file: Path
Absolute path of the uncompressed XML score file
- score_style_file: Path | None
Absolute path of the score style file
- thumbnail_file: Path | None
Absolute path of the thumbnail file
- audiosettings_file: Path | None
Absolute path of the audio settings file
- viewsettings_file: Path | None
Absolute path of the view settings file
- save(dest: str | Path) None[source]
- mscxyz.utils.read_file(filename: str | Path) str[source]
Read the file as text.
- Returns:
The content of file as text.