Browse Source

fix unix compliance + remove hardcoded inputfile from xml-parser

Noah Vogt 4 years ago
parent
commit
6d58e5846f
3 changed files with 12 additions and 4 deletions
  1. 2 0
      src/motiv_gen
  2. 8 4
      src/xml-parser
  3. 2 0
      tests/randomness-test-file

+ 2 - 0
src/motiv_gen

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+
 from gizmo_transforming_functions import *
 from gizmo_funtions import gizmo_stdout
 

+ 8 - 4
src/xml-parser

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+
 from bs4 import BeautifulSoup
 from gizmo_funtions import gizmo_stdout
 from gizmo_transforming_functions import duration_to_string, convert_multiple_key_signetures
@@ -16,9 +18,9 @@ def how_many_alter_signs(value):
 
 # Reading the data inside the xml 
 # file to a variable under the name  
-# data 
-with open('../tests/motiv.xml', 'r') as f:
-    data = f.read()
+# data from standard input
+import sys
+data = sys.stdin.read()
 
 # Passing the stored data inside 
 # the beautifulsoup parser, storing  
@@ -36,7 +38,7 @@ for note in notes:
     duration = float(note.find('duration').text) / float(BS_data.find('divisions').text)
     duration = duration_to_string(duration)
     pitch = note.find('pitch')
-    if pitch == None: # cut out pauses does not work yet
+    if pitch == None: # TODO: cutting out pauses does not work yet
         next
     else:
         new_note = duration + ',' + note.find('step').text
@@ -45,4 +47,6 @@ for note in notes:
         new_note += note.find('octave').text
         new_note = convert_multiple_key_signetures(new_note)
     working_list.append(new_note)
+
+# print to standard output
 gizmo_stdout(working_list)   

+ 2 - 0
tests/randomness-test-file

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+
 import random
 
 def normal(mu):