Created
June 30, 2017 09:06
-
-
Save Mark24Code/d919559feffe5074541250942a411d0c to your computer and use it in GitHub Desktop.
px2rem.py
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
import re | |
newlines = [] | |
with open('ff','r',encoding='UTF-8') as f: | |
lines = f.readlines() | |
for line in lines: | |
m = re.search(r'.+: (\d.px).+',line) | |
newline = '' | |
if m: | |
print(m.group(0)) | |
print(m.group(1)) | |
pxword = m.group(1) | |
break_lines_arr = line.split(pxword) | |
new_pxword = 'rem({})'.format(pxword) | |
break_lines_arr.insert(1, new_pxword) | |
newline = ''.join(break_lines_arr) | |
newlines.append( newline if m else line) | |
nf = open('new_scss.scss','w') | |
nf.writelines(newlines) | |
nf.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment