Code Duplication    Length = 62-64 lines in 2 locations

opcua/ua/uaprotocol_auto.py 2 locations

@@ 1861-1924 (lines=64) @@
1858
    __repr__ = __str__
1859
1860
1861
class UserTokenPolicy(FrozenClass):
1862
    '''
1863
    Describes a user token that can be used with a server.
1864
1865
    :ivar PolicyId:
1866
    :vartype PolicyId: String
1867
    :ivar TokenType:
1868
    :vartype TokenType: UserTokenType
1869
    :ivar IssuedTokenType:
1870
    :vartype IssuedTokenType: String
1871
    :ivar IssuerEndpointUrl:
1872
    :vartype IssuerEndpointUrl: String
1873
    :ivar SecurityPolicyUri:
1874
    :vartype SecurityPolicyUri: String
1875
    '''
1876
1877
    ua_types = {
1878
        'PolicyId': 'String',
1879
        'TokenType': 'UserTokenType',
1880
        'IssuedTokenType': 'String',
1881
        'IssuerEndpointUrl': 'String',
1882
        'SecurityPolicyUri': 'String',
1883
               }
1884
1885
    def __init__(self, binary=None):
1886
        if binary is not None:
1887
            self._binary_init(binary)
1888
            self._freeze = True
1889
            return
1890
        self.PolicyId = None
1891
        self.TokenType = UserTokenType(0)
1892
        self.IssuedTokenType = None
1893
        self.IssuerEndpointUrl = None
1894
        self.SecurityPolicyUri = None
1895
        self._freeze = True
1896
1897
    def to_binary(self):
1898
        packet = []
1899
        packet.append(uabin.Primitives.String.pack(self.PolicyId))
1900
        packet.append(uabin.Primitives.UInt32.pack(self.TokenType.value))
1901
        packet.append(uabin.Primitives.String.pack(self.IssuedTokenType))
1902
        packet.append(uabin.Primitives.String.pack(self.IssuerEndpointUrl))
1903
        packet.append(uabin.Primitives.String.pack(self.SecurityPolicyUri))
1904
        return b''.join(packet)
1905
1906
    @staticmethod
1907
    def from_binary(data):
1908
        return UserTokenPolicy(data)
1909
1910
    def _binary_init(self, data):
1911
        self.PolicyId = uabin.Primitives.String.unpack(data)
1912
        self.TokenType = UserTokenType(uabin.Primitives.UInt32.unpack(data))
1913
        self.IssuedTokenType = uabin.Primitives.String.unpack(data)
1914
        self.IssuerEndpointUrl = uabin.Primitives.String.unpack(data)
1915
        self.SecurityPolicyUri = uabin.Primitives.String.unpack(data)
1916
1917
    def __str__(self):
1918
        return 'UserTokenPolicy(' + 'PolicyId:' + str(self.PolicyId) + ', ' + \
1919
               'TokenType:' + str(self.TokenType) + ', ' + \
1920
               'IssuedTokenType:' + str(self.IssuedTokenType) + ', ' + \
1921
               'IssuerEndpointUrl:' + str(self.IssuerEndpointUrl) + ', ' + \
1922
               'SecurityPolicyUri:' + str(self.SecurityPolicyUri) + ')'
1923
1924
    __repr__ = __str__
1925
1926
1927
class EndpointDescription(FrozenClass):
@@ 2689-2750 (lines=62) @@
2686
    __repr__ = __str__
2687
2688
2689
class OpenSecureChannelParameters(FrozenClass):
2690
    '''
2691
    :ivar ClientProtocolVersion:
2692
    :vartype ClientProtocolVersion: UInt32
2693
    :ivar RequestType:
2694
    :vartype RequestType: SecurityTokenRequestType
2695
    :ivar SecurityMode:
2696
    :vartype SecurityMode: MessageSecurityMode
2697
    :ivar ClientNonce:
2698
    :vartype ClientNonce: ByteString
2699
    :ivar RequestedLifetime:
2700
    :vartype RequestedLifetime: UInt32
2701
    '''
2702
2703
    ua_types = {
2704
        'ClientProtocolVersion': 'UInt32',
2705
        'RequestType': 'SecurityTokenRequestType',
2706
        'SecurityMode': 'MessageSecurityMode',
2707
        'ClientNonce': 'ByteString',
2708
        'RequestedLifetime': 'UInt32',
2709
               }
2710
2711
    def __init__(self, binary=None):
2712
        if binary is not None:
2713
            self._binary_init(binary)
2714
            self._freeze = True
2715
            return
2716
        self.ClientProtocolVersion = 0
2717
        self.RequestType = SecurityTokenRequestType(0)
2718
        self.SecurityMode = MessageSecurityMode(0)
2719
        self.ClientNonce = None
2720
        self.RequestedLifetime = 0
2721
        self._freeze = True
2722
2723
    def to_binary(self):
2724
        packet = []
2725
        packet.append(uabin.Primitives.UInt32.pack(self.ClientProtocolVersion))
2726
        packet.append(uabin.Primitives.UInt32.pack(self.RequestType.value))
2727
        packet.append(uabin.Primitives.UInt32.pack(self.SecurityMode.value))
2728
        packet.append(uabin.Primitives.ByteString.pack(self.ClientNonce))
2729
        packet.append(uabin.Primitives.UInt32.pack(self.RequestedLifetime))
2730
        return b''.join(packet)
2731
2732
    @staticmethod
2733
    def from_binary(data):
2734
        return OpenSecureChannelParameters(data)
2735
2736
    def _binary_init(self, data):
2737
        self.ClientProtocolVersion = uabin.Primitives.UInt32.unpack(data)
2738
        self.RequestType = SecurityTokenRequestType(uabin.Primitives.UInt32.unpack(data))
2739
        self.SecurityMode = MessageSecurityMode(uabin.Primitives.UInt32.unpack(data))
2740
        self.ClientNonce = uabin.Primitives.ByteString.unpack(data)
2741
        self.RequestedLifetime = uabin.Primitives.UInt32.unpack(data)
2742
2743
    def __str__(self):
2744
        return 'OpenSecureChannelParameters(' + 'ClientProtocolVersion:' + str(self.ClientProtocolVersion) + ', ' + \
2745
               'RequestType:' + str(self.RequestType) + ', ' + \
2746
               'SecurityMode:' + str(self.SecurityMode) + ', ' + \
2747
               'ClientNonce:' + str(self.ClientNonce) + ', ' + \
2748
               'RequestedLifetime:' + str(self.RequestedLifetime) + ')'
2749
2750
    __repr__ = __str__
2751
2752
2753
class OpenSecureChannelRequest(FrozenClass):