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

Python compat.iteritems函数代码示例

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

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



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

示例1: update_config

def update_config(conf, overwrites):
    wildcard_keys = []
    for k, v in iteritems(overwrites):
        if k == '__all__':
            continue
        if  k.startswith('___') or k.endswith('___'):
            wildcard_keys.append(k)
            continue

        if k.endswith('__extend__'):
            k = k[:-len('__extend__')]
            if k not in conf:
                conf[k] = v
            elif isinstance(v, list):
                conf[k].extend(v)
            else:
                raise ValueError('cannot extend non-list:', v)
        elif k not in conf:
            conf[k] = copy(v)
        else:
            if isinstance(conf[k], dict) and isinstance(v, dict):
                conf[k] = update_config(conf[k], v)
            else:
                conf[k] = copy(v)

    if '__all__' in overwrites:
        v = overwrites['__all__']
        for conf_k, conf_v in iteritems(conf):
            if isinstance(conf_v, dict):
                conf[conf_k] = update_config(conf_v, v)
            else:
                conf[conf_k] = v

    if wildcard_keys:
        for key in wildcard_keys:
            v = overwrites[key]
            if key.startswith('___'):
                key = key[3:]
                key_check = lambda x: x.endswith(key)
            else:
                key = key[:-3]
                key_check = lambda x: x.startswith(key)
            for conf_k, conf_v in iteritems(conf):
                if not key_check(conf_k):
                    continue
                if isinstance(conf_v, dict):
                    conf[conf_k] = update_config(conf_v, v)
                else:
                    conf[conf_k] = v

    return conf
开发者ID:Geodan,项目名称:mapproxy,代码行数:51,代码来源:utils.py


示例2: is_cached

 def is_cached(self, tile):
     if tile.source or tile.coord is None:
         return True
     for bundle_file, bundle_tiles in iteritems(self._get_bundle_tiles([tile])):
         with BundleDataV2(bundle_file) as bundledata:
             for tile in bundle_tiles:
                 return bundledata.tile_size(tile.coord) != 0
开发者ID:tjay,项目名称:mapproxy,代码行数:7,代码来源:compact.py


示例3: adapt_params_to_version

 def adapt_params_to_version(self):
     params = self.params.copy()
     for key, value in iteritems(self.fixed_params):
         params[key] = value
     if 'styles' not in params:
         params['styles'] = ''
     return params
开发者ID:kaiCu,项目名称:mapproxy,代码行数:7,代码来源:__init__.py


示例4: __repr__

 def __repr__(self):
     items = [
         (k, v) for k, v in iteritems(self)]
     items.sort()
     return '<%s %s>' % (
         self.__class__.__name__,
         ' '.join(['%s=%r' % (k, v) for k, v in items]))
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:7,代码来源:__init__.py


示例5: remove_tile

 def remove_tile(self, tile):
     if tile.coord is None:
         return True
     for bundle_file, bundle_tiles in iteritems(self._get_bundle_tiles([tile])):
         with BundleDataV2(bundle_file, mode="write") as bundledata:
             for tile in bundle_tiles:
                 return bundledata.remove_tile(tile)
开发者ID:tjay,项目名称:mapproxy,代码行数:7,代码来源:compact.py


示例6: restart_with_reloader

def restart_with_reloader():
    """Spawn a new Python interpreter with the same arguments as this one,
    but running the reloader thread.
    """
    while 1:
        _log('info', ' * Restarting with reloader')

        args = [sys.executable] + sys.argv
        # pip installs commands as .exe, but sys.argv[0]
        # can miss the prefix. add .exe to avoid file-not-found
        # in subprocess call
        if os.name == 'nt' and '.' not in args[1]:
            args[1] = args[1] + '.exe'

        new_environ = os.environ.copy()
        new_environ['WERKZEUG_RUN_MAIN'] = 'true'

        # a weird bug on windows. sometimes unicode strings end up in the
        # environment and subprocess.call does not like this, encode them
        # to latin1 and continue.
        if os.name == 'nt' and PY2:
            for key, value in iteritems(new_environ):
                if isinstance(value, text_type):
                    new_environ[key] = value.encode('iso-8859-1')

        exit_code = subprocess.call(args, env=new_environ)
        if exit_code != 3:
            return exit_code
开发者ID:Geodan,项目名称:mapproxy,代码行数:28,代码来源:serving.py


示例7: layer_srs_bbox

    def layer_srs_bbox(self, layer, epsg_axis_order=False):
        for srs, extent in iteritems(self.srs_extents):
            # is_default is True when no explicit bbox is defined for this srs
            # use layer extent
            if extent.is_default:
                bbox = layer.extent.bbox_for(SRS(srs))
            elif layer.extent.is_default:
                bbox = extent.bbox_for(SRS(srs))
            else:
                # Use intersection of srs_extent and layer.extent.
                bbox = extent.intersection(layer.extent).bbox_for(SRS(srs))

            if epsg_axis_order:
                bbox = switch_bbox_epsg_axis_order(bbox, srs)

            if srs in self.srs:
                yield srs, bbox

        # add native srs
        layer_srs_code = layer.extent.srs.srs_code
        if layer_srs_code not in self.srs_extents:
            bbox = layer.extent.bbox
            if epsg_axis_order:
                bbox = switch_bbox_epsg_axis_order(bbox, layer_srs_code)
            if layer_srs_code in self.srs:
                yield layer_srs_code, bbox
开发者ID:drnextgis,项目名称:mapproxy,代码行数:26,代码来源:wms.py


示例8: print_layers

    def print_layers(self, capabilities, indent=None, root=False):
        if root:
            print("# Note: This is not a valid MapProxy configuration!")
            print('Capabilities Document Version %s' % (self.version,))
            print('Root-Layer:')
            layer_list = capabilities.layers()['layers']
        else:
            layer_list = capabilities['layers']

        indent = indent or self.indent
        for layer in layer_list:
            marked_first = False
            # print ordered items first
            for item in self.print_order:
                if layer.get(item, False):
                    if not marked_first:
                        marked_first = True
                        self._format_output(item, layer[item], indent, mark_first=marked_first)
                    else:
                        self._format_output(item, layer[item], indent)
            # print remaining items except sublayers
            for key, value in iteritems(layer):
                if key in self.print_order or key == 'layers':
                    continue
                self._format_output(key, value, indent)
            # print the sublayers now
            if layer.get('layers', False):
                self.print_line(indent, 'layers')
                self.print_layers(layer, indent=indent+self.indent)
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:29,代码来源:wms_capabilities.py


示例9: load_base_config

def load_base_config(config_file=None, clear_existing=False):
    """
    Load system wide base configuration.

    :param config_file: the file name of the mapproxy.yaml configuration.
                        if ``None``, load the internal proxylib/default.yaml conf
    :param clear_existing: if ``True`` remove the existing configuration settings,
                           else overwrite the settings.
    """

    if config_file is None:
        from mapproxy.config import defaults
        config_dict = {}
        for k, v in iteritems(defaults.__dict__):
            if k.startswith('_'): continue
            config_dict[k] = v
        conf_base_dir = os.getcwd()
        load_config(base_config(), config_dict=config_dict, clear_existing=clear_existing)
    else:
        conf_base_dir = os.path.abspath(os.path.dirname(config_file))
        load_config(base_config(), config_file=config_file, clear_existing=clear_existing)

    bc = base_config()
    finish_base_config(bc)

    bc.conf_base_dir = conf_base_dir
开发者ID:LKajan,项目名称:mapproxy,代码行数:26,代码来源:config.py


示例10: restart_with_reloader

def restart_with_reloader():
    """Spawn a new Python interpreter with the same arguments as this one,
    but running the reloader thread.
    """
    while 1:
        _log('info', ' * Restarting with reloader')

        args = [sys.executable] + sys.argv
        if os.name == 'nt':
            # pip installs commands as .exe, but sys.argv[0]
            # can miss the prefix.
            # Add .exe to avoid file-not-found in subprocess call.
            # Also, recent pip versions create .exe commands that are not
            # executable by Python, but there is a -script.py which
            # we need to call in this case. Check for this first.
            if os.path.exists(args[1] + '-script.py'):
                args[1] = args[1] + '-script.py'
            elif not args[1].endswith('.exe'):
                args[1] = args[1] + '.exe'
        new_environ = os.environ.copy()
        new_environ['WERKZEUG_RUN_MAIN'] = 'true'

        # a weird bug on windows. sometimes unicode strings end up in the
        # environment and subprocess.call does not like this, encode them
        # to latin1 and continue.
        if os.name == 'nt' and PY2:
            for key, value in iteritems(new_environ):
                if isinstance(value, text_type):
                    new_environ[key] = value.encode('iso-8859-1')

        exit_code = subprocess.call(args, env=new_environ)
        if exit_code != 3:
            return exit_code
开发者ID:olt,项目名称:mapproxy,代码行数:33,代码来源:serving.py


示例11: __getitem__

 def __getitem__(self, key):
     if self.defaults is None:
         defaults = {}
         for epsg, bbox in iteritems(self._defaults):
             defaults[SRS(epsg)] = bbox
         self.defaults = defaults
     return self.defaults[key]
开发者ID:tjay,项目名称:mapproxy,代码行数:7,代码来源:grid.py


示例12: __init__

 def __init__(self, seed_conf, mapproxy_conf):
     self.conf = seed_conf
     self.mapproxy_conf = mapproxy_conf
     self.grids = bidict((name, grid_conf.tile_grid()) for name, grid_conf in iteritems(self.mapproxy_conf.grids))
     self.seed_tasks = []
     self.cleanup_tasks = []
     self._init_tasks()
开发者ID:Geodan,项目名称:mapproxy,代码行数:7,代码来源:config.py


示例13: seed_tasks

    def seed_tasks(self):
        for grid_name in self.grids:
            for cache_name, cache in iteritems(self.caches):
                tile_manager = cache[grid_name]
                grid = self.seeding_conf.grids[grid_name]
                if self.coverage is False:
                    coverage = False
                elif self.coverage:
                    coverage = self.coverage.transform_to(grid.srs)
                else:
                    coverage = BBOXCoverage(grid.bbox, grid.srs)

                try:
                    if coverage is not False:
                        coverage.extent.llbbox
                except TransformationError:
                    raise SeedConfigurationError('%s: coverage transformation error' % self.name)

                if self.levels:
                    levels = self.levels.for_grid(grid)
                else:
                    levels = list(range(0, grid.levels))

                if not tile_manager.cache.supports_timestamp:
                    if self.refresh_timestamp:
                        # remove everything
                        self.refresh_timestamp = 0

                md = dict(name=self.name, cache_name=cache_name, grid_name=grid_name)
                yield SeedTask(md, tile_manager, levels, self.refresh_timestamp, coverage)
开发者ID:Geodan,项目名称:mapproxy,代码行数:30,代码来源:config.py


示例14: adapt_params_to_version

 def adapt_params_to_version(self):
     params = self.params.copy()
     for key, value in iteritems(self.fixed_params):
         params[key] = value
     if "styles" not in params:
         params["styles"] = ""
     return params
开发者ID:TNRIS,项目名称:mapproxy,代码行数:7,代码来源:__init__.py


示例15: fixed_headers

 def fixed_headers(self):
     headers = []
     for key, value in iteritems(self.headers):
         if PY2 and isinstance(value, unicode):
             value = value.encode('utf-8')
         headers.append((key, value))
     return headers
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:7,代码来源:response.py


示例16: needs_reload

 def needs_reload(self, app_name, timestamps):
     if not timestamps:
         return True
     for conf_file, timestamp in iteritems(timestamps):
         m_time = os.path.getmtime(conf_file)
         if m_time > timestamp:
             return True
     return False
开发者ID:LKajan,项目名称:mapproxy,代码行数:8,代码来源:multiapp.py


示例17: check_request_dimensions

 def check_request_dimensions(self, tile_layer, request):
     # check that unknown dimension for this layer are set to default
     if request.dimensions:
         for dimension, value in iteritems(request.dimensions):
             dimension = dimension.lower()
             if dimension not in tile_layer.dimensions and value != 'default':
                 raise RequestError('unknown dimension: ' + str(dimension),
                     code='InvalidParameterValue', request=request)
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:8,代码来源:wmts.py


示例18: caches

def caches(cap, sources, srs_grids):
    caches = {}
    for name, source in iteritems(sources):
        conf = for_source(name, source, srs_grids)
        if not conf:
            continue
        caches[name[:-len('_wms')] + '_cache'] = conf

    return caches
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:9,代码来源:caches.py


示例19: _format_output

 def _format_output(self, key, value, indent, mark_first=False):
     if key == 'bbox':
         self.print_line(indent, key)
         for srs_code, bbox in iteritems(value):
             self.print_line(indent+self.indent, srs_code, value=bbox, mark_first=mark_first)
     else:
         if isinstance(value, set):
             value = list(value)
         self.print_line(indent, key, value=value, mark_first=mark_first)
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:9,代码来源:wms_capabilities.py


示例20: __init__

 def __init__(self, attributes):
     self.attributes = attributes
     for key, value in iteritems(attributes):
         if value == '{{timestamp}}':
             self.timestamp_key = key
             break
     else:
         attributes['timestamp'] = '{{timestamp}}'
         self.timestamp_key = 'timestamp'
开发者ID:Geodan,项目名称:mapproxy,代码行数:9,代码来源:couchdb.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python image.Image类代码示例发布时间:2022-05-27
下一篇:
Python tile.TileManager类代码示例发布时间: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