Code Duplication    Length = 10-12 lines in 2 locations

opcua/ua/uatypes.py 1 location

@@ 575-586 (lines=12) @@
572
        self.Locale = None
573
        self._freeze = True
574
575
    def to_binary(self):
576
        packet = []
577
        if self.Locale:
578
            self.Encoding |= (1 << 0)
579
        if self.Text:
580
            self.Encoding |= (1 << 1)
581
        packet.append(uabin.Primitives.UInt8.pack(self.Encoding))
582
        if self.Locale:
583
            packet.append(uabin.Primitives.String.pack(self.Locale))
584
        if self.Text:
585
            packet.append(uabin.Primitives.String.pack(self.Text))
586
        return b''.join(packet)
587
588
    @staticmethod
589
    def from_binary(data):

opcua/ua/uaprotocol_auto.py 1 location

@@ 929-938 (lines=10) @@
926
    @staticmethod
927
    def from_binary(data):
928
        obj = LocalizedText()
929
        self.Encoding = uabin.Primitives.UInt8.unpack(data)
930
        if obj.Encoding & (1 << 0):
931
            self.Locale = uabin.Primitives.CharArray.unpack(data)
932
        else:
933
            obj.Locale = None
934
        if obj.Encoding & (1 << 1):
935
            self.Text = uabin.Primitives.CharArray.unpack(data)
936
        else:
937
            obj.Text = None
938
            return obj
939
940
    def __str__(self):
941
        return 'LocalizedText(' + 'Encoding:' + str(self.Encoding) + ', ' + \