mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
add pre-commit; add line-count functions & badge
This commit is contained in:
34
develop.py
Normal file
34
develop.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""Devloper functions."""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def count_lines(directory):
|
||||
"""Count lines of code.
|
||||
|
||||
Arguments:
|
||||
directory {str} -- Path to count
|
||||
|
||||
Returns:
|
||||
{int} -- Line count
|
||||
"""
|
||||
lines = 0
|
||||
excluded = ("\n",)
|
||||
for thing in os.listdir(directory):
|
||||
thing = os.path.join(directory, thing)
|
||||
if os.path.isfile(thing):
|
||||
if thing.endswith(".py"):
|
||||
with open(thing, "r") as f:
|
||||
readlines = [
|
||||
line
|
||||
for line in f.readlines()
|
||||
if line not in excluded and not line.startswith("#")
|
||||
]
|
||||
lines += len(readlines)
|
||||
|
||||
for thing in os.listdir(directory):
|
||||
thing = os.path.join(directory, thing)
|
||||
if os.path.isdir(thing):
|
||||
lines += count_lines(thing)
|
||||
|
||||
return lines
|
Reference in New Issue
Block a user