/usr/lib/python3/dist-packages/clint/eng.py is in python3-clint 0.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | # -*- coding: utf-8 -*-
"""
clint.eng
~~~~~~~~~
This module provides English language string helpers.
"""
from __future__ import print_function
MORON_MODE = False
COMMA = ','
CONJUNCTION = 'and'
SPACE = ' '
try:
unicode
except NameError:
unicode = str
def join(l, conj=CONJUNCTION, im_a_moron=MORON_MODE, separator=COMMA):
"""Joins lists of words. Oxford comma and all."""
collector = []
left = len(l)
separator = separator + SPACE
conj = conj + SPACE
for _l in l[:]:
left += -1
collector.append(_l)
if left == 1:
if len(l) == 2 or im_a_moron:
collector.append(SPACE)
else:
collector.append(separator)
collector.append(conj)
elif left is not 0:
collector.append(separator)
return unicode(str().join(collector))
if __name__ == '__main__':
print(join(['blue', 'red', 'yellow'], conj='or', im_a_moron=True))
print(join(['blue', 'red', 'yellow'], conj='or'))
print(join(['blue', 'red'], conj='or'))
print(join(['blue', 'red'], conj='and'))
print(join(['blue'], conj='and'))
print(join(['blue', 'red', 'yellow', 'green', 'ello'], conj='and'))
|