Skip to content

Instantly share code, notes, and snippets.

@micahjlucas
Last active August 29, 2015 14:08
Show Gist options
  • Save micahjlucas/e877ade5761c98d6e9b7 to your computer and use it in GitHub Desktop.
Save micahjlucas/e877ade5761c98d6e9b7 to your computer and use it in GitHub Desktop.
Converts .CSS file from FontCustom to Usable Enum list for AndroidIconify
__author__ = 'micahjlucas@gmail.com'
'''
Purpose: Converts generated CSS file (fontcustom.css) from FontCustom
to usable Enum list for Android-Iconify
Input: fontcustom.css
Output: fontcustom-output.txt
Notes: All file operations are done on /Desktop
'''
import os
sDesktop = '~/Desktop/'
sInputFileName = 'fontcustom.css'
sOutputFileName = 'fontcustom-output.txt'
def clean(sDirty):
lines = iter(sDirty.splitlines())
cleaning = ''
for line in lines:
if '\\' in line:
line = line.replace('.icon-', 'fa_') \
.replace(':before { content: "\\', '(\'\\u') \
.replace('\"; }', '\'),\n')
## used exclusively for storymaker formatting
#.replace('-', '_') \
#.replace('_48px', '') \
#.replace('_64px', '') \
#.replace('_72px', '')
cleaning += line
#replace bottom line's last two characters (,/n) with colon
return cleaning[:-2] + ';'
fInput = open(os.path.expanduser(sDesktop + sInputFileName), 'r')
sInput = fInput.read()
fInput.close()
fOutput = open(os.path.expanduser(sDesktop + sOutputFileName), 'w')
sClean = clean(sInput)
fOutput.write(sClean)
fOutput.close()
print("File fontcustom-output.txt written to Desktop")
@micahjlucas
Copy link
Author

Converts the generated CSS file (fontcustom.css) from FontCustom to a usable Enum list (fontcustom-output.txt) for Android-Iconify. All files are read/written on the Desktop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment