Skip to content

Commit

Permalink
Merge pull request #4 from looptailG/v2.1.0
Browse files Browse the repository at this point in the history
Iteration utils
  • Loading branch information
looptailG authored Nov 29, 2024
2 parents 5ebf81b + a10f200 commit caf1dbd
Show file tree
Hide file tree
Showing 7 changed files with 538 additions and 295 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
out
out/*
!out/Generate22EDOPlugin.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This plugin remembers which accidental is applied to any given note, and will au

This plugin supports custom key signatures. If the custom key signatures only contain standard accidentals, no extra action is required other than inserting the custom key signaturs into the score.

If the key signature contains microtonal accidentals, then it is necessary to also add a text (`System Text` or `Staff Text`) to inform the plugin about the accidentals present in the key signature. This text has to be formatted as `X.X.X.X.X.X.X`, where `X` are the accidental applied to each note, arranged according to the circle of fifths: `F.C.G.D.A.E.B`. These accidentals are written using ASCII characters only in the following way:
If the key signature contains microtonal accidentals, then it is necessary to also add a text (`System Text` for a global key signature or `Staff Text` for a local key signature) to inform the plugin about the accidentals present in the key signature. This text has to be formatted as `X.X.X.X.X.X.X`, where `X` are the accidental applied to each note, arranged according to the circle of fifths: `F.C.G.D.A.E.B`. These accidentals are written using ASCII characters only in the following way:

| Accidental | Text |
| :--------: | :--: |
Expand Down
61 changes: 61 additions & 0 deletions out/Generate22EDOPlugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import os
import shutil
import re


PLUGIN_FOLDER_NAME = "22edo_tuner"
SOURCE_FOLDER = "../source"
LOGS_FOLDER = f"{PLUGIN_FOLDER_NAME}/logs"
README_PATH = "../README.md"
LICENSE_PATH = "../LICENSE"
THUMBNAIL_PATH = "../thumbnail/22EdoThumbnail.png"
FILES_TO_COPY = [
LICENSE_PATH,
THUMBNAIL_PATH,
]


def main():
try:
shutil.copytree(SOURCE_FOLDER, PLUGIN_FOLDER_NAME, dirs_exist_ok=True)
for file_path in FILES_TO_COPY:
file_name = file_path[file_path.rindex("/") + 1:]
shutil.copyfile(file_path, f"{PLUGIN_FOLDER_NAME}/{file_name}")
if not os.path.exists(LOGS_FOLDER):
os.makedirs(LOGS_FOLDER)

version_number = get_version_number()
output_folder_name = f"{PLUGIN_FOLDER_NAME}_{version_number}"
temporary_folder = "tmp"
shutil.copytree(PLUGIN_FOLDER_NAME, f"{temporary_folder}/{PLUGIN_FOLDER_NAME}", dirs_exist_ok=True)
shutil.make_archive(output_folder_name, "zip", temporary_folder)
shutil.rmtree(temporary_folder)

except Exception as e:
print(e)
input()


def get_version_number() -> str:
version_number_pattern = re.compile(r"version:\s*\"(.+)\";")
for root, _, files in os.walk(SOURCE_FOLDER):
for file_name in files:
if simplify_file_name(PLUGIN_FOLDER_NAME) not in simplify_file_name(file_name):
continue

file_path = os.path.join(root, file_name)
with open(file_path, "r") as file:
for line in file:
match = version_number_pattern.match(line.strip())
if match:
return match.group(1)

raise Exception("Could not get the version number.")


def simplify_file_name(file_name: str) -> str:
return file_name.replace("_", "").lower()


if __name__ == "__main__":
main()
Loading

0 comments on commit caf1dbd

Please sign in to comment.