Skip to content

Commit 3fc08b9

Browse files
Jack AdamJack Adam
authored andcommitted
parser now continues printing tail of file after finished cleaning. new readme.
1 parent 2ccd792 commit 3fc08b9

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

README.md

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
# CSS parser
22

3-
``` bash
4-
$ python3 main.py
5-
Do you have more than 1 .css file? (yes/no):
6-
Path to directory / Path to .css file:
7-
Read file1.css
8-
Read file2.css
9-
Do you have more than 1 .html file? (yes/no):
10-
Path to directory / Path to .html file:
11-
Read file1.html
12-
13-
Identified [ ] unique classes and [ ] unique IDs.
14-
15-
Undefined class: .[ ] : file1.html
16-
Undefined ID: #[ ] : file1.html
17-
18-
Unused class: .[ ] : file1.css, line 0, 00
19-
Unused ID: #[ ] : file2.css, line 000, 0
20-
21-
May I remove these unused rules and output new .css files? (yes/no):
22-
Wrote file1-clean.css
23-
Wrote file2-clean.css
24-
```
3+
![Terminal screenshot demonstrating user experience with parsing software](https://github.com/jckdm/CSS-parser/blob/master/demo.png?raw=true)
254

265
0. prompts user for path to/filename of singular or multiple .css file(s)
276
1. prompts user for path to/filename of singular or multiple .html file(s)
@@ -32,5 +11,3 @@ Wrote file2-clean.css
3211
TODO:
3312

3413
0. thoroughly edgecase re-writing stage
35-
1. something is wrong with cleaning multiple files
36-
2. fix comments disappearing in media queries?

cleaner.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def clean(u, fn, fc):
2626

2727
# open new file to write
2828
with open(new, 'w') as newF:
29-
soloFlag, mediaFlag, multiFlag, newline = False, False, False, False
29+
soloFlag, multiFlag, newline = False, False, False
3030
for num, line in enumerate(f, 1):
3131
# if haven't yet removed all items
3232
if index < numItems[i]:
@@ -52,9 +52,6 @@ def clean(u, fn, fc):
5252
line = ' '.join(l) + '\n'
5353
index += 1
5454
multiFlag = False
55-
# if media query opening
56-
if line[:6] == '@media':
57-
mediaFlag = True
5855
# if one rule
5956
if soloFlag:
6057
for c in line:
@@ -67,7 +64,7 @@ def clean(u, fn, fc):
6764
if not newline or line != '\n':
6865
newF.write(line)
6966
newline = True if line == '\n' else False
70-
# bandage, add closing brace to media query
71-
if mediaFlag:
72-
newF.write('}')
67+
# if all items removed, just print rest of file
68+
else:
69+
newF.write(line)
7370
newF.close()

demo.png

540 KB
Loading

0 commit comments

Comments
 (0)