Repository navigation
Expand file tree
/
Copy pathregles.py
More file actions
68 lines (58 loc) · 1.96 KB
/
Copy pathregles.py
File metadata and controls
68 lines (58 loc) · 1.96 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
67
68
#!/usr/bin/python3.6
# -*- coding: utf-8 -*-
from sys import path
path.append ('C:\\Users\\LENOVO\\Desktop\\python')
from datetime import datetime, timedelta
from fileCls import File
from fileList import FileTable
import loggerFct as log
# ============ récupérer les règles de l'année passée ============
dataFull = FileTable ('b/perso\\regles.tsv')
dataFull.read()
dataFull.pop (0)
# récupération des données de deux ans
year = dataFull[0][0][:4]
periodYears = '-'+ year
r=0
while dataFull[r][0][:4] == year: r+=1
year = dataFull[r][0][:4]
periodYears = year + periodYears
while dataFull[r][0][:4] == year: r+=1
dataRafined = FileTable()
dataRafined.extend (dataFull[:r])
# début du graphe
dateStart = datetime.strptime (dataRafined[-1][0][:8] +'01', '%Y/%m/%d')
averageStartGap =0
# transformer les dates
dataRange = range (len (dataRafined))
dateEcart = None
for r in dataRange:
dateEcart = datetime.strptime (dataRafined[r][0], '%Y/%m/%d')
dateEcart = dateEcart - dateStart
dataRafined[r][0] = str (dateEcart.days)
averageStartGap += dateEcart
averageStartGap /= (len (dataRafined) -1)
# créer les données
# templateLine = "<line y1='0' y2='300' x1='$' x2='$' />"
templateRect = "<rect y='0' height='300' x='$debut' width='$large' />"
graphic =""
for r in dataRange:
graphic = graphic + templateRect
graphic = graphic.replace ('$debut', dataRafined[r][0])
graphic = graphic.replace ('$large', dataRafined[r][1])
# remplir le modèle html
templateHtml = File ('b/perso\\regles template.html')
templateHtml.read()
templateHtml.title = 'regles recentes'
templateHtml.toPath()
templateHtml.replace ('$graphic', graphic)
templateHtml.replace ('$periodYears', periodYears)
templateHtml.replace ('$averageStartGap', str (averageStartGap))
templateHtml.write()
# remplir le modèle svg
templateSvg = File ('b/perso\\regles template.svg')
templateSvg.read()
templateSvg.title = 'regles recentes'
templateSvg.toPath()
templateSvg.replace ('$graphic', graphic)
templateSvg.write()