Skip to content

Commit 858bac8

Browse files
committed
[#558] iRODSAccess: Handle non-str types in constructor
This change enables the iRODSAccess constructor to handle iRODSCollection and iRODSDataObject types in addition to str-like types for the 'path' parameter. A TypeError is now raised when an unsupported type is used for this parameter.
1 parent afc3ff0 commit 858bac8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

irods/access.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import collections
22
import copy
33
import six
4+
from irods.collection import iRODSCollection
5+
from irods.data_object import iRODSDataObject
46
from irods.path import iRODSPath
57

68
class _Access_LookupMeta(type):
@@ -59,7 +61,15 @@ def to_string(cls,key):
5961

6062
def __init__(self, access_name, path, user_name='', user_zone='', user_type=None):
6163
self.access_name = access_name
62-
self.path = path
64+
if isinstance(path, (iRODSCollection, iRODSDataObject)):
65+
self.path = path.path
66+
elif isinstance(path, str):
67+
# This should cover irods.path.iRODSPath as well as it is a descendant type of str.
68+
self.path = path
69+
else:
70+
raise TypeError(
71+
"'path' parameter must be of type 'str', 'irods.collection.iRODSCollection', "
72+
"'irods.data_object.iRODSDataObject', or 'irods.path.iRODSPath'.")
6373
self.user_name = user_name
6474
self.user_zone = user_zone
6575
self.user_type = user_type

0 commit comments

Comments
 (0)