Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
width = 20
# Mix of colors and emoji with a color fill
lyr_color_pairs = [(poly, ':+1:'), (lines, 'blue'), (points, 'red')]
actual = gj2ascii.style_multiple(
lyr_color_pairs, fill='yellow', width=width, bbox=bbox)
assert emoji.unicode_codes.EMOJI_ALIAS_UNICODE[':+1:'] in actual
assert '\x1b[34m\x1b[44m' in actual # blue
assert '\x1b[31m\x1b[41m' in actual # red
assert '\x1b[33m\x1b[43m' in actual # yellow
# Same as above but single character fill
lyr_color_pairs = [(poly, ':+1:'), (lines, 'blue'), (points, 'red')]
actual = gj2ascii.style_multiple(
lyr_color_pairs, fill='.', width=width, bbox=bbox)
assert emoji.unicode_codes.EMOJI_ALIAS_UNICODE[':+1:'] in actual
assert '\x1b[34m\x1b[44m' in actual # blue
assert '\x1b[31m\x1b[41m' in actual # red
assert '.' in actual
# Same as above but emoji fill
lyr_color_pairs = [(poly, ':+1:'), (lines, 'blue'), (points, 'red')]
actual = gj2ascii.style_multiple(
lyr_color_pairs, fill=':water_wave:', width=width, bbox=bbox)
assert emoji.unicode_codes.EMOJI_ALIAS_UNICODE[':+1:'] in actual
assert '\x1b[34m\x1b[44m' in actual # blue
assert '\x1b[31m\x1b[41m' in actual # red
assert emoji.unicode_codes.EMOJI_ALIAS_UNICODE[':water_wave:'] in actual
def test_with_emoji():
result = CliRunner().invoke(cli.main, [
POLY_FILE,
LINE_FILE,
'-c', ':water_wave:',
'-c', ':+1:'
])
assert result.exit_code is 0
for c in (':water_wave:', ':+1:'):
ucode = emoji.unicode_codes.EMOJI_ALIAS_UNICODE[c]
assert ucode in result.output
def replace(match):
mg = match.group(1).replace(delimiters[0], _DEFAULT_DELIMITER).replace(delimiters[1], _DEFAULT_DELIMITER)
if use_aliases:
return unicode_codes.EMOJI_ALIAS_UNICODE.get(mg, mg)
else:
return unicode_codes.EMOJI_UNICODE.get(mg, mg)
def emoji(data):
if not data.startswith(':'):
data = ':' + data
if not data.endswith(':'):
data += ':'
if data in EMOJI_ALIAS_UNICODE.values():
return data
if data not in EMOJI_ALIAS_UNICODE.keys():
raise ValueError(u'Unknown emoji {}'.format(data))
return EMOJI_ALIAS_UNICODE[data]
def emoji(data):
if not data.startswith(':'):
data = ':' + data
if not data.endswith(':'):
data += ':'
if data in EMOJI_ALIAS_UNICODE.values():
return data
if data not in EMOJI_ALIAS_UNICODE.keys():
raise ValueError(u'Unknown emoji {}'.format(data))
return EMOJI_ALIAS_UNICODE[data]