py3 related changes - maps and filters to list comp, print to func, etc

py3_forced
parent acb67f1857
commit 27667a1a19

@ -13,6 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import print_function
import os import os
import cl_base import cl_base
import cl_utils import cl_utils
@ -30,7 +31,7 @@ class fillVars(object, cl_base.glob_attr):
res = self._runos(runStr) res = self._runos(runStr)
if res: if res:
return res.strip() return res.strip()
print "Error generate hash (slappasswd)" print("Error generate hash (slappasswd)")
exit(1) exit(1)
def get_cl_profile_path(self): def get_cl_profile_path(self):
@ -230,7 +231,7 @@ class fillVars(object, cl_base.glob_attr):
for replServer in replServers: for replServer in replServers:
if replServer: if replServer:
md5hex = hashlib.md5(replServer).hexdigest() md5hex = hashlib.md5(replServer).hexdigest()
data8bit = "".join(map(lambda x: str(int(x,16)/2),list(md5hex))) data8bit = "".join((str(int(x,16)/2) for x in list(md5hex)))
dStart = 0 dStart = 0
dEnd = 3 dEnd = 3
dMax = 32 dMax = 32
@ -470,13 +471,13 @@ class fillVars(object, cl_base.glob_attr):
netAllow = self.Get("sr_proxy_net_allow") netAllow = self.Get("sr_proxy_net_allow")
if netAllow: if netAllow:
netAllow = netAllow.split(",") netAllow = netAllow.split(",")
netAllow = map(lambda x: "acl localnet src %s"%x,netAllow) netAllow = ["acl localnet src %s" % x for x in netAllow]
netAllow = "\n".join(netAllow) netAllow = "\n".join(netAllow)
return netAllow return netAllow
netAllow = self.Get("os_net_allow") netAllow = self.Get("os_net_allow")
if netAllow: if netAllow:
netAllow = netAllow.split(",") netAllow = netAllow.split(",")
netAllow = map(lambda x: "acl localnet src %s"%x,netAllow) netAllow = ["acl localnet src %s" % x for x in netAllow]
netAllow = "\n".join(netAllow) netAllow = "\n".join(netAllow)
return netAllow return netAllow
return "acl localnet src 127.0.0.1/32" return "acl localnet src 127.0.0.1/32"
@ -543,14 +544,14 @@ class fillVars(object, cl_base.glob_attr):
"""Текст в ejabberd.cfg - имена хостов с которыми работает сервис""" """Текст в ejabberd.cfg - имена хостов с которыми работает сервис"""
jabberHosts = self.Get("sr_jabber_hosts") jabberHosts = self.Get("sr_jabber_hosts")
if jabberHosts: if jabberHosts:
return ", ".join(map(lambda x: '"'+x+'"', jabberHosts.split(","))) return ", ".join(('"'+x+'"' for x in jabberHosts.split(",")))
return "" return ""
def get_sr_jabber_hosts_yml(self): def get_sr_jabber_hosts_yml(self):
"""Текст в ejabberd.cfg - имена хостов с которыми работает сервис""" """Текст в ejabberd.cfg - имена хостов с которыми работает сервис"""
jabberHosts = self.Get("sr_jabber_hosts") jabberHosts = self.Get("sr_jabber_hosts")
if jabberHosts: if jabberHosts:
return "\n".join(map(lambda x: ' - "%s"' % x, jabberHosts.split(","))) return "\n".join((' - "%s"' % x for x in jabberHosts.split(",")))
return "" return ""
def get_sr_jabber_user_name(self): def get_sr_jabber_user_name(self):
@ -591,7 +592,7 @@ class fillVars(object, cl_base.glob_attr):
break break
if not foundLoc: if not foundLoc:
netAllow.append("127.0.0.1") netAllow.append("127.0.0.1")
netAllow = map(lambda x: "%s;"%x,netAllow) netAllow = ["%s;" % x for x in netAllow]
netAllow = " ".join(netAllow) netAllow = " ".join(netAllow)
return "listen-on { %s };"%netAllow return "listen-on { %s };"%netAllow
netAllow = self.Get("sr_dns_net_allow") netAllow = self.Get("sr_dns_net_allow")

File diff suppressed because it is too large Load Diff

@ -140,15 +140,18 @@ class cl_install_data(install_data):
def run (self): def run (self):
install_data.run(self) install_data.run(self)
data_file = \ data_file = \
[("/etc/init.d/sortmilter.init","sortmilter",0755), [("/etc/init.d/sortmilter.init","sortmilter",0o755),
("/etc/conf.d/sortmilter.conf","sortmilter",None)] ("/etc/conf.d/sortmilter.conf","sortmilter",None)]
data_find = \ data_find = \
dict( dict(
map(lambda x:(os.path.basename(x[0]), # map(lambda x:(os.path.basename(x[0]),
[list(reversed(filter(lambda y:y,x[0].split("/")))), # [list(reversed(filter(lambda y:y,x[0].split("/")))),
x[1], # x[1],
x[2]]), # x[2]]),
data_file)) # data_file))
# [(os.path.basename(x[0]), [list(reversed(filter(lambda y:y,x[0].split("/")))), x[1],x[2]]) for x in data_file])
[(os.path.basename(x[0]), [list(reversed((y for y in x[0].split("/") if y))), x[1],x[2]]) for x in data_file])
for path in self.get_outputs(): for path in self.get_outputs():
nameFile = os.path.split(path)[1] nameFile = os.path.split(path)[1]

Loading…
Cancel
Save