コード例 #1
0
ファイル: test_shutil.py プロジェクト: plirof/minibloq_v0.83
    def test_register_archive_format(self):

        self.assertRaises(TypeError, register_archive_format, "xxx", 1)
        self.assertRaises(TypeError, register_archive_format, "xxx", lambda: x, 1)
        self.assertRaises(TypeError, register_archive_format, "xxx", lambda: x, [(1, 2), (1, 2, 3)])

        register_archive_format("xxx", lambda: x, [(1, 2)], "xxx file")
        formats = [name for name, params in get_archive_formats()]
        self.assertIn("xxx", formats)

        unregister_archive_format("xxx")
        formats = [name for name, params in get_archive_formats()]
        self.assertNotIn("xxx", formats)
コード例 #2
0
    def test_make_archive_cwd(self):
        current_dir = os.getcwd()
        def _breaks(*args, **kw):
            raise RuntimeError()

        register_archive_format('xxx', _breaks, [], 'xxx file')
        try:
            try:
                make_archive('xxx', 'xxx', root_dir=self.mkdtemp())
            except Exception:
                pass
            self.assertEqual(os.getcwd(), current_dir)
        finally:
            unregister_archive_format('xxx')
コード例 #3
0
ファイル: test_shutil.py プロジェクト: zgpxgame/kbengine
    def test_register_archive_format(self):

        self.assertRaises(TypeError, register_archive_format, 'xxx', 1)
        self.assertRaises(TypeError, register_archive_format, 'xxx', lambda: x,
                          1)
        self.assertRaises(TypeError, register_archive_format, 'xxx', lambda: x,
                          [(1, 2), (1, 2, 3)])

        register_archive_format('xxx', lambda: x, [(1, 2)], 'xxx file')
        formats = [name for name, params in get_archive_formats()]
        self.assertIn('xxx', formats)

        unregister_archive_format('xxx')
        formats = [name for name, params in get_archive_formats()]
        self.assertNotIn('xxx', formats)
コード例 #4
0
ファイル: test_shutil.py プロジェクト: ashleyh/mypy
    def test_make_archive_cwd(self) -> None:
        current_dir = os.getcwd()

        def _breaks(*args: Any, **kw: Any) -> Any:
            raise RuntimeError()

        register_archive_format("xxx", _breaks, [], "xxx file")
        try:
            try:
                make_archive("xxx", "xxx", root_dir=self.mkdtemp())
            except Exception:
                pass
            self.assertEqual(os.getcwd(), current_dir)
        finally:
            unregister_archive_format("xxx")
コード例 #5
0
ファイル: test_shutil.py プロジェクト: ChaiYuanUMN/mypy
    def test_register_archive_format(self) -> None:

        self.assertRaises(TypeError, register_archive_format, 'xxx', 1)
        self.assertRaises(TypeError, register_archive_format, 'xxx',
                          lambda: 1/0,
                          1)
        self.assertRaises(TypeError, register_archive_format, 'xxx',
                          lambda: 1/0,
                          [(1, 2), (1, 2, 3)])

        register_archive_format('xxx', lambda: 1/0, [('x', 2)], 'xxx file')
        formats = [name for name, params in get_archive_formats()]
        self.assertIn('xxx', formats)

        unregister_archive_format('xxx')
        formats = [name for name, params in get_archive_formats()]
        self.assertNotIn('xxx', formats)
コード例 #6
0
from tempfile import TemporaryDirectory
from time import time
from zipfile import ZipFile
from re import match, search

from cdflow_commands.constants import (
    CONFIG_BASE_PATH, INFRASTRUCTURE_DEFINITIONS_PATH,
    PLATFORM_CONFIG_BASE_PATH, RELEASE_METADATA_FILE, TERRAFORM_BINARY,
    ACCOUNT_SCHEME_FILE
)
from cdflow_commands.logger import logger
from cdflow_commands.process import check_call
from cdflow_commands.zip_patch import _make_zipfile


shutil.unregister_archive_format('zip')
shutil.register_archive_format('zip', _make_zipfile)


@contextmanager
def fetch_release(
    boto_session, account_scheme, team_name, component_name, version,
):
    if account_scheme.classic_metadata_handling:
        release_key = format_release_key_classic(component_name, version)
    else:
        release_key = format_release_key(team_name, component_name, version)
    release_archive = download_release(
        boto_session, account_scheme.release_bucket, release_key,
    )
    with TemporaryDirectory(prefix='{}/release-{}'.format(getcwd(), time())) \
コード例 #7
0
import shutil

print('--before--')
for name, description in shutil.get_archive_formats():
    print('%-5s: %s' % (name, description))

shutil.unregister_archive_format('bztar')

print('--after--')
for name, description in shutil.get_archive_formats():
    print('%-5s: %s' % (name, description))
コード例 #8
0
ファイル: nodes.py プロジェクト: xxoolm/Ryven
 def update_event(self, inp=-1):
     self.set_output_val(0, shutil.unregister_archive_format(self.input(0)))