MCPcopy Create free account
hub / github.com/ActiveState/code / parse

Function parse

recipes/Python/125532_linecountpy/recipe-125532.py:11–25  ·  view source on GitHub ↗
(sourcefile)

Source from the content-addressed store, hash-verified

9expression = re.compile('^\s*?[/*|//|#][*]*.*?')
10
11def parse(sourcefile):
12 lcount, ccount = 0, 0
13
14 try:
15 file = open(sourcefile, 'r')
16 except IOError:
17 sys.exit(0)
18
19 for line in file.readlines():
20 lcount += 1
21 if expression.match(line):
22 ccount += 1
23
24 file.close()
25 return lcount, ccount
26
27
28def main():

Callers 4

mainFunction · 0.70
recipe-192914.pyFile · 0.50
readConfigFunction · 0.50
parseMethod · 0.50

Calls 5

openFunction · 0.50
exitMethod · 0.45
readlinesMethod · 0.45
matchMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected