| 1 |
import os |
| 2 |
import sys |
| 3 |
import linecache |
| 4 |
|
| 5 |
PATH = sys.argv[1] |
| 6 |
os.chdir(PATH) |
| 7 |
|
| 8 |
with open('fontinfo.plist') as f: |
| 9 |
if '<key>guidelines</key>' in f.read(): |
| 10 |
sys.exit() |
| 11 |
else: |
| 12 |
file_read = open('fontinfo.plist', "r") |
| 13 |
num_lines = sum(1 for line in open('fontinfo.plist')) |
| 14 |
BreakLine = num_lines - 2 |
| 15 |
|
| 16 |
section_2 = " <key>guidelines</key>\n" |
| 17 |
|
| 18 |
section_1 = "" |
| 19 |
l = 0 |
| 20 |
while l < BreakLine: |
| 21 |
section_1 = section_1 + linecache.getline('fontinfo.plist', l) |
| 22 |
l += 1 |
| 23 |
|
| 24 |
section_3 = "" |
| 25 |
l = BreakLine |
| 26 |
while True: |
| 27 |
section_3 = section_3 + linecache.getline('fontinfo.plist', l) |
| 28 |
l += 1 |
| 29 |
if (linecache.getline('fontinfo.plist', l) == ""): |
| 30 |
break |
| 31 |
|
| 32 |
data = section_1 + section_2 + section_3 |
| 33 |
fontinfo = open("fontinfo.plist" , "w") |
| 34 |
fontinfo.write(data) |
| 35 |
fontinfo.close() |