Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c153b7

Browse files
committed
Merge branch 'hotfix/0.5.4'
2 parents 248e026 + b84d1c3 commit 5c153b7

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27,py34
2+
envlist = py27,py35
33
#envlist = py27
44
[testenv]
55
deps=pytest

wcf/records/text.py

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ def to_bytes(self):
120120
struct.pack(b'<b', self.value))
121121

122122
def __str__(self):
123+
r"""
124+
>>> str(Int8TextRecord(42))
125+
'42'
126+
"""
123127
return str(self.value)
124128

125129
@classmethod
@@ -238,6 +242,10 @@ def to_bytes(self):
238242
struct.pack(b'<B', 1 if self.value else 0))
239243

240244
def __str__(self):
245+
r"""
246+
>>> str(BoolTextRecord(True))
247+
'True'
248+
"""
241249
return str(self.value)
242250

243251
@classmethod
@@ -275,6 +283,10 @@ def to_bytes(self):
275283
return bytes(bt)
276284

277285
def __str__(self):
286+
r"""
287+
>>> str(UnicodeChars8TextRecord('abc'))
288+
'abc'
289+
"""
278290
return self.value
279291

280292
@classmethod
@@ -306,9 +318,6 @@ def to_bytes(self):
306318
bt += data
307319
return bytes(bt)
308320

309-
def __str__(self):
310-
return self.value
311-
312321
@classmethod
313322
def parse(cls, fp):
314323
"""
@@ -338,9 +347,6 @@ def to_bytes(self):
338347
bt += data
339348
return bytes(bt)
340349

341-
def __str__(self):
342-
return self.value
343-
344350
@classmethod
345351
def parse(cls, fp):
346352
"""
@@ -490,6 +496,10 @@ def __init__(self, value):
490496
self.value = value
491497

492498
def __str__(self):
499+
r"""
500+
>>> str(DecimalTextRecord(Decimal(False, 0, 1337, 3)))
501+
'1.337'
502+
"""
493503
return str(self.value)
494504

495505
def to_bytes(self):
@@ -573,6 +583,12 @@ def __init__(self, value):
573583
self.value = str(value)
574584

575585
def __str__(self):
586+
r"""
587+
>>> str(Chars8TextRecord("abc"))
588+
'abc'
589+
>>> str(Chars8TextRecord("a<b>c>>&'\""))
590+
"a&lt;b&gt;c&gt;&gt;&amp;'&quot;"
591+
"""
576592
return escape(self.value)
577593

578594
def to_bytes(self):
@@ -673,6 +689,10 @@ def to_bytes(self):
673689
return bytes(bt)
674690

675691
def __str__(self):
692+
r"""
693+
>>> str(UniqueIdTextRecord('urn:uuid:33221100-5544-7766-8899-aabbccddeeff'))
694+
'urn:uuid:33221100-5544-7766-8899-aabbccddeeff'
695+
"""
676696
return self.uuid.urn
677697

678698
@classmethod
@@ -717,7 +737,11 @@ def to_bytes(self):
717737
return bytes(bt)
718738

719739
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()
721745

722746
@classmethod
723747
def parse(cls, fp):
@@ -736,10 +760,7 @@ class Bytes16TextRecord(Bytes8TextRecord):
736760
type = 0xA0
737761

738762
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)
743764

744765
def to_bytes(self):
745766
r"""
@@ -769,10 +790,7 @@ class Bytes32TextRecord(Bytes8TextRecord):
769790
type = 0xA2
770791

771792
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)
776794

777795
def to_bytes(self):
778796
r"""
@@ -854,6 +872,10 @@ def to_bytes(self):
854872
MultiByteInt31(self.index).to_bytes())
855873

856874
def __str__(self):
875+
r"""
876+
>>> str(DictionaryTextRecord(2))
877+
'Envelope'
878+
"""
857879
return dictionary[self.index]
858880

859881
@classmethod

0 commit comments

Comments
 (0)