diff --git a/README.rst b/README.rst index 82d1e63..74cda5a 100644 --- a/README.rst +++ b/README.rst @@ -307,6 +307,65 @@ The output of the code example is very long, so here is a shortened version: ... edit the meta data of a score file? --------------------------------------- +metatag +^^^^^^^ + +XML structure of a meta tag: + +.. code-block:: xml + + + +All meta tags: + +- arranger +- audioComUrl (new in v4) +- composer +- copyright +- creationDate +- lyricist +- movementNumber +- movementTitle +- mscVersion +- platform +- poet (not in v4) +- source +- sourceRevisionId +- subtitle +- translator +- workNumber +- workTitle + +vbox +^^^^ + +XML structure of a vbox tag: + +.. code-block:: xml + + + + + Some title text + + +All vbox tags: + +- title (v2,3: Title) +- subtitle (v2,3: Subtitle) +- composer (v2,3: Composer) +- lyricist (v2,3: Lyricist) + +This command line tool bundles some meta data informations: + +Combined meta data fields: +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- title (1. vbox_title 2. metatag_work_title) +- subtitle (1. vbox_subtitle 2. metatag_movement_title) +- composer (1. vbox_composer 2. metatag_composer) +- lyricist (1. vbox_lyricist 2. metatag_lyricist) + Set the meta tag ``composer``: .. code-block:: xml @@ -413,59 +472,7 @@ CLI Usage file (*.mscz). meta: - Deal with meta data informations stored in the MuseScore file. MuseScore can store meta data informations in different places: - - # metatag - - ## XML structure of a meta tag: - - - - ## All meta tags: - - - arranger - - audioComUrl (new in v4 - - composer - - copyright - - creationDate - - lyricist - - movementNumber - - movementTitle - - mscVersion - - platform - - poet (not in v4) - - source - - sourceRevisionId - - subtitle - - translator - - workNumber - - workTitle - - # vbox - - ## XML structure of a vbox tag: - - - - - Some title text - - - ## All vbox tags: - - - title (v2,3: Title) - - subtitle (v2,3: Subtitle) - - composer (v2,3: Composer) - - lyricist (v2,3: Lyricist) - - This command line tool bundles some meta data informations: - - # Combined meta data fields: - - - title (1. vbox_title 2. metatag_work_title) - - subtitle (1. vbox_subtitle 2. metatag_movement_title) - - composer (1. vbox_composer 2. metatag_composer) - - lyricist (1. vbox_lyricist 2. metatag_lyricist) + Deal with meta data informations stored in the MuseScore file. -c META_CLEAN, --clean-meta META_CLEAN Clean the meta data fields. Possible values: „all“ or a @@ -533,164 +540,7 @@ CLI Usage correct hyphenation ("la - la - la") rename: - Rename the “*.msc[zx]” files. Fields and functions you can use in the path template string (-r, --rename): - - Functions - ========= - - alpha - ----- - - %alpha{text} - This function first ASCIIfies the given text, then all non alphabet - characters are replaced with whitespaces. - - alphanum - -------- - - %alphanum{text} - This function first ASCIIfies the given text, then all non alpanumeric - characters are replaced with whitespaces. - - asciify - ------- - - %asciify{text} - Translate non-ASCII characters to their ASCII equivalents. For - example, “café” becomes “cafe”. Uses the mapping provided by the - unidecode module. - - delchars - -------- - - %delchars{text,chars} - Delete every single character of “chars“ in “text”. - - deldupchars - ----------- - - %deldupchars{text,chars} - Search for duplicate characters and replace with only one occurrance - of this characters. - - first - ----- - - %first{text} or %first{text,count,skip} or - %first{text,count,skip,sep,join} - Returns the first item, separated by ; . You can use - %first{text,count,skip}, where count is the number of items (default - 1) and skip is number to skip (default 0). You can also use - %first{text,count,skip,sep,join} where sep is the separator, like ; or - / and join is the text to concatenate the items. - - if - -- - - %if{condition,truetext} or %if{condition,truetext,falsetext} - If condition is nonempty (or nonzero, if it’s a number), then returns - the second argument. Otherwise, returns the third argument if - specified (or nothing if falsetext is left off). - - ifdef - ----- - - %ifdef{field}, %ifdef{field,text} or %ifdef{field,text,falsetext} - If field exists, then return truetext or field (default). Otherwise, - returns falsetext. The field should be entered without $. - - ifdefempty - ---------- - - %ifdefempty{field,text} or %ifdefempty{field,text,falsetext} - If field exists and is empty, then return truetext. Otherwise, returns - falsetext. The field should be entered without $. - - ifdefnotempty - ------------- - - %ifdefnotempty{field,text} or %ifdefnotempty{field,text,falsetext} - If field is not empty, then return truetext. Otherwise, returns - falsetext. The field should be entered without $. - - initial - ------- - - %initial{text} - Get the first character of a text in lowercase. The text is converted - to ASCII. All non word characters are erased. - - left - ---- - - %left{text,n} - Return the first “n” characters of “text”. - - lower - ----- - - %lower{text} - Convert “text” to lowercase. - - nowhitespace - ------------ - - %nowhitespace{text,replace} - Replace all whitespace characters with replace. By default: a dash (-) - %nowhitespace{$track,_} - - num - --- - - %num{number,count} - Pad decimal number with leading zeros. - %num{$track,3} - - replchars - --------- - - %replchars{text,chars,replace} - Replace the characters “chars” in “text” with “replace”. - %replchars{text,ex,-} > t--t - - right - ----- - - %right{text,n} - Return the last “n” characters of “text”. - - sanitize - -------- - - %sanitize{text} - Delete in most file systems not allowed characters. - - shorten - ------- - - %shorten{text} or %shorten{text,max_size} - Shorten “text” on word boundarys. - %shorten{$title,32} - - time - ---- - - %time{date_time,format,curformat} - Return the date and time in any format accepted by strftime. For - example, to get the year some music was added to your library, use - %time{$added,%Y}. - - title - ----- - - %title{text} - Convert “text” to Title Case. - - upper - ----- - - %upper{text} - Convert “text” to UPPERCASE. + Rename the “*.msc[zx]” files. --rename A path template string to set the destination location. diff --git a/README_template.rst b/README_template.rst index 63f09ae..973a59e 100644 --- a/README_template.rst +++ b/README_template.rst @@ -312,6 +312,65 @@ The output of the code example is very long, so here is a shortened version: ... edit the meta data of a score file? --------------------------------------- +metatag +^^^^^^^ + +XML structure of a meta tag: + +.. code-block:: xml + + + +All meta tags: + +- arranger +- audioComUrl (new in v4) +- composer +- copyright +- creationDate +- lyricist +- movementNumber +- movementTitle +- mscVersion +- platform +- poet (not in v4) +- source +- sourceRevisionId +- subtitle +- translator +- workNumber +- workTitle + +vbox +^^^^ + +XML structure of a vbox tag: + +.. code-block:: xml + + + + + Some title text + + +All vbox tags: + +- title (v2,3: Title) +- subtitle (v2,3: Subtitle) +- composer (v2,3: Composer) +- lyricist (v2,3: Lyricist) + +This command line tool bundles some meta data informations: + +Combined meta data fields: +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- title (1. vbox_title 2. metatag_work_title) +- subtitle (1. vbox_subtitle 2. metatag_movement_title) +- composer (1. vbox_composer 2. metatag_composer) +- lyricist (1. vbox_lyricist 2. metatag_lyricist) + Set the meta tag ``composer``: .. code-block:: xml diff --git a/docs/cli.rst b/docs/cli.rst index a969558..80edab8 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -80,59 +80,7 @@ Comande line interface file (*.mscz). meta: - Deal with meta data informations stored in the MuseScore file. MuseScore can store meta data informations in different places: - - # metatag - - ## XML structure of a meta tag: - - - - ## All meta tags: - - - arranger - - audioComUrl (new in v4 - - composer - - copyright - - creationDate - - lyricist - - movementNumber - - movementTitle - - mscVersion - - platform - - poet (not in v4) - - source - - sourceRevisionId - - subtitle - - translator - - workNumber - - workTitle - - # vbox - - ## XML structure of a vbox tag: - - - - - Some title text - - - ## All vbox tags: - - - title (v2,3: Title) - - subtitle (v2,3: Subtitle) - - composer (v2,3: Composer) - - lyricist (v2,3: Lyricist) - - This command line tool bundles some meta data informations: - - # Combined meta data fields: - - - title (1. vbox_title 2. metatag_work_title) - - subtitle (1. vbox_subtitle 2. metatag_movement_title) - - composer (1. vbox_composer 2. metatag_composer) - - lyricist (1. vbox_lyricist 2. metatag_lyricist) + Deal with meta data informations stored in the MuseScore file. -c META_CLEAN, --clean-meta META_CLEAN Clean the meta data fields. Possible values: „all“ or a @@ -200,164 +148,7 @@ Comande line interface correct hyphenation ("la - la - la") rename: - Rename the “*.msc[zx]” files. Fields and functions you can use in the path template string (-r, --rename): - - Functions - ========= - - alpha - ----- - - %alpha{text} - This function first ASCIIfies the given text, then all non alphabet - characters are replaced with whitespaces. - - alphanum - -------- - - %alphanum{text} - This function first ASCIIfies the given text, then all non alpanumeric - characters are replaced with whitespaces. - - asciify - ------- - - %asciify{text} - Translate non-ASCII characters to their ASCII equivalents. For - example, “café” becomes “cafe”. Uses the mapping provided by the - unidecode module. - - delchars - -------- - - %delchars{text,chars} - Delete every single character of “chars“ in “text”. - - deldupchars - ----------- - - %deldupchars{text,chars} - Search for duplicate characters and replace with only one occurrance - of this characters. - - first - ----- - - %first{text} or %first{text,count,skip} or - %first{text,count,skip,sep,join} - Returns the first item, separated by ; . You can use - %first{text,count,skip}, where count is the number of items (default - 1) and skip is number to skip (default 0). You can also use - %first{text,count,skip,sep,join} where sep is the separator, like ; or - / and join is the text to concatenate the items. - - if - -- - - %if{condition,truetext} or %if{condition,truetext,falsetext} - If condition is nonempty (or nonzero, if it’s a number), then returns - the second argument. Otherwise, returns the third argument if - specified (or nothing if falsetext is left off). - - ifdef - ----- - - %ifdef{field}, %ifdef{field,text} or %ifdef{field,text,falsetext} - If field exists, then return truetext or field (default). Otherwise, - returns falsetext. The field should be entered without $. - - ifdefempty - ---------- - - %ifdefempty{field,text} or %ifdefempty{field,text,falsetext} - If field exists and is empty, then return truetext. Otherwise, returns - falsetext. The field should be entered without $. - - ifdefnotempty - ------------- - - %ifdefnotempty{field,text} or %ifdefnotempty{field,text,falsetext} - If field is not empty, then return truetext. Otherwise, returns - falsetext. The field should be entered without $. - - initial - ------- - - %initial{text} - Get the first character of a text in lowercase. The text is converted - to ASCII. All non word characters are erased. - - left - ---- - - %left{text,n} - Return the first “n” characters of “text”. - - lower - ----- - - %lower{text} - Convert “text” to lowercase. - - nowhitespace - ------------ - - %nowhitespace{text,replace} - Replace all whitespace characters with replace. By default: a dash (-) - %nowhitespace{$track,_} - - num - --- - - %num{number,count} - Pad decimal number with leading zeros. - %num{$track,3} - - replchars - --------- - - %replchars{text,chars,replace} - Replace the characters “chars” in “text” with “replace”. - %replchars{text,ex,-} > t--t - - right - ----- - - %right{text,n} - Return the last “n” characters of “text”. - - sanitize - -------- - - %sanitize{text} - Delete in most file systems not allowed characters. - - shorten - ------- - - %shorten{text} or %shorten{text,max_size} - Shorten “text” on word boundarys. - %shorten{$title,32} - - time - ---- - - %time{date_time,format,curformat} - Return the date and time in any format accepted by strftime. For - example, to get the year some music was added to your library, use - %time{$added,%Y}. - - title - ----- - - %title{text} - Convert “text” to Title Case. - - upper - ----- - - %upper{text} - Convert “text” to UPPERCASE. + Rename the “*.msc[zx]” files. --rename A path template string to set the destination location. diff --git a/mscxyz/cli.py b/mscxyz/cli.py index 8983748..8a97389 100644 --- a/mscxyz/cli.py +++ b/mscxyz/cli.py @@ -9,7 +9,6 @@ from typing import Sequence import shtab -import tmep import mscxyz.export from mscxyz import utils @@ -189,65 +188,7 @@ def _split_lines(self, text: typing.Text, width: int) -> typing.List[str]: ############################################################################### meta_group = parser.add_argument_group( - "meta", - "Deal with meta data informations stored in the MuseScore file. " - + textwrap.dedent( - """\ - MuseScore can store meta data informations in different places: - - # metatag - - ## XML structure of a meta tag: - - - - ## All meta tags: - - - arranger - - audioComUrl (new in v4 - - composer - - copyright - - creationDate - - lyricist - - movementNumber - - movementTitle - - mscVersion - - platform - - poet (not in v4) - - source - - sourceRevisionId - - subtitle - - translator - - workNumber - - workTitle - - # vbox - - ## XML structure of a vbox tag: - - - - - Some title text - - - ## All vbox tags: - - - title (v2,3: Title) - - subtitle (v2,3: Subtitle) - - composer (v2,3: Composer) - - lyricist (v2,3: Lyricist) - - This command line tool bundles some meta data informations: - - # Combined meta data fields: - - - title (1. vbox_title 2. metatag_work_title) - - subtitle (1. vbox_subtitle 2. metatag_movement_title) - - composer (1. vbox_composer 2. metatag_composer) - - lyricist (1. vbox_lyricist 2. metatag_lyricist) - """ - ), + "meta", "Deal with meta data informations stored in the MuseScore file." ) meta_group.add_argument( @@ -423,13 +364,7 @@ def _split_lines(self, text: typing.Text, width: int) -> typing.List[str]: # rename ############################################################################### -rename_group = parser.add_argument_group( - "rename", - "Rename the “*.msc[zx]” files. " - "Fields and functions you can use in the path " - "template string (-r, --rename):\n\n" - "Functions\n=========\n\n{}".format(tmep.get_doc()), -) +rename_group = parser.add_argument_group("rename", "Rename the “*.msc[zx]” files. ") rename_group.add_argument( "--rename", diff --git a/tests/test_cli.py b/tests/test_cli.py index c5cf5ed..23f7713 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -80,9 +80,9 @@ def test_help_text(self, capsys: CaptureFixture[str]) -> None: assert "[-h]" in capture.out -def test_functions_in_rename() -> None: +def test_option_help() -> None: stderr = Cli("--help", append_score=False).sysexit() - assert "%asciify{text}" in stderr + assert "notation software MuseScore" in stderr def test_version() -> None: