zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# DO NOT EDIT THIS FILE!
#
# This file is generated from the CDP specification. If you need to make
# changes, edit the generator and regenerate all of the modules.
#
# CDP domain: Console
from __future__ import annotations
from .util import event_class, T_JSON_DICT
from dataclasses import dataclass
import enum
import typing
 
@dataclass
class ConsoleMessage:
    '''
    Console message.
    '''
    #: Message source.
    source: str
 
    #: Message severity.
    level: str
 
    #: Message text.
    text: str
 
    #: URL of the message origin.
    url: typing.Optional[str] = None
 
    #: Line number in the resource that generated this message (1-based).
    line: typing.Optional[int] = None
 
    #: Column number in the resource that generated this message (1-based).
    column: typing.Optional[int] = None
 
    def to_json(self):
        json = dict()
        json['source'] = self.source
        json['level'] = self.level
        json['text'] = self.text
        if self.url is not None:
            json['url'] = self.url
        if self.line is not None:
            json['line'] = self.line
        if self.column is not None:
            json['column'] = self.column
        return json
 
    @classmethod
    def from_json(cls, json):
        return cls(
            source=str(json['source']),
            level=str(json['level']),
            text=str(json['text']),
            url=str(json['url']) if 'url' in json else None,
            line=int(json['line']) if 'line' in json else None,
            column=int(json['column']) if 'column' in json else None,
        )
 
 
def clear_messages() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
    '''
    Does nothing.
    '''
    cmd_dict: T_JSON_DICT = {
        'method': 'Console.clearMessages',
    }
    json = yield cmd_dict
 
 
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
    '''
    Disables console domain, prevents further console messages from being reported to the client.
    '''
    cmd_dict: T_JSON_DICT = {
        'method': 'Console.disable',
    }
    json = yield cmd_dict
 
 
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
    '''
    Enables console domain, sends the messages collected so far to the client by means of the
    ``messageAdded`` notification.
    '''
    cmd_dict: T_JSON_DICT = {
        'method': 'Console.enable',
    }
    json = yield cmd_dict
 
 
@event_class('Console.messageAdded')
@dataclass
class MessageAdded:
    '''
    Issued when new console message is added.
    '''
    #: Console message that has been added.
    message: ConsoleMessage
 
    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> MessageAdded:
        return cls(
            message=ConsoleMessage.from_json(json['message'])
        )