<s> import os <EOL> import re <EOL> from BeautifulSoup import BeautifulSoup <EOL> import sys <EOL> import string <EOL> def findindex ( haystack , needle ) : <EOL> count = <NUM_LIT:0> <EOL> for line in haystack : <EOL> if needle in line : <EOL> return count <EOL> count += <NUM_LIT:1> <EOL> def getsection ( file , start , end ) : <EOL> html = '<STR_LIT>' <EOL> for i in file [ start : end ] : <EOL> html = "<STR_LIT>" % ( html , i ) <EOL> return html <EOL> def getall ( file ) : <EOL> html = '<STR_LIT>' <EOL> for i in file : <EOL> html = "<STR_LIT>" % ( html , i ) <EOL> return html <EOL> r1 = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findtr = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findtd = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findtable = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findp = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findpre = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findh2 = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findh3 = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findcode = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findcodeupper = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findmethoddetail = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> finda = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findb = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findddtop = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findinherit = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> findopenclosetags = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> spaces = re . compile ( '''<STR_LIT>''' , re . DOTALL ) <EOL> dirList = [ ] <EOL> dir = "<STR_LIT>" <EOL> for ( path , dirs , files ) in os . walk ( dir ) : <EOL> if '<STR_LIT>' not in path : <EOL> for f in files : <EOL> dirList . append ( "<STR_LIT>" % ( path , f ) ) <EOL> first = True <EOL> for fname in dirList : <EOL> file = [ ] <EOL> if fname . endswith ( '<STR_LIT>' ) and '<STR_LIT>' not in fname and '<STR_LIT>' not in fname : <EOL> for line in open ( "<STR_LIT:%s>" % ( fname ) ) : <EOL> line = line . strip ( ) . replace ( "<STR_LIT:'>" , '<STR_LIT>' ) <EOL> line = '<STR_LIT>' . join ( filter ( lambda x : x in string . printable , line ) ) <EOL> file . append ( line ) <EOL> start = findindex ( file , "<STR_LIT>" ) <EOL> consum = findindex ( file , "<STR_LIT>" ) <EOL> methsum = findindex ( file , "<STR_LIT>" ) <EOL> condet = findindex ( file , "<STR_LIT>" ) <EOL> methdet = findindex ( file , "<STR_LIT>" ) <EOL> end = findindex ( file , "<STR_LIT>" ) <EOL> np = findh2 . findall ( getall ( file ) ) [ <NUM_LIT:0> ] <EOL> np = np . split ( '<STR_LIT>' ) <EOL> namespace = r1 . sub ( '<STR_LIT>' , np [ <NUM_LIT:0> ] ) . strip ( ) <EOL> classtype = r1 . sub ( '<STR_LIT>' , np [ <NUM_LIT:1> ] ) . strip ( ) <EOL> if '<STR_LIT>' in classtype . lower ( ) : <EOL> continue <EOL> desc = findp . findall ( getall ( file ) ) [ <NUM_LIT:0> ] <EOL> name = fname . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> url = "<STR_LIT>" % ( fname . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> description = spaces . sub ( '<STR_LIT:U+0020>' , findopenclosetags . sub ( '<STR_LIT>' , desc ) . strip ( ) ) <EOL> if len ( sys . argv ) == <NUM_LIT:1> or sys . argv [ <NUM_LIT:1> ] . lower ( ) == '<STR_LIT>' : <EOL> print "<STR_LIT>" % ( name , namespace , url , description , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if sys . argv [ <NUM_LIT:1> ] . lower ( ) == '<STR_LIT>' : <EOL> print '''<STR_LIT>''' % ( name , namespace , url , description , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> for i in findinherit . findall ( getall ( file ) ) : <EOL> description = spaces . sub ( '<STR_LIT:U+0020>' , findopenclosetags . sub ( '<STR_LIT>' , findb . findall ( i ) [ <NUM_LIT:0> ] . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) ) <EOL> for j in findcodeupper . findall ( i ) [ <NUM_LIT:0> ] . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) . split ( '<STR_LIT>' ) : <EOL> synopsis = '<STR_LIT>' <EOL> methodname = r1 . sub ( '<STR_LIT>' , j ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) . strip ( ) <EOL> url = '<STR_LIT>' % ( fname . replace ( '<STR_LIT>' , '<STR_LIT>' ) , methodname ) <EOL> namespaceinherited = "<STR_LIT>" % ( namespace , name ) <EOL> if len ( sys . argv ) == <NUM_LIT:1> or sys . argv [ <NUM_LIT:1> ] . lower ( ) == '<STR_LIT>' : <EOL> print "<STR_LIT>" % ( methodname , namespaceinherited , url , description , synopsis , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if sys . argv [ <NUM_LIT:1> ] . lower ( ) == '<STR_LIT>' : <EOL> print '''<STR_LIT>''' % ( methodname , namespaceinherited , url , description , synopsis , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> for meth in findmethoddetail . findall ( "<STR_LIT>" % ( findtable . sub ( '<STR_LIT>' , getsection ( file , methdet , end ) ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) ) : <EOL> try : <EOL> methodname = r1 . sub ( '<STR_LIT>' , findh3 . findall ( meth ) [ <NUM_LIT:0> ] ) . strip ( ) <EOL> methodurl = finda . findall ( meth ) [ <NUM_LIT:0> ] <EOL> methodurl = methodurl . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> url = '<STR_LIT>' % ( fname . replace ( '<STR_LIT>' , '<STR_LIT>' ) , methodurl ) <EOL> synopsis = findopenclosetags . sub ( '<STR_LIT>' , findpre . findall ( meth ) [ <NUM_LIT:0> ] . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( "<STR_LIT:\r\n>" , '<STR_LIT>' ) . strip ( ) ) <EOL> description = spaces . sub ( '<STR_LIT:U+0020>' , findopenclosetags . sub ( '<STR_LIT>' , findddtop . findall ( meth ) [ <NUM_LIT:0> ] . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) ) <EOL> namespaceinherited = "<STR_LIT>" % ( namespace , name ) <EOL> if len ( sys . argv ) == <NUM_LIT:1> or sys . argv [ <NUM_LIT:1> ] . lower ( ) == '<STR_LIT>' : <EOL> print "<STR_LIT>" % ( methodname , namespaceinherited , url , description , synopsis , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if sys . argv [ <NUM_LIT:1> ] . lower ( ) == '<STR_LIT>' : <EOL> print '''<STR_LIT>''' % ( methodname , namespaceinherited , url , description , synopsis , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> except : <EOL> pass </s>
