Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
scripts.multiemitter.MultiEmitter Class Reference
Inheritance diagram for scripts.multiemitter.MultiEmitter:

Public Member Functions

def __init__ (self, logging_level=logging.WARNING)
 
def FileEmitter (self, filename, key=None)
 
def Associate (self, key, emitter)
 
def Find (self, key)
 
def Flush (self, writer=None)
 

Detailed Description

A set of Emitters that write to different files.

Each entry has a key.

file --> emitter
key --> emitter

Definition at line 17 of file multiemitter.py.

Constructor & Destructor Documentation

◆ __init__()

def scripts.multiemitter.MultiEmitter.__init__ (   self,
  logging_level = logging.WARNING 
)

Definition at line 27 of file multiemitter.py.

27 def __init__(self, logging_level=logging.WARNING):
28 self._key_to_emitter = {} # key -> Emitter
29 self._filename_to_emitter = {} # filename -> Emitter
30
31 _logger.setLevel(logging_level)
32

Member Function Documentation

◆ Associate()

def scripts.multiemitter.MultiEmitter.Associate (   self,
  key,
  emitter 
)
Associates a key with an emitter.

Definition at line 51 of file multiemitter.py.

51 def Associate(self, key, emitter):
52 """Associates a key with an emitter."""
53 self._key_to_emitter[key] = emitter
54

◆ FileEmitter()

def scripts.multiemitter.MultiEmitter.FileEmitter (   self,
  filename,
  key = None 
)
Creates an emitter for writing to a file.

When this MultiEmitter is flushed, the contents of the emitter are written
to the file.

Arguments:
filename: a string, the path name of the file
key: provides an access key to retrieve the emitter.

Returns: the emitter.

Definition at line 33 of file multiemitter.py.

33 def FileEmitter(self, filename, key=None):
34 """Creates an emitter for writing to a file.
35
36 When this MultiEmitter is flushed, the contents of the emitter are written
37 to the file.
38
39 Arguments:
40 filename: a string, the path name of the file
41 key: provides an access key to retrieve the emitter.
42
43 Returns: the emitter.
44 """
45 e = emitter.Emitter()
46 self._filename_to_emitter[filename] = e
47 if key:
48 self.Associate(key, e)
49 return e
50

◆ Find()

def scripts.multiemitter.MultiEmitter.Find (   self,
  key 
)
Returns the emitter associated with |key|.

Definition at line 55 of file multiemitter.py.

55 def Find(self, key):
56 """Returns the emitter associated with |key|."""
57 return self._key_to_emitter[key]
58

◆ Flush()

def scripts.multiemitter.MultiEmitter.Flush (   self,
  writer = None 
)
Writes all pending files.

Arguments:
writer: a function called for each file and it's lines.

Definition at line 59 of file multiemitter.py.

59 def Flush(self, writer=None):
60 """Writes all pending files.
61
62 Arguments:
63 writer: a function called for each file and it's lines.
64 """
65 if not writer:
66 writer = _WriteFile
67 for file in sorted(self._filename_to_emitter.keys()):
68 emitter = self._filename_to_emitter[file]
69 writer(file, emitter.Fragments())
70
71
void Flush(SkSurface *surface)
Definition: GpuTools.h:25

The documentation for this class was generated from the following file: