py3 changes

py3_forced
idziubenko 3 years ago
parent 89b8539539
commit d0d17648ef

@ -39,9 +39,8 @@ class ImageViewer(QtGui.QMainWindow):
@staticmethod @staticmethod
def select_color(): def select_color():
try: try:
#TODO change for any in list compr? if [x for x in os.listdir('/var/db/pkg/media-gfx')
if list(filter(re.compile(r"(cld|cldx|cldg|cmc|cls)-themes-12").search, if re.compile(r"(cld|cldx|cldg|cmc|cls)-themes-12").search(x)]:
os.listdir('/var/db/pkg/media-gfx'))):
return "#73a363" return "#73a363"
except OSError: except OSError:
pass pass

@ -201,10 +201,10 @@ class Desktop(MethodsInterface):
mountProfileDir = path.join(dirStart, ".%s" % dirEnd) mountProfileDir = path.join(dirStart, ".%s" % dirEnd)
mountRemoteProfileDir = path.join(dirStart, ".%s.remote" % dirEnd) mountRemoteProfileDir = path.join(dirStart, ".%s.remote" % dirEnd)
with open("/proc/mounts") as f: with open("/proc/mounts") as f:
return list(filter(lambda x: x.startswith(homeDir) or return [x for x in (y.split(" ")[1] for y in f)
x.startswith(mountProfileDir) or if x.startswith(homeDir)
x.startswith(mountRemoteProfileDir), or x.startswith(mountProfileDir)
map(lambda x: x.split(" ")[1], f))) or x.startswith(mountRemoteProfileDir)]
def umountSleepPath(self, rpath): def umountSleepPath(self, rpath):
""" """
@ -216,7 +216,7 @@ class Desktop(MethodsInterface):
fuser_cmd = getProgPath("/bin/fuser") fuser_cmd = getProgPath("/bin/fuser")
loops = getLoopFromPath(rpath) loops = getLoopFromPath(rpath)
if loops: if loops:
setLoops = set(map(lambda x: x.partition('/dev/')[2], loops)) setLoops = set((x.partition('/dev/')[2] for x in loops))
mdInfo = getMdRaidDevices() mdInfo = getMdRaidDevices()
for k, v in mdInfo.items(): for k, v in mdInfo.items():
if setLoops & set(v): if setLoops & set(v):
@ -335,17 +335,14 @@ class Desktop(MethodsInterface):
if uid: if uid:
uid = int(uid) uid = int(uid)
for i in range(0, postWaitTime): for i in range(0, postWaitTime):
if not list(filter(lambda x: "ksmserver" in x, if not [x for x in getRunCommands(uid=uid) if "ksmserver" in x]:
getRunCommands(uid=uid))):
break break
time.sleep(1) time.sleep(1)
time.sleep(1) time.sleep(1)
if list(filter(lambda x: "xdm/xdm\x00--logout" in x, if [x for x in getRunCommands() if "xdm/xdm\x00--logout" in x]:
getRunCommands())):
for i in range(0, waitTime): for i in range(0, waitTime):
if not list(filter(lambda x: "xdm/xdm\x00--logout" in x, if not [x for x in getRunCommands() if "xdm/xdm\x00--logout" in x]:
getRunCommands())):
return True return True
time.sleep(1) time.sleep(1)
else: else:

@ -15,6 +15,7 @@
# limitations under the License. # limitations under the License.
import os import os
from posixpath import split
import sys import sys
import re import re
from os import path from os import path
@ -59,9 +60,8 @@ class DomainInfoHelper(VariableInterface):
""" """
def getUserDataInFile(self, login, filePasswd): def getUserDataInFile(self, login, filePasswd):
return list(filter(lambda x: x[0] == login, return [x for x in (y.strip().split(':') for y
map(lambda x: x.strip().split(':'), in readLinesFile(filePasswd)) if x[0] == login]
readLinesFile(filePasswd))))
def isDomainUser(self, userName): def isDomainUser(self, userName):
if userName: if userName:
@ -93,9 +93,8 @@ class VariableUrDomainSet(ReadonlyVariable, DomainInfoHelper):
type = "bool" type = "bool"
def getUserDataInFile(self, login, file_passwd): def getUserDataInFile(self, login, file_passwd):
return list(filter(lambda x: x[0] == login, return [x for x in (y.strip().split(':') for y
map(lambda x: x.strip().split(':'), in readLinesFile(file_passwd)) if x[0] == login]
readLinesFile(file_passwd))))
def get(self): def get(self):
return "on" if self.isDomainUser(self.Get('ur_login')) else "off" return "on" if self.isDomainUser(self.Get('ur_login')) else "off"
@ -156,10 +155,9 @@ class VariableClDesktopGstData(ReadonlyVariable):
if res == gst.STATE_CHANGE_SUCCESS: if res == gst.STATE_CHANGE_SUCCESS:
outdata['device_name'] = alsamixer.get_property("device-name") outdata['device_name'] = alsamixer.get_property("device-name")
outdata['long_name'] = alsamixer.get_factory().get_longname() outdata['long_name'] = alsamixer.get_factory().get_longname()
outdata['internal_name'] = list(filter(str.isalnum, outdata['internal_name'] = [x for x
"%s (%s)" % ( in "%s (%s)" % (outdata['device_name'],outdata['long_name'])
outdata['device_name'], if str.isalnum(x)]
outdata['long_name'])))
outdata['channels'] = [] outdata['channels'] = []
for t in alsamixer.list_tracks(): for t in alsamixer.list_tracks():
if t.flags & gst.interfaces.MIXER_TRACK_OUTPUT: if t.flags & gst.interfaces.MIXER_TRACK_OUTPUT:
@ -200,9 +198,8 @@ class VariableClDesktopXfceMixer(ReadonlyVariable):
""" """
def get(self): def get(self):
return "\n".join( return "\n".join((' <value type="string" value="%s" />' % x for x
map(lambda x: ' <value type="string" value="%s" />' % x, in self.Get('cl_desktop_gst_data').get('channels', [])))
self.Get('cl_desktop_gst_data').get('channels', [])))
class VariableClDesktopXfcePointers(ReadonlyVariable): class VariableClDesktopXfcePointers(ReadonlyVariable):
@ -257,25 +254,32 @@ class VariableClDesktopOnlineData(ReadonlyTableVariable, DomainInfoHelper):
if resWho.success(): if resWho.success():
listProcessing = lambda x: (x[0], x[1], x[-1]) \ listProcessing = lambda x: (x[0], x[1], x[-1]) \
if len(x) >= 5 else [] if len(x) >= 5 else []
# xData = groupby(
# sorted(
# filter(lambda x: x[0] != "root",
# map(lambda x: (x[0], self._getDisplay(x[1], x[2])),
# filter(lambda x: x and \
# (x[2].startswith("(:") or
# x[1].startswith(":")),
# map(lambda x: listProcessing(
# list(filter(lambda y: y, x.split()))),
# resWho)))),
# key=lambda x: x[0]),
# lambda x: x[0])
xData = groupby( xData = groupby(
sorted( sorted((x for x in ((y[0], self._getDisplay(y[1], y[2])) for y
filter(lambda x: x[0] != "root", in (listProcessing([o for o in z.split() if o]) for z
map(lambda x: (x[0], self._getDisplay(x[1], x[2])), in resWho)
filter(lambda x: x and \ if y and (y[2].startswith("(:") or y[1].startswith(":")))
(x[2].startswith("(:") or if x[0] != "root"),
x[1].startswith(":")), key=lambda x: x[0]),
map(lambda x: listProcessing(
list(filter(lambda y: y, x.split()))),
resWho)))),
key=lambda x: x[0]),
lambda x: x[0]) lambda x: x[0])
xData = list(map(lambda x: (x[0][0], x[0][1],
self.get_user_uid(x[0][0]),
"on" if self.isDomainUser( xData = [(x[0][0], x[0][1], self.get_user_uid(x[0][0]), "on"
x[0][0]) else "off", if self.isDomainUser(x[0][0]) else "off", len(x)) for x
len(x)), in (list(y[1]) for y in xData)]
map(lambda x: list(x[1]),
xData)))
return xData return xData
setValue = Variable.setValue setValue = Variable.setValue
@ -367,13 +371,14 @@ class VariableUrMountDirs(ReadonlyVariable):
mountProfileDir = path.join(dirStart, ".%s" % dirEnd) mountProfileDir = path.join(dirStart, ".%s" % dirEnd)
mountRemoteProfileDir = path.join(dirStart, ".%s.remote" % dirEnd) mountRemoteProfileDir = path.join(dirStart, ".%s.remote" % dirEnd)
directories = filter(lambda x: x != homeDir, directories = (x for x
filter(lambda x: (x.startswith(homeDir) or in (y for y
x.startswith(mountProfileDir) or in (z.split(" ")[1] for z
x.startswith( in readLinesFile('/proc/mounts'))
mountRemoteProfileDir)), if (y.startswith(homeDir)
map(lambda x: x.split(" ")[1], or y.startswith(mountProfileDir)
readLinesFile('/proc/mounts')))) or y.startswith(mountRemoteProfileDir)))
if x != homeDir)
# if isMount(homeDir): # if isMount(homeDir):
# directories.append(homeDir) # directories.append(homeDir)
return sorted(directories, reverse=True) return sorted(directories, reverse=True)
@ -446,9 +451,8 @@ class VariableClDesktopFaceList(Variable):
type = "list" type = "list"
def get(self): def get(self):
return sorted( return sorted((x for x in listDirectory(self.Get('cl_desktop_face_path'))
filter(lambda x: x.endswith('.png'), if x.endswith('.png')))
listDirectory(self.Get('cl_desktop_face_path'))))
class VariableClDesktopHashFace(Variable): class VariableClDesktopHashFace(Variable):

Loading…
Cancel
Save