-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwext.py
More file actions
66 lines (61 loc) · 2.13 KB
/
wext.py
File metadata and controls
66 lines (61 loc) · 2.13 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python3.6
# -*- coding: utf-8 -*-
from os import sep
from folderCls import Folder
import loggerFct as log
pathRefCss = 'C:\\wamp64\\www\\site-dp\\library-css\\'
pathRefJs = 'C:\\wamp64\\www\\site-dp\\library-js\\'
PathExt = 'C:\\Users\\deborah.powers\\Desktop\\webext\\'
wext =( 'all-clean-article', 'all-md-perso', 'rgaa vb' )
# récupérer les fichiers css et js
folderRefCss = Folder (pathRefCss)
folderRefCss.get ('.css')
folderRefJs = Folder (pathRefJs)
folderRefJs.get ('.js')
folderRefJs.filter ('.json', False)
folderExtJs = Folder (PathExt)
folderExtJs.get ('.js')
folderExtJs.filter ('service-worker', False)
folderExtJs.filter ('.json', False)
folderExtJs.filter ('code', False)
folderExtCss = Folder (PathExt)
folderExtCss.get ('.css')
# vérifier la présence de certaines références
def groupByRef (folderRef, folderExt):
dicoFiles ={}
for ref in folderRef.list:
dicoFiles[ref.title] = Folder (PathExt)
dicoFiles[ref.title].append (ref) # la référence est faussement considérée comme le premier élément du folder
f=0
nbFile = len (folderExt.list)
while f< nbFile:
if ref.title == folderExt.list[f].title:
dicoFiles[ref.title].append (folderExt.list[f])
folderExt.list.remove (folderExt.list[f])
f= nbFile
f+=1
refKeys = dicoFiles.keys()
delKeys =[]
for ref in refKeys:
if len (dicoFiles[ref]) ==1: delKeys.append (ref)
for ref in delKeys: dicoFiles.pop (ref)
return dicoFiles
def findModif (pathRef, folderIdem):
# le premier élément du dossier contient la référence
fileRef = folderIdem.list.pop (0)
fileRef.path = pathRef + fileRef.path
fileRef.read()
folderIdem.read()
for fidem in folderIdem.list:
if fidem.text != fileRef.text:
f= fidem.path.find (sep)
fidem.title = fidem.path[:f]
# print ('modification possible dans', fileRef.title, fidem.title)
fileRef.comparer (fidem)
# print ('\t=== comparer les fichiers css ===\n')
groups = groupByRef (folderRefCss, folderExtCss)
refList = groups.keys()
for ref in refList: findModif (pathRefCss, groups [ref])
groups = groupByRef (folderRefJs, folderExtJs)
refList = groups.keys()
for ref in refList: findModif (pathRefJs, groups [ref])