Skip to content

Commit

Permalink
Python 3 support in Python interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpearce committed May 31, 2017
1 parent d74d514 commit 9fca3d4
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 13 deletions.
10 changes: 6 additions & 4 deletions bindings/python/libs/client/__init__.py
@@ -1,4 +1,6 @@
from filesystem import FileSystem as FileSystem
from file import File as File
from url import URL as URL
from copyprocess import CopyProcess as CopyProcess
from __future__ import absolute_import, division, print_function

from .filesystem import FileSystem as FileSystem
from .file import File as File
from .url import URL as URL
from .copyprocess import CopyProcess as CopyProcess
5 changes: 3 additions & 2 deletions bindings/python/libs/client/copyprocess.py
Expand Up @@ -21,6 +21,7 @@
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.
#-------------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function

from pyxrootd import client
from XRootD.client.url import URL
Expand All @@ -37,7 +38,7 @@ def begin(self, jobId, total, source, target):
self.handler.begin(jobId, total, URL(source), URL(target))

def end(self, jobId, results):
if results.has_key('status'):
if 'success' in results:
results['status'] = XRootDStatus(results['status'])
if self.handler:
self.handler.end(jobId, results)
Expand Down Expand Up @@ -134,6 +135,6 @@ def run(self, handler=None):
"""
status, results = self.__process.run(ProgressHandlerWrapper(handler))
for x in results:
if x.has_key('status'):
if 'status' in x:
x['status'] = XRootDStatus(x['status'])
return XRootDStatus(status), results
3 changes: 2 additions & 1 deletion bindings/python/libs/client/file.py
Expand Up @@ -21,6 +21,7 @@
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.
#-------------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function

from pyxrootd import client
from XRootD.client.responses import XRootDStatus, StatInfo, VectorReadInfo
Expand All @@ -42,7 +43,7 @@ def __exit__(self, type, value, traceback):
def __iter__(self):
return self

def next(self):
def __next__(self):
return self.__file.next()

def open(self, url, flags=0, mode=0, timeout=0, callback=None):
Expand Down
1 change: 1 addition & 0 deletions bindings/python/libs/client/filesystem.py
Expand Up @@ -21,6 +21,7 @@
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.
#-------------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function

from pyxrootd import client
from XRootD.client.responses import XRootDStatus, StatInfo, StatInfoVFS
Expand Down
3 changes: 2 additions & 1 deletion bindings/python/libs/client/flags.py
Expand Up @@ -15,10 +15,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with XRootD. If not, see <http:#www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function

def enum(**enums):
"""Build the equivalent of a C++ enum"""
reverse = dict((value, key) for key, value in enums.iteritems())
reverse = dict((value, key) for key, value in enums.items())
enums['reverse_mapping'] = reverse
return type('Enum', (), enums)

Expand Down
4 changes: 3 additions & 1 deletion bindings/python/libs/client/responses.py
Expand Up @@ -15,6 +15,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with XRootD. If not, see <http:#www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function

from XRootD.client.url import URL

class Struct(object):
Expand All @@ -23,7 +25,7 @@ def __init__(self, entries):
self.__dict__.update(**entries)
def __repr__(self):
return '<%s>' % str(', '.join('%s: %s' % (k, repr(v))
for (k, v) in self.__dict__.iteritems()))
for (k, v) in self.__dict__.items()))

class LocationInfo(Struct):
"""Path location information (a list of discovered file locations).
Expand Down
1 change: 1 addition & 0 deletions bindings/python/libs/client/url.py
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with XRootD. If not, see <http:#www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function

from pyxrootd import client

Expand Down
1 change: 1 addition & 0 deletions bindings/python/libs/client/utils.py
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with XRootD. If not, see <http:#www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function

from threading import Lock
from XRootD.client.responses import XRootDStatus, HostList
Expand Down
10 changes: 6 additions & 4 deletions bindings/python/setup.py.in
@@ -1,3 +1,5 @@
from __future__ import print_function

from distutils.core import setup, Extension
from distutils import sysconfig
from os import getenv, walk, path
Expand Down Expand Up @@ -25,10 +27,10 @@ xrdsrcincdir = "${XRD_SRCINCDIR}"
xrdbinincdir = "${XRD_BININCDIR}"
version = "${XROOTD_VERSION}"

print 'XRootD library dir: ', xrdlibdir
print 'XRootD src include dir:', xrdsrcincdir
print 'XRootD bin include dir:', xrdbinincdir
print 'Version: ', version
print('XRootD library dir: ', xrdlibdir)
print('XRootD src include dir:', xrdsrcincdir)
print('XRootD bin include dir:', xrdbinincdir)
print('Version: ', version)

setup( name = 'pyxrootd',
version = version,
Expand Down

0 comments on commit 9fca3d4

Please sign in to comment.