CMS 3D CMS Logo

Functions | Variables

linker Namespace Reference

Functions

def filter
def findMatchingFiles
def getLink
def process
def replace

Variables

string BASE = "http://cmssdt.cern.ch/SDT/doxygen/"
list DIR = sys.argv[1]
tuple files = output.read()
list h_source_htmls = []
int i = 0
dictionary INDEX = {}
tuple output = os.popen(query)
 printOutput = False;
list py_source_htmls = []
string query = "find "

Function Documentation

def linker::filter (   s,
  w,
  k 
)

Definition at line 23 of file linker.py.

00024                  :
00025     o = s.split()
00026     if len(o) > 1:
00027         betterChoice = ""
00028         for i in range(len(o)):
00029             if re.search("[^a-zA-Z]"+w+"[^a-zA-Z]", o[i]):
00030                 if re.search(".*"+k+".*",o[i]):
00031                     return o[i]
00032                 else:
00033                     if betterChoice == "" or len(betterChoice) > o[i]:
00034                         betterChoice = o[i]
00035         return betterChoice
00036     else:
00037         if re.search("[^a-zA-Z]"+w+"[^a-zA-Z]", s):
00038             return s
00039         else:
00040             return ""
        
def linker::findMatchingFiles (   w,
  source_htmls 
)

Definition at line 15 of file linker.py.

00016                                       :
00017     ret = ""
00018     for srcFile in source_htmls:
00019         if srcFile.split("/")[-1].__str__().find(w) != -1:
00020             ret +=  " " + srcFile
00021             
00022     return ret

def linker::getLink (   word)

Definition at line 41 of file linker.py.

00042                  :
00043         
00044     if word.isdigit() or (len(word) < 5):
00045         return ""
00046     
00047     out = filter(findMatchingFiles(word, py_source_htmls),word,"")
00048     if not out or out == "":
00049         out = filter(findMatchingFiles(word, h_source_htmls),word,"")
00050         if not out or out == "":
00051             return ""
00052     return BASE+out.lstrip()

def linker::process (   filename)

Definition at line 53 of file linker.py.

00054                      :
00055     
00056     if (filename != None) and (len(filename) < 5):
00057         return
00058     
00059     fh = open(filename,'r')
00060     html = fh.read()
00061     fh.close()
00062 
00063   
00064     content = ""
00065     # find only code block
00066     soup = BeautifulSoup(html)
00067     pres = soup.findAll("pre", {"class":"fragment"})
00068     
00069     for pre in pres:
00070         if pre.contents != None:
00071             content += pre.renderContents()
00072     # END OF find only code block
00073 
00074     # remove links
00075     content = replace(r'<a\b[^>]*>(.*?)</a>','',content)
00076     
00077     content = content.replace("&#39;", "'")    
00078     content = content.replace("&quot;", '"')
00079     
00080     matches = []
00081     tmp = re.findall('[\w,\.]+_cf[i,g,f]',content)
00082     for t in tmp:
00083         matches.extend(t.split("."))
00084         
00085     matches.extend(re.findall('"\w+"',content))
00086     matches.extend(re.findall("'\w+'",content))
00087     
00088     set = {}                                  # 
00089     map(set.__setitem__, matches, [])         # removing duplicate keywords
00090     matches = set.keys()                      # 
00091     
00092     for match in matches:
00093         
00094         match = match.replace("'", "")    
00095         match = match.replace('"', "")
00096         
00097         if (INDEX.has_key(match)):
00098             href = INDEX[match]
00099         else:
00100             href = getLink(match)
00101         
00102         if (href != ""):
00103             INDEX[match] = BASE+href[href.find("CMSSW_"):]
00104             
00105             link = "<a class=\"configfileLink\" href=\""+href+"\">"+match+"</a>"
00106             regex = r"\b"+match+r"\b"
00107             html = replace(regex, link, html)
00108             
00109             ########################
00110             if printOutput:
00111                 print ">>>>>["+match+"]",
00112             ########################
00113         
00114             ########################
00115             if printOutput:
00116                 print href
00117             ########################
00118         
00119     fh = open(filename,'w')
00120     fh.write(html)
00121     fh.close()

def linker::replace (   regex,
  replacement,
  content 
)

Definition at line 10 of file linker.py.

00011                                       :
00012     p = re.compile(regex,re.IGNORECASE);
00013     c = p.sub(replacement,content)
00014     return c 


Variable Documentation

string linker::BASE = "http://cmssdt.cern.ch/SDT/doxygen/"

Definition at line 6 of file linker.py.

list linker::DIR = sys.argv[1]

Definition at line 124 of file linker.py.

tuple linker::files = output.read()

Definition at line 146 of file linker.py.

Definition at line 129 of file linker.py.

int linker::i = 0
dictionary linker::INDEX = {}

Definition at line 7 of file linker.py.

tuple linker::output = os.popen(query)

Definition at line 135 of file linker.py.

Definition at line 8 of file linker.py.

Definition at line 130 of file linker.py.

string linker::query = "find "

Definition at line 134 of file linker.py.