Skip to content

Commit

Permalink
- Bump to Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Jan 16, 2020
1 parent b1ba71f commit d5f6c44
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build/
/dist/
43 changes: 22 additions & 21 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# file GENERATED by distutils, do NOT edit
setup.py
arcrest\__init__.py
arcrest\ago.py
arcrest\compat.py
arcrest\geometry.py
arcrest\gptypes.py
arcrest\projections.py
arcrest\server.py
arcrest\utils.py
arcrest\admin\__init__.py
arcrest\admin\admin_objects.py
arcrest\admin\cmdline.py
cmdline\convertcachestorageformat.py
cmdline\createcacheschema.py
cmdline\createservice.py
cmdline\deletecache.py
cmdline\managecachetiles.py
cmdline\manageservice.py
cmdline\managesite.py
cmdline\reportcachestatus.py
# file GENERATED by distutils, do NOT edit
setup.py
arcrest/__init__.py
arcrest/ago.py
arcrest/compat.py
arcrest/geometry.py
arcrest/gptypes.py
arcrest/portal.py
arcrest/projections.py
arcrest/server.py
arcrest/utils.py
arcrest/admin/__init__.py
arcrest/admin/admin_objects.py
arcrest/admin/cmdline.py
cmdline/convertcachestorageformat.py
cmdline/createcacheschema.py
cmdline/createservice.py
cmdline/deletecache.py
cmdline/managecachetiles.py
cmdline/manageservice.py
cmdline/managesite.py
cmdline/reportcachestatus.py
6 changes: 6 additions & 0 deletions arcrest/admin/admin_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
'Directory', 'Directories',
'Clusters', 'Cluster']

try:
long, unicode, basestring
except NameError:
long, unicode, basestring = int, str, str


class Admin(server.RestURL):
"""Represents the top level URL resource of the ArcGIS Server
Administration API"""
Expand Down
2 changes: 1 addition & 1 deletion arcrest/admin/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def manageservice(action):
service = services[args.name]
operation = (args.operation or '').lower()
if operation == 'status':
for key, item in sorted(service.status.iteritems()):
for key, item in sorted(service.status.items()):
print("{0}: {1}".format(key, item))
elif operation == 'start':
with action("starting service"):
Expand Down
17 changes: 14 additions & 3 deletions arcrest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
'urljoin', 'urlunsplit', 'urlencode', 'quote', 'string_type',
'ensure_string', 'ensure_bytes', 'get_headers']

try:
long, unicode, basestring
except NameError:
long, unicode, basestring = int, str, str

try:
import cookielib
except ImportError:
Expand Down Expand Up @@ -43,9 +48,15 @@
string_type = str

def ensure_string(payload_bytes):
if isinstance(payload_bytes, bytes):
return payload_bytes.decode("utf-8")
return payload_bytes
import re
_payload = payload_bytes
try:
_payload = payload_bytes.decode("utf-8")
except:
pass
if re.match(r'b\'(.*)\'', _payload):
_payload = re.match(r'b\'(.*)\'', _payload).groups()[0]
return _payload

def ensure_bytes(payload_string):
if isinstance(payload_string, unicode):
Expand Down
13 changes: 9 additions & 4 deletions arcrest/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

from .projections import projected, geographic

try:
long, unicode, basestring
except NameError:
long, unicode, basestring = int, str, str

def pointlist(points, sr):
"""Convert a list of the form [[x, y] ...] to a list of Point instances
with the given x, y coordinates."""
Expand Down Expand Up @@ -587,14 +592,14 @@ def fromJson(struct, attributes=None):
return Envelope(*map(float, struct.split(',')))
# Look for telltale attributes in the dict
if isinstance(struct, dict):
for key, cls in indicative_attributes.iteritems():
for key, cls in indicative_attributes.items():
if key in struct:
ret = cls.fromJson(dict((str(key), value)
for (key, value) in struct.iteritems()))
for (key, value) in struct.items()))
if attributes:
ret.attributes = dict((str(key.lower()), val)
for (key, val)
in attributes.iteritems())
in attributes.items())
return ret
raise ValueError("Unconvertible to geometry")

Expand Down Expand Up @@ -638,7 +643,7 @@ def fromGeoJson(struct, attributes=None):
if attributes:
if not hasattr(instance, 'attributes'):
instance.attributes = {}
for k, v in attributes.iteritems():
for k, v in attributes.items():
instance.attributes[k] = v
i.append(instance)
if i:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import os

setup(
name='arcrest',
version='10.3',
name='gn-arcrest',
version='10.5',
summary="ArcGIS for Server REST API wrapper",
description="""Wrapper to the ArcGIS REST API, and a Python analogue to the Javascript APIs""",
author="Esri",
Expand Down

0 comments on commit d5f6c44

Please sign in to comment.