Coverage for blind_charging/annotation.py: 69%

13 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-02-17 20:36 +0000

1from typing import Optional 

2 

3 

4class Redaction(object): 

5 def __init__( 

6 self, start: int, end: int, text: str, info: str, color: Optional[str] = None 

7 ): 

8 """Create a new redaction. 

9 

10 :param start: Start index of redaction 

11 :param end: End index of redaction 

12 :param text: Replacement text to use instead of underlying span 

13 """ 

14 self.start = start 

15 self.end = end 

16 self.text = text 

17 self.info = info 

18 self.color = color 

19 

20 def __json__(self): 

21 json = { 

22 "start": self.start, 

23 "end": self.end, 

24 "content": self.text, 

25 "extent": len(self.text), 

26 "type": "redaction", 

27 "info": self.info, 

28 } 

29 if self.color: 

30 json["format"] = {"color": self.color} 

31 return json