当前位置: 首页>>代码示例>>Python>>正文


Python Catalog.close方法代码示例

本文整理汇总了Python中catalog.Catalog.close方法的典型用法代码示例。如果您正苦于以下问题:Python Catalog.close方法的具体用法?Python Catalog.close怎么用?Python Catalog.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在catalog.Catalog的用法示例。


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

示例1: run

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import close [as 别名]
    def run(self):
        condition=self.condition
        path=self.path
        end_cb=self.query_end_cb
        while(True):

            condition.acquire()
            try:
                while not self.query:
                    condition.wait()
                q=self.query
                self.query=""
            finally:
                condition.release()

            def cb(catalog, entry):
                return self.catalog_cb(q, catalog, entry)

            catalog=Catalog(path)
            try:
                print "run query: "+q
                catalog.query(q, cb)
                end_cb(q)
            finally:
                catalog.close()
开发者ID:BackupTheBerlios,项目名称:ocha-svn,代码行数:27,代码来源:ui.py

示例2: __init__

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import close [as 别名]
class Area:
    image_url = IMAGE_URL
    buffer = 10
    save_attrs = ["code", "area_type", "attrs", "image_path", "center", "extent", "image_extent", "width", "height"]

    def __init__(self, code="", area_type=1, epsilon=5, media_path="", with_log=True, catalog="",
                 coord_out="EPSG:3857", center_only=False, with_proxy=False):
        self.with_log = with_log
        self.area_type = area_type
        self.media_path = media_path
        self.image_url = ""
        self.xy = []  # [[[area1], [hole1], [holeN]], [[area2]]]
        self.image_xy_corner = []  # cartesian coord from image, for draw plot
        self.width = 0
        self.height = 0
        self.image_path = ""
        self.extent = {}
        self.image_extent = {}
        self.center = {'x': None, 'y': None}
        self.center_only = center_only
        self.attrs = {}
        self.epsilon = epsilon
        self.code = code
        self.code_id = ""
        self.file_name = self.code[:].replace(":", "_")
        self.with_proxy = with_proxy

        self.coord_out = coord_out

        t = string.Template(SEARCH_URL)
        self.search_url = t.substitute({"area_type": area_type})
        t = string.Template(FEATURE_INFO_URL)
        self.feature_info_url = t.substitute({"area_type": area_type})
        
        if not self.media_path:
            # self.media_path = os.path.dirname(os.path.realpath(__file__))
            self.media_path = os.getcwd()
        if not os.path.isdir(self.media_path):
            os.makedirs(self.media_path)
        if catalog:
            self.catalog = Catalog(catalog)
            restore = self.catalog.find(self.code)
            if restore:
                self.restore(restore)
                self.log("%s - restored from %s" % (self.code, catalog))
                return
        if not code:
            return

        feature_info = self.download_feature_info()
        if feature_info:
            geometry = self.get_geometry()
            if catalog and geometry:
                self.catalog.update(self)
                self.catalog.close()
        else:
            self.log("Nothing found")


    def restore(self, restore):
        for a in self.save_attrs:
            setattr(self, a, restore[a])
        if self.coord_out:
            setattr(self, "coord_out", self.coord_out)
        setattr(self, "code_id", self.code)
        self.get_geometry()
        self.file_name = self.code.replace(":", "_")

    def get_coord(self):
        if self.xy:
            return self.xy
        center = self.get_center_xy()
        if center:
            return center
        return []

    def get_attrs(self):
        return self.attrs

    def _get_attrs_to_geojson(self):
        if self.attrs:
            for a in self.attrs:
                attr = self.attrs[a]
                if isinstance(attr, basestring):
                    try:
                        attr = attr.encode('utf-8').strip()
                        self.attrs[a] = attr
                    except:
                        pass
        return self.attrs

    def to_geojson_poly(self, with_attrs=False, dumps=True):
        return self.to_geojson("polygon", with_attrs, dumps)

    def to_geojson_center(self, with_attrs=False, dumps=True):
        current_center_status = self.center_only
        self.center_only = True
        to_return = self.to_geojson("point", with_attrs, dumps)
        self.center_only = current_center_status
        return to_return
#.........这里部分代码省略.........
开发者ID:rendrom,项目名称:rosreestr2coord,代码行数:103,代码来源:parser.py


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