in uberpoet/commandlineutil.py [0:0]
def count_loc(code_path):
"""Returns the number of lines of code in `code_path` using cloc. If cloc is not
on your system or there is an error, then it returns -1"""
try:
logging.info('Counting lines of code in %s', code_path)
raw_json_out = subprocess.check_output(['cloc', '--quiet', '--json', code_path])
except OSError:
logging.warning("You do not have cloc installed, skipping line counting.")
return -1
json_out = json.loads(raw_json_out)
swift_loc = json_out.get('Swift', {}).get('code', 0)
if not swift_loc:
logging.error('Unexpected cloc output "%s"', raw_json_out)
raise ValueError('cloc did not give a correct value')
return swift_loc