Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
LOGGER.error('Prerequisite environment variable for upload missing, cannot continue.')
raise SystemExit(1)
upload_command = ('twine upload dist/* '
f'-u {os.environ.get("PYPI_UPLOAD_USERNAME")} '
f'-p {os.environ.get("PYPI_UPLOAD_PASSWORD")} '
'--skip-existing '
f'--repository-url {os.environ.get("PYPI_URL")}')
LOGGER.info('Trying to upload built artifact...')
success = execute_command(upload_command)
if success:
LOGGER.info('%s Successfully uploaded artifact! %s',
emojize(':white_heavy_check_mark:'),
emojize(':thumbs_up:'))
else:
LOGGER.error('%s Errors found in uploading artifact! %s',
emojize(':cross_mark:'),
emojize(':crying_face:'))
raise SystemExit(0 if success else 1)
def _calc_emoji_offset(to_calc) -> int:
# Get all emoji in text.
emoticons = emoji.get_emoji_regexp().finditer(to_calc)
# Check the utf16 length of the emoji to determine the offset it caused.
# Normal, 1 character emoji don't affect; hence sub 1.
# special, eg with two emoji characters (eg face, and skin col) will have length 2, so by subbing one we
# know we'll get one extra offset,
return sum(len(e.group(0).encode('utf-16-le')) // 2 - 1 for e in emoticons)
def test_in_should_work_when_looking_for_emoji(self):
emoji = Emoji()
self.assertTrue('relaxed' in emoji)
def test_should_also_store_the_unicode_of_an_emoji(self):
self.assertEqual(len(Emoji._unicode_characters), TOTAL_EMOJIS_UNICODE)
def test_should_replace_hex_encoded_unicode(self):
self.assertEqual(
Emoji.replace_html_entities(self.HEX_KISS),
self.UNICODE_KISS
)
def test_emoji_is_singleton(self):
e = Emoji()
e2 = Emoji()
self.assertEqual(id(e), id(e2))
def test_convert_instance_to_dict_and_act_like_dict(self):
e = Emoji()
as_dict = dict(e)
self.assertEqual(len(as_dict), TOTAL_EMOJIS)
self.assertEqual(as_dict['+1'], '/static/emoji/img/%2B1.png')
with self.assertRaises(KeyError):
as_dict['nonexistant']
def test_emoji_is_singleton(self):
e = Emoji()
e2 = Emoji()
self.assertEqual(id(e), id(e2))
def test_emojis_that_were_showing_wrong(self):
# These emojis were showing other images than the ones intended.
emoji = '🍆'
self.assertEqual(Emoji.name_for(emoji), 'eggplant')
emoji = '😘'
self.assertEqual(Emoji.name_for(emoji), 'kissing_heart')
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