本文整理汇总了Python中LongBow.countLines方法的典型用法代码示例。如果您正苦于以下问题:Python LongBow.countLines方法的具体用法?Python LongBow.countLines怎么用?Python LongBow.countLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LongBow
的用法示例。
在下文中一共展示了LongBow.countLines方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: csvSummary
# 需要导入模块: import LongBow [as 别名]
# 或者: from LongBow import countLines [as 别名]
def csvSummary(distribution, documentation):
formatString ="documentation,%s,%d,%d,%.2f%%"
for entry in documentation:
badLines = len(documentation[entry])
totalLines = LongBow.countLines(entry)
score = float(totalLines - badLines) / float(totalLines) * 100.0
LongBow.scorePrinter(distribution, score, formatString % (entry, totalLines, badLines, score))
return
示例2: textualSummary
# 需要导入模块: import LongBow [as 别名]
# 或者: from LongBow import countLines [as 别名]
def textualSummary(distribution, documentation):
maxWidth = 0
for entry in documentation:
if len(entry) > maxWidth:
maxWidth = len(entry)
formatString ="%-" + str(maxWidth) + "s %8d %8d %.2f%%"
for entry in documentation:
badLines = len(documentation[entry])
totalLines = LongBow.countLines(entry)
score = float(totalLines - badLines) / float(totalLines) * 100.0
LongBow.scorePrinter(distribution, score, formatString % (entry, totalLines, badLines, score))
return
示例3: textualAverage
# 需要导入模块: import LongBow [as 别名]
# 或者: from LongBow import countLines [as 别名]
def textualAverage(distribution, documentation, format):
sum = 0.0
for entry in documentation:
badLines = len(documentation[entry])
totalLines = LongBow.countLines(entry)
score = float(totalLines - badLines) / float(totalLines) * 100.0
sum = sum + score
if len(documentation) == 0:
averageScore = 100.0
else:
averageScore = sum / float(len(documentation))
LongBow.scorePrinter(distribution, averageScore, format % averageScore)
示例4: main
# 需要导入模块: import LongBow [as 别名]
# 或者: from LongBow import countLines [as 别名]
def main():
desc = '''
Report on number of lines of one or more C source or header files.
Input is either from a list of files supplied as command line parameters,
or as a list of newline separated file names read from standard input.
Output is a plain text (default) or a CSV file reporting
the file name and the total number of lines in the file.
Usage:
% longbow-size-report *.[ch]
Report the number of lines in .c and .h files specified as command line parameters.
% longbow-size-report -
Read the lists of files from standard input, one file per line.
$ longbow-size-report parc_JSON.c
parc_JSON.c 239
$
$
$ echo parc_JSON.c | longbow-size-report -o csv -
parc_JSON.c,239
$
'''
parser = argparse.ArgumentParser(prog='longbow-size-report', formatter_class=argparse.RawDescriptionHelpFormatter, description=desc)
parser.add_argument('-', '--stdin', default=False, action="store_true", required=False, help="read the list of files from standard input.")
parser.add_argument('-s', '--summary', default=False, action="store_true", required=False, help="display the number of lines for each file")
parser.add_argument('-t', '--total', default=False, action="store_true", required=False, help="display the total number of lines for all files")
parser.add_argument('-o', '--output', default="text", action="store", required=False, type=str, help="the output format: \"text\" or \"csv\"")
parser.add_argument("files", help="Files to check", nargs="*")
args = parser.parse_args()
if args.summary == False and args.total == False:
args.summary = True
targets = []
if args.stdin:
for line in sys.stdin:
t = line.strip()
if len(t) > 0:
targets.append(t)
else:
targets = args.files
if len(targets) == 0:
parser.print_usage()
sys.exit(1)
files = map(lambda fileName: [ fileName, LongBow.countLines(fileName)], targets)
total = sum(map(lambda element: element[1], files))
if args.summary:
if args.output == "text":
textSummary(files)
else:
csvSummary(files)
if args.total:
if args.output == "text":
textTotal(files)
else:
csvTotal(files)