-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_gdb_inventory.py
72 lines (56 loc) · 1.76 KB
/
build_gdb_inventory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
Create an inventory of content in a geodatabase.
"""
import os
import json
import arcpy
from arcgis.gis import GIS
from config import Config
VERSION = '1.0'
path,exe = os.path.split(__file__)
myname = exe + ' ' + VERSION
def get_content(gdb):
arcpy.env.workspace = gdb
datasets = arcpy.ListDatasets("*")
workspaces = arcpy.ListWorkspaces("*")
featureclasses = arcpy.ListFeatureClasses("*")
tables = arcpy.ListTables("*")
versions = arcpy.ListVersions(gdb)
return {
"datasets": datasets,
"workspaces": workspaces,
"featureclasses": featureclasses,
"tables": tables,
"versions": versions,
}
def get_portal_content(gis):
q="NOT owner:esri_*"
l = gis.content.search(q, max_items=5000, outside_org=False)
d = dict()
for item in l:
if item.type in d:
d[item.type].append(item)
else:
d[item.type] = [item]
if __name__ == "__main__":
gis = GIS(profile=os.environ.get('USERNAME'))
pcd = get_portal_content(gis)
# Generate a CSV of portal content
for type in sorted(pcd):
#print(type)
for item in pcd[type]:
print("\"%s\",\"%s\",\"%s\"" % (item.type, item.title, item.owner))
gdb = "K:/webmaps/basemap/cc-thesql.sde"
d = get_content(gdb)
# What tables are versioned?
# Who owns what?
# What tables are published as registered data in Portal?
# How many rows are in each table?
# Is there metadata?
fcd = list()
for item in d["featureclasses"]:
fcd.append(arcpy.Describe(item))
for item in fcd:
count = arcpy.management.GetCount(item.name)
print(item.name, count)
# That's all!