Last active
August 29, 2015 14:06
-
-
Save gamesbook/94b1c645f05f534b15ea to your computer and use it in GitHub Desktop.
Extract/find glyphicon name and hex code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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