github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/python/aistore/sdk/list_object_flag.py (about)

     1  from __future__ import annotations
     2  from enum import Enum
     3  
     4  from typing import List
     5  
     6  
     7  class ListObjectFlag(Enum):
     8      """
     9      Flags to pass when listing objects in a bucket.
    10      See api/apc/lsmsg.go
    11      """
    12  
    13      CACHED = 0
    14      ALL = 1
    15      DELETED = 2
    16      ARCH_DIR = 3
    17      NAME_ONLY = 4
    18      NAME_SIZE = 5
    19      DONT_HEAD_REMOTE = 6
    20      TRY_HEAD_REMOTE = 7
    21      DONT_ADD_REMOTE = 8
    22      USE_CACHE = 9
    23      ONLY_REMOTE_PROPS = 10
    24  
    25      @staticmethod
    26      def join_flags(flags: List[ListObjectFlag]) -> int:
    27          """
    28          Take a list of ListObjectFlag enums and return the integer value of the combined flags
    29          Args:
    30              flags: List of ListObjectFlag enums
    31  
    32          Returns:
    33              A single bit string with each digit corresponding to the flag's value from the right.
    34                  E.g. USE_CACHE = 9 and NAME_ONLY = 4 so if both flags are passed, the result will be 2^9 + 2^4 = 528
    35  
    36          """
    37          res = 0
    38          for flag in flags:
    39              res = res ^ 2**flag.value
    40          return res