-
Notifications
You must be signed in to change notification settings - Fork 0
/
counter.py
71 lines (65 loc) · 1.98 KB
/
counter.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import json
class Counter:
def __init__(self,number,config=
{"want":2500,"width":250,"file":"counter.html"}):
self.number=number
self.config=config
self.string="""<html><head>
<link rel="stylesheet" href="style-counter.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="counter">
<h1>"Stoppt die Vorratsdatenspeicherung"</h1>
<!--
<div class="wantbar" style="width: %dpx">
</div>
<div class="havebar" style="width: %dpx">
</div>-->
<div class="number">
%d<!--/%d--> Unterschriften
</div>
<a href="http://zeichnemit.at" target="_new">Jetzt mitzeichnen!</a>
</div>
</body>
</html>"""
def write(self):
f=open(self.config["file"],"w")
f.write("%s"%self)
f.close()
def __str__(self):
hw=self.number/self.config["want"]*self.config["width"]
if hw> self.config["width"]:
hw=self.config["width"]
return self.string%(self.config["width"],
hw,
self.number, self.config["want"])
class CounterInternal(Counter):
def __init__(self,number,config={"want":2500,"width":250,
"file":"counter-internal.html"}):
Counter.__init__(self,number,config)
self.string="""<html><head>
<link rel="stylesheet" href="style-counter.css" type="text/css" />
</head>
<body>
<div class="counter">
Seit 17.10.2011:
<!--<div class="wantbar" style="width: %dpx">
</div>
<div class="havebar" style="width: %dpx">
</div> -->
<div class="number">%d<!--/%d--> Unterschriften</div>
</div>
</body>
</html>"""
if __name__=="__main__":
import sys
number=int(sys.argv[1])
counter=Counter(number)
counter.write()
ci=CounterInternal(number)
ci.write()
a={"need": 10000, "have": number}
f=open("counter.json","w")
json.dump(a,f)
f.close()