Mercurial > libervia-website
annotate tasks/task_social_contract.py @ 11:87262027cbf5
news: use pagination and search box as in Libervia Web's blog
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 23 Apr 2021 11:04:36 +0200 |
parents | b5fc67c97c50 |
children | 5fd933e238bb |
rev | line source |
---|---|
0 | 1 #!/ur/bin/env python2 |
2 | |
3 import glob | |
7
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
4 import os.path |
0 | 5 import markdown |
6 from sat.core.i18n import _ | |
7 from sat.core.log import getLogger | |
7
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
8 from libervia.server.tasks import task |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
9 |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
10 |
0 | 11 log = getLogger(__name__) |
12 | |
13 | |
7
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
14 class Task(task.Task): |
0 | 15 |
7
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
16 def start(self): |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
17 sat_path = self.getConfig("sat_repos_path") |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
18 for filepath in glob.glob(os.path.join(sat_path, "CONTRAT_SOCIAL*")): |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
19 filename = os.path.basename(filepath) |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
20 with open(filepath) as f: |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
21 md = markdown.markdown(f.read()) |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
22 build_path = os.path.join(self.build_path, filename + '.html') |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
23 with open(build_path, 'w') as f: |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
24 f.write(md) |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
25 |
b5fc67c97c50
tasks: updated tasks following changes in Libervia
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
26 log.info(_("social contract has been converted to HTML")) |