Skip to content

Commit dd33858

Browse files
committed
use status names.
1 parent f9af9af commit dd33858

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

irods/data_object.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ast
22
import datetime
3+
import enum
34
import io
45
import logging
56
import os
@@ -42,9 +43,28 @@ def __repr__(self):
4243
return "<{}.{} {}>".format(self.__class__.__module__, self.__class__.__name__, self.resource_name)
4344

4445

45-
_REPL_STATUSES = (1, 0, 2, 3, 4)
46-
_REFERENCE_DATETIME = datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc)
46+
class _repl_status(enum.Enum):
47+
STALE_REPLICA, \
48+
GOOD_REPLICA, \
49+
INTERMEDIATE_REPLICA, \
50+
READ_LOCKED, \
51+
WRITE_LOCKED = range(5)
52+
4753

54+
# Ordering by fitness for use/interface, for various replica status values.
55+
_REPL_STATUSES = tuple(
56+
getattr(_repl_status, ident).value for ident in (
57+
"GOOD_REPLICA",
58+
"STALE_REPLICA",
59+
"INTERMEDIATE_REPLICA",
60+
"READ_LOCKED",
61+
"WRITE_LOCKED",
62+
)
63+
)
64+
65+
# An appropriate reference datetime value for gauging replica age as part of
66+
# the default sort key in PRC4 and onward.
67+
_REFERENCE_DATETIME = datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc)
4868

4969
def _REPLICA_NUMBER_SORT_KEY_FN(row):
5070
return row[DataObject.replica_number]

0 commit comments

Comments
 (0)