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


Python OrangeGbl.dbAssetOpening方法代码示例

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


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

示例1: ParseGooglePlaces

# 需要导入模块: import OrangeGbl [as 别名]
# 或者: from OrangeGbl import dbAssetOpening [as 别名]

#.........这里部分代码省略.........
            url = d['url']
        else:
            url = ''
        
        # ---------------------------- INSERISCO L'ASSET
        AddrCity=AddrCounty=AddrZIP=AddrPhone=AddrPhone1=AddrWebsite=AddrLat=AddrLong=AddrRegion=FormattedAddress=AddrCountry=Address=''
        Asset = gL.dbAsset(country, assettype, gL.GoogleSource, nam, url, AAsset, pid)  # inserisco l'asset        
        if Asset == 0:
            return Asset
        rc = gL.dbAssetTag(Asset, tag, "Tipologia")
        rc = gL.dbAssetPrice(Asset, PriceList, gL.currency)
        
        AddrCounty = AddrStreet = AddrNumber = AddrRegion = AddrCity = AddrZIP = ""; 
        for component in d['address_components']:
            a = component['types']
            if a:
                if a[0] == "locality":             
                            AddrCity = component['long_name']     
                if a[0] == "route":             
                            AddrStreet = component['long_name']     
                if a[0] == "administrative_area_level_1":             
                            AddrRegion = component['long_name']     
                if a[0] == "administrative_area_level_2":             
                            AddrCounty = component['short_name']     
                if a[0] == "administrative_area_level_3":             
                            AddrCity = component['long_name']     
                if a[0] == "street_number":             
                            AddrNumber = component['long_name']     
                if a[0] == "postal_code":             
                            AddrZIP = component['long_name']     
    
        AddrStreet = AddrStreet + " " + AddrNumber                    
        if 'international_phone_number' in d:
            if d['international_phone_number']:
                AddrPhone = d['international_phone_number']
            elif d['formatted_phone_number']:
                AddPhone = d['formatted_phone_number']
        
        punt = 0; nreview = 0
        if 'rating' in d:
            punt = d['rating']        
            nreview = d['user_ratings_total']
        if 'website' in d:
            AddrWebsite = d['website']
        if 'geometry' in d:        
            AddrLat  = d['geometry']['location']['lat']
            AddrLong = d['geometry']['location']['lng']        

        AddrValidated = gL.NO
        FormattedAddress = d['formatted_address']
        AddrList = {'AddrStreet': AddrStreet,
            'AddrCity': AddrCity,
            'AddrCounty': AddrCounty,
            'AddrZIP': AddrZIP,
            'AddrPhone': AddrPhone,
            'AddrPhone1': '',
            'AddrWebsite': AddrWebsite,
            'AddrLat': AddrLat,
            'AddrLong': AddrLong,
            'AddrRegion': AddrRegion,
            'FormattedAddress': FormattedAddress,
            'AddrValidated': gL.YES,
            'AddrCountry': country,
            'Address': indirizzo}
        rc = gL.dbAssettAddress(Asset, AddrList) 
                   
        # gestione recensioni    
        if punt and nreview:            
            r = []
            r.append((int(nreview), int(punt)))
            rc = gL.dbAssetReview(Asset, r)
        
        # gestione orario
        if 'opening_hours' in d:        
            ope = d['opening_hours']['periods']
            #orario = namedtuple('orario', 'ggft')
            orario = []
            for item in ope:
                dayo = fro = dayc = to = '0000'
                if 'close' in item:
                    o = item['open']
                    if 'day' in o:
                        dayo = o['day']
                    if 'time' in o:
                        fro = o['time']
                if 'close' in item:
                    c = item['close']
                    if 'day' in c:
                        dayc = c['day']
                    if 'time' in c:
                        to = c['time']

                orario.append((dayo, fro, to))
            rc = gL.dbAssetOpening(Asset, orario)
    
    except Exception as err:        
        gL.log(gL.ERROR, (name + " " + indirizzo), err)
        return False

    return Asset
开发者ID:micheledalonzo,项目名称:Orange,代码行数:104,代码来源:OrangeParse.py


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