@@ -42,16 +42,19 @@ class Gtid(object):
4242
4343 SID:1-74
4444
45- Adding an already present transaction number (one that overlaps) will
46- raise an exception.
47-
48- Adding a Gtid with a different SID will raise an exception .
45+ Raises:
46+ ValueError: If construction parsing from string fails
47+ Exception: Adding an already present transaction number (one that overlaps).
48+ Exception: Adding a Gtid with a different SID.
4949 """
5050 @staticmethod
5151 def parse_interval (interval ):
5252 """
5353 We parse a human-generated string here. So our end value b
5454 is incremented to conform to the internal representation format.
55+
56+ Raises:
57+ - ValueError if GTID format is incorrect
5558 """
5659 m = re .search ('^([0-9]+)(?:-([0-9]+))?$' , interval )
5760 if not m :
@@ -62,6 +65,11 @@ def parse_interval(interval):
6265
6366 @staticmethod
6467 def parse (gtid ):
68+ """Parse a GTID from mysql textual format.
69+
70+ Raises:
71+ - ValueError: if GTID format is incorrect.
72+ """
6573 m = re .search ('^([0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12})'
6674 '((?::[0-9-]+)+)$' , gtid )
6775 if not m :
@@ -79,6 +87,9 @@ def __add_interval(self, itvl):
7987 """
8088 Use the internal representation format and add it
8189 to our intervals, merging if required.
90+
91+ Raises:
92+ Exception: if Malformated interval or Overlapping interval
8293 """
8394 new = []
8495
@@ -103,7 +114,9 @@ def __add_interval(self, itvl):
103114 self .intervals = sorted (new + [itvl ])
104115
105116 def __sub_interval (self , itvl ):
106- """Using the internal representation, remove an interval"""
117+ """Using the internal representation, remove an interval
118+
119+ Raises: Exception if itvl malformated"""
107120 new = []
108121
109122 if itvl [0 ] > itvl [1 ]:
@@ -144,8 +157,10 @@ def __init__(self, gtid, sid=None, intervals=[]):
144157 self .__add_interval (itvl )
145158
146159 def __add__ (self , other ):
147- """Include the transactions of this gtid. Raise if the
148- attempted merge has different SID"""
160+ """Include the transactions of this gtid.
161+
162+ Raises:
163+ Exception: if the attempted merge has different SID"""
149164 if self .sid != other .sid :
150165 raise Exception ('Attempt to merge different SID'
151166 '%s != %s' % (self .sid , other .sid ))
0 commit comments