-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
82 lines (63 loc) · 2.05 KB
/
__init__.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
73
74
75
76
77
78
79
80
81
82
"""
Some of these methods were originally taken from the
arcapi project by Filip Kral, Caleb Mackey (01/02/2014)
Their original repository can be found on CEH's github site.
https://github.com/NERC-CEH/arcapi
The intention is to make this library seamlessly compatible with
ArcMap arcpy and ArcGISPro arcpy. However due to daily requirements
this has slipped by the wayside and is currently only compatible
with ArcGISPro.
Compatibility with ArcMap will be a PITA because of Python differences
between 2 and 3.
Much work is still required to make this package compatible with
both. (Graham Monkman 9/3/2022)
"""
import arcpy as _arcpy
__all__ = ['charts', 'common', 'data', 'display', 'environ',
'errors', 'httplib', 'meta', 'projections', 'raster', 'sql',
'structure']
from enum import Enum as _Enum
from arcproapi.errors import *
class Version(_Enum):
"""Version enumeration"""
ArcPro = 1
ArcMap = 2
def version_as_enum() -> Version:
"""
Get version, ie ArcPro or ArcMap
Returns:
Version: Version as an enumeration.
Examples:
>>> version_as_enum()
Version.ArcPro
"""
d = _arcpy.GetInstallInfo()
return Version.ArcPro if d['ProductName'] == 'ArcGISPro' else Version.ArcMap
def product_name():
return _arcpy.GetInstallInfo()['ProductName']
def arcpro_version():
try:
return _arcpy.GetInstallInfo()['Version']
except:
return ''
def release() -> str:
"""Get the release number.
Returns:
str: The release number
Example:
>>> release()
'3.0'
"""
return _arcpy.GetInstallInfo()['Version']
def current_project():
"""Return handle to the CURRENT map document.
***Can be used only in an ArcMap session***
"""
if version_as_enum() == Version.ArcPro:
return mp.ArcGISProject("CURRENT")
return mp.MapDocument("CURRENT") # noqa
if version_as_enum() == Version.ArcPro:
import arcpy.mp as mp # noqa
#import arcpy.MetadataImporter_conversion # noqa
else:
import arcpy.mapping as mp # noqa