Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
tools.skpbench.skiaperf.JSONDict Class Reference
Inheritance diagram for tools.skpbench.skiaperf.JSONDict:

Public Member Functions

def __init__ (self, key_value_pairs=None)
 
def __getitem__ (self, key)
 
def __setitem__ (self, key, val)
 
def emit (self, outfile)
 

Detailed Description

Simple class for building a JSON dictionary

Returns another JSONDict upon accessing an undefined item. Does not allow an
item to change once it has been inserted.

Definition at line 33 of file skiaperf.py.

Constructor & Destructor Documentation

◆ __init__()

def tools.skpbench.skiaperf.JSONDict.__init__ (   self,
  key_value_pairs = None 
)

Definition at line 40 of file skiaperf.py.

40 def __init__(self, key_value_pairs=None):
41 dict.__init__(self)
42 if not key_value_pairs:
43 return
44 if len(key_value_pairs) % 2:
45 raise Exception("uneven number of key/value arguments.")
46 for k,v in zip(key_value_pairs[::2], key_value_pairs[1::2]):
47 self[k] = v
48
Definition: zip.py:1

Member Function Documentation

◆ __getitem__()

def tools.skpbench.skiaperf.JSONDict.__getitem__ (   self,
  key 
)

Definition at line 49 of file skiaperf.py.

49 def __getitem__(self, key):
50 if not key in self:
51 dict.__setitem__(self, key, JSONDict())
52 return dict.__getitem__(self, key)
53

◆ __setitem__()

def tools.skpbench.skiaperf.JSONDict.__setitem__ (   self,
  key,
  val 
)

Definition at line 54 of file skiaperf.py.

54 def __setitem__(self, key, val):
55 if key in self:
56 raise Exception("%s: tried to set already-defined JSONDict item\n"
57 " old value: '%s'\n"
58 " new value: '%s'" % (key, self[key], val))
59 dict.__setitem__(self, key, val)
60

◆ emit()

def tools.skpbench.skiaperf.JSONDict.emit (   self,
  outfile 
)

Definition at line 61 of file skiaperf.py.

61 def emit(self, outfile):
62 json.dump(self, outfile, indent=4, separators=(',', ' : '), sort_keys=True)
63 print('', file=outfile)
64
def print(*args, **kwargs)
Definition: run_tests.py:49

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