annotate tasks/task_social_contract.py @ 6:9ce41ef66dfa

python 3 port
author Goffi <goffi@goffi.org>
date Sat, 05 Oct 2019 01:26:51 +0200
parents 09d66acc7c73
children b5fc67c97c50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/ur/bin/env python2
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 import glob
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 import markdown
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 import os.path
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 from sat.core.i18n import _
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 from sat.core.log import getLogger
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 log = getLogger(__name__)
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 def start(self):
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 sat_path = self.getConfig("sat_repos_path")
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 for filepath in glob.glob(os.path.join(sat_path, "CONTRAT_SOCIAL*")):
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 filename = os.path.basename(filepath)
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 with open(filepath) as f:
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
16 md = markdown.markdown(f.read())
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 build_path = os.path.join(self.build_path, filename + '.html')
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 with open(build_path, 'w') as f:
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
19 f.write(md)
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
21 log.info(_("social contract has been converted to HTML"))