)
-def _colorize(what, colour, with_colours, attrs=("bold",)):
+def _colourize(what, colour, with_colours, attrs=("bold",)):
return colored(what, colour, attrs=attrs) if with_colours else what
),
LENINDEF_PP_CHAR if pp.expl_lenindef else " ",
)
- cols.append(_colorize(col, "red", with_colours, ()))
+ cols.append(_colourize(col, "red", with_colours, ()))
col = "[%d,%d,%4d]%s" % (
pp.tlen,
pp.llen,
pp.vlen,
LENINDEF_PP_CHAR if pp.lenindef else " "
)
- col = _colorize(col, "green", with_colours, ())
+ col = _colourize(col, "green", with_colours, ())
cols.append(col)
if len(pp.decode_path) > 0:
cols.append(" ." * (len(pp.decode_path)))
ent = pp.decode_path[-1]
if isinstance(ent, DecodePathDefBy):
- cols.append(_colorize("DEFINED BY", "red", with_colours, ("reverse",)))
+ cols.append(_colourize("DEFINED BY", "red", with_colours, ("reverse",)))
value = str(ent.defined_by)
if (
oids is not None and
ObjectIdentifier.asn1_type_name and
value in oids
):
- cols.append(_colorize("%s:" % oids[value], "green", with_colours))
+ cols.append(_colourize("%s:" % oids[value], "green", with_colours))
else:
- cols.append(_colorize("%s:" % value, "white", with_colours, ("reverse",)))
+ cols.append(_colourize("%s:" % value, "white", with_colours, ("reverse",)))
else:
- cols.append(_colorize("%s:" % ent, "yellow", with_colours, ("reverse",)))
+ cols.append(_colourize("%s:" % ent, "yellow", with_colours, ("reverse",)))
if pp.expl is not None:
klass, _, num = pp.expl
col = "[%s%d] EXPLICIT" % (TagClassReprs[klass], num)
- cols.append(_colorize(col, "blue", with_colours))
+ cols.append(_colourize(col, "blue", with_colours))
if pp.impl is not None:
klass, _, num = pp.impl
col = "[%s%d]" % (TagClassReprs[klass], num)
- cols.append(_colorize(col, "blue", with_colours))
+ cols.append(_colourize(col, "blue", with_colours))
if pp.asn1_type_name.replace(" ", "") != pp.obj_name.upper():
- cols.append(_colorize(pp.obj_name, "magenta", with_colours))
+ cols.append(_colourize(pp.obj_name, "magenta", with_colours))
if pp.bered:
- cols.append(_colorize("BER", "red", with_colours))
- cols.append(_colorize(pp.asn1_type_name, "cyan", with_colours))
+ cols.append(_colourize("BER", "red", with_colours))
+ cols.append(_colourize(pp.asn1_type_name, "cyan", with_colours))
if pp.value is not None:
value = pp.value
- cols.append(_colorize(value, "white", with_colours, ("reverse",)))
+ cols.append(_colourize(value, "white", with_colours, ("reverse",)))
if (
oids is not None and
pp.asn1_type_name == ObjectIdentifier.asn1_type_name and
value in oids
):
- cols.append(_colorize("(%s)" % oids[value], "green", with_colours))
+ cols.append(_colourize("(%s)" % oids[value], "green", with_colours))
if with_blob:
if isinstance(pp.blob, binary_type):
cols.append(hexenc(pp.blob))
elif isinstance(pp.blob, tuple):
cols.append(", ".join(pp.blob))
if pp.optional:
- cols.append(_colorize("OPTIONAL", "red", with_colours))
+ cols.append(_colourize("OPTIONAL", "red", with_colours))
if pp.default:
- cols.append(_colorize("DEFAULT", "red", with_colours))
+ cols.append(_colourize("DEFAULT", "red", with_colours))
return " ".join(cols)