Skip to content

Instantly share code, notes, and snippets.

@gamesbook
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamesbook/94b1c645f05f534b15ea to your computer and use it in GitHub Desktop.
Save gamesbook/94b1c645f05f534b15ea to your computer and use it in GitHub Desktop.
Extract/find glyphicon name and hex code
"""
Uses the glyphicons.css file from http://glyphicons.com
To use:
python hex_from_glyphicons.py name
or:
python hex_from_glyphicons.py -all
"""
import sys
def get_icon_hex(name):
f = open('glyphicons.css', 'r')
for l in f:
x = l # icons appear in last line of CSS file
icons = x.split('.glyphicons')
found = False
for icon in icons:
if 'content:' in icon and (name in icon or name == '-all'):
ele = icon.split(':')
print '%s , %s' % (ele[0].strip('.'), ele[2].strip('}'))
found = True
if not found:
print '%s not found!' % name
try:
name = sys.argv[1:][0]
if name:
get_icon_hex(name)
except:
print 'Supply icon name after program name (-all for all)!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment