Code Duplication    Length = 26-31 lines in 3 locations

opcua/ua/uaprotocol_auto.py 2 locations

@@ 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 = ''
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 = ''
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):

opcua/ua/uatypes.py 1 location

@@ 1043-1068 (lines=26) @@
1040
    return dims
1041
1042
1043
class XmlElement(FrozenClass):
1044
    '''
1045
    An XML element encoded as an UTF-8 string.
1046
    '''
1047
    def __init__(self, binary=None):
1048
        if binary is not None:
1049
            self._binary_init(binary)
1050
            self._freeze = True
1051
            return
1052
        self.Value = []
1053
        self._freeze = True
1054
1055
    def to_binary(self):
1056
        return pack_string(self.Value)
1057
1058
    @staticmethod
1059
    def from_binary(data):
1060
        return XmlElement(data)
1061
1062
    def _binary_init(self, data):
1063
        self.Value = unpack_string(data)
1064
1065
    def __str__(self):
1066
        return 'XmlElement(Value:' + str(self.Value) + ')'
1067
1068
    __repr__ = __str__
1069
1070
1071
class DataValue(FrozenClass):