Home       Goals       Download       Documentation       Support Us       Development       Job Openings       Webstore       Patrons       Contact us / Enlist      

 

anyfilename = 'tekst_dk_nix.txt'
f = open(anyfilename,'r')
output = []
newoutput=[]
htmloutput=[]
countup = 0

sc = ''
fun = ''
vari = ''
timset = ''
pl = ''
endbrack = ''
javscript_to_play = ''





for line in f:
 if '' in line:
  output.append(line)
f.close()


'''determine length of list and then setnumber_of_lines to this value'''
count = 0
number_of_lines = 0
linenumber = 0

for i in output:
   
   count = count+1

'''Now we have the number of lines'''

number_of_lines = count

for i in range(0, number_of_lines):
        
    '''print "gubblegub"        '''
    '''print output[i] '''
    
else:
    print 'Reading the information into output complete now we should perform string operation'
    print " "
    print " "
    '''First assignment clean output for anything after : in each line'''
    print "Innerloop beginning, finding all instances of '.png'"
    for i in range(0, number_of_lines):
       
        search = '.png'
        output[i].find(search)
        index = output[i].find(search)
        countup = countup + 1
        print countup
        indexval=index
        '''print search, "found at index", index'''
        '''Now we cut the end of every sentence of output'''
        cut_text_from_string=output[i][:index]
        
        '''print ' \n'
        print cut_text_from_string'''
        
        anameback = cut_text_from_string[-4::]
        imagename = anameback
        imagename = imagename + '.png'
        '''anameback = anameback+'.mp3' '''
        testvariable = output[i]
        print testvariable
        addtoback = cut_text_from_string[:-5]

        soundfilename = anameback+'.mp3'

      


        ''' lav audio loads - samt audio playback script  add disse hhv. i top og bund af anyfilename listerne efter de er skrevet '''

        '''<audio src="http://globability.org/webapp/sound/'+ soundfilename + '"></audio>'  '''

        audioload1 = '<audio  preload="auto" autobuffer id="'

        audioload2 = '" src="http://globability.org/webapp/sound/'
        
        audioload4 = '" type="audio/mp3" > \n Your browser does not seem to support the HTML5 audio element. </audio> \n'

        
        audioload3 = str(testvariable[:-5])+'mp3'

        
        
        audioload5 = audioload1 + anameback + audioload2 + audioload3


        audioload_before = audioload5[:-9]
        audioload_after = audioload5[-8:]
        audioload_processed = audioload_before + audioload_after
        
        audioload = audioload_processed + audioload4

    

        '''audioload2 + audioload3 + audioload4'''
        

        htmlimagecode = ' <img style="border: 0px solid ; width: 70px; height: 60px;" alt="'+ anameback + '" title="This is the image for ' + imagename + '" src="http://globability.org/webapp/images/' + imagename +' "></center></a></td>'

        soundplayback = '<td style="vertical-align: top;">  <center> <a onclick="' + anameback +'()"; >' + htmlimagecode


        ''' Dette er struktur på audio script til playback'''

        sc = '<script type="text/javascript"> \n \n'
        fun = "function "+ anameback + '() { \n'
        variab = 'var ' + anameback + " = document.getElementById('" + anameback + "'); \n"
        timset = 'this.currentTime = 0; \n'
        pl = anameback + '.play(); '
        endbrack = '} \n \n </script> '

        javscript_to_play = sc+fun+variab+timset+pl+endbrack

        newoutput.append(audioload + '\n' + '\n' + soundplayback +' \n'+' \n' + javscript_to_play + '\n' + '\n')
        
        
    
        
        
 
        
        
    
        
        


print "All done"


anyfilename1 = 'htmltablefile001_test.txt'
fob3 = open(anyfilename1,'w')
fob3.writelines(newoutput[0:111])
fob3.close()
        
anyfilename2 = 'htmltablefile002_test.txt'
fob4 = open(anyfilename2,'w')
fob4.writelines(newoutput[112:224])
fob4.close()

anyfilename3 = 'htmltablefile003_test.txt'
fob5 = open(anyfilename3,'w')
fob5.writelines(newoutput[225:337])
fob5.close()

anyfilename4 = 'htmltablefile004_test.txt'
fob6 = open(anyfilename4,'w')
fob6.writelines(newoutput[338:449])
fob6.close()

anyfilename5 = 'htmltablefile005_test.txt'
fob7 = open(anyfilename5,'w')
fob7.writelines(newoutput[450:561])
fob7.close()

anyfilename6 = 'htmltablefile006_test.txt'
fob8 = open(anyfilename6,'w')
fob8.writelines(newoutput[562:673])
fob8.close()
        
anyfilename7 = 'htmltablefile007_test.txt'
fob9 = open(anyfilename7,'w')
fob9.writelines(newoutput[674:785])
fob9.close()

anyfilename8 = 'htmltablefile008_test.txt'
fob10 = open(anyfilename6,'w')
fob10.writelines(newoutput[786:888])
fob10.close()

even_uglier_python_hack_20111115.txt · Last modified: 2012/03/30 01:32 (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki



The contents of this site, i.e. texts, programs and images, but not limited to these, belongs to their respective owners and are protected under international copyright treaties according to individual licensing.

Please make sure you familiarize yourself with the appropriate permissions / licenses and follow these individually before using anything you find on this site.

The Global Ability Initiative is a Non Profit venture dedicated to the development of gratis, open source software for the disabled, the sick and the needy - We aim to provide assistive software to a wide variety of people, suffering for example from Aphasia, MS, ALS, Cerebral Palsy and other disabilities as well as pushing initiatives in the field of ECG monitoring.

With reservation for changes and errors.