From 8dabc6e1870f6e9efe492dd0774ce3b736d47315 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Thu, 18 May 2017 13:50:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=87=D0=B0=D1=81=D1=82=D0=B8=D1=87=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D0=B0?= =?UTF-8?q?=20tar.xz.=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81=20?= =?UTF-8?q?layman/make.conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pym/calculate/lib/utils/files.py | 53 ++++++++++++++++++++++++- pym/calculate/lib/utils/portage.py | 6 +-- pym/calculate/lib/variables/__init__.py | 2 +- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/pym/calculate/lib/utils/files.py b/pym/calculate/lib/utils/files.py index 5b1ebef..5d72b81 100644 --- a/pym/calculate/lib/utils/files.py +++ b/pym/calculate/lib/utils/files.py @@ -1440,8 +1440,7 @@ def get_free_dirname(dn): """ Возвращает имя указанной директорий если оно отсутствует либо добавляются цифры - :param base_dn: - :param name: + :param dn: :return: """ if not path.exists(dn): @@ -1498,6 +1497,21 @@ def tar_directory(dn, archfile): except (IOError, OSError) as e: raise FilesError(_("Failed to create tarball: %s") % str(e)) +def tar_xz_directory(dn, archfile): + """ + Заархивировать указанную директорю в xz формате + :param dn: + :param archfile: + :return: + """ + try: + tar = "/bin/tar" + p = process(tar, "-cJf", archfile, "-C", dn, *listDirectory(dn)) + if p.failed(): + raise FilesError(_("Failed to create tarball: %s") + % str(p.readerr())) + except (IOError, OSError) as e: + raise FilesError(_("Failed to create tarball: %s") % str(e)) def tar_list(file_list, archfile, prefix='/'): """ @@ -1585,3 +1599,38 @@ def xz(data, decompress=False): return data else: raise FilesError(errors) + +class XZStreamRead(object): + """ + XZ объект для чтения данных для tarfile + """ + def __init__(self, data): + self._data = xz(data, decompress=True) + self.pos = 0 + + def tell(self): + return self.pos + + def seek(self, n=0): + self.pos = n + + def read(self, size=None): + if size is None: + try: + return self._data[self.pos:] + finally: + self.pos = len(self._data) + try: + return self._data[self.pos:self.pos+size] + finally: + self.pos += min(size,len(self._data)) + +@contextmanager +def xztaropen(fn): + f = None + try: + f = tarfile.TarFile(mode="r", fileobj=XZStreamRead(readFile(fn))) + yield f + finally: + if f: + f.close() diff --git a/pym/calculate/lib/utils/portage.py b/pym/calculate/lib/utils/portage.py index f7f15ae..07e7b58 100644 --- a/pym/calculate/lib/utils/portage.py +++ b/pym/calculate/lib/utils/portage.py @@ -419,8 +419,7 @@ class Layman(object): self._add_to_installed(rname, rurl) if self.is_new_layman(): self._add_to_laymanconf(rname, rurl, rpath) - else: - self._add_to_makeconf(rpath) + self._add_to_makeconf(rpath) return True def _remove_from_installed(self, rname): @@ -450,8 +449,7 @@ class Layman(object): self._remove_from_installed(rname) if self.is_new_layman(): self._remove_from_laymanconf(rname) - else: - self._remove_from_makeconf(rpath) + self._remove_from_makeconf(rpath) return True def get_installed(self): diff --git a/pym/calculate/lib/variables/__init__.py b/pym/calculate/lib/variables/__init__.py index 7fb1628..500f2c4 100644 --- a/pym/calculate/lib/variables/__init__.py +++ b/pym/calculate/lib/variables/__init__.py @@ -41,4 +41,4 @@ class VariableClVer(ReadonlyVariable): """ Package version """ - value = "3.5.4" + value = "3.5.4.1"