Skip to content

Instantly share code, notes, and snippets.

@Lykaksparsz
Created January 15, 2018 18:51
Show Gist options
  • Save Lykaksparsz/5be9438b8fc86b74a8e07b6a78fb716a to your computer and use it in GitHub Desktop.
Save Lykaksparsz/5be9438b8fc86b74a8e07b6a78fb716a to your computer and use it in GitHub Desktop.
TL;DR Precentage Command Line.
# TLDR - The command line That Calculates If it's Too long or not.
# MADE BY LYKAKSPARS WITH <3
import sys
import math
TLlimits = 600
def getlength(files):
results = 0
with open(files, "r") as f:
data = f.read()
for some in data:
words = some.split()
results = int(results+len(words))
return results
def main():
global TLlimits
args = sys.argv[1:]
tfile = args[0]
try:
modes = args[1]
except IndexError:
modes = None
lengths = getlength(tfile)
res = math.floor(lengths/TLlimits*80)
res = str(res)
if modes == "n":
print(res+"%")
else:
print(res+"% TL;DR Percent.")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment