-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss-formatter.py
More file actions
20 lines (18 loc) · 652 Bytes
/
css-formatter.py
File metadata and controls
20 lines (18 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
target = "input.css"
with open(target, "r", encoding="utf-8") as f:
d = f.readlines()
temp = []
temp2 = []
for i in d:
if(len(i) >= 1):
x = i.replace("\n", "").strip().casefold()
if len(x) != 0 and x[-1:] != "{" and x[-1:] != "}" and x[-1:] != "," and x[-1:] != ";":
x = x + ";"
temp.append(x)
if x[-1:] == "}":
temp2.append(sorted(temp))
temp = []
with open("output.css", "w", encoding="utf-8") as r:
for a in sorted(temp2, reverse=True):
for i in a:
print(str(i).encode("utf-8").decode("utf-8"), file=r)