@@ 3068-3098 (lines=31) @@ | ||
3065 | __repr__ = __str__ |
|
3066 | ||
3067 | ||
3068 | class AnonymousIdentityToken(FrozenClass): |
|
3069 | ''' |
|
3070 | A token representing an anonymous user. |
|
3071 | ||
3072 | :ivar PolicyId: |
|
3073 | :vartype PolicyId: String |
|
3074 | ''' |
|
3075 | def __init__(self, binary=None): |
|
3076 | if binary is not None: |
|
3077 | self._binary_init(binary) |
|
3078 | self._freeze = True |
|
3079 | return |
|
3080 | self.PolicyId = None |
|
3081 | self._freeze = True |
|
3082 | ||
3083 | def to_binary(self): |
|
3084 | packet = [] |
|
3085 | packet.append(pack_string(self.PolicyId)) |
|
3086 | return b''.join(packet) |
|
3087 | ||
3088 | @staticmethod |
|
3089 | def from_binary(data): |
|
3090 | return AnonymousIdentityToken(data) |
|
3091 | ||
3092 | def _binary_init(self, data): |
|
3093 | self.PolicyId = unpack_string(data) |
|
3094 | ||
3095 | def __str__(self): |
|
3096 | return 'AnonymousIdentityToken(' + 'PolicyId:' + str(self.PolicyId) + ')' |
|
3097 | ||
3098 | __repr__ = __str__ |
|
3099 | ||
3100 | ||
3101 | class UserNameIdentityToken(FrozenClass): |
|
@@ 3035-3065 (lines=31) @@ | ||
3032 | __repr__ = __str__ |
|
3033 | ||
3034 | ||
3035 | class UserIdentityToken(FrozenClass): |
|
3036 | ''' |
|
3037 | A base type for a user identity token. |
|
3038 | ||
3039 | :ivar PolicyId: |
|
3040 | :vartype PolicyId: String |
|
3041 | ''' |
|
3042 | def __init__(self, binary=None): |
|
3043 | if binary is not None: |
|
3044 | self._binary_init(binary) |
|
3045 | self._freeze = True |
|
3046 | return |
|
3047 | self.PolicyId = None |
|
3048 | self._freeze = True |
|
3049 | ||
3050 | def to_binary(self): |
|
3051 | packet = [] |
|
3052 | packet.append(pack_string(self.PolicyId)) |
|
3053 | return b''.join(packet) |
|
3054 | ||
3055 | @staticmethod |
|
3056 | def from_binary(data): |
|
3057 | return UserIdentityToken(data) |
|
3058 | ||
3059 | def _binary_init(self, data): |
|
3060 | self.PolicyId = unpack_string(data) |
|
3061 | ||
3062 | def __str__(self): |
|
3063 | return 'UserIdentityToken(' + 'PolicyId:' + str(self.PolicyId) + ')' |
|
3064 | ||
3065 | __repr__ = __str__ |
|
3066 | ||
3067 | ||
3068 | class AnonymousIdentityToken(FrozenClass): |
@@ 1043-1068 (lines=26) @@ | ||
1040 | subsize = 1 |
|
1041 | for i in subdims: |
|
1042 | if i == 0: |
|
1043 | i = 1 |
|
1044 | subsize *= i |
|
1045 | while dims[0] * subsize > len(flat): |
|
1046 | flat.append([]) |
|
1047 | if not subdims or subdims == [0]: |
|
1048 | return flat |
|
1049 | return [reshape(flat[i: i + subsize], subdims) for i in range(0, len(flat), subsize)] |
|
1050 | ||
1051 | ||
1052 | def _split_list(l, n): |
|
1053 | n = max(1, n) |
|
1054 | return [l[i:i + n] for i in range(0, len(l), n)] |
|
1055 | ||
1056 | ||
1057 | def flatten_and_get_shape(mylist): |
|
1058 | dims = [] |
|
1059 | dims.append(len(mylist)) |
|
1060 | while isinstance(mylist[0], (list, tuple)): |
|
1061 | dims.append(len(mylist[0])) |
|
1062 | mylist = [item for sublist in mylist for item in sublist] |
|
1063 | if len(mylist) == 0: |
|
1064 | break |
|
1065 | return mylist, dims |
|
1066 | ||
1067 | ||
1068 | def flatten(mylist): |
|
1069 | if len(mylist) == 0: |
|
1070 | return mylist |
|
1071 | while isinstance(mylist[0], (list, tuple)): |