|
9 | 9 | from irods.models import DataObject, Collection |
10 | 10 | from irods.manager import Manager |
11 | 11 | from irods.manager._internal import _api_impl, _logical_path |
| 12 | + |
12 | 13 | from irods.message import ( |
13 | 14 | iRODSMessage, |
14 | 15 | FileOpenRequest, |
|
30 | 31 | chunks, |
31 | 32 | irods_dirname, |
32 | 33 | irods_basename, |
| 34 | + REPLICA_NUMBER_SORT_KEY_FN, |
| 35 | + REPLICA_FITNESS_SORT_KEY_FN, |
33 | 36 | ) |
34 | 37 | import irods.client_configuration as client_config |
35 | 38 | import irods.keywords as kw |
@@ -258,17 +261,26 @@ def _download(self, obj_path, local_path, num_threads, updatables=(), **options) |
258 | 261 | f.write(chunk) |
259 | 262 | do_progress_updates(updatables, len(chunk)) |
260 | 263 |
|
261 | | - def get(self, path, local_path=None, num_threads=DEFAULT_NUMBER_OF_THREADS, updatables=(), **options): |
| 264 | + def get(self, |
| 265 | + path, |
| 266 | + local_path=None, |
| 267 | + num_threads=DEFAULT_NUMBER_OF_THREADS, |
| 268 | + updatables=(), |
| 269 | + replica_sort_function = None, |
| 270 | + **options): |
262 | 271 | """ |
263 | 272 | Get a reference to the data object at the specified `path'. |
264 | 273 |
|
265 | 274 | Only download the object if the local_path is a string (specifying |
266 | 275 | a path in the local filesystem to use as a destination file). |
| 276 | +
|
| 277 | + If replica_sort_function is not specified, the replicas list contained in the returned |
| 278 | + object will be sorted according to replica number (REPLICA_NUMBER_SORT_KEY_FN) in PRC < v4 |
| 279 | + or by general fitness to be considered as a current data copy (REPLICA_FITNESS_SORT_KEY_FN). |
| 280 | + in PRC >= v4. For those definitions, see irods/data_object.py . |
267 | 281 | """ |
268 | 282 | parent = self.sess.collections.get(irods_dirname(path)) |
269 | 283 |
|
270 | | - replica_sort_function = options.pop('replica_sort_function', None) |
271 | | - |
272 | 284 | # TODO: optimize |
273 | 285 | if local_path: |
274 | 286 | self._download(path, local_path, num_threads=num_threads, updatables=updatables, **options) |
|
0 commit comments