Asterisk - The Open Source Telephony Project GIT-master-f36a736
Public Member Functions | Data Fields | Static Public Attributes
Section Class Reference
Inheritance diagram for Section:
Inheritance graph
[legend]
Collaboration diagram for Section:
Collaboration graph
[legend]

Public Member Functions

def __cmp__ (self, other)
 
def __eq__ (self, other)
 
def __ge__ (self, other)
 
def __getitem__ (self, key)
 
def __gt__ (self, other)
 
def __init__ (self, defaults=None, templates=None)
 
def __le__ (self, other)
 
def __lt__ (self, other)
 
def add_defaults (self, defaults)
 
def add_templates (self, templates)
 
def get (self, key, from_self=True, from_templates=True, from_defaults=True)
 
def get_merged (self, key)
 
def keys (self, self_only=False)
 
- Public Member Functions inherited from MultiOrderedDict
def __init__ (self, *args, **kwds)
 
def __setitem__ (self, key, val, i=None)
 
def copy (self)
 
def insert (self, i, key, val)
 
- Public Member Functions inherited from OrderedDict
def __delitem__ (self, key, dict_delitem=dict.__delitem__)
 
def __eq__ (self, other)
 
def __init__ (self, *args, **kwds)
 
def __iter__ (self)
 
def __ne__ (self, other)
 
def __reduce__ (self)
 
def __repr__ (self, _repr_running={})
 
def __reversed__ (self)
 
def __setitem__ (self, key, value, dict_setitem=dict.__setitem__)
 
def clear (self)
 
def copy (self)
 
def fromkeys (cls, iterable, value=None)
 
def items (self)
 
def iteritems (self)
 
def iterkeys (self)
 
def itervalues (self)
 
def keys (self)
 
def pop (self, key, default=__marker)
 
def popitem (self, last=True)
 
def setdefault (self, key, default=None)
 
def update (*args, **kwds)
 
def values (self)
 
def viewitems (self)
 
def viewkeys (self)
 
def viewvalues (self)
 

Data Fields

 id
 

Static Public Attributes

int count = 0
 

Detailed Description

A Section is a MultiOrderedDict itself that maintains a list of
key/value options.  However, in the case of an Asterisk config
file a section may have other defaults sections that is can pull
data from (i.e. templates).  So when an option is looked up by key
it first checks the base section and if not found looks in the
added default sections. If not found at that point then a 'KeyError'
exception is raised.

Definition at line 29 of file astconfigparser.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  args = None,
  kwds = None 
)
Initialize an ordered dictionary.  Signature is the same as for
regular dictionaries, but keyword arguments are not recommended
because their insertion order is arbitrary.

Reimplemented from MultiOrderedDict.

Definition at line 41 of file astconfigparser.py.

41 def __init__(self, defaults=None, templates=None):
42 MultiOrderedDict.__init__(self)
43 # track an ordered id of sections
44 Section.count += 1
45 self.id = Section.count
46 self._defaults = [] if defaults is None else defaults
47 self._templates = [] if templates is None else templates
48

Member Function Documentation

◆ __cmp__()

def __cmp__ (   self,
  other 
)
Use self.id as means of determining equality

Definition at line 49 of file astconfigparser.py.

49 def __cmp__(self, other):
50 """
51 Use self.id as means of determining equality
52 """
53 return (self.id > other.id) - (self.id < other.id)
54

References adsi_flag.id, unistim_device.id, mbl_pvt.id, adsi_display.id, id, srv_result_datastore.id, adapter_pvt.id, adsi_event.id, adsi_soft_key.id, adsi_subscript.id, adsi_state.id, adsi_key_cmd.id, local_optimization.id, conf_menu_action.id, native_rtp_framehook_data.id, audiosocket_instance.id, Section.id, enum_result_datastore.id, ast_aoc_charging_association.id, ast_cc_monitor.id, ast_party_caller.id, ast_set_party_caller.id, ast_party_connected_line.id, ast_set_party_connected_line.id, ast_codec.id, ast_aeap_message_type.id, ast_fax_session_details.id, ast_fax_session.id, ast_geoloc_eprofile.id, ast_sip_transport_state.id, ast_sip_endpoint.id, ast_sip_session.id, ast_sip_session_sdp_handler.id, ast_rtp_engine_ice_candidate.id, ast_channel_snapshot_bridge.id, ast_endpoint_snapshot.id, ast_xmpp_message.id, ast_xmpp_buddy.id, aoc_ie_billing.id, sync_payload.id, bridge_sync.id, cel_linkedid.id, dns_HEADER.id, ast_endpoint.id, ast_framehook.id, io_rec.id, category_t.id, ast_state_cb.id, sched_id.id, ast_sorcery_object.id, cache_entry_key.id, stasis_message_type.id, stasis_state_proxy.id, stasis_state.id, stun_header.id, worker_thread.id, dundi_result_datastore.id, ast_ari_asterisk_get_object_args.id, ast_ari_asterisk_update_object_args.id, ast_ari_asterisk_delete_object_args.id, aeap_user_data.id, aeap_transaction.id, calendar_id.id, corosync_node.id, eprofiles_datastore.id, internal_state.id, exten_state_subscription.id, ast_sip_outbound_publish_state.id, mwi_subscription.id, stun_trans_id.id, hep_ctrl.id, unbound_resolver_data.id, smdi_msg_datastore.id, stasis_app_playback.id, app_forwards.id, Model.id, mock_payload.id, test_obj.id, and cache_test_data.id.

◆ __eq__()

def __eq__ (   self,
  other 
)
Use self.id as means of determining equality

Reimplemented from OrderedDict.

Definition at line 55 of file astconfigparser.py.

55 def __eq__(self, other):
56 """
57 Use self.id as means of determining equality
58 """
59 return self.id == other.id
60

References adsi_flag.id, unistim_device.id, mbl_pvt.id, adsi_display.id, id, srv_result_datastore.id, adapter_pvt.id, adsi_event.id, adsi_soft_key.id, adsi_subscript.id, adsi_state.id, adsi_key_cmd.id, local_optimization.id, conf_menu_action.id, native_rtp_framehook_data.id, audiosocket_instance.id, Section.id, enum_result_datastore.id, ast_aoc_charging_association.id, ast_cc_monitor.id, ast_party_caller.id, ast_set_party_caller.id, ast_party_connected_line.id, ast_set_party_connected_line.id, ast_codec.id, ast_aeap_message_type.id, ast_fax_session_details.id, ast_fax_session.id, ast_geoloc_eprofile.id, ast_sip_transport_state.id, ast_sip_endpoint.id, ast_sip_session.id, ast_sip_session_sdp_handler.id, ast_rtp_engine_ice_candidate.id, ast_channel_snapshot_bridge.id, ast_endpoint_snapshot.id, ast_xmpp_message.id, ast_xmpp_buddy.id, aoc_ie_billing.id, sync_payload.id, bridge_sync.id, cel_linkedid.id, dns_HEADER.id, ast_endpoint.id, ast_framehook.id, io_rec.id, category_t.id, ast_state_cb.id, sched_id.id, ast_sorcery_object.id, cache_entry_key.id, stasis_message_type.id, stasis_state_proxy.id, stasis_state.id, stun_header.id, worker_thread.id, dundi_result_datastore.id, ast_ari_asterisk_get_object_args.id, ast_ari_asterisk_update_object_args.id, ast_ari_asterisk_delete_object_args.id, aeap_user_data.id, aeap_transaction.id, calendar_id.id, corosync_node.id, eprofiles_datastore.id, internal_state.id, exten_state_subscription.id, ast_sip_outbound_publish_state.id, mwi_subscription.id, stun_trans_id.id, hep_ctrl.id, unbound_resolver_data.id, smdi_msg_datastore.id, stasis_app_playback.id, app_forwards.id, Model.id, mock_payload.id, test_obj.id, and cache_test_data.id.

◆ __ge__()

def __ge__ (   self,
  other 
)
Use self.id as means of determining equality

Definition at line 79 of file astconfigparser.py.

79 def __ge__(self, other):
80 """
81 Use self.id as means of determining equality
82 """
83 return self.id >= other.id
84

References adsi_flag.id, unistim_device.id, mbl_pvt.id, adsi_display.id, id, srv_result_datastore.id, adapter_pvt.id, adsi_event.id, adsi_soft_key.id, adsi_subscript.id, adsi_state.id, adsi_key_cmd.id, local_optimization.id, conf_menu_action.id, native_rtp_framehook_data.id, audiosocket_instance.id, Section.id, enum_result_datastore.id, ast_aoc_charging_association.id, ast_cc_monitor.id, ast_party_caller.id, ast_set_party_caller.id, ast_party_connected_line.id, ast_set_party_connected_line.id, ast_codec.id, ast_aeap_message_type.id, ast_fax_session_details.id, ast_fax_session.id, ast_geoloc_eprofile.id, ast_sip_transport_state.id, ast_sip_endpoint.id, ast_sip_session.id, ast_sip_session_sdp_handler.id, ast_rtp_engine_ice_candidate.id, ast_channel_snapshot_bridge.id, ast_endpoint_snapshot.id, ast_xmpp_message.id, ast_xmpp_buddy.id, aoc_ie_billing.id, sync_payload.id, bridge_sync.id, cel_linkedid.id, dns_HEADER.id, ast_endpoint.id, ast_framehook.id, io_rec.id, category_t.id, ast_state_cb.id, sched_id.id, ast_sorcery_object.id, cache_entry_key.id, stasis_message_type.id, stasis_state_proxy.id, stasis_state.id, stun_header.id, worker_thread.id, dundi_result_datastore.id, ast_ari_asterisk_get_object_args.id, ast_ari_asterisk_update_object_args.id, ast_ari_asterisk_delete_object_args.id, aeap_user_data.id, aeap_transaction.id, calendar_id.id, corosync_node.id, eprofiles_datastore.id, internal_state.id, exten_state_subscription.id, ast_sip_outbound_publish_state.id, mwi_subscription.id, stun_trans_id.id, hep_ctrl.id, unbound_resolver_data.id, smdi_msg_datastore.id, stasis_app_playback.id, app_forwards.id, Model.id, mock_payload.id, test_obj.id, and cache_test_data.id.

◆ __getitem__()

def __getitem__ (   self,
  key 
)
Get the value for the given key. If it is not found in the 'self'
then check inside templates and defaults before declaring raising
a KeyError exception.

Definition at line 121 of file astconfigparser.py.

121 def __getitem__(self, key):
122 """
123 Get the value for the given key. If it is not found in the 'self'
124 then check inside templates and defaults before declaring raising
125 a KeyError exception.
126 """
127 return self.get(key)
128

References Section.get(), MultiOrderedConfigParser.get(), ast_jb_impl.get, and ast_speech_engine.get.

◆ __gt__()

def __gt__ (   self,
  other 
)
Use self.id as means of determining equality

Definition at line 67 of file astconfigparser.py.

67 def __gt__(self, other):
68 """
69 Use self.id as means of determining equality
70 """
71 return self.id > other.id
72

References adsi_flag.id, unistim_device.id, mbl_pvt.id, adsi_display.id, id, srv_result_datastore.id, adapter_pvt.id, adsi_event.id, adsi_soft_key.id, adsi_subscript.id, adsi_state.id, adsi_key_cmd.id, local_optimization.id, conf_menu_action.id, native_rtp_framehook_data.id, audiosocket_instance.id, Section.id, enum_result_datastore.id, ast_aoc_charging_association.id, ast_cc_monitor.id, ast_party_caller.id, ast_set_party_caller.id, ast_party_connected_line.id, ast_set_party_connected_line.id, ast_codec.id, ast_aeap_message_type.id, ast_fax_session_details.id, ast_fax_session.id, ast_geoloc_eprofile.id, ast_sip_transport_state.id, ast_sip_endpoint.id, ast_sip_session.id, ast_sip_session_sdp_handler.id, ast_rtp_engine_ice_candidate.id, ast_channel_snapshot_bridge.id, ast_endpoint_snapshot.id, ast_xmpp_message.id, ast_xmpp_buddy.id, aoc_ie_billing.id, sync_payload.id, bridge_sync.id, cel_linkedid.id, dns_HEADER.id, ast_endpoint.id, ast_framehook.id, io_rec.id, category_t.id, ast_state_cb.id, sched_id.id, ast_sorcery_object.id, cache_entry_key.id, stasis_message_type.id, stasis_state_proxy.id, stasis_state.id, stun_header.id, worker_thread.id, dundi_result_datastore.id, ast_ari_asterisk_get_object_args.id, ast_ari_asterisk_update_object_args.id, ast_ari_asterisk_delete_object_args.id, aeap_user_data.id, aeap_transaction.id, calendar_id.id, corosync_node.id, eprofiles_datastore.id, internal_state.id, exten_state_subscription.id, ast_sip_outbound_publish_state.id, mwi_subscription.id, stun_trans_id.id, hep_ctrl.id, unbound_resolver_data.id, smdi_msg_datastore.id, stasis_app_playback.id, app_forwards.id, Model.id, mock_payload.id, test_obj.id, and cache_test_data.id.

◆ __le__()

def __le__ (   self,
  other 
)
Use self.id as means of determining equality

Definition at line 73 of file astconfigparser.py.

73 def __le__(self, other):
74 """
75 Use self.id as means of determining equality
76 """
77 return self.id <= other.id
78

References adsi_flag.id, unistim_device.id, mbl_pvt.id, adsi_display.id, id, srv_result_datastore.id, adapter_pvt.id, adsi_event.id, adsi_soft_key.id, adsi_subscript.id, adsi_state.id, adsi_key_cmd.id, local_optimization.id, conf_menu_action.id, native_rtp_framehook_data.id, audiosocket_instance.id, Section.id, enum_result_datastore.id, ast_aoc_charging_association.id, ast_cc_monitor.id, ast_party_caller.id, ast_set_party_caller.id, ast_party_connected_line.id, ast_set_party_connected_line.id, ast_codec.id, ast_aeap_message_type.id, ast_fax_session_details.id, ast_fax_session.id, ast_geoloc_eprofile.id, ast_sip_transport_state.id, ast_sip_endpoint.id, ast_sip_session.id, ast_sip_session_sdp_handler.id, ast_rtp_engine_ice_candidate.id, ast_channel_snapshot_bridge.id, ast_endpoint_snapshot.id, ast_xmpp_message.id, ast_xmpp_buddy.id, aoc_ie_billing.id, sync_payload.id, bridge_sync.id, cel_linkedid.id, dns_HEADER.id, ast_endpoint.id, ast_framehook.id, io_rec.id, category_t.id, ast_state_cb.id, sched_id.id, ast_sorcery_object.id, cache_entry_key.id, stasis_message_type.id, stasis_state_proxy.id, stasis_state.id, stun_header.id, worker_thread.id, dundi_result_datastore.id, ast_ari_asterisk_get_object_args.id, ast_ari_asterisk_update_object_args.id, ast_ari_asterisk_delete_object_args.id, aeap_user_data.id, aeap_transaction.id, calendar_id.id, corosync_node.id, eprofiles_datastore.id, internal_state.id, exten_state_subscription.id, ast_sip_outbound_publish_state.id, mwi_subscription.id, stun_trans_id.id, hep_ctrl.id, unbound_resolver_data.id, smdi_msg_datastore.id, stasis_app_playback.id, app_forwards.id, Model.id, mock_payload.id, test_obj.id, and cache_test_data.id.

◆ __lt__()

def __lt__ (   self,
  other 
)
Use self.id as means of determining equality

Definition at line 61 of file astconfigparser.py.

61 def __lt__(self, other):
62 """
63 Use self.id as means of determining equality
64 """
65 return self.id < other.id
66

References adsi_flag.id, unistim_device.id, mbl_pvt.id, adsi_display.id, id, srv_result_datastore.id, adapter_pvt.id, adsi_event.id, adsi_soft_key.id, adsi_subscript.id, adsi_state.id, adsi_key_cmd.id, local_optimization.id, conf_menu_action.id, native_rtp_framehook_data.id, audiosocket_instance.id, Section.id, enum_result_datastore.id, ast_aoc_charging_association.id, ast_cc_monitor.id, ast_party_caller.id, ast_set_party_caller.id, ast_party_connected_line.id, ast_set_party_connected_line.id, ast_codec.id, ast_aeap_message_type.id, ast_fax_session_details.id, ast_fax_session.id, ast_geoloc_eprofile.id, ast_sip_transport_state.id, ast_sip_endpoint.id, ast_sip_session.id, ast_sip_session_sdp_handler.id, ast_rtp_engine_ice_candidate.id, ast_channel_snapshot_bridge.id, ast_endpoint_snapshot.id, ast_xmpp_message.id, ast_xmpp_buddy.id, aoc_ie_billing.id, sync_payload.id, bridge_sync.id, cel_linkedid.id, dns_HEADER.id, ast_endpoint.id, ast_framehook.id, io_rec.id, category_t.id, ast_state_cb.id, sched_id.id, ast_sorcery_object.id, cache_entry_key.id, stasis_message_type.id, stasis_state_proxy.id, stasis_state.id, stun_header.id, worker_thread.id, dundi_result_datastore.id, ast_ari_asterisk_get_object_args.id, ast_ari_asterisk_update_object_args.id, ast_ari_asterisk_delete_object_args.id, aeap_user_data.id, aeap_transaction.id, calendar_id.id, corosync_node.id, eprofiles_datastore.id, internal_state.id, exten_state_subscription.id, ast_sip_outbound_publish_state.id, mwi_subscription.id, stun_trans_id.id, hep_ctrl.id, unbound_resolver_data.id, smdi_msg_datastore.id, stasis_app_playback.id, app_forwards.id, Model.id, mock_payload.id, test_obj.id, and cache_test_data.id.

◆ add_defaults()

def add_defaults (   self,
  defaults 
)
Add a list of defaults to the section. Defaults are
sections such as 'general'

Definition at line 150 of file astconfigparser.py.

150 def add_defaults(self, defaults):
151 """
152 Add a list of defaults to the section. Defaults are
153 sections such as 'general'
154 """
155 defaults.sort()
156 for i in defaults:
157 self._defaults.insert(0, i)
158

References Section._defaults, MultiOrderedConfigParser._defaults, and MultiOrderedDict.insert().

◆ add_templates()

def add_templates (   self,
  templates 
)
Add a list of templates to the section.

Definition at line 159 of file astconfigparser.py.

159 def add_templates(self, templates):
160 """
161 Add a list of templates to the section.
162 """
163 templates.sort()
164 for i in templates:
165 self._templates.insert(0, i)
166

References Section._templates, and MultiOrderedDict.insert().

◆ get()

def get (   self,
  key,
  from_self = True,
  from_templates = True,
  from_defaults = True 
)
Get the values corresponding to a given key. The parameters to this
function form a hierarchy that determines priority of the search.
from_self takes priority over from_templates, and from_templates takes
priority over from_defaults.

Parameters:
from_self - If True, search within the given section.
from_templates - If True, search in this section's templates.
from_defaults - If True, search within this section's defaults.

Definition at line 85 of file astconfigparser.py.

86 from_defaults=True):
87 """
88 Get the values corresponding to a given key. The parameters to this
89 function form a hierarchy that determines priority of the search.
90 from_self takes priority over from_templates, and from_templates takes
91 priority over from_defaults.
92
93 Parameters:
94 from_self - If True, search within the given section.
95 from_templates - If True, search in this section's templates.
96 from_defaults - If True, search within this section's defaults.
97 """
98 if from_self and key in self:
99 return MultiOrderedDict.__getitem__(self, key)
100
101 if from_templates:
102 if self in self._templates:
103 return []
104 for t in self._templates:
105 try:
106 # fail if not found on the search - doing it this way
107 # allows template's templates to be searched.
108 return t.get(key, True, from_templates, from_defaults)
109 except KeyError:
110 pass
111
112 if from_defaults:
113 for d in self._defaults:
114 try:
115 return d.get(key, True, from_templates, from_defaults)
116 except KeyError:
117 pass
118
119 raise KeyError(key)
120

References Section._defaults, MultiOrderedConfigParser._defaults, and Section._templates.

Referenced by Section.__getitem__(), and MultiOrderedConfigParser.multi_get().

◆ get_merged()

def get_merged (   self,
  key 
)
Return a list of values for a given key merged from default(s)

Definition at line 167 of file astconfigparser.py.

167 def get_merged(self, key):
168 """Return a list of values for a given key merged from default(s)"""
169 # first merge key/values from defaults together
170 merged = []
171 for i in reversed(self._defaults):
172 if not merged:
173 merged = i
174 continue
175 merged = merge_values(merged, i, key)
176
177 for i in reversed(self._templates):
178 if not merged:
179 merged = i
180 continue
181 merged = merge_values(merged, i, key)
182
183 # then merge self in
184 return merge_values(merged, self, key)
185
def merge_values(left, right, key)

References Section._defaults, MultiOrderedConfigParser._defaults, Section._templates, and astconfigparser.merge_values().

◆ keys()

def keys (   self,
  self_only = False 
)
Get the keys from this section. If self_only is True, then
keys from this section's defaults and templates are not
included in the returned value

Reimplemented from OrderedDict.

Definition at line 129 of file astconfigparser.py.

129 def keys(self, self_only=False):
130 """
131 Get the keys from this section. If self_only is True, then
132 keys from this section's defaults and templates are not
133 included in the returned value
134 """
135 res = MultiOrderedDict.keys(self)
136 if self_only:
137 return res
138
139 for d in self._templates:
140 for key in d.keys():
141 if key not in res:
142 res.append(key)
143
144 for d in self._defaults:
145 for key in d.keys():
146 if key not in res:
147 res.append(key)
148 return res
149
static struct keys keys

References Section._defaults, MultiOrderedConfigParser._defaults, and Section._templates.

Field Documentation

◆ count

int count = 0
static

Definition at line 39 of file astconfigparser.py.

◆ id

id

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