else/Toolbox/linenumbers.py

13 lines
308 B
Python
Raw Normal View History

2017-03-30 22:56:12 +00:00
import sys
from voussoirkit import clipext
2017-05-07 01:30:10 +00:00
if len(sys.argv) == 1:
sys.argv.append('!i')
2017-03-30 22:56:12 +00:00
text = clipext.resolve(sys.argv[1])
lines = text.splitlines()
digits = len(str(len(lines)))
form = '{no:>0%d} | {line}' % digits
for (index, line) in enumerate(lines):
print(form.format(no=index+1, line=line))