@@ -33,6 +33,9 @@ def safe_tag(self, tag):
3333 else :
3434 return "p"
3535
36+ def new_id (self ):
37+ return max ([obj ['id' ] for obj in self .data ]) + 1 if self .data else 0
38+
3639 def typo (self , url , old , new , name , tag = "p" ):
3740 if any (obj ['type' ] == 'typo' and
3841 obj ['url' ] == url and
@@ -42,7 +45,7 @@ def typo(self, url, old, new, name, tag="p"):
4245 if isinstance (url , str ) and isinstance (old , str ) and \
4346 isinstance (new , str ) and isinstance (name , str ):
4447 self .data .append ({
45- 'id' : len ( self .data ),
48+ 'id' : self .new_id ( ),
4649 'time' : time .time (),
4750 'type' : 'typo' ,
4851 'tag' : self .safe_tag (tag ),
@@ -65,7 +68,7 @@ def text_comment(self, url, text, comment, name, tag="p"):
6568 if isinstance (url , str ) and isinstance (text , str ) and \
6669 isinstance (comment , str ) and isinstance (name , str ):
6770 self .data .append ({
68- 'id' : len ( self .data ),
71+ 'id' : self .new_id ( ),
6972 'time' : time .time (),
7073 'type' : 'comment' ,
7174 'tag' : self .safe_tag (tag ),
@@ -87,7 +90,7 @@ def chapter_comment(self, url, comment, name, email):
8790 if isinstance (url , str ) and isinstance (email , str ) and \
8891 isinstance (comment , str ) and isinstance (name , str ):
8992 self .data .append ({
90- 'id' : len ( self .data ),
93+ 'id' : self .new_id ( ),
9194 'time' : time .time (),
9295 'type' : 'chapter_comment' ,
9396 'url' : url ,
0 commit comments