Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.py
More file actions
Latest commit
executable file
·142 lines (113 loc) · 4.27 KB
/
Copy pathgenerate.py
File metadata and controls
executable file
·142 lines (113 loc) · 4.27 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# generate.py
# Copyright Rainer Kersten and penny for the PHP-Scripts
# Copyright 2013 - 2014 Mechtilde Stehmann <ooo@mechtilde>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
importconfig
importfunctions
importos
importre
importsys
def_(String):
"""solange keine gettext Integration erfolgt ist, ist dies ein dummy"""
returnString
classGenerate(object):
def__init__(self):
self.ARGV_GENALL=False
self.ARGV_GENFILELIST=False
self.ARGV_MKDIR=False
iflen(sys.argv) >1:
foriinrange(len(sys.argv)):
ifi=="-a":
self.ARGV_GENALL=True
ifi=="-f":
self.ARGV_GENFILELIST=True
ifi=="-p":
self.ARGV_MKDIR=True
iflen(sys.argv) >=2and (sys.argv[1] =='--help'orsys.argv[1] =='-h'):
print(_("Usage:") +" generate [-h|--help] "+_("[-a] generate all pages, [-f] generate filelist, [-p] gereate directories"))
sys.exit(1)
self.mainConfig=config.main("sampleProject/config.txt")
self.seitendict=config.main("sampleProject/seiten.txt")
defreadIndexTemplate(self):
withopen("sampleProject/templates/template.index", "r") asf:
self.IndexTemplate=f.read()
print("<h1>WWW2.0</h1>\n<p>Ich suche aktuelle Änderungen.</p>\n")
#def generateSitemap(self):
"""#echo "<p>Generiere Sitemap(s) ...";
#include($Path['global'] . "/sitemap.php");$
#echo " <br />done.</p>\n";
if (file_exists($Path['home'] . "/linkfeld.php")) {
echo "<p>Generiere Linkseite(n) ...";
include($Path['global'] . "/linklist.php");
echo " done.</p>\n";
}"""
defgeneratePages(self):
pageCounter=0
file_list=""
print("\n<p>Seiten werden geschrieben:\n")
forSiteinself.seitendict:
urlPartAr=Site.split("-")
Site_siteid=urlPartAr[0]
Site_siteid=Site_siteid.replace("Sites", "")
Site_language=urlPartAr[1]
Site_languagepath=config.main("sampleProject/sprachen.txt")[urlPartAr[1] +"-pfad"]
Site_actpath=self.seitendict[urlPartAr[0] +"-"+urlPartAr[1] +"-ordner"]
Site_file=self.seitendict[urlPartAr[0] +"-"+urlPartAr[1] +"-datei"]
ifSite_file!="":
ifSite_languagepath[-1:] !=""andSite_languagepath[-1:] !="/":
Site_languagepath=Site_languagepath+"/"
ifSite_actpath[-1:] !=""andSite_actpath[-1:] !="/":
Site_actpath=Site_actpath+"/"
Site_target=Site_languagepath+Site_actpath+Site_file
Funktionen=functions.Funktionen()
Funktionen.setGlobals(Site_siteid,Site_language,Site_languagepath,Site_actpath,Site_file)
ThisSite=Funktionen.mkHead() +self.IndexTemplate
i=0
whileThisSite.find("@@@") >=0:
ThisSite=Funktionen.subTemplates(ThisSite)
Target=self.mainConfig["docrootpath"] +"/"+Site_target
ifself.ARGV_MKDIRandnotos.path.exists(self.mainConfig["docrootpath"] +Site_languagepath+Site_actpath):
Meldung=Funktionen.myMkDir(self.mainConfig["docrootpath"] +Site_languagepath+Site_actpath)
print(Meldung)
try:
withopen(Target, "r") asf:
myOrig=f.read()
except:
myOrig=""
if (myOrig!=ThisSite) orself.ARGV_GENALL:
try:
withopen(Target, "w") asf:
f.write(ThisSite)
except:
print("<p>error writing file: "+Target+"</p>\n")
print("ThisSite: "+ThisSite)
ifself.ARGV_GENFILELIST:
file_list+="Target "
print(".")
pageCounter+=1
print("\n<br />"+str(pageCounter) +" Seiten wurden geschrieben.</p>\n")
iflen(file_list) >0:
print("FILELIST: "+str(file_list) +"\n")
defmain():
g=Generate()
g.readIndexTemplate()
g.generatePages()
if__name__=='__main__':
main()