Change to Python3 coding style

This commit is contained in:
shortcutme 2019-03-15 21:06:59 +01:00
parent fc0fe0557b
commit b0b9a4d33c
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
137 changed files with 910 additions and 913 deletions

View file

@ -3,7 +3,7 @@ import json
import logging
import inspect
import re
import cgi
import html
import string
from Config import config
@ -15,8 +15,8 @@ class EscapeProxy(dict):
# Automatically escape the accessed string values
def __getitem__(self, key):
val = dict.__getitem__(self, key)
if type(val) in (str, unicode):
return cgi.escape(val, quote=True)
if type(val) in (str, str):
return html.escape(val)
elif type(val) is dict:
return EscapeProxy(val)
elif type(val) is list:
@ -105,7 +105,7 @@ class Translate(dict):
data = data.decode("utf8")
patterns = []
for key, val in translate_table.items():
for key, val in list(translate_table.items()):
if key.startswith("_("): # Problematic string: only match if called between _(" ") function
key = key.replace("_(", "").replace(")", "").replace(", ", '", "')
translate_table[key] = "|" + val
@ -128,6 +128,6 @@ class Translate(dict):
else:
pattern = '"(' + "|".join(patterns) + ')"'
data = re.sub(pattern, replacer, data)
return data.encode("utf8")
return data
translate = Translate()

View file

@ -1 +1 @@
from Translate import *
from .Translate import *