Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
threshold_w_nonp = threshold
print_line = ''
if first_last:
print_line += ' '
for i in range(threshold_w_nonp):
if i
def color_transition(old_type, new_type):
new_color = termcolor.colored("", None, "on_red" if new_type ==
"-" else "on_green" if new_type == "+" else None)
return "{}{}".format(termcolor.RESET, new_color[:-len(termcolor.RESET)])
fmt_str = '\001' + fmt_str + '\002'
fmt_str += '%s'
if color is not None:
text = fmt_str % (termcolor.COLORS[color], text)
if on_color is not None:
text = fmt_str % (termcolor.HIGHLIGHTS[on_color], text)
if attrs is not None:
for attr in attrs:
text = fmt_str % (termcolor.ATTRIBUTES[attr], text)
if rlsafe:
text += '\001' + termcolor.RESET + '\002'
else:
text += termcolor.RESET
return text
assert isinstance(filename, pathlib.Path)
# Remember filename for future references (to show errors)
self.filename = filename
# Make an empty dict for configuration data
self.data = {}
# Set some predefined values
# TODO Replace w/ `enum`
class dummy:
pass
self.color = dummy
setattr(self.color, 'normal', '\x1b[38m')
setattr(self.color, 'normal_bg', '\x1b[48m')
setattr(self.color, 'reset', termcolor.RESET)
# NOTE Konsole terminal from KDE supports itallic font style
termcolor.ATTRIBUTES['itallic'] = 3
if not filename.exists():
return
# Read the file line by line, and collect keys and values into an internal dict
# TODO Use configparser
with filename.open() as ifs:
for l in ifs.readlines():
# Strip possible comment lines
line_str = l.strip()
if not line_str or line_str.startswith('#'):
continue
# Split by first '=' char