Skip to content

Commit d9729d8

Browse files
author
jckdm
committed
bug fix; added helper fn to add full filepath to css files for revising
1 parent 1840c76 commit d9729d8

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# CSS parser
22

3-
![Terminal screenshot demonstrating user experience with parsing software](https://github.com/jckdm/CSS-parser/blob/master/demo.png?raw=true)
3+
![Terminal screenshot demonstrating user experience with parsing software](https://github.com/jckdm/CSS-parser/blob/master/terminal-demo.png?raw=true)
4+
5+
![Screenshot of code editor showing result of using parsing software](https://github.com/jckdm/CSS-parser/blob/master/result.png?raw=true)
46

57
0. prompts user for .css file(s)
68
1. prompts user for .html file(s)

demo.png

-343 KB
Binary file not shown.

helper.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,13 @@ def full(l):
8181
if '{' in l and '}' in l:
8282
return True
8383
return False
84+
85+
# update .css files to have full filepaths
86+
def updateFilePaths(filenames, d):
87+
for html, css in d.items():
88+
for cssFile in filenames:
89+
# filename == file
90+
if cssFile.split('/')[-1] == d[html]:
91+
# update with full filepath
92+
d[html] = cssFile
93+
return d

main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from parser import parse_css, parse_html
1+
from parser import parse_css, parse_html
22
from cleaner import clean
33
from definer import define
4-
from sys import exit
4+
from helper import updateFilePaths
5+
from sys import exit
56

67
def main():
78
# parse the files
@@ -71,6 +72,9 @@ def main():
7172
print(o)
7273
results += '\n' + o
7374

75+
# update dict with full css filepaths
76+
fullFilePairs = updateFilePaths(fileNames, h[1])
77+
7478
# predefined in case file is already clean
7579
q, qq = 'no', 'no'
7680
if not final:
@@ -90,7 +94,7 @@ def main():
9094
# may i define?
9195
qq = input('May I add definitions for undefined rules? (yes/no): ')
9296
if qq.lower() in ('yes', 'y'):
93-
define(undefined, h[1])
97+
define(undefined, fullFilePairs)
9498

9599
# no cleaning, but maybe a humble .txt file?
96100
if q.lower() in ('no', 'n') and qq.lower() in ('no', 'n'):

result.png

151 KB
Loading

terminal-demo.png

355 KB
Loading

0 commit comments

Comments
 (0)