本文整理匯總了Python中OrangeGbl.dbAsset方法的典型用法代碼示例。如果您正苦於以下問題:Python OrangeGbl.dbAsset方法的具體用法?Python OrangeGbl.dbAsset怎麽用?Python OrangeGbl.dbAsset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OrangeGbl
的用法示例。
在下文中一共展示了OrangeGbl.dbAsset方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ParseContent
# 需要導入模塊: import OrangeGbl [as 別名]
# 或者: from OrangeGbl import dbAsset [as 別名]
def ParseContent(country, assettype, source, starturl, asseturl, name):
if gL.trace: gL.log(gL.DEBUG)
try:
Asset = gL.dbAsset(country, assettype, source, name, asseturl) # inserisco l'asset
if Asset == 0:
raise Exception("Errore nella creazione dell'asset")
fn = gL.GetFunzione("PARSE", source, assettype, country)
if not fn:
raise Exception("Funzione PARSE non trovata")
rc = globals()[fn](country, asseturl, name, Asset)
if rc:
return Asset
else:
raise Exception("Funzione PARSE con errori")
except Exception as err:
gL.log(gL.ERROR, err)
return False
示例2: ParseGooglePlaces
# 需要導入模塊: import OrangeGbl [as 別名]
# 或者: from OrangeGbl import dbAsset [as 別名]
#.........這裏部分代碼省略.........
PriceTo = 25
if prz == 3:
PriceFrom = 26
PriceTo = 60
if prz == 4:
PriceFrom = 60
PriceTo = 100
PriceList = [['PriceCurr', gL.currency],
['PriceFrom', PriceFrom],
['PriceTo', PriceTo]]
# chiedo il dettaglio
detailurl = 'https://maps.googleapis.com/maps/api/place/details/json'
params = dict(
placeid = pid,
key = API_KEY,
language='it',
#types='cafe|reastaurant|bakery|bar|food|meal_takeaway'
)
response = requests.get(url=detailurl, params=params)
data2 = json.loads(response.text)
if data2['status'] != 'OK':
gL.log(gL.WARNING, "GooglePlaces Status " + data['status'])
return False
d = data2['result']
if d['url']:
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