Skip to content

Instantly share code, notes, and snippets.

@theseanco
Created July 22, 2016 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theseanco/9734c2be4fee904a9246278740079e2b to your computer and use it in GitHub Desktop.
Save theseanco/9734c2be4fee904a9246278740079e2b to your computer and use it in GitHub Desktop.
script chopper for x201 dissection program
# A Python script to print random (potentially) paragraphs from scripts within folders when triggered
import os
import random
# opening the python script
pyscript = open(os.path.join(os.path.dirname(__file__), 'Scripts/OSCResponder/011_RecievingProcessingTestValues.py'))
pyparagraph = []
scscript = open(os.path.join(os.path.dirname(__file__), 'Scripts/SuperCollider/HeartbeatInductionCombined/002_FormattedForTest.scd'))
scparagraph = []
pdescript = open(os.path.join(os.path.dirname(__file__), 'Scripts/Processing/StressTestTypes/type_x_combination_003_verticallines/type_x_combination_003_verticallines.pde'))
pdeparagraph = []
scripts = [scparagraph, pdeparagraph, pyparagraph]
# A function which chops scripts into paragraphs
def chopscript(script,out):
para = []
# splits the script into paragraphs
for line in script:
if line == "\n":
para.append(line)
out.append(para)
para = []
else:
para.append(line)
# calls the function on each file to chop them all up
chopscript(pyscript,pyparagraph)
chopscript(pdescript,pdeparagraph)
chopscript(scscript,scparagraph)
# prints a random paragraph
def scriptprint(script):
print ''.join(script[random.randrange(0,len(script))])
# print random paragraph from random script
scriptprint(random.choice(scripts))
# i can then send this a random.choose of an array of script string names
#printscript(pyscript)
#print pyscriptlines
#print scscriptlines
#print processingscriptlines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment