Expand|Select|Wrap|Line Numbers
- def get_instr(from_file, to_file, instr_num):
- instr_num_str = str(instr_num)
- out_list = []
- infile = open(from_file, 'r')
- for line in infile: # Internally, for calls the files next() method
- line_list = line.split()
- if len(line_list) > 1 and line_list[1] == instr_num_str:
- out_list.append(line)
- while True:
- cmd = infile.next(), # so by the time we get here, we're ready
- cmd_str = cmd[0]
- print repr(cmd_str)
- out_list.append(cmd_str)
- if cmd_str.rstrip() == "endin":
- break
- break
- infile.close()
- print out_list
- outfile = open(to_file, "w")
- outfile.writelines(out_list)
- outfile.close()
Expand|Select|Wrap|Line Numbers
- csoundroutines.get_instr('bay-at-night.csd', 'test.orc', 1)
Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\boa-constructor\test of snake\test_of_csoundroutines.py", line 4, in ?
csoundroutines.get_instr('bay-at-night.csd', 'test.orc', 1)
File "C:\Python24\Lib\site-packages\boa-constructor\test of snake\csoundroutines.py", line 18, in get_instr
cmd = infile.next(), # so by the time we get here, we're ready
StopIteration