From 8b356a3d225f2ae56f067634bd6848dc3cd4b8bb Mon Sep 17 00:00:00 2001 From: idziubenko Date: Mon, 2 Aug 2021 15:33:58 +0300 Subject: [PATCH] fixed/reverted regex --- pym/update/emerge_parser.py | 39 +++++++++++++++++----------------- pym/update/profile.py | 6 +++--- pym/update/update.py | 4 ++-- pym/update/update_info.py | 2 +- pym/update/utils/cl_update.py | 2 +- pym/update/variables/update.py | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/pym/update/emerge_parser.py b/pym/update/emerge_parser.py index a13b0d1..1dfe046 100644 --- a/pym/update/emerge_parser.py +++ b/pym/update/emerge_parser.py @@ -55,7 +55,7 @@ class EmergeNeedRootError(EmergeError): pass -class CommandExecutor(object): +class CommandExecutor(): """ Запуск программы для объекта Emerge """ @@ -133,7 +133,7 @@ class EmergeCommand(CommandExecutor): env.update(env_update) params = self.default_params + extra_params + packages - super(EmergeCommand, self).__init__(self.emerge_cmd, params=params, + super().__init__(self.emerge_cmd, params=params, env=env, cwd=cwd, logfile=logfile) @@ -172,7 +172,7 @@ def Linux32(obj): return obj -class InfoBlockInterface(object): +class InfoBlockInterface(): """ Интерфейс для информационного блока """ @@ -192,8 +192,8 @@ class InfoBlockInterface(object): class EmergeInformationBlock(InfoBlockInterface): - _color_block = r"(?:\033\[[^m]+?m)?" - _new_line = r"(?:\r*\n)" + _color_block = "(?:\033\[[^m]+?m)?" + _new_line = "(?:\r*\n)" end_token = ["\n"] re_block = None re_match_type = type(re.match("", "")) @@ -281,7 +281,7 @@ class InstallPackagesBlock(EmergeInformationBlock): re_blocks = re.compile(r"\[{c}blocks{c} {c}b".format(c=_color_block)) def get_data(self, match): - super(InstallPackagesBlock, self).get_data(match) + super().get_data(match) list_block = XmlConverter().transform(self.result).split('\n') self.list = PackageList(map(EmergeUpdateInfo, list_block)) self.remove_list = PackageList(map(EmergeRemoveInfo, list_block)) @@ -433,7 +433,7 @@ class QuestionGroup(GroupEmergeInformationBlock): end_token = ["]", "\n"] _color_block = EmergeInformationBlock._color_block re_block = re.compile( - r"(Would you.*)\[{c}Yes{c}/{c}No{c}".format(c=_color_block)) + "(Would you.*)\[{c}Yes{c}/{c}No{c}".format(c=_color_block)) def get_block(self, child): try: @@ -511,7 +511,7 @@ class NotifierInformationBlock(EmergeInformationBlock): Информационный блок поддерживающий observing """ def __init__(self, parent): - super(NotifierInformationBlock, self).__init__(parent) + super().__init__(parent) self.observers = [] def get_data(self, match): @@ -546,8 +546,8 @@ class EmergingPackage(NotifierInformationBlock): _color_block = EmergeInformationBlock._color_block token = ">>> Emerging " re_block = re.compile( - r"Emerging (binary )?\({c}(\d+){c} " - r"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block)) + "Emerging (binary )?\({c}(\d+){c} " + "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(r"Saving to:\s*[‘'](\S+)?['’]") + re_block = re.compile("Saving to:\s*[‘'](\S+)?['’]") def notify(self, observer, groups): observer(groups[0]) @@ -591,9 +591,10 @@ class InstallingPackage(NotifierInformationBlock): binary = None token = ">>> Installing " + #TODO \033 - unicode symbol? probably gonna have to fix this re_block = re.compile( - r"Installing \({c}(\d+){c} " - r"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block)) + "Installing \({c}(\d+){c} " + "of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block)) def notify(self, observer, groups): strpkg = str(EmergePackage(groups[2])) @@ -612,8 +613,8 @@ class EmergeingErrorBlock(EmergeInformationBlock): """ token = ["* ERROR: ", " * \033[39;49;00mERROR: "] end_token = "Working directory:" - re_block = re.compile(r"ERROR: (\S*) failed \([^)]+\).*?" - r"The complete build log is located at '([^']+)", + re_block = re.compile("ERROR: (\S*) failed \([^)]+\).*?" + "The complete build log is located at '([^']+)", re.DOTALL) package = "" @@ -637,7 +638,7 @@ class RevdepPercentBlock(NotifierInformationBlock): end_token = [re.compile("Assigning files to packages|" "All prepared. Starting rebuild")] # re_block = re.compile("\[\s(\d+)%\s\]") - re_block = re.compile(r"\[\s(\d+)%\s\]") + re_block = re.compile("\[\s(\d+)%\s\]") action = None def notify(self, observer, groups): @@ -733,7 +734,7 @@ class EmergeParser(InfoBlockInterface): self.close() -class MtimeCheckvalue(object): +class MtimeCheckvalue(): def __init__(self, *fname): self.fname = fname @@ -758,7 +759,7 @@ class Md5Checkvalue(MtimeCheckvalue): return hashlib.md5(readFile(fn)).hexdigest() -class GitCheckvalue(object): +class GitCheckvalue(): def __init__(self, git, rpath): self.rpath = rpath self.git = git @@ -769,7 +770,7 @@ class GitCheckvalue(object): yield self.rpath, self.git.getCurrentCommit(self.rpath) -class EmergeCache(object): +class EmergeCache(): """ Кэш пакетов """ diff --git a/pym/update/profile.py b/pym/update/profile.py index 827aa72..7d1c62d 100644 --- a/pym/update/profile.py +++ b/pym/update/profile.py @@ -28,7 +28,7 @@ setLocalTranslate('cl_update3', sys.modules[__name__]) DEFAULT_BRANCH = Git.Reference.Master -class RepositoryStorageInterface(object): +class RepositoryStorageInterface(): def __iter__(self): raise StopIteration @@ -141,7 +141,7 @@ class RepositoryStorageSet(RepositoryStorageInterface): def __repr__(self): return "Repository set" -class Profile(object): +class Profile(): """ Профиль репозитория """ @@ -170,7 +170,7 @@ class Profile(object): self.repository.directory) -class ProfileRepository(object): +class ProfileRepository(): """ Репозиторий либо скачивается, либо берется из кэша """ diff --git a/pym/update/update.py b/pym/update/update.py index d2b0f3e..9f4eb17 100644 --- a/pym/update/update.py +++ b/pym/update/update.py @@ -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(r"^(\d+)\s*(hours?|days?|weeks?)?", re.I) + re_interval = re.compile("^(\d+)\s*(hours?|days?|weeks?)?", re.I) interval_match = re_interval.search(interval) MINUTE = 60 HOUR = MINUTE * 60 @@ -1487,7 +1487,7 @@ class Update(MethodsInterface): raise return True - class Reason(object): + class Reason(): Success = 0 BadSign = 1 Outdated = 2 diff --git a/pym/update/update_info.py b/pym/update/update_info.py index 962ce60..32c7a5d 100644 --- a/pym/update/update_info.py +++ b/pym/update/update_info.py @@ -23,7 +23,7 @@ from calculate.lib.utils.content import getCfgFiles from calculate.lib.utils.files import getRunCommands, readFile, writeFile -class UpdateInfo(object): +class UpdateInfo(): """ Информационный объект о процессе обновления """ diff --git a/pym/update/utils/cl_update.py b/pym/update/utils/cl_update.py index f139015..edf831f 100644 --- a/pym/update/utils/cl_update.py +++ b/pym/update/utils/cl_update.py @@ -213,7 +213,7 @@ def get_synchronization_tasks(object_name): }, ] -class UpdateConditions(object): +class UpdateConditions(): @staticmethod def was_installed(pkg, task_name): def func(): diff --git a/pym/update/variables/update.py b/pym/update/variables/update.py index 6d28dcb..8311dd6 100644 --- a/pym/update/variables/update.py +++ b/pym/update/variables/update.py @@ -935,7 +935,7 @@ class VariableClUpdateProfileUrl(Variable): r"^(?:(%s)://)?((?:git@)?\w[\w\./:-]+?\w)(\.git)?$" % "|".join( ["http", "https", "git", "ssh"])) - re_shortname = re.compile(r'^(?:([\w\.-]+):)?([\w\.-]+)$') + re_shortname = re.compile('^(?:([\w\.-]+):)?([\w\.-]+)$') @classmethod def normalize_url(cls, url):