Py3 changes

migration_mirror
idziubenko 3 年之前
父節點 659f1d1920
當前提交 10922f61c6

6
.gitignore vendored

@ -0,0 +1,6 @@
revert_changes_to_vmachine
push_to_vmachine*
.vscode
*.pyc
*.pyo
*.bak

@ -192,8 +192,8 @@ class InfoBlockInterface(object):
class EmergeInformationBlock(InfoBlockInterface):
_color_block = "(?:\033\[[^m]+?m)?"
_new_line = "(?:\r*\n)"
_color_block = r"(?:\033\[[^m]+?m)?"
_new_line = r"(?:\r*\n)"
end_token = ["\n"]
re_block = None
re_match_type = type(re.match("", ""))
@ -433,7 +433,7 @@ class QuestionGroup(GroupEmergeInformationBlock):
end_token = ["]", "\n"]
_color_block = EmergeInformationBlock._color_block
re_block = re.compile(
"(Would you.*)\[{c}Yes{c}/{c}No{c}".format(c=_color_block))
r"(Would you.*)\[{c}Yes{c}/{c}No{c}".format(c=_color_block))
def get_block(self, child):
try:
@ -546,8 +546,8 @@ class EmergingPackage(NotifierInformationBlock):
_color_block = EmergeInformationBlock._color_block
token = ">>> Emerging "
re_block = re.compile(
"Emerging (binary )?\({c}(\d+){c} "
"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block))
r"Emerging (binary )?\({c}(\d+){c} "
r"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block))
def notify(self, observer, groups):
observer(EmergePackage(groups[3]), num=groups[1], max_num=groups[2],
@ -575,7 +575,7 @@ class FetchingTarball(NotifierInformationBlock):
Происходит скачивание архивов
"""
token = "Saving to:"
re_block = re.compile("Saving to:\s*[‘'](\S+)?['’]")
re_block = re.compile(r"Saving to:\s*[‘'](\S+)?['’]")
def notify(self, observer, groups):
observer(groups[0])
@ -592,8 +592,8 @@ class InstallingPackage(NotifierInformationBlock):
token = ">>> Installing "
re_block = re.compile(
"Installing \({c}(\d+){c} "
"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block))
r"Installing \({c}(\d+){c} "
r"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block))
def notify(self, observer, groups):
strpkg = str(EmergePackage(groups[2]))
@ -612,8 +612,8 @@ class EmergeingErrorBlock(EmergeInformationBlock):
"""
token = ["* ERROR: ", " * \033[39;49;00mERROR: "]
end_token = "Working directory:"
re_block = re.compile("ERROR: (\S*) failed \([^)]+\).*?"
"The complete build log is located at '([^']+)",
re_block = re.compile(r"ERROR: (\S*) failed \([^)]+\).*?"
r"The complete build log is located at '([^']+)",
re.DOTALL)
package = ""
@ -636,7 +636,8 @@ class RevdepPercentBlock(NotifierInformationBlock):
token = "Collecting system binaries"
end_token = [re.compile("Assigning files to packages|"
"All prepared. Starting rebuild")]
re_block = re.compile("\[\s(\d+)%\s\]")
# re_block = re.compile("\[\s(\d+)%\s\]")
re_block = re.compile(r"\[\s(\d+)%\s\]")
action = None
def notify(self, observer, groups):

@ -158,7 +158,7 @@ class Profile(object):
@classmethod
def from_string(cls, repository, s):
parts = filter(None, s.split())
parts = list(filter(None, s.split()))
if len(parts) == 3 and parts[0] in cls.available_arch:
return Profile(repository, parts[1], parts[0])
return None
@ -261,8 +261,8 @@ class ProfileRepository(object):
Получить список профилей репозитория
"""
profiles_desc = path.join(self.directory, "profiles/profiles.desc")
return filter(None, (Profile.from_string(self, line)
for line in readLinesFile(profiles_desc)))
return list(filter(None, (Profile.from_string(self, line)
for line in readLinesFile(profiles_desc))))
def __repr__(self):
return "<ProfileRepository %s url=%s>" % (self.directory, self.url)

@ -40,7 +40,7 @@ from calculate.lib.cl_log import log
import hashlib
import re
import shutil
from collections import MutableSet
from collections.abc import MutableSet
from contextlib import contextmanager
import tempfile
from fnmatch import fnmatch
@ -277,7 +277,7 @@ class Update(MethodsInterface):
self.printWARNING(_("Updates autocheck is not enabled"))
return False
last_check = SystemIni(self.clVars).getVar('system', 'last_check') or ""
re_interval = re.compile("^(\d+)\s*(hours?|days?|weeks?)?", re.I)
re_interval = re.compile(r"^(\d+)\s*(hours?|days?|weeks?)?", re.I)
interval_match = re_interval.search(interval)
MINUTE = 60
HOUR = MINUTE * 60

@ -70,7 +70,7 @@ class UpdateInfo(object):
"""
Проверить есть ли уже запущенная копия console-gui
"""
return any(filter(lambda x: "cl-console-gui" in x, getRunCommands()))
return any(list(filter(lambda x: "cl-console-gui" in x, getRunCommands())))
def update_already_run(self):
"""

@ -453,8 +453,8 @@ class VariableClUpdateSyncOverlayRep(ReadonlyVariable):
type = "list"
def get(self):
return filter(lambda x: x not in ("portage", "gentoo"),
self.Get('cl_update_sync_rep'))
return list(filter(lambda x: x not in ("portage", "gentoo"),
self.Get('cl_update_sync_rep')))
class VariableClUpdateOutdateSet(ReadonlyVariable):
@ -782,11 +782,11 @@ class VariableClUpdateProfileDependData(ReadonlyTableVariable):
dv = self.Get(self.datavars)
if dv:
if hr == HumanReadable.Yes:
return reversed(zip([x.capitalize() for x in dv.Get('cl_update_rep_name')],
dv.Get('cl_update_rep_url')))
return reversed(list(zip([x.capitalize() for x in dv.Get('cl_update_rep_name')],
dv.Get('cl_update_rep_url'))))
else:
return reversed(zip(dv.Get('cl_update_rep_name'),
dv.Get('cl_update_rep_url')))
return reversed(list(zip(dv.Get('cl_update_rep_name'),
dv.Get('cl_update_rep_url'))))
return ""
setValue = Variable.setValue
@ -828,7 +828,7 @@ class VariableClUpdateTemplatesLocate(Variable):
def choice(self):
descr = lambda x: self.descriptionMap.get(x,
_("%s overlay templates" % x))
return map(lambda x: (x, descr(x)), self.get())
return list(map(lambda x: (x, descr(x)), self.get()))
class VariableClUpdateProfileDependName(FieldValue, ReadonlyVariable):
@ -936,7 +936,7 @@ class VariableClUpdateProfileUrl(Variable):
r"^(?:(%s)://)?((?:git@)?\w[\w\./:-]+?\w)(\.git)?$" % "|".join(
["http", "https", "git", "ssh"]))
re_shortname = re.compile('^(?:([\w\.-]+):)?([\w\.-]+)$')
re_shortname = re.compile(r'^(?:([\w\.-]+):)?([\w\.-]+)$')
@classmethod
def normalize_url(cls, url):
@ -1094,10 +1094,10 @@ class VariableClProfileData(ReadonlyTableVariable):
profile_arch = [x.arch for x in filtered_profiles]
short_name = simplify_profiles(full_name)
full_name = ["%s:%s" % (repo_name, x) for x in full_name]
return zip(full_name,
return list(zip(full_name,
short_name,
profile_path,
profile_arch)
profile_arch))
setValue = Variable.setValue
@ -1262,12 +1262,12 @@ class VariableClUpdateProfileSystem(Variable):
if not url:
return []
arch = self.Get(self.gentoo_arch)
profiles = zip(*self.Select([self.profiles_shortname,
profiles = list(zip(*self.Select([self.profiles_shortname,
self.profiles_fullname],
where=self.profiles_arch, eq=arch))
where=self.profiles_arch, eq=arch)))
if profiles:
short_name, full_name = profiles
return zip(short_name, full_name)
return list(zip(short_name, full_name))
return []

@ -22,15 +22,16 @@ from calculate.core.server.func import WsdlBase
from calculate.install.install import InstallError
from .update import Update, UpdateError
from calculate.lib.utils.git import GitError
from utils.cl_update import ClUpdateAction
from utils.cl_update_profile import ClUpdateProfileAction
from utils.cl_setup_update import ClSetupUpdateAction
from .utils.cl_update import ClUpdateAction
from .utils.cl_update_profile import ClUpdateProfileAction
from .utils.cl_setup_update import ClSetupUpdateAction
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate, _
setLocalTranslate('cl_update3', sys.modules[__name__])
__ = getLazyLocalTranslate(_)
class Wsdl(WsdlBase):
methods = [
#

Loading…
取消
儲存