-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetclasses.py
52 lines (41 loc) · 1.33 KB
/
getclasses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import re
def getClassesInHTML(pathHTML):
openFileHTML = open(os.path.expanduser(pathHTML), "r")
fileHTML = openFileHTML.read()
openFileHTML.close()
regexJS = 'className={(.+?)}'
allClassesHTML = re.findall(regexJS, fileHTML)
# Limpando as classes
listClasses = []
for i in allClassesHTML:
# Retirando o espaço do final da palavra e quebro a classe
splitList = i.rstrip(" ").split(" ")
listClasses += splitList
# Remover classes duplicadas
listClasses = list(dict.fromkeys(listClasses))
# Remover row, scroll, scroll_green, others
# Apagando as classes que nao sao bem vindas com os prefixos ou inteiras
classesRemove = []
for removeItem in classesRemove:
for classItem in listClasses:
if removeItem in classItem:
listClasses.remove(removeItem)
return listClasses
def getClassesInCSS(pathCSS):
openFileCSS = open(os.path.expanduser(pathCSS), "r")
fileCSS = openFileCSS.read()
openFileCSS.close()
#regexCSS = '\.(.+) \{'
regexCSS = "(.+?)\{"
allClassesCSS = re.findall(regexCSS, fileCSS)
# Limpando as classes CSS
listCSS = []
for i in allClassesCSS:
# Retirando o espaço do final da palavra e quebro a classe
splitList = i.lstrip("\t").rstrip(" ")
if splitList.startswith("."):
listCSS.append(splitList)
# Remover css duplicadas
listCSS = list(dict.fromkeys(listCSS))
return listCSS