本文整理汇总了Python中portalpy.Portal.search方法的典型用法代码示例。如果您正苦于以下问题:Python Portal.search方法的具体用法?Python Portal.search怎么用?Python Portal.search使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portalpy.Portal
的用法示例。
在下文中一共展示了Portal.search方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user_group_item_reports
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def create_user_group_item_reports():
portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
item_fields = ['id', 'title', 'owner', 'numViews']
items = portal.search(item_fields, sort_field='numViews', sort_order='desc')
csvfile = csv.writer(open('items-report.csv', 'wb'))
csvfile.writerow(item_fields)
for item in items:
row = [item[field] for field in item_fields]
csvfile.writerow(row)
groups_fields = ['id', 'title', 'owner']
groups = portal.groups(groups_fields)
csvfile = csv.writer(open('groups-report.csv', 'wb'))
csvfile.writerow(groups_fields)
for group in groups:
row = [group[field] for field in groups_fields]
csvfile.writerow(row)
user_fields = ['username', 'fullName', 'email', 'role']
users = portal.org_users(user_fields)
csvfile = csv.writer(open('users-report.csv', 'wb'))
csvfile.writerow(user_fields)
for user in users:
row = [user[field] for field in user_fields]
csvfile.writerow(row)
示例2: daily_item_stats
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def daily_item_stats():
portal = Portal('http://www.arcgis.com')
today = datetime.utcnow()
weekago = today - timedelta(days=1)
q = 'modified:[' + portal_time(weekago) + ' TO ' + portal_time(today) + ']'
results = portal.search(['type', 'count(type)'], q, group_fields=['type'], num=5000)
pprint(results, indent=2)
示例3: count_tags
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def count_tags():
portal = Portal('http://www.geoplatform.gov')
results = portal.search(['tags'])
tags = unpack(results, flatten=True)
counts = dict((tag, tags.count(tag)) for tag in tags)
sorted_counts = sorted(counts.iteritems(), key=itemgetter(1), reverse=True)
pprint(sorted_counts, indent=2)
示例4: copy_items_query
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def copy_items_query():
source = Portal('http://www.arcgis.com')
target = Portal('http://wittm.esri.com', 'wmathot', 'wmathot')
items = source.search(q='h1n1')
copied_items = copy_items(items, source, target, 'wmathot', 'Copied Items (h1n1)')
for sourceid in copied_items.keys():
print 'Copied ' + sourceid + ' to ' + copied_items[sourceid]
示例5: count_item_types
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def count_item_types():
portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
counts = portal.search(properties=['type', 'count(type)'],
group_fields=['type'],\
sort_field='count(type)',\
sort_order='desc')
pprint(counts, indent=2)
示例6: export_import_content
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def export_import_content():
source = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
target = Portal('http://wittm.esri.com', 'admin', 'esri.agp')
file_path = 'C:\\temp\\export'
web_content = source.search(q=portalpy.WEB_ITEM_FILTER)
save_items(source, web_content, file_path, indent=4)
load_items(target, file_path)
示例7: copy_items_with_related
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def copy_items_with_related():
source = Portal('http://dev.arcgis.com')
target = Portal('http://wittm.esri.com', 'wmathot', 'wmathot')
items = source.search(q='type:"Web Mapping Application"', num=5)
copied_items = copy_items(items, source, target, 'wmathot', 'Web Apps 5', \
relationships=['WMA2Code', 'MobileApp2Code'])
for sourceid in copied_items.keys():
print 'Copied ' + sourceid + ' to ' + copied_items[sourceid]
示例8: hide_user
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def hide_user():
portal = Portal('http://portaldev.arcgis.com', 'admin', 'esri.agp')
user_to_hide = 'wmathot'
portal.update_user(user_to_hide, {'access': 'private'})
groups = portal.groups(['id'], 'owner:' + user_to_hide)
for group in groups:
portal.update_group(group['id'], {'access': 'private'})
items = portal.search(['id'], 'owner:' + user_to_hide)
portal.share_items(user_to_hide, items, None, False, False)
示例9: create_demographics_group
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def create_demographics_group():
arcgisonline = Portal('http://www.arcgis.com')
portal = Portal('http://wittm.esri.com', 'admin', 'esri.agp')
owner = portal.logged_in_user()['username']
items = arcgisonline.search(q='demographics owner:esri ' + WEBMAP_ITEM_FILTER)
copied_items = copy_items(items, arcgisonline, portal, owner)
group_id = portal.create_group({'title': 'Demographics', 'access': 'public',
'tags': 'demographics'},
thumbnail='http://bit.ly/WEaIh5')
for item_id in copied_items.values():
portal.share_items(owner, [item_id], [group_id], True, True)
示例10: average_coverage_by_item_type
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def average_coverage_by_item_type():
portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
def avg_area(extents):
extents = filter(None, extents)
if extents:
areas = []
for e in extents:
if e: areas.append((e[1][0] - e[0][0]) * (e[1][1] - e[0][1]))
return sum(area for area in areas) / len(areas)
return 0
portal.aggregate_functions['avg_area'] = avg_area
results = portal.search(['type', 'avg_area(extent)'], group_fields=['type'])
pprint(results, indent=2)
示例11: find_hostname_references
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def find_hostname_references():
hostname = 'wh94.fltplan.com'
portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
hostname_references = []
url_items = portal.search(['id','type','url'], portalpy.URL_ITEM_FILTER)
for item in url_items:
if parse_hostname(item['url']) == hostname:
hostname_references.append((item['id'], item['type'], item['url']))
webmaps = portal.webmaps()
for webmap in webmaps:
urls = webmap.urls(normalize=True)
for url in urls:
if parse_hostname(url) == hostname:
hostname_references.append((webmap.id, 'Web Map', url))
pprint(hostname_references, indent=2)
示例12: find_public_content_with_weak_descriptions
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def find_public_content_with_weak_descriptions():
portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
public_items = portal.search(q='access:public')
weak_items = []
for item in public_items:
snippet = item.get('snippet')
description = item.get('description')
thumbnail = item.get('thumbnail')
if not snippet or not description or not thumbnail or len(snippet) < 20 \
or len(description) < 50:
weak_items.append(item)
for weak_item in weak_items:
owner = weak_item['owner']
email = portal.user(owner)['email']
print owner + ', ' + email + ', ' + weak_item['id']
示例13: copy_group_with_shared_content
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def copy_group_with_shared_content():
source = Portal('http://www.arcgis.com')
target = Portal('http://wittm.esri.com', 'admin', 'esri.agp')
target_owner = target.logged_in_user()['username']
group_id = '2394b887a80347fb8544610cfa30489c'
# Copy the groups
groups = source.groups(q='id:' + group_id)
copied_groups = copy_groups(groups, source, target)
print 'Copied ' + str(len(copied_groups)) + ' groups'
# Copy the items
items = source.search(q='group:' + group_id)
copied_items = copy_items(items, source, target, target_owner,
'Copied Items (' + group_id + ')')
print 'Copied ' + str(len(copied_items)) + ' items'
# Share the items in the target portal
for item_id in copied_items.keys():
sharing = source.user_item(item_id)[1]
# If we have access to the full sharing properties of the source
# item, then copy all of them, otherwise just share with the group
if sharing and sharing['access'] != 'private':
target_item_id = copied_items[item_id]
target_group_ids = [copied_groups[id] for id in sharing['groups'] \
if id in copied_groups]
share_org = (sharing['access'] == 'org')
share_public = (sharing['access'] == 'public')
if not target.is_multitenant():
share_public = (share_public or share_org)
target.share_items(target_owner, [target_item_id],
target_group_ids, \
share_org or share_public, \
share_public)
else:
target_item_id = copied_items[item_id]
target_group_id = copied_groups[group_id]
target.share_items(target_owner, [target_item_id], \
[target_group_id])
示例14: update_hostname_references
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def update_hostname_references():
portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
hostname_map = {'wh94.fltplan.com:8080': 'wh94.fltplan.com'}
url_items = portal.search(['id','type','url'], portalpy.URL_ITEM_FILTER)
for item in url_items:
url = item.get('url')
if url:
url = normalize_url(url)
host = parse_hostname(url, include_port=True)
if host in hostname_map:
url = url.replace(host, hostname_map[host])
portal.update_item(item['id'], {'url': url})
webmaps = portal.webmaps()
for webmap in webmaps:
is_update = False
for url in webmap.urls():
normalized_url = normalize_url(url)
host = parse_hostname(normalized_url, include_port=True)
if host in hostname_map:
new_url = normalized_url.replace(host, hostname_map[host])
webmap.data = webmap.data.replace(url, new_url)
is_update = True
if is_update:
portal.update_webmap(webmap)
示例15: most_active_publishers
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import search [as 别名]
def most_active_publishers():
portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
results = portal.search(['owner','count(owner)'], group_fields=['owner'], scope='org')
pprint(results, indent=2)