-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMusicNotes.py
89 lines (80 loc) · 2.32 KB
/
MusicNotes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- coding: utf-8 -*-
# Created by Richard Siena
# you are free to modify and distribute.
# please reference that it came from me.
# the Notes.correct.txt has sharp and flat unicode characters which python seems to have issues with.
#import codecs
import os
import sys
#UTF8Writer = codecs.getwriter('utf8')
#sys.stdout = UTF8Writer(sys.stdout)
import random
accidentals = False
helpoption = True
spellaccidentals =False
message = " Press Enter to continue, H for help!, Q to quit: "
#command line args
flat= "Flat" #"♭".encode('utf-8')
sharp= "Sharp" #"♯".encode('utf-8')
#print(f"Arguments count: {len(sys.argv)}")
l = range(0,len(sys.argv))
for i in l:
if sys.argv[i] == "-?":
print("-? for help")
print("-a for acidentals")
print("-h for no help ootion")
print("-s spell acidentals")
print("q to quit")
keystroke = input("Press enter to continue")
exit()
elif sys.argv[i] == "-a":
accidentals = True
elif sys.argv[i] == "-s":
spellaccidentals = True
elif sys.argv[i] == "-h":
helpoption = False
message = " Press Enter to continue: "
#open the file
file = open("Notes.txt", "r")
#store the lines from the file in a list
lines = file.readlines()
#shuffle the list
random.shuffle(lines)
#loop through each line in the list
for line in lines:
#split the line into two parts
text, help = line.split(",")
if not accidentals:
if sharp in text or flat in text:
continue
#if spellaccidentals:
# if sharp in text:
# test = text.replace(sharp, " sharp")
# elif flat in text:
# test = text.replace(flat, " flat")
#print the text
os.system('cls') # this line does not work in the debugger?
#you may need to change cls to clear for linux
print("")
print("")
print("")
print("")
print(" ",text)
print("")
print("")
#wait for user input
keystroke = input(message)
if keystroke == 'q' or keystroke == 'Q':
break
if keystroke == 'h' or keystroke == 'H':
#print('\n')
print("")
print("")
print("")
print(" ",help)
print("")
print("")
input(" Press Enter to continue...")
#print('\n')
#close the file
file.close()