util.py 973 B

123456789101112131415161718192021222324252627282930313233
  1. def uni_to_hex_hash(uni):
  2. return ' '.join(map(lambda x: '#' + hex(x)[2:], uni))
  3. def uni_to_hex_filename(uni):
  4. return '-'.join(map(lambda x: hex(x)[2:], uni))
  5. def get_color_palettes(emoji, manifest):
  6. """Get the source and destination colour palettes for the given emoji."""
  7. if 'color' not in emoji:
  8. return None
  9. cmap = manifest.colormaps[emoji['color']]
  10. pfrom = manifest.palettes[cmap['src']]
  11. pto = manifest.palettes[cmap['dst']]
  12. return (pfrom, pto)
  13. """Mapping of the license type, keyed by export format."""
  14. _license_format_map = {
  15. 'svg': 'svg',
  16. 'png': 'exif',
  17. 'pngc': 'exif',
  18. }
  19. def get_license_type_for_format(f):
  20. """Gets the license type for a given export format, or None if not set."""
  21. return _license_format_map.get(f.split('-')[0])
  22. def get_formats_for_license_type(t):
  23. """Get the export formats for a given license type."""
  24. return tuple(f for f, ft in _license_format_map.items() if ft == t)