• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python config.base_config函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mapproxy.config.base_config函数的典型用法代码示例。如果您正苦于以下问题:Python base_config函数的具体用法?Python base_config怎么用?Python base_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了base_config函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _init_proj

def _init_proj():
    global _proj_initalized
    if not _proj_initalized and 'proj_data_dir' in base_config().srs:
        proj_data_dir = base_config().srs['proj_data_dir']
        log_system.info('loading proj data from %s', proj_data_dir)
        set_datapath(proj_data_dir)
        _proj_initalized = True
开发者ID:LKajan,项目名称:mapproxy,代码行数:7,代码来源:srs.py


示例2: img_to_buf

def img_to_buf(img, image_opts):
    defaults = {}

    if image_opts.mode and img.mode[0] == "I" and img.mode != image_opts.mode:
        img = img.convert(image_opts.mode)

    if image_opts.colors is None and base_config().image.paletted and image_opts.format.endswith("png"):
        # force 255 colors for png with globals.image.paletted
        image_opts = image_opts.copy()
        image_opts.colors = 255

    if image_opts.colors:
        quantizer = None
        if "quantizer" in image_opts.encoding_options:
            quantizer = image_opts.encoding_options["quantizer"]

        if image_opts.transparent:
            img = quantize(img, colors=image_opts.colors, alpha=True, defaults=defaults, quantizer=quantizer)
        else:
            img = quantize(img, colors=image_opts.colors, quantizer=quantizer)
        if hasattr(Image, "RLE"):
            defaults["compress_type"] = Image.RLE
    format = filter_format(image_opts.format.ext)
    buf = StringIO()
    if format == "jpeg":
        img = img.convert("RGB")
        if "jpeg_quality" in image_opts.encoding_options:
            defaults["quality"] = image_opts.encoding_options["jpeg_quality"]
        else:
            defaults["quality"] = base_config().image.jpeg_quality
    img.save(buf, format, **defaults)
    buf.seek(0)
    return buf
开发者ID:atrawog,项目名称:mapproxy,代码行数:33,代码来源:__init__.py


示例3: test_defaults

    def test_defaults(self):
        with TempFiles() as tmp:
            with open(tmp[0], 'wb') as f:
                f.write(TestDefaultsLoading.defaults_yaml)
            load_base_config(config_file=tmp[0], clear_existing=True)

            assert base_config().biz == 'foobar'
            assert base_config().wiz == 'foobar'
            assert base_config().foo.bar.ham == 2
            assert base_config().foo.bar.eggs == 4
            assert not hasattr(base_config(), 'wms')
开发者ID:LKajan,项目名称:mapproxy,代码行数:11,代码来源:test_config.py


示例4: img_to_buf

def img_to_buf(img, image_opts):
    defaults = {}
    image_opts = image_opts.copy()

    # convert I or L images to target mode
    if image_opts.mode and img.mode[0] in ('I', 'L') and img.mode != image_opts.mode:
        img = img.convert(image_opts.mode)

    if (image_opts.colors is None and base_config().image.paletted
        and image_opts.format.endswith('png')):
        # force 255 colors for png with globals.image.paletted
        image_opts.colors = 255

    format = filter_format(image_opts.format.ext)
    if format == 'mixed':
        if img_has_transparency(img):
            format = 'png'
        else:
            format = 'jpeg'
            image_opts.colors = None
            image_opts.transparent = False

    # quantize if colors is set, but not if we already have a paletted image
    if image_opts.colors and not (img.mode == 'P' and len(img.getpalette()) == image_opts.colors*3):
        quantizer = None
        if 'quantizer' in image_opts.encoding_options:
            quantizer = image_opts.encoding_options['quantizer']
        if image_opts.transparent:
            img = quantize(img, colors=image_opts.colors, alpha=True,
                defaults=defaults, quantizer=quantizer)
        else:
            img = quantize(img, colors=image_opts.colors,
                quantizer=quantizer)
        if hasattr(Image, 'RLE'):
            defaults['compress_type'] = Image.RLE

    buf = BytesIO()
    if format == 'jpeg':
        img = img.convert('RGB')
        if 'jpeg_quality' in image_opts.encoding_options:
            defaults['quality'] = image_opts.encoding_options['jpeg_quality']
        else:
            defaults['quality'] = base_config().image.jpeg_quality

    # unsupported transparency tuple can still be in non-RGB img.infos
    # see: https://github.com/python-pillow/Pillow/pull/2633
    if format == 'png' and img.mode != 'RGB' and 'transparency' in img.info and isinstance(img.info['transparency'], tuple):
        del img.info['transparency']

    img.save(buf, format, **defaults)
    buf.seek(0)
    return buf
开发者ID:olt,项目名称:mapproxy,代码行数:52,代码来源:__init__.py


示例5: test_base_config

    def test_base_config(self):
        # test that all concurrent have access to their
        # local base_config
        from mapproxy.config import base_config
        from mapproxy.config import local_base_config
        from copy import deepcopy

        # make two separate base_configs
        conf1 = deepcopy(base_config())
        conf1.conf = 1
        conf2 = deepcopy(base_config())
        conf2.conf = 2
        base_config().bar = 'baz'

        # run test in parallel, check1 and check2 should interleave
        # each with their local conf

        error_occured = False

        def check1(x):
            global error_occured
            if base_config().conf != 1 or 'bar' in base_config():
                error_occured = True

        def check2(x):
            global error_occured
            if base_config().conf != 2 or 'bar' in base_config():
                error_occured = True

        assert 'bar' in base_config()

        def test1():
            with local_base_config(conf1):
                pool1 = ThreadPool(5)
                list(pool1.imap(check1, range(200)))

        def test2():
            with local_base_config(conf2):
                pool2 = ThreadPool(5)
                list(pool2.imap(check2, range(200)))

        t1 = threading.Thread(target=test1)
        t2 = threading.Thread(target=test2)
        t1.start()
        t2.start()
        t1.join()
        t2.join()
        assert not error_occured
        assert 'bar' in base_config()
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:49,代码来源:test_async.py


示例6: test_user_srs_definitions

    def test_user_srs_definitions(self):
        user_yaml = b"""
        srs:
          axis_order_ne: ['EPSG:9999']
        """
        with TempFiles() as tmp:
            with open(tmp[0], 'wb') as f:
                f.write(user_yaml)

            load_base_config(config_file=tmp[0])

            assert 'EPSG:9999' in base_config().srs.axis_order_ne
            assert 'EPSG:9999' not in base_config().srs.axis_order_en

            #defaults still there
            assert 'EPSG:31468' in base_config().srs.axis_order_ne
            assert 'CRS:84' in base_config().srs.axis_order_en
开发者ID:LKajan,项目名称:mapproxy,代码行数:17,代码来源:test_config.py


示例7: font_file

def font_file(font_name):
    font_dir = base_config().image.font_dir
    if font_dir:
        abspath(font_dir)
    else:
        font_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'fonts')
    font_name = font_name.replace(' ', '')
    path = os.path.join(font_dir, font_name + '.ttf')
    return path
开发者ID:atrawog,项目名称:mapproxy,代码行数:9,代码来源:message.py


示例8: font_file

def font_file(font_name):
    font_dir = base_config().image.font_dir
    font_name = font_name.replace(' ', '')
    if font_dir:
        abspath(font_dir)
        path = os.path.join(font_dir, font_name + '.ttf')
    else:
        path = pkg_resources.resource_filename(__name__, 'fonts/' + font_name + '.ttf')
    return path
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:9,代码来源:message.py


示例9: img_to_buf

def img_to_buf(img, image_opts):
    defaults = {}
    image_opts = image_opts.copy()
    if image_opts.mode and img.mode[0] == 'I' and img.mode != image_opts.mode:
        img = img.convert(image_opts.mode)

    if (image_opts.colors is None and base_config().image.paletted
        and image_opts.format.endswith('png')):
        # force 255 colors for png with globals.image.paletted
        image_opts.colors = 255

    format = filter_format(image_opts.format.ext)
    if format == 'mixed':
        if img_has_transparency(img):
            format = 'png'
        else:
            format = 'jpeg'
            image_opts.colors = None
            image_opts.transparent = False

    if image_opts.colors:
        quantizer = None
        if 'quantizer' in image_opts.encoding_options:
            quantizer = image_opts.encoding_options['quantizer']
        if image_opts.transparent:
            img = quantize(img, colors=image_opts.colors, alpha=True,
                defaults=defaults, quantizer=quantizer)
        else:
            img = quantize(img, colors=image_opts.colors,
                quantizer=quantizer)
        if hasattr(Image, 'RLE'):
            defaults['compress_type'] = Image.RLE

    buf = StringIO()
    if format == 'jpeg':
        img = img.convert('RGB')
        if 'jpeg_quality' in image_opts.encoding_options:
            defaults['quality'] = image_opts.encoding_options['jpeg_quality']
        else:
            defaults['quality'] = base_config().image.jpeg_quality
    img.save(buf, format, **defaults)
    buf.seek(0)
    return buf
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:43,代码来源:__init__.py


示例10: __init__

 def __init__(self, task, worker_class, size=2, dry_run=False, progress_logger=None):
     self.tiles_queue = queue_class(size)
     self.task = task
     self.dry_run = dry_run
     self.procs = []
     self.progress_logger = progress_logger
     conf = base_config()
     for _ in xrange(size):
         worker = worker_class(self.task, self.tiles_queue, conf)
         worker.start()
         self.procs.append(worker)
开发者ID:atrawog,项目名称:mapproxy,代码行数:11,代码来源:seeder.py


示例11: is_axis_order_ne

    def is_axis_order_ne(self):
        """
        Returns `True` if the axis order is North, then East
        (i.e. y/x or lat/lon).

        >>> SRS(4326).is_axis_order_ne
        True
        >>> SRS('CRS:84').is_axis_order_ne
        False
        >>> SRS(31468).is_axis_order_ne
        True
        >>> SRS(31463).is_axis_order_ne
        False
        >>> SRS(25831).is_axis_order_ne
        False
        """
        if self.srs_code in base_config().srs.axis_order_ne:
            return True
        if self.srs_code in base_config().srs.axis_order_en:
            return False
        if self.is_latlong:
            return True
        return False
开发者ID:LKajan,项目名称:mapproxy,代码行数:23,代码来源:srs.py


示例12: test_defaults_overwrite

    def test_defaults_overwrite(self):
        with TempFiles(2) as tmp:
            with open(tmp[0], 'wb') as f:
                f.write(TestDefaultsLoading.defaults_yaml)
            with open(tmp[1], 'wb') as f:
                f.write(b"""
                baz: [9, 2, 1, 4]
                biz: 'barfoo'
                foo:
                    bar:
                        eggs: 5
                """)

            load_base_config(config_file=tmp[0], clear_existing=True)
            load_base_config(config_file=tmp[1])

            assert base_config().biz == 'barfoo'
            assert base_config().wiz == 'foobar'
            assert base_config().baz == [9, 2, 1, 4]
            assert base_config().foo.bar.ham == 2
            assert base_config().foo.bar.eggs == 5
            assert not hasattr(base_config(), 'wms')
开发者ID:LKajan,项目名称:mapproxy,代码行数:22,代码来源:test_config.py


示例13: __init__

 def __init__(self, task_queue, result_queue):
     threading.Thread.__init__(self)
     self.task_queue = task_queue
     self.result_queue = result_queue
     self.base_config = base_config()
开发者ID:ChrisRenton,项目名称:mapproxy,代码行数:5,代码来源:async.py


示例14: teardown

 def teardown(self):
     srs._proj_initalized = False
     srs._srs_cache = {}
     base_config().srs.proj_data_dir = None
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:4,代码来源:test_srs.py


示例15: check2

 def check2(x):
     global error_occured
     if base_config().conf != 2 or 'bar' in base_config():
         error_occured = True
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:4,代码来源:test_async.py


示例16: setup

 def setup(self):
     srs._proj_initalized = False
     srs._srs_cache = {}
     base_config().srs.proj_data_dir = os.path.dirname(__file__)
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:4,代码来源:test_srs.py



注:本文中的mapproxy.config.base_config函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python loader.load_configuration函数代码示例发布时间:2022-05-27
下一篇:
Python image.Image类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap