9 return len(f.readlines())
12 # short description (string or None)
13 # long decsription (array of strings or None)
15 def parseDescr(lines):
17 return (None, None, False)
19 if re.match( r"!!!options!!!", lines[0] ):
25 if len(linesRest) == 0:
26 return(None,None,optStop)
27 short = linesRest[0].rstrip()
29 for l in linesRest[1:]:
31 if re.search( r"\S", ll ):
36 return (short, long, optStop)
38 # RETURNS a tree with nodes like: (
40 # short description (string or None)
41 # long decsription (array of strings or None)
43 # list of subdirs (child nodes like this one)
49 with open( path+'/DESCRIPTION' ) as f:
50 short, long, optStop = parseDescr( f.readlines() )
55 for fname in os.listdir(path):
56 if fname != '.git' and os.path.isdir(path+'/'+fname):
57 subdir = parseDir(path+'/'+fname)
60 (dummy0, dummy1, dummy2, subLines, dummy4) = subdir
63 if os.path.isfile(path+'/'+fname) \
64 and not os.path.islink(path+'/'+fname):
65 cntLines += countLines(path+'/'+fname)
67 return path, short, long, cntLines, dirs
70 ### ##### PRINT AS TEXT
72 ### def printTextSub(path,indent,withLongDesc):
73 ### short, long, dirs, loc = parseDir(path)
75 ### p = re.sub(r"^\./", '', path)
76 ### print '%s%s -- ' % (indent, p)
78 ### p = re.sub(r"^\./", '', path)
79 ### print '%s%s -- %s' % (indent, p, short)
84 ### print '%s%s' % (indent+' ',line)
87 ### printTextSub(path+'/'+dir, indent+' ', withLongDesc)
89 ### def printText(path,withLongDesc):
90 ### printTextSub(path,'',withLongDesc)
92 ### def printTextWoMain(path,withLongDesc):
93 ### short, long, dirs, loc = parseDir(path)
95 ### printTextSub(path+'/'+dir, '', withLongDesc)
98 ##### PRINT AS a sort of CSV delimited by '|'
100 # indent is a number (0..)
101 def printTabSub(tree,indent):
102 path, short, long, loc, subdirs = tree
103 p = re.sub(r"^\./", '', path)
104 m = re.search(r"/([^/]*$)", p)
105 if m != None: p = m.groups()[0]
107 print '%s%s|%d|' % (" "*indent, p, loc)
109 print '%s%s|%d|%s' % (" "*indent, p, loc, short)
111 printTabSub(dir, indent+1)
116 def printTabWoMain(tree):
117 path, short, long, loc, dirs = tree