body
stringlengths 26
98.2k
| body_hash
int64 -9,222,864,604,528,158,000
9,221,803,474B
| docstring
stringlengths 1
16.8k
| path
stringlengths 5
230
| name
stringlengths 1
96
| repository_name
stringlengths 7
89
| lang
stringclasses 1
value | body_without_docstring
stringlengths 20
98.2k
|
|---|---|---|---|---|---|---|---|
def _migrate_alerts_to_user(self):
"\n Transfer any active alerts linked to a user's email address to the\n newly registered user.\n "
ProductAlert = self.alerts.model
alerts = ProductAlert.objects.filter(email=self.email, status=ProductAlert.ACTIVE)
alerts.update(user=self, key='', email='')
| 8,188,914,276,710,226,000
|
Transfer any active alerts linked to a user's email address to the
newly registered user.
|
src/oscar/apps/customer/abstract_models.py
|
_migrate_alerts_to_user
|
Abirami15/django-oscar
|
python
|
def _migrate_alerts_to_user(self):
"\n Transfer any active alerts linked to a user's email address to the\n newly registered user.\n "
ProductAlert = self.alerts.model
alerts = ProductAlert.objects.filter(email=self.email, status=ProductAlert.ACTIVE)
alerts.update(user=self, key=, email=)
|
def burnin_action_func():
'Select random actions until model is updated one or more times.'
return np.random.uniform(action_space.low, action_space.high).astype(np.float32)
| -3,542,636,584,993,908,700
|
Select random actions until model is updated one or more times.
|
examples/mujoco/reproduction/td3/train_td3.py
|
burnin_action_func
|
toslunar/pfrl
|
python
|
def burnin_action_func():
return np.random.uniform(action_space.low, action_space.high).astype(np.float32)
|
def test_create_namespaced_endpoint_slice(self):
'Test case for create_namespaced_endpoint_slice\n\n '
pass
| 6,967,969,199,373,308,000
|
Test case for create_namespaced_endpoint_slice
|
kubernetes/test/test_discovery_v1alpha1_api.py
|
test_create_namespaced_endpoint_slice
|
ACXLM/python
|
python
|
def test_create_namespaced_endpoint_slice(self):
'\n\n '
pass
|
def test_delete_collection_namespaced_endpoint_slice(self):
'Test case for delete_collection_namespaced_endpoint_slice\n\n '
pass
| -4,308,250,587,412,544,500
|
Test case for delete_collection_namespaced_endpoint_slice
|
kubernetes/test/test_discovery_v1alpha1_api.py
|
test_delete_collection_namespaced_endpoint_slice
|
ACXLM/python
|
python
|
def test_delete_collection_namespaced_endpoint_slice(self):
'\n\n '
pass
|
def test_delete_namespaced_endpoint_slice(self):
'Test case for delete_namespaced_endpoint_slice\n\n '
pass
| -6,705,403,246,008,787,000
|
Test case for delete_namespaced_endpoint_slice
|
kubernetes/test/test_discovery_v1alpha1_api.py
|
test_delete_namespaced_endpoint_slice
|
ACXLM/python
|
python
|
def test_delete_namespaced_endpoint_slice(self):
'\n\n '
pass
|
def test_get_api_resources(self):
'Test case for get_api_resources\n\n '
pass
| -3,517,160,739,447,319,000
|
Test case for get_api_resources
|
kubernetes/test/test_discovery_v1alpha1_api.py
|
test_get_api_resources
|
ACXLM/python
|
python
|
def test_get_api_resources(self):
'\n\n '
pass
|
def test_list_endpoint_slice_for_all_namespaces(self):
'Test case for list_endpoint_slice_for_all_namespaces\n\n '
pass
| -3,018,315,634,421,458,000
|
Test case for list_endpoint_slice_for_all_namespaces
|
kubernetes/test/test_discovery_v1alpha1_api.py
|
test_list_endpoint_slice_for_all_namespaces
|
ACXLM/python
|
python
|
def test_list_endpoint_slice_for_all_namespaces(self):
'\n\n '
pass
|
def test_list_namespaced_endpoint_slice(self):
'Test case for list_namespaced_endpoint_slice\n\n '
pass
| -5,316,603,969,257,258,000
|
Test case for list_namespaced_endpoint_slice
|
kubernetes/test/test_discovery_v1alpha1_api.py
|
test_list_namespaced_endpoint_slice
|
ACXLM/python
|
python
|
def test_list_namespaced_endpoint_slice(self):
'\n\n '
pass
|
def test_patch_namespaced_endpoint_slice(self):
'Test case for patch_namespaced_endpoint_slice\n\n '
pass
| -6,017,129,758,885,959,000
|
Test case for patch_namespaced_endpoint_slice
|
kubernetes/test/test_discovery_v1alpha1_api.py
|
test_patch_namespaced_endpoint_slice
|
ACXLM/python
|
python
|
def test_patch_namespaced_endpoint_slice(self):
'\n\n '
pass
|
def test_read_namespaced_endpoint_slice(self):
'Test case for read_namespaced_endpoint_slice\n\n '
pass
| -4,456,913,912,642,745,000
|
Test case for read_namespaced_endpoint_slice
|
kubernetes/test/test_discovery_v1alpha1_api.py
|
test_read_namespaced_endpoint_slice
|
ACXLM/python
|
python
|
def test_read_namespaced_endpoint_slice(self):
'\n\n '
pass
|
def test_replace_namespaced_endpoint_slice(self):
'Test case for replace_namespaced_endpoint_slice\n\n '
pass
| -8,514,298,246,401,826,000
|
Test case for replace_namespaced_endpoint_slice
|
kubernetes/test/test_discovery_v1alpha1_api.py
|
test_replace_namespaced_endpoint_slice
|
ACXLM/python
|
python
|
def test_replace_namespaced_endpoint_slice(self):
'\n\n '
pass
|
def _shuffle_members(self):
"Non-recursive shuffling of this section's members."
members = list(self.members.items())
shuffle(members)
self._members = dict(members)
| -541,292,337,497,925,900
|
Non-recursive shuffling of this section's members.
|
src/alfred3/section.py
|
_shuffle_members
|
ctreffe/alfred
|
python
|
def _shuffle_members(self):
members = list(self.members.items())
shuffle(members)
self._members = dict(members)
|
@property
def members(self) -> dict:
"\n Dictionary of the section's members.\n "
return self._members
| 4,628,018,571,238,628,000
|
Dictionary of the section's members.
|
src/alfred3/section.py
|
members
|
ctreffe/alfred
|
python
|
@property
def members(self) -> dict:
"\n \n "
return self._members
|
@property
def empty(self) -> bool:
'\n True, if there are no pages or subsections in this section.\n '
return (False if self.members else True)
| -7,433,897,029,048,087,000
|
True, if there are no pages or subsections in this section.
|
src/alfred3/section.py
|
empty
|
ctreffe/alfred
|
python
|
@property
def empty(self) -> bool:
'\n \n '
return (False if self.members else True)
|
@property
def all_updated_members(self) -> dict:
'\n Returns a dict of all members that already have exp access.\n Operates recursively, i.e. pages and subsections of subsections\n are included.\n '
return {name: m for (name, m) in self.all_members.items() if (m.exp is not None)}
| 6,464,644,984,505,028,000
|
Returns a dict of all members that already have exp access.
Operates recursively, i.e. pages and subsections of subsections
are included.
|
src/alfred3/section.py
|
all_updated_members
|
ctreffe/alfred
|
python
|
@property
def all_updated_members(self) -> dict:
'\n Returns a dict of all members that already have exp access.\n Operates recursively, i.e. pages and subsections of subsections\n are included.\n '
return {name: m for (name, m) in self.all_members.items() if (m.exp is not None)}
|
@property
def all_updated_pages(self) -> dict:
'\n Returns a dict of all pages in the current section that have\n access to the experiment session. Operates recursively, i.e.\n pages in subsections are included.\n '
pages = {}
for (name, member) in self.all_updated_members.items():
if isinstance(member, _PageCore):
pages[name] = member
return pages
| -4,069,789,948,536,934,400
|
Returns a dict of all pages in the current section that have
access to the experiment session. Operates recursively, i.e.
pages in subsections are included.
|
src/alfred3/section.py
|
all_updated_pages
|
ctreffe/alfred
|
python
|
@property
def all_updated_pages(self) -> dict:
'\n Returns a dict of all pages in the current section that have\n access to the experiment session. Operates recursively, i.e.\n pages in subsections are included.\n '
pages = {}
for (name, member) in self.all_updated_members.items():
if isinstance(member, _PageCore):
pages[name] = member
return pages
|
@property
def all_updated_elements(self) -> dict:
'\n Returns a dict of all elements in the current section that have\n access to the experiment session. Operates recursively, i.e.\n elements on pages in subsections are included.\n '
elements = {}
for page in self.all_updated_pages.values():
elements.update(page.updated_elements)
return elements
| 9,115,409,147,925,964,000
|
Returns a dict of all elements in the current section that have
access to the experiment session. Operates recursively, i.e.
elements on pages in subsections are included.
|
src/alfred3/section.py
|
all_updated_elements
|
ctreffe/alfred
|
python
|
@property
def all_updated_elements(self) -> dict:
'\n Returns a dict of all elements in the current section that have\n access to the experiment session. Operates recursively, i.e.\n elements on pages in subsections are included.\n '
elements = {}
for page in self.all_updated_pages.values():
elements.update(page.updated_elements)
return elements
|
@property
def all_members(self) -> dict:
'\n Returns a flat dict of all members in this section and its subsections.\n\n The order is preserved, i.e. members are listed in this dict in\n the same order in which they appear in the experiment.\n '
members = {}
for (name, member) in self.members.items():
members[name] = member
if isinstance(member, Section):
members.update(member.all_members)
return members
| 4,820,792,085,479,438,000
|
Returns a flat dict of all members in this section and its subsections.
The order is preserved, i.e. members are listed in this dict in
the same order in which they appear in the experiment.
|
src/alfred3/section.py
|
all_members
|
ctreffe/alfred
|
python
|
@property
def all_members(self) -> dict:
'\n Returns a flat dict of all members in this section and its subsections.\n\n The order is preserved, i.e. members are listed in this dict in\n the same order in which they appear in the experiment.\n '
members = {}
for (name, member) in self.members.items():
members[name] = member
if isinstance(member, Section):
members.update(member.all_members)
return members
|
@property
def last_member(self):
'\n Returns the last member of the current section. Can be a page\n or a subsection.\n '
try:
return list(self.members.values())[(- 1)]
except IndexError:
return None
| -1,284,087,237,134,734,600
|
Returns the last member of the current section. Can be a page
or a subsection.
|
src/alfred3/section.py
|
last_member
|
ctreffe/alfred
|
python
|
@property
def last_member(self):
'\n Returns the last member of the current section. Can be a page\n or a subsection.\n '
try:
return list(self.members.values())[(- 1)]
except IndexError:
return None
|
@property
def first_member(self):
'\n Returns the first member of the current section. Can be a page\n or a subsection.\n '
try:
return list(self.members.values())[0]
except IndexError:
return None
| 159,721,463,895,738,100
|
Returns the first member of the current section. Can be a page
or a subsection.
|
src/alfred3/section.py
|
first_member
|
ctreffe/alfred
|
python
|
@property
def first_member(self):
'\n Returns the first member of the current section. Can be a page\n or a subsection.\n '
try:
return list(self.members.values())[0]
except IndexError:
return None
|
@property
def first_page(self):
'\n Returns the first page inside the current section.\n '
try:
return list(self.all_pages.values())[0]
except IndexError:
return None
| -482,715,077,692,563,840
|
Returns the first page inside the current section.
|
src/alfred3/section.py
|
first_page
|
ctreffe/alfred
|
python
|
@property
def first_page(self):
'\n \n '
try:
return list(self.all_pages.values())[0]
except IndexError:
return None
|
@property
def last_page(self):
'\n Returns the last page inside the current section.\n '
try:
return list(self.all_pages.values())[(- 1)]
except IndexError:
return None
| -3,403,605,383,365,845,000
|
Returns the last page inside the current section.
|
src/alfred3/section.py
|
last_page
|
ctreffe/alfred
|
python
|
@property
def last_page(self):
'\n \n '
try:
return list(self.all_pages.values())[(- 1)]
except IndexError:
return None
|
@property
def all_subsections(self) -> dict:
'\n Returns a flat dict of all sections in this section and its subsections.\n\n The order is preserved, i.e. sections are listed in this dict in\n the same order in which they appear in the experiment.\n '
subsections = {}
for (name, member) in self.members.items():
if isinstance(member, Section):
subsections[name] = member
subsections.update(member.all_subsections)
return subsections
| 2,256,899,079,032,611,600
|
Returns a flat dict of all sections in this section and its subsections.
The order is preserved, i.e. sections are listed in this dict in
the same order in which they appear in the experiment.
|
src/alfred3/section.py
|
all_subsections
|
ctreffe/alfred
|
python
|
@property
def all_subsections(self) -> dict:
'\n Returns a flat dict of all sections in this section and its subsections.\n\n The order is preserved, i.e. sections are listed in this dict in\n the same order in which they appear in the experiment.\n '
subsections = {}
for (name, member) in self.members.items():
if isinstance(member, Section):
subsections[name] = member
subsections.update(member.all_subsections)
return subsections
|
@property
def subsections(self) -> dict:
'\n Returns a flat dict of all subsections in this section.\n\n Subsections in subsections are not included. Use\n :attr:`.all_subsections` for that purpose.\n '
return {name: sec for (name, sec) in self.members.items() if isinstance(sec, Section)}
| -4,685,276,551,271,564,000
|
Returns a flat dict of all subsections in this section.
Subsections in subsections are not included. Use
:attr:`.all_subsections` for that purpose.
|
src/alfred3/section.py
|
subsections
|
ctreffe/alfred
|
python
|
@property
def subsections(self) -> dict:
'\n Returns a flat dict of all subsections in this section.\n\n Subsections in subsections are not included. Use\n :attr:`.all_subsections` for that purpose.\n '
return {name: sec for (name, sec) in self.members.items() if isinstance(sec, Section)}
|
@property
def all_pages(self) -> dict:
'\n Returns a flat dict of all pages in this section and its subsections.\n\n The order is preserved, i.e. pages are listed in this dict in\n the same order in which they appear in the experiment.\n '
pages = {}
for (name, member) in self.members.items():
if isinstance(member, _PageCore):
pages[name] = member
elif isinstance(member, Section):
pages.update(member.all_pages)
return pages
| -9,055,108,038,299,239,000
|
Returns a flat dict of all pages in this section and its subsections.
The order is preserved, i.e. pages are listed in this dict in
the same order in which they appear in the experiment.
|
src/alfred3/section.py
|
all_pages
|
ctreffe/alfred
|
python
|
@property
def all_pages(self) -> dict:
'\n Returns a flat dict of all pages in this section and its subsections.\n\n The order is preserved, i.e. pages are listed in this dict in\n the same order in which they appear in the experiment.\n '
pages = {}
for (name, member) in self.members.items():
if isinstance(member, _PageCore):
pages[name] = member
elif isinstance(member, Section):
pages.update(member.all_pages)
return pages
|
@property
def all_closed_pages(self) -> dict:
'\n Returns a flat dict of all *closed* pages in this section and its\n subsections.\n\n The order is preserved, i.e. pages are listed in this dict in\n the same order in which they appear in the experiment.\n '
return {name: page for (name, page) in self.all_pages.items() if page.is_closed}
| 3,720,372,728,307,364,400
|
Returns a flat dict of all *closed* pages in this section and its
subsections.
The order is preserved, i.e. pages are listed in this dict in
the same order in which they appear in the experiment.
|
src/alfred3/section.py
|
all_closed_pages
|
ctreffe/alfred
|
python
|
@property
def all_closed_pages(self) -> dict:
'\n Returns a flat dict of all *closed* pages in this section and its\n subsections.\n\n The order is preserved, i.e. pages are listed in this dict in\n the same order in which they appear in the experiment.\n '
return {name: page for (name, page) in self.all_pages.items() if page.is_closed}
|
@property
def all_shown_pages(self) -> dict:
'\n Returns a flat dict of all pages in this section and its\n subsections that have already been shown.\n\n The order is preserved, i.e. pages are listed in this dict in\n the same order in which they appear in the experiment.\n '
return {name: page for (name, page) in self.all_pages.items() if page.has_been_shown}
| -977,786,988,546,026,400
|
Returns a flat dict of all pages in this section and its
subsections that have already been shown.
The order is preserved, i.e. pages are listed in this dict in
the same order in which they appear in the experiment.
|
src/alfred3/section.py
|
all_shown_pages
|
ctreffe/alfred
|
python
|
@property
def all_shown_pages(self) -> dict:
'\n Returns a flat dict of all pages in this section and its\n subsections that have already been shown.\n\n The order is preserved, i.e. pages are listed in this dict in\n the same order in which they appear in the experiment.\n '
return {name: page for (name, page) in self.all_pages.items() if page.has_been_shown}
|
@property
def pages(self) -> dict:
'\n Returns a flat dict of all pages in this section.\n\n Pages in subsections are not included. Use :attr:`.all_pages`\n for that purpose.\n '
return {name: page for (name, page) in self.members.items() if isinstance(page, _PageCore)}
| 2,295,304,945,504,118,500
|
Returns a flat dict of all pages in this section.
Pages in subsections are not included. Use :attr:`.all_pages`
for that purpose.
|
src/alfred3/section.py
|
pages
|
ctreffe/alfred
|
python
|
@property
def pages(self) -> dict:
'\n Returns a flat dict of all pages in this section.\n\n Pages in subsections are not included. Use :attr:`.all_pages`\n for that purpose.\n '
return {name: page for (name, page) in self.members.items() if isinstance(page, _PageCore)}
|
@property
def all_elements(self) -> dict:
'\n Returns a flat dict of all elements in this section.\n\n Recursive: Includes elements from pages in this section and all\n its subsections.\n '
elements = {}
for page in self.all_pages.values():
elements.update(page.elements)
return elements
| -7,676,972,339,128,569,000
|
Returns a flat dict of all elements in this section.
Recursive: Includes elements from pages in this section and all
its subsections.
|
src/alfred3/section.py
|
all_elements
|
ctreffe/alfred
|
python
|
@property
def all_elements(self) -> dict:
'\n Returns a flat dict of all elements in this section.\n\n Recursive: Includes elements from pages in this section and all\n its subsections.\n '
elements = {}
for page in self.all_pages.values():
elements.update(page.elements)
return elements
|
@property
def all_input_elements(self) -> dict:
'\n Returns a flat dict of all input elements in this section.\n\n Recursive: Includes elements from pages in this section and all\n its subsections.\n '
elements = {}
for page in self.all_pages.values():
elements.update(page.input_elements)
return elements
| -6,885,980,519,612,828,000
|
Returns a flat dict of all input elements in this section.
Recursive: Includes elements from pages in this section and all
its subsections.
|
src/alfred3/section.py
|
all_input_elements
|
ctreffe/alfred
|
python
|
@property
def all_input_elements(self) -> dict:
'\n Returns a flat dict of all input elements in this section.\n\n Recursive: Includes elements from pages in this section and all\n its subsections.\n '
elements = {}
for page in self.all_pages.values():
elements.update(page.input_elements)
return elements
|
@property
def all_shown_input_elements(self) -> dict:
'\n Returns a flat dict of all shown input elements in this section.\n\n Recursive: Includes elements from pages in this section and all\n its subsections.\n '
elements = {}
for page in self.all_pages.values():
if page.has_been_shown:
elements.update(page.input_elements)
return elements
| 927,104,831,021,543,400
|
Returns a flat dict of all shown input elements in this section.
Recursive: Includes elements from pages in this section and all
its subsections.
|
src/alfred3/section.py
|
all_shown_input_elements
|
ctreffe/alfred
|
python
|
@property
def all_shown_input_elements(self) -> dict:
'\n Returns a flat dict of all shown input elements in this section.\n\n Recursive: Includes elements from pages in this section and all\n its subsections.\n '
elements = {}
for page in self.all_pages.values():
if page.has_been_shown:
elements.update(page.input_elements)
return elements
|
@property
def data(self) -> dict:
'\n Returns a dictionary of user input data for all pages in this\n section and its subsections.\n '
data = {}
for page in self.all_pages.values():
data.update(page.data)
return data
| -1,315,948,296,893,108,000
|
Returns a dictionary of user input data for all pages in this
section and its subsections.
|
src/alfred3/section.py
|
data
|
ctreffe/alfred
|
python
|
@property
def data(self) -> dict:
'\n Returns a dictionary of user input data for all pages in this\n section and its subsections.\n '
data = {}
for page in self.all_pages.values():
data.update(page.data)
return data
|
@property
def unlinked_data(self) -> dict:
'\n Returns a dictionary of user input data for all *unlinked* pages\n in this section and its subsections.\n '
data = {}
for page in self.all_pages.values():
data.update(page.unlinked_data)
return data
| 6,063,287,200,941,507,000
|
Returns a dictionary of user input data for all *unlinked* pages
in this section and its subsections.
|
src/alfred3/section.py
|
unlinked_data
|
ctreffe/alfred
|
python
|
@property
def unlinked_data(self) -> dict:
'\n Returns a dictionary of user input data for all *unlinked* pages\n in this section and its subsections.\n '
data = {}
for page in self.all_pages.values():
data.update(page.unlinked_data)
return data
|
def append(self, *items):
'\n Appends a variable number of pages or subsections to the section.\n\n In practice, it is recommended to use the augmented assignment\n operator ``+=`` instead in order to add pages or subsections.\n '
for item in items:
if (item.name in dir(self)):
raise ValueError(f'Name of {item} is also an attribute of {self}.')
if (item.name in self.members):
raise AlfredError(f"Name '{item.name}' is already present in the experiment.")
item.added_to_section(self)
self.members[item.name] = item
if (self.experiment is not None):
item.added_to_experiment(self.experiment)
item._update_members_recursively()
if (not item.tag):
item.tag = str((len(self.members) + 1))
| -930,174,773,543,036,700
|
Appends a variable number of pages or subsections to the section.
In practice, it is recommended to use the augmented assignment
operator ``+=`` instead in order to add pages or subsections.
|
src/alfred3/section.py
|
append
|
ctreffe/alfred
|
python
|
def append(self, *items):
'\n Appends a variable number of pages or subsections to the section.\n\n In practice, it is recommended to use the augmented assignment\n operator ``+=`` instead in order to add pages or subsections.\n '
for item in items:
if (item.name in dir(self)):
raise ValueError(f'Name of {item} is also an attribute of {self}.')
if (item.name in self.members):
raise AlfredError(f"Name '{item.name}' is already present in the experiment.")
item.added_to_section(self)
self.members[item.name] = item
if (self.experiment is not None):
item.added_to_experiment(self.experiment)
item._update_members_recursively()
if (not item.tag):
item.tag = str((len(self.members) + 1))
|
def on_exp_access(self):
'\n Executed *once*, when the :class:`.ExperimentSession` becomes\n available to the section.\n\n .. warning:: We are currently questioning the four section hooks *on_enter*,\n *on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish \n to accomplish with these hooks can be done in page hooks. The section\n versions have some caveats that make them a bit tougher\n to use correctly. So, for the meantime, please avoid these hooks and\n use page hooks instead. The attributes :attr:`.Section.first_page`\n and :attr:`.Section.last_page` may be useful for you in this regard.\n\n The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may \n at some point decide to introduce an alternative name for it in order\n to avoid confusion with :meth:`.Page.on_exp_access`.\n\n See Also:\n See "How to use hooks" for a how to on using hooks and an overview\n of available hooks.\n\n '
pass
| -9,148,113,707,308,057,000
|
Executed *once*, when the :class:`.ExperimentSession` becomes
available to the section.
.. warning:: We are currently questioning the four section hooks *on_enter*,
*on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish
to accomplish with these hooks can be done in page hooks. The section
versions have some caveats that make them a bit tougher
to use correctly. So, for the meantime, please avoid these hooks and
use page hooks instead. The attributes :attr:`.Section.first_page`
and :attr:`.Section.last_page` may be useful for you in this regard.
The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may
at some point decide to introduce an alternative name for it in order
to avoid confusion with :meth:`.Page.on_exp_access`.
See Also:
See "How to use hooks" for a how to on using hooks and an overview
of available hooks.
|
src/alfred3/section.py
|
on_exp_access
|
ctreffe/alfred
|
python
|
def on_exp_access(self):
'\n Executed *once*, when the :class:`.ExperimentSession` becomes\n available to the section.\n\n .. warning:: We are currently questioning the four section hooks *on_enter*,\n *on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish \n to accomplish with these hooks can be done in page hooks. The section\n versions have some caveats that make them a bit tougher\n to use correctly. So, for the meantime, please avoid these hooks and\n use page hooks instead. The attributes :attr:`.Section.first_page`\n and :attr:`.Section.last_page` may be useful for you in this regard.\n\n The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may \n at some point decide to introduce an alternative name for it in order\n to avoid confusion with :meth:`.Page.on_exp_access`.\n\n See Also:\n See "How to use hooks" for a how to on using hooks and an overview\n of available hooks.\n\n '
pass
|
def on_enter(self):
'\n Executed *every time* this section is entered.\n\n .. warning:: We are currently questioning the four section hooks *on_enter*,\n *on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish \n to accomplish with these hooks can be done in page hooks. The section\n versions have some caveats that make them a bit tougher\n to use correctly. So, for the meantime, please avoid these hooks and\n use page hooks instead. The attributes :attr:`.Section.first_page`\n and :attr:`.Section.last_page` may be useful for you in this regard.\n\n The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may \n at some point decide to introduce an alternative name for it in order\n to avoid confusion with :meth:`.Page.on_exp_access`.\n\n See Also:\n See "How to use hooks" for a how to on using hooks and an overview\n of available hooks.\n '
pass
| -911,496,953,005,024,000
|
Executed *every time* this section is entered.
.. warning:: We are currently questioning the four section hooks *on_enter*,
*on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish
to accomplish with these hooks can be done in page hooks. The section
versions have some caveats that make them a bit tougher
to use correctly. So, for the meantime, please avoid these hooks and
use page hooks instead. The attributes :attr:`.Section.first_page`
and :attr:`.Section.last_page` may be useful for you in this regard.
The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may
at some point decide to introduce an alternative name for it in order
to avoid confusion with :meth:`.Page.on_exp_access`.
See Also:
See "How to use hooks" for a how to on using hooks and an overview
of available hooks.
|
src/alfred3/section.py
|
on_enter
|
ctreffe/alfred
|
python
|
def on_enter(self):
'\n Executed *every time* this section is entered.\n\n .. warning:: We are currently questioning the four section hooks *on_enter*,\n *on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish \n to accomplish with these hooks can be done in page hooks. The section\n versions have some caveats that make them a bit tougher\n to use correctly. So, for the meantime, please avoid these hooks and\n use page hooks instead. The attributes :attr:`.Section.first_page`\n and :attr:`.Section.last_page` may be useful for you in this regard.\n\n The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may \n at some point decide to introduce an alternative name for it in order\n to avoid confusion with :meth:`.Page.on_exp_access`.\n\n See Also:\n See "How to use hooks" for a how to on using hooks and an overview\n of available hooks.\n '
pass
|
def on_leave(self):
'\n Executed *every time* this section is left.\n\n .. warning:: We are currently questioning the four section hooks *on_enter*,\n *on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish \n to accomplish with these hooks can be done in page hooks. The section\n versions have some caveats that make them a bit tougher\n to use correctly. So, for the meantime, please avoid these hooks and\n use page hooks instead. The attributes :attr:`.Section.first_page`\n and :attr:`.Section.last_page` may be useful for you in this regard.\n\n The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may \n at some point decide to introduce an alternative name for it in order\n to avoid confusion with :meth:`.Page.on_exp_access`.\n\n See Also:\n See "How to use hooks" for a how to on using hooks and an overview\n of available hooks.\n '
pass
| -6,899,368,194,527,871,000
|
Executed *every time* this section is left.
.. warning:: We are currently questioning the four section hooks *on_enter*,
*on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish
to accomplish with these hooks can be done in page hooks. The section
versions have some caveats that make them a bit tougher
to use correctly. So, for the meantime, please avoid these hooks and
use page hooks instead. The attributes :attr:`.Section.first_page`
and :attr:`.Section.last_page` may be useful for you in this regard.
The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may
at some point decide to introduce an alternative name for it in order
to avoid confusion with :meth:`.Page.on_exp_access`.
See Also:
See "How to use hooks" for a how to on using hooks and an overview
of available hooks.
|
src/alfred3/section.py
|
on_leave
|
ctreffe/alfred
|
python
|
def on_leave(self):
'\n Executed *every time* this section is left.\n\n .. warning:: We are currently questioning the four section hooks *on_enter*,\n *on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish \n to accomplish with these hooks can be done in page hooks. The section\n versions have some caveats that make them a bit tougher\n to use correctly. So, for the meantime, please avoid these hooks and\n use page hooks instead. The attributes :attr:`.Section.first_page`\n and :attr:`.Section.last_page` may be useful for you in this regard.\n\n The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may \n at some point decide to introduce an alternative name for it in order\n to avoid confusion with :meth:`.Page.on_exp_access`.\n\n See Also:\n See "How to use hooks" for a how to on using hooks and an overview\n of available hooks.\n '
pass
|
def on_resume(self):
'\n Executed *every time* the experiment resumes from a direct subsection to this section.\n\n Resuming takes place, when a child section is left and the\n next page is a direct child of the parent section. Then this\n the parent section becomes the primary current section again: it\n resumes its status.\n\n .. warning:: We are currently questioning the four section hooks *on_enter*,\n *on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish \n to accomplish with these hooks can be done in page hooks. The section\n versions have some caveats that make them a bit tougher\n to use correctly. So, for the meantime, please avoid these hooks and\n use page hooks instead. The attributes :attr:`.Section.first_page`\n and :attr:`.Section.last_page` may be useful for you in this regard.\n\n The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may \n at some point decide to introduce an alternative name for it in order\n to avoid confusion with :meth:`.Page.on_exp_access`.\n\n See Also:\n See "How to use hooks" for a how to on using hooks and an overview\n of available hooks.\n '
pass
| 6,499,724,298,176,104,000
|
Executed *every time* the experiment resumes from a direct subsection to this section.
Resuming takes place, when a child section is left and the
next page is a direct child of the parent section. Then this
the parent section becomes the primary current section again: it
resumes its status.
.. warning:: We are currently questioning the four section hooks *on_enter*,
*on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish
to accomplish with these hooks can be done in page hooks. The section
versions have some caveats that make them a bit tougher
to use correctly. So, for the meantime, please avoid these hooks and
use page hooks instead. The attributes :attr:`.Section.first_page`
and :attr:`.Section.last_page` may be useful for you in this regard.
The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may
at some point decide to introduce an alternative name for it in order
to avoid confusion with :meth:`.Page.on_exp_access`.
See Also:
See "How to use hooks" for a how to on using hooks and an overview
of available hooks.
|
src/alfred3/section.py
|
on_resume
|
ctreffe/alfred
|
python
|
def on_resume(self):
'\n Executed *every time* the experiment resumes from a direct subsection to this section.\n\n Resuming takes place, when a child section is left and the\n next page is a direct child of the parent section. Then this\n the parent section becomes the primary current section again: it\n resumes its status.\n\n .. warning:: We are currently questioning the four section hooks *on_enter*,\n *on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish \n to accomplish with these hooks can be done in page hooks. The section\n versions have some caveats that make them a bit tougher\n to use correctly. So, for the meantime, please avoid these hooks and\n use page hooks instead. The attributes :attr:`.Section.first_page`\n and :attr:`.Section.last_page` may be useful for you in this regard.\n\n The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may \n at some point decide to introduce an alternative name for it in order\n to avoid confusion with :meth:`.Page.on_exp_access`.\n\n See Also:\n See "How to use hooks" for a how to on using hooks and an overview\n of available hooks.\n '
pass
|
def on_hand_over(self):
'\n Executed *every time* a direct subsection of this section is entered.\n\n .. warning:: We are currently questioning the four section hooks *on_enter*,\n *on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish \n to accomplish with these hooks can be done in page hooks. The section\n versions have some caveats that make them a bit tougher\n to use correctly. So, for the meantime, please avoid these hooks and\n use page hooks instead. The attributes :attr:`.Section.first_page`\n and :attr:`.Section.last_page` may be useful for you in this regard.\n\n The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may \n at some point decide to introduce an alternative name for it in order\n to avoid confusion with :meth:`.Page.on_exp_access`.\n\n See Also:\n See "How to use hooks" for a how to on using hooks and an overview\n of available hooks.\n\n '
pass
| 8,845,640,291,402,514,000
|
Executed *every time* a direct subsection of this section is entered.
.. warning:: We are currently questioning the four section hooks *on_enter*,
*on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish
to accomplish with these hooks can be done in page hooks. The section
versions have some caveats that make them a bit tougher
to use correctly. So, for the meantime, please avoid these hooks and
use page hooks instead. The attributes :attr:`.Section.first_page`
and :attr:`.Section.last_page` may be useful for you in this regard.
The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may
at some point decide to introduce an alternative name for it in order
to avoid confusion with :meth:`.Page.on_exp_access`.
See Also:
See "How to use hooks" for a how to on using hooks and an overview
of available hooks.
|
src/alfred3/section.py
|
on_hand_over
|
ctreffe/alfred
|
python
|
def on_hand_over(self):
'\n Executed *every time* a direct subsection of this section is entered.\n\n .. warning:: We are currently questioning the four section hooks *on_enter*,\n *on_hand_over*, *on_resume*, and *on_leave*. Everything that you may wish \n to accomplish with these hooks can be done in page hooks. The section\n versions have some caveats that make them a bit tougher\n to use correctly. So, for the meantime, please avoid these hooks and\n use page hooks instead. The attributes :attr:`.Section.first_page`\n and :attr:`.Section.last_page` may be useful for you in this regard.\n\n The :meth:`.Section.on_exp_access` hook is not going anywhere, although we may \n at some point decide to introduce an alternative name for it in order\n to avoid confusion with :meth:`.Page.on_exp_access`.\n\n See Also:\n See "How to use hooks" for a how to on using hooks and an overview\n of available hooks.\n\n '
pass
|
def _move(self, direction, from_page, to_page):
"\n Conducts a section's part of moving in an alfred experiment.\n\n Raises:\n ValidationError: If validation of the current page fails.\n "
if (direction == 'forward'):
self._forward()
elif (direction == 'backward'):
self._backward()
elif (direction == 'jumpto'):
self._jumpto()
elif direction.startswith('jump'):
self._jumpfrom()
if (to_page.section.name in self.all_members):
self._hand_over()
elif (not (to_page.section is self)):
self._leave()
if direction.startswith('jump'):
to_page.section._jumpto()
if (self.name in to_page.section.all_members):
to_page.section._resume()
elif (not (to_page.section is self)):
to_page.section._enter()
if self.exp.aborted:
raise AbortMove
| 7,604,988,326,934,567,000
|
Conducts a section's part of moving in an alfred experiment.
Raises:
ValidationError: If validation of the current page fails.
|
src/alfred3/section.py
|
_move
|
ctreffe/alfred
|
python
|
def _move(self, direction, from_page, to_page):
"\n Conducts a section's part of moving in an alfred experiment.\n\n Raises:\n ValidationError: If validation of the current page fails.\n "
if (direction == 'forward'):
self._forward()
elif (direction == 'backward'):
self._backward()
elif (direction == 'jumpto'):
self._jumpto()
elif direction.startswith('jump'):
self._jumpfrom()
if (to_page.section.name in self.all_members):
self._hand_over()
elif (not (to_page.section is self)):
self._leave()
if direction.startswith('jump'):
to_page.section._jumpto()
if (self.name in to_page.section.all_members):
to_page.section._resume()
elif (not (to_page.section is self)):
to_page.section._enter()
if self.exp.aborted:
raise AbortMove
|
def validate_on_leave(self):
'\n Validates pages and their input elements within the section.\n\n Can be overloaded to change the validating behavior of a derived\n section.\n\n Notes:\n Validation is conducted only for pages that are direct\n children of this section. Pages in subsections are not\n validated.\n\n Raises:\n ValidationError: If validation fails.\n '
for page in self.pages.values():
if (not page._validate()):
raise ValidationError()
if (not page._validate_elements()):
msg = self.exp.config.get('hints', 'no_input_section_validation')
msg = msg.format(n=len(self.pages))
self.exp.post_message(msg, level='danger')
raise ValidationError()
| -6,773,332,875,304,839,000
|
Validates pages and their input elements within the section.
Can be overloaded to change the validating behavior of a derived
section.
Notes:
Validation is conducted only for pages that are direct
children of this section. Pages in subsections are not
validated.
Raises:
ValidationError: If validation fails.
|
src/alfred3/section.py
|
validate_on_leave
|
ctreffe/alfred
|
python
|
def validate_on_leave(self):
'\n Validates pages and their input elements within the section.\n\n Can be overloaded to change the validating behavior of a derived\n section.\n\n Notes:\n Validation is conducted only for pages that are direct\n children of this section. Pages in subsections are not\n validated.\n\n Raises:\n ValidationError: If validation fails.\n '
for page in self.pages.values():
if (not page._validate()):
raise ValidationError()
if (not page._validate_elements()):
msg = self.exp.config.get('hints', 'no_input_section_validation')
msg = msg.format(n=len(self.pages))
self.exp.post_message(msg, level='danger')
raise ValidationError()
|
def validate_on_move(self):
'\n Validates the current page and its elements.\n\n Can be overloaded to change the validating behavior of a derived\n section. By default, this validation method is called on each\n foward and backward move, as well as when participants jump\n *from* the section, but not when they jump *to* the section.\n\n Raises:\n ValidationError: If validation fails.\n\n See Also:\n Use the individual methods :meth:`.validate_on_forward`,\n :meth:`.validate_on_backward`, :meth:`.validate_on_jumpfrom`,\n and :meth:`.validate_on_jumpto` if you want even more fine-\n grained control over validation behavior.\n\n .. versionchanged:: 2.1.0\n Switched the default order of validation. Now, elements are\n validated first, then the page itself is validated.\n\n '
if (not self.exp.current_page._validate_elements()):
raise ValidationError()
if (not self.exp.current_page._validate()):
raise ValidationError()
| 8,320,829,602,456,611,000
|
Validates the current page and its elements.
Can be overloaded to change the validating behavior of a derived
section. By default, this validation method is called on each
foward and backward move, as well as when participants jump
*from* the section, but not when they jump *to* the section.
Raises:
ValidationError: If validation fails.
See Also:
Use the individual methods :meth:`.validate_on_forward`,
:meth:`.validate_on_backward`, :meth:`.validate_on_jumpfrom`,
and :meth:`.validate_on_jumpto` if you want even more fine-
grained control over validation behavior.
.. versionchanged:: 2.1.0
Switched the default order of validation. Now, elements are
validated first, then the page itself is validated.
|
src/alfred3/section.py
|
validate_on_move
|
ctreffe/alfred
|
python
|
def validate_on_move(self):
'\n Validates the current page and its elements.\n\n Can be overloaded to change the validating behavior of a derived\n section. By default, this validation method is called on each\n foward and backward move, as well as when participants jump\n *from* the section, but not when they jump *to* the section.\n\n Raises:\n ValidationError: If validation fails.\n\n See Also:\n Use the individual methods :meth:`.validate_on_forward`,\n :meth:`.validate_on_backward`, :meth:`.validate_on_jumpfrom`,\n and :meth:`.validate_on_jumpto` if you want even more fine-\n grained control over validation behavior.\n\n .. versionchanged:: 2.1.0\n Switched the default order of validation. Now, elements are\n validated first, then the page itself is validated.\n\n '
if (not self.exp.current_page._validate_elements()):
raise ValidationError()
if (not self.exp.current_page._validate()):
raise ValidationError()
|
def validate_on_forward(self):
'\n Called for validation on each forward move.\n\n Overload this method to customize validation behavior.\n\n See Also:\n By default, sections use :meth:`.validate_on_move` for \n validation on all kinds of moves.\n \n '
self.validate_on_move()
| -4,412,367,376,897,423,400
|
Called for validation on each forward move.
Overload this method to customize validation behavior.
See Also:
By default, sections use :meth:`.validate_on_move` for
validation on all kinds of moves.
|
src/alfred3/section.py
|
validate_on_forward
|
ctreffe/alfred
|
python
|
def validate_on_forward(self):
'\n Called for validation on each forward move.\n\n Overload this method to customize validation behavior.\n\n See Also:\n By default, sections use :meth:`.validate_on_move` for \n validation on all kinds of moves.\n \n '
self.validate_on_move()
|
def validate_on_backward(self):
'\n Called for validation on each backward move.\n\n Overload this method to customize validation behavior.\n\n See Also:\n By default, sections use :meth:`.validate_on_move` for \n validation on all kinds of moves.\n '
self.validate_on_move()
| 1,736,007,470,395,342,600
|
Called for validation on each backward move.
Overload this method to customize validation behavior.
See Also:
By default, sections use :meth:`.validate_on_move` for
validation on all kinds of moves.
|
src/alfred3/section.py
|
validate_on_backward
|
ctreffe/alfred
|
python
|
def validate_on_backward(self):
'\n Called for validation on each backward move.\n\n Overload this method to customize validation behavior.\n\n See Also:\n By default, sections use :meth:`.validate_on_move` for \n validation on all kinds of moves.\n '
self.validate_on_move()
|
def validate_on_jump(self):
'\n Called for validation on jumping from this section.\n\n Overload this method to customize validation behavior.\n\n See Also:\n By default, sections use :meth:`.validate_on_move` for \n validation on all kinds of moves.\n '
self.validate_on_move()
| 9,122,010,457,286,822,000
|
Called for validation on jumping from this section.
Overload this method to customize validation behavior.
See Also:
By default, sections use :meth:`.validate_on_move` for
validation on all kinds of moves.
|
src/alfred3/section.py
|
validate_on_jump
|
ctreffe/alfred
|
python
|
def validate_on_jump(self):
'\n Called for validation on jumping from this section.\n\n Overload this method to customize validation behavior.\n\n See Also:\n By default, sections use :meth:`.validate_on_move` for \n validation on all kinds of moves.\n '
self.validate_on_move()
|
def _catch_page_hooks(self):
'\n Raises errors, if users define page hooks on a section.\n '
explanation = ' This does not work. Remove the method to continue.'
try:
self.on_first_show()
msg = f"You tried to use the page-only hook method 'on_first_show' on the section {self}."
raise AlfredError((msg + explanation))
except AttributeError:
pass
try:
self.on_each_show()
msg = f"You tried to use the page-only hook method 'on_each_show' on the section {self}."
raise AlfredError((msg + explanation))
except AttributeError:
pass
try:
self.on_each_hide()
msg = f"You tried to use the page-only hook method 'on_each_hide' on the section {self}."
raise AlfredError((msg + explanation))
except AttributeError:
pass
try:
self.on_first_hide()
msg = f"You tried to use the page-only hook method 'on_first_hide' on the section {self}."
raise AlfredError((msg + explanation))
except AttributeError:
pass
| -3,794,765,742,075,681,000
|
Raises errors, if users define page hooks on a section.
|
src/alfred3/section.py
|
_catch_page_hooks
|
ctreffe/alfred
|
python
|
def _catch_page_hooks(self):
'\n \n '
explanation = ' This does not work. Remove the method to continue.'
try:
self.on_first_show()
msg = f"You tried to use the page-only hook method 'on_first_show' on the section {self}."
raise AlfredError((msg + explanation))
except AttributeError:
pass
try:
self.on_each_show()
msg = f"You tried to use the page-only hook method 'on_each_show' on the section {self}."
raise AlfredError((msg + explanation))
except AttributeError:
pass
try:
self.on_each_hide()
msg = f"You tried to use the page-only hook method 'on_each_hide' on the section {self}."
raise AlfredError((msg + explanation))
except AttributeError:
pass
try:
self.on_first_hide()
msg = f"You tried to use the page-only hook method 'on_first_hide' on the section {self}."
raise AlfredError((msg + explanation))
except AttributeError:
pass
|
@property
def all_page_names(self):
'\n Improvised caching mechanism for the list of all page names.\n \n Danger: The caching is not compatible with sections that shuffle their members.\n The shuffling does not affect this list, which is unexpected\n behavior in most cases.\n\n For this reason, the caching is currently deactivated.\n '
return list(self.all_pages.keys())
| 7,435,914,336,117,601,000
|
Improvised caching mechanism for the list of all page names.
Danger: The caching is not compatible with sections that shuffle their members.
The shuffling does not affect this list, which is unexpected
behavior in most cases.
For this reason, the caching is currently deactivated.
|
src/alfred3/section.py
|
all_page_names
|
ctreffe/alfred
|
python
|
@property
def all_page_names(self):
'\n Improvised caching mechanism for the list of all page names.\n \n Danger: The caching is not compatible with sections that shuffle their members.\n The shuffling does not affect this list, which is unexpected\n behavior in most cases.\n\n For this reason, the caching is currently deactivated.\n '
return list(self.all_pages.keys())
|
@property
def all_pages_list(self):
'\n Improvised caching mechanism for the list of all pages.\n\n Danger: The caching is not compatible with sections that shuffle their members.\n The shuffling does not affect this list, which is unexpected\n behavior in most cases.\n\n For this reason, the caching is currently deactivated.\n '
return list(self.all_pages.values())
| 3,306,890,657,990,226,000
|
Improvised caching mechanism for the list of all pages.
Danger: The caching is not compatible with sections that shuffle their members.
The shuffling does not affect this list, which is unexpected
behavior in most cases.
For this reason, the caching is currently deactivated.
|
src/alfred3/section.py
|
all_pages_list
|
ctreffe/alfred
|
python
|
@property
def all_pages_list(self):
'\n Improvised caching mechanism for the list of all pages.\n\n Danger: The caching is not compatible with sections that shuffle their members.\n The shuffling does not affect this list, which is unexpected\n behavior in most cases.\n\n For this reason, the caching is currently deactivated.\n '
return list(self.all_pages.values())
|
def parse_iso_duration(value: str) -> timedelta:
'\n Parses duration string according to ISO 8601 and returns timedelta representation (it excludes year and month)\n http://www.datypic.com/sc/xsd/t-xsd_dayTimeDuration.html\n :param str value:\n :return dict:\n '
if (not ISO_8601_TIME_DURATION_REGEX.match(value)):
raise ValueError(f'Passed value {value} is not valid ISO-8601 duration.')
duration = ISO_8601_TIME_DURATION_REGEX.fullmatch(value)
sign = ((- 1) if duration.group('sign') else 1)
kwargs = {'weeks': ((int(duration.group('weeks')) * sign) if duration.group('weeks') else 0), 'days': ((int(duration.group('days')) * sign) if duration.group('days') else 0), 'hours': ((int(duration.group('hours')) * sign) if duration.group('hours') else 0), 'minutes': ((int(duration.group('minutes')) * sign) if duration.group('minutes') else 0), 'seconds': ((float(duration.group('seconds')) * sign) if duration.group('seconds') else 0)}
return timedelta(**kwargs)
| -5,296,927,487,293,375,000
|
Parses duration string according to ISO 8601 and returns timedelta representation (it excludes year and month)
http://www.datypic.com/sc/xsd/t-xsd_dayTimeDuration.html
:param str value:
:return dict:
|
chili/iso_datetime.py
|
parse_iso_duration
|
kodemore/chili
|
python
|
def parse_iso_duration(value: str) -> timedelta:
'\n Parses duration string according to ISO 8601 and returns timedelta representation (it excludes year and month)\n http://www.datypic.com/sc/xsd/t-xsd_dayTimeDuration.html\n :param str value:\n :return dict:\n '
if (not ISO_8601_TIME_DURATION_REGEX.match(value)):
raise ValueError(f'Passed value {value} is not valid ISO-8601 duration.')
duration = ISO_8601_TIME_DURATION_REGEX.fullmatch(value)
sign = ((- 1) if duration.group('sign') else 1)
kwargs = {'weeks': ((int(duration.group('weeks')) * sign) if duration.group('weeks') else 0), 'days': ((int(duration.group('days')) * sign) if duration.group('days') else 0), 'hours': ((int(duration.group('hours')) * sign) if duration.group('hours') else 0), 'minutes': ((int(duration.group('minutes')) * sign) if duration.group('minutes') else 0), 'seconds': ((float(duration.group('seconds')) * sign) if duration.group('seconds') else 0)}
return timedelta(**kwargs)
|
def __init__(self, u_inf=1.0, alpha=0.0):
'\n Sets the freestream speed and angle (in degrees).\n \n Parameters\n ----------\n u_inf: float, optional\n Freestream speed;\n default: 1.0.\n alpha: float, optional\n Angle of attack in degrees;\n default 0.0.\n '
self.u_inf = u_inf
self.alpha = ((alpha * numpy.pi) / 180.0)
| -2,516,974,361,463,451,600
|
Sets the freestream speed and angle (in degrees).
Parameters
----------
u_inf: float, optional
Freestream speed;
default: 1.0.
alpha: float, optional
Angle of attack in degrees;
default 0.0.
|
steapy/freestream.py
|
__init__
|
Sparsh-Sharma/SteaPy
|
python
|
def __init__(self, u_inf=1.0, alpha=0.0):
'\n Sets the freestream speed and angle (in degrees).\n \n Parameters\n ----------\n u_inf: float, optional\n Freestream speed;\n default: 1.0.\n alpha: float, optional\n Angle of attack in degrees;\n default 0.0.\n '
self.u_inf = u_inf
self.alpha = ((alpha * numpy.pi) / 180.0)
|
@bacpypes_debugging
def abort(err):
'Abort everything, everywhere.'
if _debug:
abort._debug('abort %r', err)
if IOServer._highlander:
IOServer._highlander.abort(err)
for controller in _local_controllers.values():
controller.abort(err)
| -1,021,531,690,256,019,000
|
Abort everything, everywhere.
|
sandbox/io.py
|
abort
|
DB-CL/bacpypes
|
python
|
@bacpypes_debugging
def abort(err):
if _debug:
abort._debug('abort %r', err)
if IOServer._highlander:
IOServer._highlander.abort(err)
for controller in _local_controllers.values():
controller.abort(err)
|
def add_callback(self, fn, *args, **kwargs):
'Pass a function to be called when IO is complete.'
if _debug:
IOCB._debug('add_callback(%d) %r %r %r', self.ioID, fn, args, kwargs)
self.ioCallback.append((fn, args, kwargs))
if self.ioComplete.isSet():
self.trigger()
| 5,854,554,043,860,182,000
|
Pass a function to be called when IO is complete.
|
sandbox/io.py
|
add_callback
|
DB-CL/bacpypes
|
python
|
def add_callback(self, fn, *args, **kwargs):
if _debug:
IOCB._debug('add_callback(%d) %r %r %r', self.ioID, fn, args, kwargs)
self.ioCallback.append((fn, args, kwargs))
if self.ioComplete.isSet():
self.trigger()
|
def wait(self, *args):
'Wait for the completion event to be set.'
if _debug:
IOCB._debug('wait(%d) %r', self.ioID, args)
self.ioComplete.wait(*args)
| -1,849,818,359,067,541,800
|
Wait for the completion event to be set.
|
sandbox/io.py
|
wait
|
DB-CL/bacpypes
|
python
|
def wait(self, *args):
if _debug:
IOCB._debug('wait(%d) %r', self.ioID, args)
self.ioComplete.wait(*args)
|
def trigger(self):
'Set the event and make the callback.'
if _debug:
IOCB._debug('trigger(%d)', self.ioID)
if self.ioQueue:
if _debug:
IOCB._debug(' - dequeue')
self.ioQueue.remove(self)
if self.ioTimeout:
if _debug:
IOCB._debug(' - cancel timeout')
self.ioTimeout.suspend_task()
self.ioComplete.set()
for (fn, args, kwargs) in self.ioCallback:
if _debug:
IOCB._debug(' - callback fn: %r %r %r', fn, args, kwargs)
fn(self, *args, **kwargs)
| -4,861,803,694,791,514,000
|
Set the event and make the callback.
|
sandbox/io.py
|
trigger
|
DB-CL/bacpypes
|
python
|
def trigger(self):
if _debug:
IOCB._debug('trigger(%d)', self.ioID)
if self.ioQueue:
if _debug:
IOCB._debug(' - dequeue')
self.ioQueue.remove(self)
if self.ioTimeout:
if _debug:
IOCB._debug(' - cancel timeout')
self.ioTimeout.suspend_task()
self.ioComplete.set()
for (fn, args, kwargs) in self.ioCallback:
if _debug:
IOCB._debug(' - callback fn: %r %r %r', fn, args, kwargs)
fn(self, *args, **kwargs)
|
def complete(self, msg):
'Called to complete a transaction, usually when process_io has\n shipped the IOCB off to some other thread or function.'
if _debug:
IOCB._debug('complete(%d) %r', self.ioID, msg)
if self.ioController:
self.ioController.complete_io(self, msg)
else:
self.ioState = COMPLETED
self.ioResponse = msg
self.trigger()
| 3,534,688,385,459,832,300
|
Called to complete a transaction, usually when process_io has
shipped the IOCB off to some other thread or function.
|
sandbox/io.py
|
complete
|
DB-CL/bacpypes
|
python
|
def complete(self, msg):
'Called to complete a transaction, usually when process_io has\n shipped the IOCB off to some other thread or function.'
if _debug:
IOCB._debug('complete(%d) %r', self.ioID, msg)
if self.ioController:
self.ioController.complete_io(self, msg)
else:
self.ioState = COMPLETED
self.ioResponse = msg
self.trigger()
|
def abort(self, err):
'Called by a client to abort a transaction.'
if _debug:
IOCB._debug('abort(%d) %r', self.ioID, err)
if self.ioController:
self.ioController.abort_io(self, err)
elif (self.ioState < COMPLETED):
self.ioState = ABORTED
self.ioError = err
self.trigger()
| -4,320,624,495,040,363,500
|
Called by a client to abort a transaction.
|
sandbox/io.py
|
abort
|
DB-CL/bacpypes
|
python
|
def abort(self, err):
if _debug:
IOCB._debug('abort(%d) %r', self.ioID, err)
if self.ioController:
self.ioController.abort_io(self, err)
elif (self.ioState < COMPLETED):
self.ioState = ABORTED
self.ioError = err
self.trigger()
|
def set_timeout(self, delay, err=TimeoutError):
'Called to set a transaction timer.'
if _debug:
IOCB._debug('set_timeout(%d) %r err=%r', self.ioID, delay, err)
if self.ioTimeout:
self.ioTimeout.suspend_task()
else:
self.ioTimeout = FunctionTask(self.abort, err)
self.ioTimeout.install_task((_time() + delay))
| 5,683,300,519,654,030,000
|
Called to set a transaction timer.
|
sandbox/io.py
|
set_timeout
|
DB-CL/bacpypes
|
python
|
def set_timeout(self, delay, err=TimeoutError):
if _debug:
IOCB._debug('set_timeout(%d) %r err=%r', self.ioID, delay, err)
if self.ioTimeout:
self.ioTimeout.suspend_task()
else:
self.ioTimeout = FunctionTask(self.abort, err)
self.ioTimeout.install_task((_time() + delay))
|
def chain_callback(self, iocb):
'Callback when this iocb completes.'
if _debug:
IOChainMixIn._debug('chain_callback %r', iocb)
if (not self.ioChain):
return
iocb = self.ioChain
try:
if _debug:
IOChainMixIn._debug(' - decoding')
self.Decode()
if _debug:
IOChainMixIn._debug(' - decode complete')
except:
err = sys.exc_info()[1]
if _debug:
IOChainMixIn._exception(' - decoding exception: %r', err)
iocb.ioState = ABORTED
iocb.ioError = err
self.ioChain = None
iocb.ioController = None
iocb.trigger()
| -246,829,593,857,649,000
|
Callback when this iocb completes.
|
sandbox/io.py
|
chain_callback
|
DB-CL/bacpypes
|
python
|
def chain_callback(self, iocb):
if _debug:
IOChainMixIn._debug('chain_callback %r', iocb)
if (not self.ioChain):
return
iocb = self.ioChain
try:
if _debug:
IOChainMixIn._debug(' - decoding')
self.Decode()
if _debug:
IOChainMixIn._debug(' - decode complete')
except:
err = sys.exc_info()[1]
if _debug:
IOChainMixIn._exception(' - decoding exception: %r', err)
iocb.ioState = ABORTED
iocb.ioError = err
self.ioChain = None
iocb.ioController = None
iocb.trigger()
|
def abort_io(self, iocb, err):
'Forward the abort downstream.'
if _debug:
IOChainMixIn._debug('abort_io %r %r', iocb, err)
if (iocb is not self.ioChain):
raise RuntimeError('broken chain')
self.abort(err)
| 5,269,168,062,476,981,000
|
Forward the abort downstream.
|
sandbox/io.py
|
abort_io
|
DB-CL/bacpypes
|
python
|
def abort_io(self, iocb, err):
if _debug:
IOChainMixIn._debug('abort_io %r %r', iocb, err)
if (iocb is not self.ioChain):
raise RuntimeError('broken chain')
self.abort(err)
|
def encode(self):
'Hook to transform the request, called when this IOCB is\n chained.'
if _debug:
IOChainMixIn._debug('encode (pass)')
| -2,566,784,616,732,559,400
|
Hook to transform the request, called when this IOCB is
chained.
|
sandbox/io.py
|
encode
|
DB-CL/bacpypes
|
python
|
def encode(self):
'Hook to transform the request, called when this IOCB is\n chained.'
if _debug:
IOChainMixIn._debug('encode (pass)')
|
def decode(self):
'Hook to transform the response, called when this IOCB is\n completed.'
if _debug:
IOChainMixIn._debug('decode')
iocb = self.ioChain
if (self.ioState == COMPLETED):
if _debug:
IOChainMixIn._debug(' - completed: %r', self.ioResponse)
iocb.ioState = COMPLETED
iocb.ioResponse = self.ioResponse
elif (self.ioState == ABORTED):
if _debug:
IOChainMixIn._debug(' - aborted: %r', self.ioError)
iocb.ioState = ABORTED
iocb.ioError = self.ioError
else:
raise RuntimeError(('invalid state: %d' % (self.ioState,)))
| 318,984,899,061,921,000
|
Hook to transform the response, called when this IOCB is
completed.
|
sandbox/io.py
|
decode
|
DB-CL/bacpypes
|
python
|
def decode(self):
'Hook to transform the response, called when this IOCB is\n completed.'
if _debug:
IOChainMixIn._debug('decode')
iocb = self.ioChain
if (self.ioState == COMPLETED):
if _debug:
IOChainMixIn._debug(' - completed: %r', self.ioResponse)
iocb.ioState = COMPLETED
iocb.ioResponse = self.ioResponse
elif (self.ioState == ABORTED):
if _debug:
IOChainMixIn._debug(' - aborted: %r', self.ioError)
iocb.ioState = ABORTED
iocb.ioError = self.ioError
else:
raise RuntimeError(('invalid state: %d' % (self.ioState,)))
|
def __init__(self, chain, *args, **kwargs):
'Initialize a chained control block.'
if _debug:
IOChain._debug('__init__ %r %r %r', chain, args, kwargs)
IOCB.__init__(self, *args, **kwargs)
IOChainMixIn.__init__(self, chain)
| 8,207,716,967,316,414,000
|
Initialize a chained control block.
|
sandbox/io.py
|
__init__
|
DB-CL/bacpypes
|
python
|
def __init__(self, chain, *args, **kwargs):
if _debug:
IOChain._debug('__init__ %r %r %r', chain, args, kwargs)
IOCB.__init__(self, *args, **kwargs)
IOChainMixIn.__init__(self, chain)
|
def __init__(self):
'Initialize a group.'
if _debug:
IOGroup._debug('__init__')
IOCB.__init__(self)
self.ioMembers = []
self.ioState = COMPLETED
self.ioComplete.set()
| 448,013,332,909,791,170
|
Initialize a group.
|
sandbox/io.py
|
__init__
|
DB-CL/bacpypes
|
python
|
def __init__(self):
if _debug:
IOGroup._debug('__init__')
IOCB.__init__(self)
self.ioMembers = []
self.ioState = COMPLETED
self.ioComplete.set()
|
def add(self, iocb):
'Add an IOCB to the group, you can also add other groups.'
if _debug:
IOGroup._debug('Add %r', iocb)
self.ioMembers.append(iocb)
self.ioState = PENDING
self.ioComplete.clear()
iocb.add_callback(self.group_callback)
| -5,197,322,878,278,358,000
|
Add an IOCB to the group, you can also add other groups.
|
sandbox/io.py
|
add
|
DB-CL/bacpypes
|
python
|
def add(self, iocb):
if _debug:
IOGroup._debug('Add %r', iocb)
self.ioMembers.append(iocb)
self.ioState = PENDING
self.ioComplete.clear()
iocb.add_callback(self.group_callback)
|
def group_callback(self, iocb):
'Callback when a child iocb completes.'
if _debug:
IOGroup._debug('group_callback %r', iocb)
for iocb in self.ioMembers:
if (not iocb.ioComplete.isSet()):
if _debug:
IOGroup._debug(' - waiting for child: %r', iocb)
break
else:
if _debug:
IOGroup._debug(' - all children complete')
self.ioState = COMPLETED
self.trigger()
| 1,874,570,306,077,664,500
|
Callback when a child iocb completes.
|
sandbox/io.py
|
group_callback
|
DB-CL/bacpypes
|
python
|
def group_callback(self, iocb):
if _debug:
IOGroup._debug('group_callback %r', iocb)
for iocb in self.ioMembers:
if (not iocb.ioComplete.isSet()):
if _debug:
IOGroup._debug(' - waiting for child: %r', iocb)
break
else:
if _debug:
IOGroup._debug(' - all children complete')
self.ioState = COMPLETED
self.trigger()
|
def abort(self, err):
'Called by a client to abort all of the member transactions.\n When the last pending member is aborted the group callback\n function will be called.'
if _debug:
IOGroup._debug('abort %r', err)
self.ioState = ABORTED
self.ioError = err
for iocb in self.ioMembers:
iocb.abort(err)
self.trigger()
| -6,670,665,419,249,530,000
|
Called by a client to abort all of the member transactions.
When the last pending member is aborted the group callback
function will be called.
|
sandbox/io.py
|
abort
|
DB-CL/bacpypes
|
python
|
def abort(self, err):
'Called by a client to abort all of the member transactions.\n When the last pending member is aborted the group callback\n function will be called.'
if _debug:
IOGroup._debug('abort %r', err)
self.ioState = ABORTED
self.ioError = err
for iocb in self.ioMembers:
iocb.abort(err)
self.trigger()
|
def put(self, iocb):
'Add an IOCB to a queue. This is usually called by the function\n that filters requests and passes them out to the correct processing\n thread.'
if _debug:
IOQueue._debug('put %r', iocb)
if (iocb.ioState != PENDING):
raise RuntimeError('invalid state transition')
wasempty = (not self.notempty.isSet())
priority = iocb.ioPriority
item = (priority, iocb)
self.queue.insert(bisect_left(self.queue, ((priority + 1),)), item)
iocb.ioQueue = self
self.notempty.set()
return wasempty
| 4,626,074,913,831,066,000
|
Add an IOCB to a queue. This is usually called by the function
that filters requests and passes them out to the correct processing
thread.
|
sandbox/io.py
|
put
|
DB-CL/bacpypes
|
python
|
def put(self, iocb):
'Add an IOCB to a queue. This is usually called by the function\n that filters requests and passes them out to the correct processing\n thread.'
if _debug:
IOQueue._debug('put %r', iocb)
if (iocb.ioState != PENDING):
raise RuntimeError('invalid state transition')
wasempty = (not self.notempty.isSet())
priority = iocb.ioPriority
item = (priority, iocb)
self.queue.insert(bisect_left(self.queue, ((priority + 1),)), item)
iocb.ioQueue = self
self.notempty.set()
return wasempty
|
def get(self, block=1, delay=None):
'Get a request from a queue, optionally block until a request\n is available.'
if _debug:
IOQueue._debug('get block=%r delay=%r', block, delay)
if ((not block) and (not self.notempty.isSet())):
return None
if delay:
self.notempty.wait(delay)
if (not self.notempty.isSet()):
return None
else:
self.notempty.wait()
(priority, iocb) = self.queue[0]
del self.queue[0]
iocb.ioQueue = None
qlen = len(self.queue)
if (not qlen):
self.notempty.clear()
return iocb
| -2,768,988,883,156,263,000
|
Get a request from a queue, optionally block until a request
is available.
|
sandbox/io.py
|
get
|
DB-CL/bacpypes
|
python
|
def get(self, block=1, delay=None):
'Get a request from a queue, optionally block until a request\n is available.'
if _debug:
IOQueue._debug('get block=%r delay=%r', block, delay)
if ((not block) and (not self.notempty.isSet())):
return None
if delay:
self.notempty.wait(delay)
if (not self.notempty.isSet()):
return None
else:
self.notempty.wait()
(priority, iocb) = self.queue[0]
del self.queue[0]
iocb.ioQueue = None
qlen = len(self.queue)
if (not qlen):
self.notempty.clear()
return iocb
|
def remove(self, iocb):
'Remove a control block from the queue, called if the request\n is canceled/aborted.'
if _debug:
IOQueue._debug('remove %r', iocb)
for (i, item) in enumerate(self.queue):
if (iocb is item[1]):
if _debug:
IOQueue._debug(' - found at %d', i)
del self.queue[i]
qlen = len(self.queue)
if (not qlen):
self.notempty.clear()
break
else:
if _debug:
IOQueue._debug(' - not found')
| 3,721,603,357,315,027,500
|
Remove a control block from the queue, called if the request
is canceled/aborted.
|
sandbox/io.py
|
remove
|
DB-CL/bacpypes
|
python
|
def remove(self, iocb):
'Remove a control block from the queue, called if the request\n is canceled/aborted.'
if _debug:
IOQueue._debug('remove %r', iocb)
for (i, item) in enumerate(self.queue):
if (iocb is item[1]):
if _debug:
IOQueue._debug(' - found at %d', i)
del self.queue[i]
qlen = len(self.queue)
if (not qlen):
self.notempty.clear()
break
else:
if _debug:
IOQueue._debug(' - not found')
|
def abort(self, err):
'abort all of the control blocks in the queue.'
if _debug:
IOQueue._debug('abort %r', err)
try:
for iocb in self.queue:
iocb.ioQueue = None
iocb.abort(err)
self.queue = []
self.notempty.clear()
except ValueError:
pass
| -4,628,013,968,519,226,000
|
abort all of the control blocks in the queue.
|
sandbox/io.py
|
abort
|
DB-CL/bacpypes
|
python
|
def abort(self, err):
if _debug:
IOQueue._debug('abort %r', err)
try:
for iocb in self.queue:
iocb.ioQueue = None
iocb.abort(err)
self.queue = []
self.notempty.clear()
except ValueError:
pass
|
def __init__(self, name=None):
'Initialize a controller.'
if _debug:
IOController._debug('__init__ name=%r', name)
self.name = name
if (name is not None):
if (name in _local_controllers):
raise RuntimeError(("already a local controller called '%s': %r" % (name, _local_controllers[name])))
_local_controllers[name] = self
| -7,556,426,016,939,734,000
|
Initialize a controller.
|
sandbox/io.py
|
__init__
|
DB-CL/bacpypes
|
python
|
def __init__(self, name=None):
if _debug:
IOController._debug('__init__ name=%r', name)
self.name = name
if (name is not None):
if (name in _local_controllers):
raise RuntimeError(("already a local controller called '%s': %r" % (name, _local_controllers[name])))
_local_controllers[name] = self
|
def abort(self, err):
'Abort all requests, no default implementation.'
pass
| -3,600,940,975,930,138,600
|
Abort all requests, no default implementation.
|
sandbox/io.py
|
abort
|
DB-CL/bacpypes
|
python
|
def abort(self, err):
pass
|
def request_io(self, iocb):
'Called by a client to start processing a request.'
if _debug:
IOController._debug('request_io %r', iocb)
iocb.ioController = self
try:
err = None
iocb.ioState = PENDING
self.process_io(iocb)
except:
err = sys.exc_info()[1]
if err:
self.abort_io(iocb, err)
| 1,856,693,541,013,511,000
|
Called by a client to start processing a request.
|
sandbox/io.py
|
request_io
|
DB-CL/bacpypes
|
python
|
def request_io(self, iocb):
if _debug:
IOController._debug('request_io %r', iocb)
iocb.ioController = self
try:
err = None
iocb.ioState = PENDING
self.process_io(iocb)
except:
err = sys.exc_info()[1]
if err:
self.abort_io(iocb, err)
|
def process_io(self, iocb):
'Figure out how to respond to this request. This must be\n provided by the derived class.'
raise NotImplementedError('IOController must implement process_io()')
| 7,590,401,165,908,194,000
|
Figure out how to respond to this request. This must be
provided by the derived class.
|
sandbox/io.py
|
process_io
|
DB-CL/bacpypes
|
python
|
def process_io(self, iocb):
'Figure out how to respond to this request. This must be\n provided by the derived class.'
raise NotImplementedError('IOController must implement process_io()')
|
def active_io(self, iocb):
'Called by a handler to notify the controller that a request is\n being processed.'
if _debug:
IOController._debug('active_io %r', iocb)
if ((iocb.ioState != IDLE) and (iocb.ioState != PENDING)):
raise RuntimeError(('invalid state transition (currently %d)' % (iocb.ioState,)))
iocb.ioState = ACTIVE
| 3,144,586,148,970,231,000
|
Called by a handler to notify the controller that a request is
being processed.
|
sandbox/io.py
|
active_io
|
DB-CL/bacpypes
|
python
|
def active_io(self, iocb):
'Called by a handler to notify the controller that a request is\n being processed.'
if _debug:
IOController._debug('active_io %r', iocb)
if ((iocb.ioState != IDLE) and (iocb.ioState != PENDING)):
raise RuntimeError(('invalid state transition (currently %d)' % (iocb.ioState,)))
iocb.ioState = ACTIVE
|
def complete_io(self, iocb, msg):
'Called by a handler to return data to the client.'
if _debug:
IOController._debug('complete_io %r %r', iocb, msg)
if (iocb.ioState == COMPLETED):
pass
elif (iocb.ioState == ABORTED):
pass
else:
iocb.ioState = COMPLETED
iocb.ioResponse = msg
iocb.trigger()
| -4,694,310,204,482,935,000
|
Called by a handler to return data to the client.
|
sandbox/io.py
|
complete_io
|
DB-CL/bacpypes
|
python
|
def complete_io(self, iocb, msg):
if _debug:
IOController._debug('complete_io %r %r', iocb, msg)
if (iocb.ioState == COMPLETED):
pass
elif (iocb.ioState == ABORTED):
pass
else:
iocb.ioState = COMPLETED
iocb.ioResponse = msg
iocb.trigger()
|
def abort_io(self, iocb, err):
'Called by a handler or a client to abort a transaction.'
if _debug:
IOController._debug('abort_io %r %r', iocb, err)
if (iocb.ioState == COMPLETED):
pass
elif (iocb.ioState == ABORTED):
pass
else:
iocb.ioState = ABORTED
iocb.ioError = err
iocb.trigger()
| -119,998,607,899,882,510
|
Called by a handler or a client to abort a transaction.
|
sandbox/io.py
|
abort_io
|
DB-CL/bacpypes
|
python
|
def abort_io(self, iocb, err):
if _debug:
IOController._debug('abort_io %r %r', iocb, err)
if (iocb.ioState == COMPLETED):
pass
elif (iocb.ioState == ABORTED):
pass
else:
iocb.ioState = ABORTED
iocb.ioError = err
iocb.trigger()
|
def __init__(self, name=None):
'Initialize a queue controller.'
if _debug:
IOQController._debug('__init__ name=%r', name)
if (not name):
name = self.__class__.__name__
IOController.__init__(self, name)
self.state = CTRL_IDLE
self.active_iocb = None
self.ioQueue = IOQueue((str(name) + '/Queue'))
| 6,163,473,207,569,920,000
|
Initialize a queue controller.
|
sandbox/io.py
|
__init__
|
DB-CL/bacpypes
|
python
|
def __init__(self, name=None):
if _debug:
IOQController._debug('__init__ name=%r', name)
if (not name):
name = self.__class__.__name__
IOController.__init__(self, name)
self.state = CTRL_IDLE
self.active_iocb = None
self.ioQueue = IOQueue((str(name) + '/Queue'))
|
def abort(self, err):
'Abort all pending requests.'
if _debug:
IOQController._debug('abort %r', err)
if (self.state == CTRL_IDLE):
if _debug:
IOQController._debug(' - idle')
return
while True:
iocb = self.ioQueue.get()
if (not iocb):
break
if _debug:
IOQController._debug(' - iocb: %r', iocb)
iocb.ioState = ABORTED
iocb.ioError = err
iocb.trigger()
if (self.state != CTRL_IDLE):
if _debug:
IOQController._debug(' - busy after aborts')
| -2,242,504,532,805,751,300
|
Abort all pending requests.
|
sandbox/io.py
|
abort
|
DB-CL/bacpypes
|
python
|
def abort(self, err):
if _debug:
IOQController._debug('abort %r', err)
if (self.state == CTRL_IDLE):
if _debug:
IOQController._debug(' - idle')
return
while True:
iocb = self.ioQueue.get()
if (not iocb):
break
if _debug:
IOQController._debug(' - iocb: %r', iocb)
iocb.ioState = ABORTED
iocb.ioError = err
iocb.trigger()
if (self.state != CTRL_IDLE):
if _debug:
IOQController._debug(' - busy after aborts')
|
def request_io(self, iocb):
'Called by a client to start processing a request.'
if _debug:
IOQController._debug('request_io %r', iocb)
iocb.ioController = self
if (self.state != CTRL_IDLE):
if _debug:
IOQController._debug(' - busy, request queued')
iocb.ioState = PENDING
self.ioQueue.put(iocb)
return
try:
err = None
self.process_io(iocb)
except:
err = sys.exc_info()[1]
if err:
self.abort_io(iocb, err)
| -7,814,230,622,668,681,000
|
Called by a client to start processing a request.
|
sandbox/io.py
|
request_io
|
DB-CL/bacpypes
|
python
|
def request_io(self, iocb):
if _debug:
IOQController._debug('request_io %r', iocb)
iocb.ioController = self
if (self.state != CTRL_IDLE):
if _debug:
IOQController._debug(' - busy, request queued')
iocb.ioState = PENDING
self.ioQueue.put(iocb)
return
try:
err = None
self.process_io(iocb)
except:
err = sys.exc_info()[1]
if err:
self.abort_io(iocb, err)
|
def process_io(self, iocb):
'Figure out how to respond to this request. This must be\n provided by the derived class.'
raise NotImplementedError('IOController must implement process_io()')
| 7,590,401,165,908,194,000
|
Figure out how to respond to this request. This must be
provided by the derived class.
|
sandbox/io.py
|
process_io
|
DB-CL/bacpypes
|
python
|
def process_io(self, iocb):
'Figure out how to respond to this request. This must be\n provided by the derived class.'
raise NotImplementedError('IOController must implement process_io()')
|
def active_io(self, iocb):
'Called by a handler to notify the controller that a request is\n being processed.'
if _debug:
IOQController._debug('active_io %r', iocb)
IOController.active_io(self, iocb)
self.state = CTRL_ACTIVE
self.active_iocb = iocb
| -186,891,810,535,572,350
|
Called by a handler to notify the controller that a request is
being processed.
|
sandbox/io.py
|
active_io
|
DB-CL/bacpypes
|
python
|
def active_io(self, iocb):
'Called by a handler to notify the controller that a request is\n being processed.'
if _debug:
IOQController._debug('active_io %r', iocb)
IOController.active_io(self, iocb)
self.state = CTRL_ACTIVE
self.active_iocb = iocb
|
def complete_io(self, iocb, msg):
'Called by a handler to return data to the client.'
if _debug:
IOQController._debug('complete_io %r %r', iocb, msg)
if (iocb is not self.active_iocb):
raise RuntimeError('not the current iocb')
IOController.complete_io(self, iocb, msg)
self.active_iocb = None
if self.wait_time:
self.state = CTRL_WAITING
task = FunctionTask(IOQController._wait_trigger, self)
task.install_task((_time() + self.wait_time))
else:
self.state = CTRL_IDLE
deferred(IOQController._trigger, self)
| 7,346,909,923,116,105,000
|
Called by a handler to return data to the client.
|
sandbox/io.py
|
complete_io
|
DB-CL/bacpypes
|
python
|
def complete_io(self, iocb, msg):
if _debug:
IOQController._debug('complete_io %r %r', iocb, msg)
if (iocb is not self.active_iocb):
raise RuntimeError('not the current iocb')
IOController.complete_io(self, iocb, msg)
self.active_iocb = None
if self.wait_time:
self.state = CTRL_WAITING
task = FunctionTask(IOQController._wait_trigger, self)
task.install_task((_time() + self.wait_time))
else:
self.state = CTRL_IDLE
deferred(IOQController._trigger, self)
|
def abort_io(self, iocb, err):
'Called by a handler or a client to abort a transaction.'
if _debug:
IOQController._debug('abort_io %r %r', iocb, err)
IOController.abort_io(self, iocb, err)
if (iocb is not self.active_iocb):
if _debug:
IOQController._debug(' - not current iocb')
return
self.active_iocb = None
self.state = CTRL_IDLE
deferred(IOQController._trigger, self)
| -909,993,631,423,759,100
|
Called by a handler or a client to abort a transaction.
|
sandbox/io.py
|
abort_io
|
DB-CL/bacpypes
|
python
|
def abort_io(self, iocb, err):
if _debug:
IOQController._debug('abort_io %r %r', iocb, err)
IOController.abort_io(self, iocb, err)
if (iocb is not self.active_iocb):
if _debug:
IOQController._debug(' - not current iocb')
return
self.active_iocb = None
self.state = CTRL_IDLE
deferred(IOQController._trigger, self)
|
def _trigger(self):
'Called to launch the next request in the queue.'
if _debug:
IOQController._debug('_trigger')
if (self.state != CTRL_IDLE):
if _debug:
IOQController._debug(' - not idle')
return
if (not self.ioQueue.queue):
if _debug:
IOQController._debug(' - empty queue')
return
iocb = self.ioQueue.get()
try:
err = None
self.process_io(iocb)
except:
err = sys.exc_info()[1]
if err:
self.abort_io(iocb, err)
if (self.state == CTRL_IDLE):
deferred(IOQController._trigger, self)
| 2,957,294,635,359,395,300
|
Called to launch the next request in the queue.
|
sandbox/io.py
|
_trigger
|
DB-CL/bacpypes
|
python
|
def _trigger(self):
if _debug:
IOQController._debug('_trigger')
if (self.state != CTRL_IDLE):
if _debug:
IOQController._debug(' - not idle')
return
if (not self.ioQueue.queue):
if _debug:
IOQController._debug(' - empty queue')
return
iocb = self.ioQueue.get()
try:
err = None
self.process_io(iocb)
except:
err = sys.exc_info()[1]
if err:
self.abort_io(iocb, err)
if (self.state == CTRL_IDLE):
deferred(IOQController._trigger, self)
|
def _wait_trigger(self):
'Called to launch the next request in the queue.'
if _debug:
IOQController._debug('_wait_trigger')
if (self.state != CTRL_WAITING):
raise RuntimeError('not waiting')
self.state = CTRL_IDLE
IOQController._trigger(self)
| -3,688,339,856,011,042,000
|
Called to launch the next request in the queue.
|
sandbox/io.py
|
_wait_trigger
|
DB-CL/bacpypes
|
python
|
def _wait_trigger(self):
if _debug:
IOQController._debug('_wait_trigger')
if (self.state != CTRL_WAITING):
raise RuntimeError('not waiting')
self.state = CTRL_IDLE
IOQController._trigger(self)
|
def __init__(self, controllerName, serverName=None, requestLimit=None):
'Create an IO client. It implements request_io like a controller, but\n passes requests on to a local controller if it happens to be in the \n same process, or the IOProxyServer instance to forward on for processing.'
if _debug:
IOProxy._debug('__init__ %r serverName=%r, requestLimit=%r', controllerName, serverName, requestLimit)
self.ioControllerRef = controllerName
self.ioServerRef = serverName
self.ioRequestLimit = requestLimit
self.ioPending = set()
self.ioBlocked = deque()
if (not serverName):
self.ioBind = _local_controllers.get(controllerName, None)
if self.ioBind:
if _debug:
IOProxy._debug(' - local bind successful')
elif _debug:
IOProxy._debug(' - local bind deferred')
else:
self.ioBind = None
if _debug:
IOProxy._debug(' - bind deferred')
| -7,610,016,565,481,723,000
|
Create an IO client. It implements request_io like a controller, but
passes requests on to a local controller if it happens to be in the
same process, or the IOProxyServer instance to forward on for processing.
|
sandbox/io.py
|
__init__
|
DB-CL/bacpypes
|
python
|
def __init__(self, controllerName, serverName=None, requestLimit=None):
'Create an IO client. It implements request_io like a controller, but\n passes requests on to a local controller if it happens to be in the \n same process, or the IOProxyServer instance to forward on for processing.'
if _debug:
IOProxy._debug('__init__ %r serverName=%r, requestLimit=%r', controllerName, serverName, requestLimit)
self.ioControllerRef = controllerName
self.ioServerRef = serverName
self.ioRequestLimit = requestLimit
self.ioPending = set()
self.ioBlocked = deque()
if (not serverName):
self.ioBind = _local_controllers.get(controllerName, None)
if self.ioBind:
if _debug:
IOProxy._debug(' - local bind successful')
elif _debug:
IOProxy._debug(' - local bind deferred')
else:
self.ioBind = None
if _debug:
IOProxy._debug(' - bind deferred')
|
def request_io(self, iocb, urgent=False):
'Called by a client to start processing a request.'
if _debug:
IOProxy._debug('request_io %r urgent=%r', iocb, urgent)
global _proxy_server
iocb.ioServerRef = self.ioServerRef
iocb.ioControllerRef = self.ioControllerRef
if (not self.ioBind):
if (not self.ioServerRef):
self.ioBind = _local_controllers.get(self.ioControllerRef, None)
if (not self.ioBind):
iocb.abort(('no local controller %s' % (self.ioControllerRef,)))
return
if _debug:
IOProxy._debug(' - local bind successful')
else:
if (not _proxy_server):
_proxy_server = IOProxyServer()
self.ioBind = _proxy_server
if _debug:
IOProxy._debug(' - proxy bind successful: %r', self.ioBind)
if ((not urgent) and self.ioRequestLimit):
iocb.add_callback(self._proxy_trigger)
if (len(self.ioPending) < self.ioRequestLimit):
if _debug:
IOProxy._debug(' - cleared for launch')
self.ioPending.add(iocb)
self.ioBind.request_io(iocb)
else:
if _debug:
IOProxy._debug(' - save for later')
self.ioBlocked.append(iocb)
else:
self.ioBind.request_io(iocb)
| 3,920,522,245,532,935,700
|
Called by a client to start processing a request.
|
sandbox/io.py
|
request_io
|
DB-CL/bacpypes
|
python
|
def request_io(self, iocb, urgent=False):
if _debug:
IOProxy._debug('request_io %r urgent=%r', iocb, urgent)
global _proxy_server
iocb.ioServerRef = self.ioServerRef
iocb.ioControllerRef = self.ioControllerRef
if (not self.ioBind):
if (not self.ioServerRef):
self.ioBind = _local_controllers.get(self.ioControllerRef, None)
if (not self.ioBind):
iocb.abort(('no local controller %s' % (self.ioControllerRef,)))
return
if _debug:
IOProxy._debug(' - local bind successful')
else:
if (not _proxy_server):
_proxy_server = IOProxyServer()
self.ioBind = _proxy_server
if _debug:
IOProxy._debug(' - proxy bind successful: %r', self.ioBind)
if ((not urgent) and self.ioRequestLimit):
iocb.add_callback(self._proxy_trigger)
if (len(self.ioPending) < self.ioRequestLimit):
if _debug:
IOProxy._debug(' - cleared for launch')
self.ioPending.add(iocb)
self.ioBind.request_io(iocb)
else:
if _debug:
IOProxy._debug(' - save for later')
self.ioBlocked.append(iocb)
else:
self.ioBind.request_io(iocb)
|
def _proxy_trigger(self, iocb):
"This has completed, remove it from the set of pending requests \n and see if it's OK to start up the next one."
if _debug:
IOProxy._debug('_proxy_trigger %r', iocb)
if (iocb not in self.ioPending):
if _debug:
IOProxy._warning('iocb not pending: %r', iocb)
else:
self.ioPending.remove(iocb)
if ((len(self.ioPending) < self.ioRequestLimit) and self.ioBlocked):
nextio = self.ioBlocked.popleft()
if _debug:
IOProxy._debug(' - cleared for launch: %r', nextio)
self.ioPending.add(nextio)
self.ioBind.request_io(nextio)
| 2,237,693,892,454,830,300
|
This has completed, remove it from the set of pending requests
and see if it's OK to start up the next one.
|
sandbox/io.py
|
_proxy_trigger
|
DB-CL/bacpypes
|
python
|
def _proxy_trigger(self, iocb):
"This has completed, remove it from the set of pending requests \n and see if it's OK to start up the next one."
if _debug:
IOProxy._debug('_proxy_trigger %r', iocb)
if (iocb not in self.ioPending):
if _debug:
IOProxy._warning('iocb not pending: %r', iocb)
else:
self.ioPending.remove(iocb)
if ((len(self.ioPending) < self.ioRequestLimit) and self.ioBlocked):
nextio = self.ioBlocked.popleft()
if _debug:
IOProxy._debug(' - cleared for launch: %r', nextio)
self.ioPending.add(nextio)
self.ioBind.request_io(nextio)
|
def __init__(self, addr=('', PORT)):
'Initialize the remote IO handler.'
if _debug:
IOServer._debug('__init__ %r', addr)
IOController.__init__(self)
self.server = UDPDirector(addr)
bind(self, self.server)
self.remoteIOCB = {}
| 7,803,228,143,079,478,000
|
Initialize the remote IO handler.
|
sandbox/io.py
|
__init__
|
DB-CL/bacpypes
|
python
|
def __init__(self, addr=(, PORT)):
if _debug:
IOServer._debug('__init__ %r', addr)
IOController.__init__(self)
self.server = UDPDirector(addr)
bind(self, self.server)
self.remoteIOCB = {}
|
def callback(self, iocb):
'Callback when an iocb is completed by a local controller and the\n result needs to be sent back to the client.'
if _debug:
IOServer._debug('callback %r', iocb)
if (not self.remoteIOCB.has_key(iocb)):
IOServer._warning('IOCB not owned by server: %r', iocb)
return
(clientID, clientAddr) = self.remoteIOCB[iocb]
del self.remoteIOCB[iocb]
if (iocb.ioState == COMPLETED):
response = (1, clientID, iocb.ioResponse)
elif (iocb.ioState == ABORTED):
response = (2, clientID, iocb.ioError)
else:
raise RuntimeError('IOCB invalid state')
if _debug:
_commlog.debug(('<<< %s: S %s %r' % (_strftime(), clientAddr, response)))
response = cPickle.dumps(response, 1)
self.request(PDU(response, destination=clientAddr))
| 6,993,227,331,891,371,000
|
Callback when an iocb is completed by a local controller and the
result needs to be sent back to the client.
|
sandbox/io.py
|
callback
|
DB-CL/bacpypes
|
python
|
def callback(self, iocb):
'Callback when an iocb is completed by a local controller and the\n result needs to be sent back to the client.'
if _debug:
IOServer._debug('callback %r', iocb)
if (not self.remoteIOCB.has_key(iocb)):
IOServer._warning('IOCB not owned by server: %r', iocb)
return
(clientID, clientAddr) = self.remoteIOCB[iocb]
del self.remoteIOCB[iocb]
if (iocb.ioState == COMPLETED):
response = (1, clientID, iocb.ioResponse)
elif (iocb.ioState == ABORTED):
response = (2, clientID, iocb.ioError)
else:
raise RuntimeError('IOCB invalid state')
if _debug:
_commlog.debug(('<<< %s: S %s %r' % (_strftime(), clientAddr, response)))
response = cPickle.dumps(response, 1)
self.request(PDU(response, destination=clientAddr))
|
def abort(self, err):
'Called by a local application to abort all transactions.'
if _debug:
IOServer._debug('abort %r', err)
for iocb in self.remoteIOCB.keys():
self.abort_io(iocb, err)
| -2,582,615,991,534,138,400
|
Called by a local application to abort all transactions.
|
sandbox/io.py
|
abort
|
DB-CL/bacpypes
|
python
|
def abort(self, err):
if _debug:
IOServer._debug('abort %r', err)
for iocb in self.remoteIOCB.keys():
self.abort_io(iocb, err)
|
def abort_io(self, iocb, err):
'Called by a local client or a local controlled to abort a transaction.'
if _debug:
IOServer._debug('abort_io %r %r', iocb, err)
if (iocb.ioState == COMPLETED):
pass
elif (iocb.ioState == ABORTED):
pass
elif self.remoteIOCB.has_key(iocb):
(clientID, clientAddr) = self.remoteIOCB[iocb]
del self.remoteIOCB[iocb]
response = (2, clientID, err)
if _debug:
_commlog.debug(('<<< %s: S %s %r' % (_strftime(), clientAddr, response)))
response = cPickle.dumps(response, 1)
self.socket.sendto(response, clientAddr)
else:
IOServer._error('no reference to aborting iocb: %r', iocb)
iocb.ioState = ABORTED
iocb.ioError = err
iocb.trigger()
| -878,114,234,887,901,000
|
Called by a local client or a local controlled to abort a transaction.
|
sandbox/io.py
|
abort_io
|
DB-CL/bacpypes
|
python
|
def abort_io(self, iocb, err):
if _debug:
IOServer._debug('abort_io %r %r', iocb, err)
if (iocb.ioState == COMPLETED):
pass
elif (iocb.ioState == ABORTED):
pass
elif self.remoteIOCB.has_key(iocb):
(clientID, clientAddr) = self.remoteIOCB[iocb]
del self.remoteIOCB[iocb]
response = (2, clientID, err)
if _debug:
_commlog.debug(('<<< %s: S %s %r' % (_strftime(), clientAddr, response)))
response = cPickle.dumps(response, 1)
self.socket.sendto(response, clientAddr)
else:
IOServer._error('no reference to aborting iocb: %r', iocb)
iocb.ioState = ABORTED
iocb.ioError = err
iocb.trigger()
|
def new_iocb(self, clientAddr, iocbid, controllerName, args, kwargs):
'Called when the server receives a new request.'
if _debug:
IOServer._debug('new_iocb %r %r %r %r %r', clientAddr, iocbid, controllerName, args, kwargs)
controller = _local_controllers.get(controllerName, None)
if (not controller):
err = RuntimeError(("no local controller '%s'" % (controllerName,)))
response = (2, iocbid, err)
if _debug:
_commlog.debug(('<<< %s: S %s %r' % (_strftime(), clientAddr, response)))
response = cPickle.dumps(response, 1)
self.request(PDU(response, destination=clientAddr))
else:
iocb = IOCB(*args, **kwargs)
if _debug:
IOServer._debug(' - local IOCB %r bound to remote %r', iocb.ioID, iocbid)
self.remoteIOCB[iocb] = (iocbid, clientAddr)
iocb.add_callback(self.callback)
controller.request_io(iocb)
| -3,229,873,268,544,389,000
|
Called when the server receives a new request.
|
sandbox/io.py
|
new_iocb
|
DB-CL/bacpypes
|
python
|
def new_iocb(self, clientAddr, iocbid, controllerName, args, kwargs):
if _debug:
IOServer._debug('new_iocb %r %r %r %r %r', clientAddr, iocbid, controllerName, args, kwargs)
controller = _local_controllers.get(controllerName, None)
if (not controller):
err = RuntimeError(("no local controller '%s'" % (controllerName,)))
response = (2, iocbid, err)
if _debug:
_commlog.debug(('<<< %s: S %s %r' % (_strftime(), clientAddr, response)))
response = cPickle.dumps(response, 1)
self.request(PDU(response, destination=clientAddr))
else:
iocb = IOCB(*args, **kwargs)
if _debug:
IOServer._debug(' - local IOCB %r bound to remote %r', iocb.ioID, iocbid)
self.remoteIOCB[iocb] = (iocbid, clientAddr)
iocb.add_callback(self.callback)
controller.request_io(iocb)
|
def abort_iocb(self, addr, iocbid, err):
'Called when the client or server receives an abort request.'
if _debug:
IOServer._debug('abort_iocb %r %r %r', addr, iocbid, err)
for iocb in self.remoteIOCB.keys():
(clientID, clientAddr) = self.remoteIOCB[iocb]
if ((addr == clientAddr) and (clientID == iocbid)):
break
else:
IOServer._error('no reference to aborting iocb %r from %r', iocbid, addr)
return
if _debug:
IOServer._debug(' - local IOCB %r bound to remote %r', iocb.ioID, iocbid)
del self.remoteIOCB[iocb]
iocb.ioCallback = []
iocb.abort(err)
| -9,042,370,814,554,502,000
|
Called when the client or server receives an abort request.
|
sandbox/io.py
|
abort_iocb
|
DB-CL/bacpypes
|
python
|
def abort_iocb(self, addr, iocbid, err):
if _debug:
IOServer._debug('abort_iocb %r %r %r', addr, iocbid, err)
for iocb in self.remoteIOCB.keys():
(clientID, clientAddr) = self.remoteIOCB[iocb]
if ((addr == clientAddr) and (clientID == iocbid)):
break
else:
IOServer._error('no reference to aborting iocb %r from %r', iocbid, addr)
return
if _debug:
IOServer._debug(' - local IOCB %r bound to remote %r', iocb.ioID, iocbid)
del self.remoteIOCB[iocb]
iocb.ioCallback = []
iocb.abort(err)
|
def __init__(self, addr=('', 0), name=None):
'Initialize the remote IO handler.'
if _debug:
IOProxyServer._debug('__init__')
IOController.__init__(self, name=name)
self.server = UDPDirector(addr)
bind(self, self.server)
if _debug:
IOProxyServer._debug(' - bound to %r', self.server.socket.getsockname())
self.localIOCB = {}
| 7,679,163,475,313,877,000
|
Initialize the remote IO handler.
|
sandbox/io.py
|
__init__
|
DB-CL/bacpypes
|
python
|
def __init__(self, addr=(, 0), name=None):
if _debug:
IOProxyServer._debug('__init__')
IOController.__init__(self, name=name)
self.server = UDPDirector(addr)
bind(self, self.server)
if _debug:
IOProxyServer._debug(' - bound to %r', self.server.socket.getsockname())
self.localIOCB = {}
|
def process_io(self, iocb):
'Package up the local IO request and send it to the server.'
if _debug:
IOProxyServer._debug('process_io %r', iocb)
self.localIOCB[iocb.ioID] = iocb
if (not iocb.ioTimeout):
iocb.set_timeout(SERVER_TIMEOUT, RuntimeError(('no response from ' + iocb.ioServerRef)))
request = (0, iocb.ioID, iocb.ioControllerRef, iocb.args, iocb.kwargs)
if _debug:
_commlog.debug(('<<< %s: P %s %r' % (_strftime(), iocb.ioServerRef, request)))
request = cPickle.dumps(request, 1)
self.request(PDU(request, destination=(iocb.ioServerRef, PORT)))
| -3,511,414,309,326,677,000
|
Package up the local IO request and send it to the server.
|
sandbox/io.py
|
process_io
|
DB-CL/bacpypes
|
python
|
def process_io(self, iocb):
if _debug:
IOProxyServer._debug('process_io %r', iocb)
self.localIOCB[iocb.ioID] = iocb
if (not iocb.ioTimeout):
iocb.set_timeout(SERVER_TIMEOUT, RuntimeError(('no response from ' + iocb.ioServerRef)))
request = (0, iocb.ioID, iocb.ioControllerRef, iocb.args, iocb.kwargs)
if _debug:
_commlog.debug(('<<< %s: P %s %r' % (_strftime(), iocb.ioServerRef, request)))
request = cPickle.dumps(request, 1)
self.request(PDU(request, destination=(iocb.ioServerRef, PORT)))
|
def abort(self, err):
'Called by a local application to abort all transactions, local\n and remote.'
if _debug:
IOProxyServer._debug('abort %r', err)
for iocb in self.localIOCB.values():
self.abort_io(iocb, err)
| -2,375,780,947,778,032,000
|
Called by a local application to abort all transactions, local
and remote.
|
sandbox/io.py
|
abort
|
DB-CL/bacpypes
|
python
|
def abort(self, err):
'Called by a local application to abort all transactions, local\n and remote.'
if _debug:
IOProxyServer._debug('abort %r', err)
for iocb in self.localIOCB.values():
self.abort_io(iocb, err)
|
def abort_io(self, iocb, err):
'Called by a local client or a local controlled to abort a transaction.'
if _debug:
IOProxyServer._debug('abort_io %r %r', iocb, err)
if (iocb.ioState == COMPLETED):
pass
elif (iocb.ioState == ABORTED):
pass
elif self.localIOCB.has_key(iocb.ioID):
del self.localIOCB[iocb.ioID]
request = (2, iocb.ioID, err)
if _debug:
_commlog.debug(('<<< %s: P %s %r' % (_strftime(), iocb.ioServerRef, request)))
request = cPickle.dumps(request, 1)
self.request(PDU(request, destination=(iocb.ioServerRef, PORT)))
else:
raise RuntimeError(('no reference to aborting iocb: %r' % (iocb.ioID,)))
iocb.ioState = ABORTED
iocb.ioError = err
iocb.trigger()
| 641,437,192,164,681,200
|
Called by a local client or a local controlled to abort a transaction.
|
sandbox/io.py
|
abort_io
|
DB-CL/bacpypes
|
python
|
def abort_io(self, iocb, err):
if _debug:
IOProxyServer._debug('abort_io %r %r', iocb, err)
if (iocb.ioState == COMPLETED):
pass
elif (iocb.ioState == ABORTED):
pass
elif self.localIOCB.has_key(iocb.ioID):
del self.localIOCB[iocb.ioID]
request = (2, iocb.ioID, err)
if _debug:
_commlog.debug(('<<< %s: P %s %r' % (_strftime(), iocb.ioServerRef, request)))
request = cPickle.dumps(request, 1)
self.request(PDU(request, destination=(iocb.ioServerRef, PORT)))
else:
raise RuntimeError(('no reference to aborting iocb: %r' % (iocb.ioID,)))
iocb.ioState = ABORTED
iocb.ioError = err
iocb.trigger()
|
def complete_iocb(self, serverAddr, iocbid, msg):
'Called when the client receives a response to a request.'
if _debug:
IOProxyServer._debug('complete_iocb %r %r %r', serverAddr, iocbid, msg)
iocb = None
if (not self.localIOCB.has_key(iocbid)):
IOProxyServer._error('no reference to IOCB %r', iocbid)
if _debug:
IOProxyServer._debug(' - localIOCB: %r', self.localIOCB)
else:
iocb = self.localIOCB[iocbid]
del self.localIOCB[iocbid]
if iocb:
iocb.ioState = COMPLETED
iocb.ioResponse = msg
iocb.trigger()
| -4,187,084,855,921,998,300
|
Called when the client receives a response to a request.
|
sandbox/io.py
|
complete_iocb
|
DB-CL/bacpypes
|
python
|
def complete_iocb(self, serverAddr, iocbid, msg):
if _debug:
IOProxyServer._debug('complete_iocb %r %r %r', serverAddr, iocbid, msg)
iocb = None
if (not self.localIOCB.has_key(iocbid)):
IOProxyServer._error('no reference to IOCB %r', iocbid)
if _debug:
IOProxyServer._debug(' - localIOCB: %r', self.localIOCB)
else:
iocb = self.localIOCB[iocbid]
del self.localIOCB[iocbid]
if iocb:
iocb.ioState = COMPLETED
iocb.ioResponse = msg
iocb.trigger()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.