This is a python script that surveys the $scohtm/index.html file and pulls out the recognized task names. It is probably over-written, but was really an early attempt at writing a python code that uses functions to slice and recognize substrings in lines of text. Hence, I show a sample below on a portion of my index.html file, and then I show the complete python code. The output values: code_name and code_type can be directed to a file, which in turn might be fed to a shell script for further processing. For intsance, one of the prime motivations was writing a script that would insure that that all of the python codes present in my $scohtm listing do, in fact, have executables present on the machine being used. With the output from scocodes1.py I can easily tabulae my python codes, and then build/run a script to insure that they will run.
% scocodes1.py T2 Name Source 2mass_00.py python 2mass02 bash boxpix otw calstats.py python XYP lmgf % cat T2
Name | Source | Task (Link) | Extra Comments |
2mass_00.py | python | Process a 2MASS catalog. | Creates a cdfp file. |
2mass02 | bash | Query 2MASS PSC | Output to 2mass.cat. |
boxpix | otw | Write image pixels in a box | O2SO |
calstats.py | python | Compute simple statistics. | O2SO |
XYP | lmgf | Interactively plot XY data. | Uses ASCII tables for input |
Notice that this code has not been refined. I must have white-space around the code names in order for them to be properly recognized. For example, the first line below will work properly, but the second will NOT:
#!/usr/bin/python def line_look_00(words): nn = len(words) return nn def line_look_trSTART(line): start = line.find('Some more advanced versions of this code will be developed to help maintain my code table(s), but the basics are here.') return start def line_look_trEND(line): start = line.find(' ') return start def getit_codename(line): words = line.split(' ') mytask = words[2] return mytask # Read and use a scocodes html file (Table) of codes # Setup to read the name of the input file from sys import argv script_name, scocodefile = argv # Read the ENTIRE file into lines # Open the files for read-only fall = open(scocodefile,'r') lines = fall.readlines() fall.close() nlines = len(lines) # scan each line and do things ii = 0 trs=[] tre=[] for line in lines: ii=ii+1 words = line.split() # Use a function to count number of words number_of_words = line_look_00(words) # count the "" occurences numtr = line_look_trSTART(line) trs.append(numtr) numte = line_look_trEND(line) tre.append(numte) ############################################################ # loop through the trs,tre arrays to see how many # sets of and were present ii = 0 while True: if ii < nlines: numostart = trs[ii] else: break ii=ii+1 ############################################################ nstarts = 0 startline=[] ii = 0 while True: if ii < nlines-5: if (trs[ii]==0) and (tre[ii+5]==0): nstarts=nstarts+1 startline.append(ii) else: break ii=ii+1 ii = 0 while True: if ii < nstarts: iw = startline[ii] + 1 task_name = getit_codename(lines[iw]) task_type = getit_codename(lines[iw+1]) print "%s %s" % (task_name,task_type) else: break ii=ii+1