Belle II Software development
NoReplacementField Class Reference

Public Member Functions

def __init__ (self, field_name, conversion=None, format_spec=None)
 
def __getattr__ (self, attr)
 
def __getitem__ (self, attr)
 
def compose (self)
 

Public Attributes

 field_name
 cached value of the field name
 
 conversion
 cached value of the conversion specifier
 
 format_spec
 cached value of the format specifier
 

Detailed Description

This class serves as a placeholder for keys in not found during lookup into
keyword or positional arguments during a call to TolerateMissingKeyFormatter.

It records potential item and attribute lookups, conversion and format_spec to
reproduce original replacement_field entry into the formatted string.

Parameters
----------
field_name : str
    field_name part of the replacement_field specifier
conversion : str
    conversion part of the replacement_field specifier
format_spec : str%
    format_spec part of the replacement_field specifier

Notes
-----
replacement_field, field_name, conversion and format_spec have the meaning as outlined in
https://docs.python.org/2/library/string.html#format-string-syntax

Definition at line 13 of file tolerate_missing_key_formatter.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  field_name,
  conversion = None,
  format_spec = None 
)
Constructor

Definition at line 36 of file tolerate_missing_key_formatter.py.

36 def __init__(self, field_name, conversion=None, format_spec=None):
37 """Constructor"""
38
39
40 self.field_name = field_name
41
42 self.conversion = conversion
43
44 self.format_spec = format_spec
45

Member Function Documentation

◆ __getattr__()

def __getattr__ (   self,
  attr 
)
Record attribute lookup

Definition at line 46 of file tolerate_missing_key_formatter.py.

46 def __getattr__(self, attr):
47 """Record attribute lookup"""
48 return NoReplacementField(self.field_name + "." + attr)
49

◆ __getitem__()

def __getitem__ (   self,
  attr 
)
Record item lookup

Definition at line 50 of file tolerate_missing_key_formatter.py.

50 def __getitem__(self, attr):
51 """Record item lookup"""
52 return NoReplacementField(self.field_name + "[" + str(attr) + "]")
53

◆ compose()

def compose (   self)
Compose a replacement_field string equivalent to the original replacement_field in the string formatting.

Definition at line 54 of file tolerate_missing_key_formatter.py.

54 def compose(self):
55 """Compose a replacement_field string equivalent to the original replacement_field in the string formatting."""
56 text_in_brackets = self.field_name
57
58 if self.conversion is not None:
59 text_in_brackets += "!" + self.conversion
60
61 if self.format_spec is not None:
62 text_in_brackets += ":" + self.format_spec
63
64 replacement_field = "{" + text_in_brackets + "}"
65 return replacement_field
66
67

Member Data Documentation

◆ conversion

conversion

cached value of the conversion specifier

Definition at line 42 of file tolerate_missing_key_formatter.py.

◆ field_name

field_name

cached value of the field name

Definition at line 40 of file tolerate_missing_key_formatter.py.

◆ format_spec

format_spec

cached value of the format specifier

Definition at line 44 of file tolerate_missing_key_formatter.py.


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