annotate tasks/task_social_contract.py @ 3:b7e8db97b3b0

presentation: added installation section, with links to Flatpak and Android packages
author Goffi <goffi@goffi.org>
date Fri, 28 Jun 2019 17:12:40 +0200
parents 09d66acc7c73
children 9ce41ef66dfa
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:
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 md = markdown.markdown(f.read().decode('utf-8'))
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:
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 f.write(md.encode('utf-8'))
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 log.info(_(u"social contract has been converted to HTML"))