@@ -120,6 +120,10 @@ def to_bytes(self):
120
120
struct .pack (b'<b' , self .value ))
121
121
122
122
def __str__ (self ):
123
+ r"""
124
+ >>> str(Int8TextRecord(42))
125
+ '42'
126
+ """
123
127
return str (self .value )
124
128
125
129
@classmethod
@@ -238,6 +242,10 @@ def to_bytes(self):
238
242
struct .pack (b'<B' , 1 if self .value else 0 ))
239
243
240
244
def __str__ (self ):
245
+ r"""
246
+ >>> str(BoolTextRecord(True))
247
+ 'True'
248
+ """
241
249
return str (self .value )
242
250
243
251
@classmethod
@@ -275,6 +283,10 @@ def to_bytes(self):
275
283
return bytes (bt )
276
284
277
285
def __str__ (self ):
286
+ r"""
287
+ >>> str(UnicodeChars8TextRecord('abc'))
288
+ 'abc'
289
+ """
278
290
return self .value
279
291
280
292
@classmethod
@@ -306,9 +318,6 @@ def to_bytes(self):
306
318
bt += data
307
319
return bytes (bt )
308
320
309
- def __str__ (self ):
310
- return self .value
311
-
312
321
@classmethod
313
322
def parse (cls , fp ):
314
323
"""
@@ -338,9 +347,6 @@ def to_bytes(self):
338
347
bt += data
339
348
return bytes (bt )
340
349
341
- def __str__ (self ):
342
- return self .value
343
-
344
350
@classmethod
345
351
def parse (cls , fp ):
346
352
"""
@@ -490,6 +496,10 @@ def __init__(self, value):
490
496
self .value = value
491
497
492
498
def __str__ (self ):
499
+ r"""
500
+ >>> str(DecimalTextRecord(Decimal(False, 0, 1337, 3)))
501
+ '1.337'
502
+ """
493
503
return str (self .value )
494
504
495
505
def to_bytes (self ):
@@ -573,6 +583,12 @@ def __init__(self, value):
573
583
self .value = str (value )
574
584
575
585
def __str__ (self ):
586
+ r"""
587
+ >>> str(Chars8TextRecord("abc"))
588
+ 'abc'
589
+ >>> str(Chars8TextRecord("a<b>c>>&'\""))
590
+ "a<b>c>>&'""
591
+ """
576
592
return escape (self .value )
577
593
578
594
def to_bytes (self ):
@@ -673,6 +689,10 @@ def to_bytes(self):
673
689
return bytes (bt )
674
690
675
691
def __str__ (self ):
692
+ r"""
693
+ >>> str(UniqueIdTextRecord('urn:uuid:33221100-5544-7766-8899-aabbccddeeff'))
694
+ 'urn:uuid:33221100-5544-7766-8899-aabbccddeeff'
695
+ """
676
696
return self .uuid .urn
677
697
678
698
@classmethod
@@ -717,7 +737,11 @@ def to_bytes(self):
717
737
return bytes (bt )
718
738
719
739
def __str__ (self ):
720
- return base64 .b64encode (self .value )
740
+ r"""
741
+ >>> str(Bytes8TextRecord(b'abc'))
742
+ 'YWJj'
743
+ """
744
+ return base64 .b64encode (self .value ).decode ()
721
745
722
746
@classmethod
723
747
def parse (cls , fp ):
@@ -736,10 +760,7 @@ class Bytes16TextRecord(Bytes8TextRecord):
736
760
type = 0xA0
737
761
738
762
def __init__ (self , data ):
739
- self .value = data
740
-
741
- def __str__ (self ):
742
- return base64 .b64encode (self .value )
763
+ super (Bytes16TextRecord , self ).__init__ (data )
743
764
744
765
def to_bytes (self ):
745
766
r"""
@@ -769,10 +790,7 @@ class Bytes32TextRecord(Bytes8TextRecord):
769
790
type = 0xA2
770
791
771
792
def __init__ (self , data ):
772
- self .value = data
773
-
774
- def __str__ (self ):
775
- return base64 .b64encode (self .value )
793
+ super (Bytes32TextRecord , self ).__init__ (data )
776
794
777
795
def to_bytes (self ):
778
796
r"""
@@ -854,6 +872,10 @@ def to_bytes(self):
854
872
MultiByteInt31 (self .index ).to_bytes ())
855
873
856
874
def __str__ (self ):
875
+ r"""
876
+ >>> str(DictionaryTextRecord(2))
877
+ 'Envelope'
878
+ """
857
879
return dictionary [self .index ]
858
880
859
881
@classmethod
0 commit comments