diff pages/social_contract/page_meta.py @ 6:9ce41ef66dfa

python 3 port
author Goffi <goffi@goffi.org>
date Sat, 05 Oct 2019 01:26:51 +0200
parents 09d66acc7c73
children 5fd933e238bb
line wrap: on
line diff
--- a/pages/social_contract/page_meta.py	Fri Jun 28 17:44:55 2019 +0200
+++ b/pages/social_contract/page_meta.py	Sat Oct 05 01:26:51 2019 +0200
@@ -5,8 +5,8 @@
 from sat.tools.common.template import safe
 from libervia.server import session_iface
 
-name = u"social_contract"
-template = u"social_contract/social_contract.html"
+name = "social_contract"
+template = "social_contract/social_contract.html"
 social_contracts = {}
 
 
@@ -14,10 +14,10 @@
     global social_contracts
     session_data = self.host.getSessionData(request, session_iface.ISATSession)
     if session_data.locale is None:
-        locale = u"en"
+        locale = "en"
     else:
         locale = session_data.locale
-        if u'_' in locale:
+        if '_' in locale:
             locale = locale[:locale.find('_')]
 
     try:
@@ -26,21 +26,21 @@
         # we don't have the document in cache
         build_path = self.host.getBuildPath(self.vhost_root.site_name)
 
-        if locale == u"fr":
+        if locale == "fr":
             # main social contract is in French, so we don't have suffix in this case
-            filename = u"CONTRAT_SOCIAL.html"
+            filename = "CONTRAT_SOCIAL.html"
         else:
-            filename = u"CONTRAT_SOCIAL_{locale}.html".format(locale=locale)
+            filename = "CONTRAT_SOCIAL_{locale}.html".format(locale=locale)
 
         filepath = os.path.join(build_path, filename)
         if not os.path.isfile(filepath):
             # there is not translation for this locale, we use English one as default
-            filename = u"CONTRAT_SOCIAL_en.html"
+            filename = "CONTRAT_SOCIAL_en.html"
             filepath = os.path.join(build_path, filename)
 
         with open(filepath) as f:
-            social_contracts[locale] = safe(f.read().decode('utf-8'))
+            social_contracts[locale] = safe(f.read())
 
         social_contract = social_contracts[locale]
 
-    request.template_data[u"social_contract"] = social_contract
+    request.template_data["social_contract"] = social_contract