109 lines
2.9 KiB
Python
Executable File
109 lines
2.9 KiB
Python
Executable File
#!/usr/bin/python3
|
|
|
|
def printHTML(str):
|
|
print("<br>====|%s|" % str)
|
|
|
|
def FindString(x, str1, str2):
|
|
pos1 = x.find(str1)
|
|
pos2 = x.find(str2, pos1+1)
|
|
if( str2 == ''):
|
|
pos2 = len(x)
|
|
|
|
offset = len(str1)
|
|
|
|
if( pos1 > -1 and pos2 > -1):
|
|
haha = x[pos1+offset:pos2].strip()
|
|
#printHTML(haha)
|
|
return haha
|
|
else:
|
|
return '404'
|
|
|
|
|
|
isotope = '404'
|
|
preacc = '404'
|
|
inflector = '404'
|
|
LEB_Voltage = '404'
|
|
LEB_Feedback = '404'
|
|
tandam_pot = '404'
|
|
beam_energy = '404'
|
|
charge = '404'
|
|
charge_frac = '404'
|
|
beta = '404'
|
|
analysisMagnet = '404'
|
|
beamLine = '404'
|
|
switchingMagnet = '404'
|
|
|
|
file = open("beam.txt")
|
|
|
|
print("Content-type:text/html\r\n\r\n")
|
|
#print('<html>')
|
|
#print('<body>')
|
|
|
|
for x in file:
|
|
#print("<br>" + x)
|
|
if( isotope == '404') :
|
|
isotope = FindString(x, 'nucleus is', 'and')
|
|
if( preacc == '404'):
|
|
preacc = FindString(x, 'is at', 'kV')
|
|
if( inflector == '404'):
|
|
inflector = FindString(x, 'magnet is', 'A')
|
|
if( LEB_Voltage == '404'):
|
|
LEB_Voltage = FindString(x, 'Voltage is', 'V')
|
|
if( LEB_Feedback == '404'):
|
|
LEB_Feedback = FindString(x, 'Feedback is', 'V')
|
|
if( tandam_pot == '404'):
|
|
tandam_pot = FindString(x, 'Potential =', 'MV')
|
|
if( beam_energy == '404'):
|
|
beam_energy = FindString(x, 'Energy =', 'MeV')
|
|
if( charge == '404'):
|
|
charge = FindString(x, 'charge=', 'Fraction')
|
|
if( charge_frac == '404'):
|
|
charge_frac = FindString(x, 'Fraction =', 'Beta')
|
|
if( beta == '404'):
|
|
beta = FindString(x, 'Beta =', '')
|
|
if( analysisMagnet == '404'):
|
|
analysisMagnet = FindString(x, 'field is', 'G')
|
|
if( beamLine == '404'):
|
|
beamLine = FindString(x, '\"', '\"')
|
|
if( switchingMagnet == '404'):
|
|
switchingMagnet = FindString(x, 'Current is', 'A')
|
|
|
|
|
|
#print('<p>===================<p>')
|
|
#print("Isotope: " + isotope.upper() + "<br>")
|
|
#print("PreAcceleration: " + preacc + " kV <br>")
|
|
#print("Inflector: " + inflector + " A<br>")
|
|
#print("LEB Voltage: " + LEB_Voltage + " V<br>")
|
|
#print("LEB feedback: " + LEB_Feedback + " V<br>")
|
|
#print("Tandem Pot.: " + tandam_pot + " MV<br>")
|
|
#print("Beam Energy: " + beam_energy + " MeV<br>")
|
|
#print("Beam Charge: " + charge + "<br>")
|
|
#print("Frac. Charge: " + charge_frac + "<br>")
|
|
#print("Beta: " + beta + "<br>")
|
|
#print("Analyzing Magnet: " + analysisMagnet + " G<br>")
|
|
#print("Beam Line: " + beamLine + "<br>")
|
|
#print("Switching Magnet: " + switchingMagnet + " A<br>")
|
|
|
|
|
|
import re
|
|
MassNumber = (re.findall(r'\d+', isotope))[0]
|
|
pos = isotope.find(str(MassNumber))
|
|
IsotopeSym = isotope[0:pos].upper()
|
|
|
|
|
|
print(MassNumber,
|
|
IsotopeSym,
|
|
preacc,
|
|
inflector,
|
|
LEB_Voltage,
|
|
tandam_pot,
|
|
beam_energy,
|
|
charge,
|
|
analysisMagnet,
|
|
beamLine,
|
|
switchingMagnet
|
|
)
|
|
|
|
|
|
#print('</body>')
|
|
#print('</html>') |