repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
codelv/enaml-native | src/enamlnative/android/android_view_pager.py | AndroidViewPager._notify_change | def _notify_change(self):
""" After all changes have settled, tell Java it changed """
d = self.declaration
self._notify_count -= 1
if self._notify_count == 0:
#: Tell the UI we made changes
self.adapter.notifyDataSetChanged(now=True)
self.get_context(... | python | def _notify_change(self):
""" After all changes have settled, tell Java it changed """
d = self.declaration
self._notify_count -= 1
if self._notify_count == 0:
#: Tell the UI we made changes
self.adapter.notifyDataSetChanged(now=True)
self.get_context(... | [
"def",
"_notify_change",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"self",
".",
"_notify_count",
"-=",
"1",
"if",
"self",
".",
"_notify_count",
"==",
"0",
":",
"self",
".",
"adapter",
".",
"notifyDataSetChanged",
"(",
"now",
"=",
"True... | After all changes have settled, tell Java it changed | [
"After",
"all",
"changes",
"have",
"settled",
"tell",
"Java",
"it",
"changed"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view_pager.py#L177-L185 | train |
codelv/enaml-native | src/enamlnative/android/android_view_pager.py | AndroidViewPager.set_current_index | def set_current_index(self, index):
""" We can only set the index once the page has been created.
otherwise we get `FragmentManager is already executing transactions`
errors in Java. To avoid this, we only call this once has been loaded.
"""
# d = self.declaration
... | python | def set_current_index(self, index):
""" We can only set the index once the page has been created.
otherwise we get `FragmentManager is already executing transactions`
errors in Java. To avoid this, we only call this once has been loaded.
"""
# d = self.declaration
... | [
"def",
"set_current_index",
"(",
"self",
",",
"index",
")",
":",
"if",
"self",
".",
"_notify_count",
">",
"0",
":",
"self",
".",
"_pending_calls",
".",
"append",
"(",
"lambda",
"index",
"=",
"index",
":",
"self",
".",
"widget",
".",
"setCurrentItem",
"("... | We can only set the index once the page has been created.
otherwise we get `FragmentManager is already executing transactions`
errors in Java. To avoid this, we only call this once has been loaded. | [
"We",
"can",
"only",
"set",
"the",
"index",
"once",
"the",
"page",
"has",
"been",
"created",
".",
"otherwise",
"we",
"get",
"FragmentManager",
"is",
"already",
"executing",
"transactions",
"errors",
"in",
"Java",
".",
"To",
"avoid",
"this",
"we",
"only",
"... | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view_pager.py#L228-L241 | train |
codelv/enaml-native | src/enamlnative/android/android_flexbox.py | AndroidFlexbox.apply_layout | def apply_layout(self, child, layout):
""" Apply the flexbox specific layout.
"""
params = self.create_layout_params(child, layout)
w = child.widget
if w:
# padding
if layout.get('padding'):
dp = self.dp
l, t, r, b ... | python | def apply_layout(self, child, layout):
""" Apply the flexbox specific layout.
"""
params = self.create_layout_params(child, layout)
w = child.widget
if w:
# padding
if layout.get('padding'):
dp = self.dp
l, t, r, b ... | [
"def",
"apply_layout",
"(",
"self",
",",
"child",
",",
"layout",
")",
":",
"params",
"=",
"self",
".",
"create_layout_params",
"(",
"child",
",",
"layout",
")",
"w",
"=",
"child",
".",
"widget",
"if",
"w",
":",
"if",
"layout",
".",
"get",
"(",
"'padd... | Apply the flexbox specific layout. | [
"Apply",
"the",
"flexbox",
"specific",
"layout",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_flexbox.py#L174-L187 | train |
codelv/enaml-native | src/enamlnative/android/android_notification.py | NotificationManager.get | def get(cls):
""" Acquires the NotificationManager service async. """
app = AndroidApplication.instance()
f = app.create_future()
if cls._instance:
f.set_result(cls._instance)
return f
def on_service(obj_id):
#: Create the manager
... | python | def get(cls):
""" Acquires the NotificationManager service async. """
app = AndroidApplication.instance()
f = app.create_future()
if cls._instance:
f.set_result(cls._instance)
return f
def on_service(obj_id):
#: Create the manager
... | [
"def",
"get",
"(",
"cls",
")",
":",
"app",
"=",
"AndroidApplication",
".",
"instance",
"(",
")",
"f",
"=",
"app",
".",
"create_future",
"(",
")",
"if",
"cls",
".",
"_instance",
":",
"f",
".",
"set_result",
"(",
"cls",
".",
"_instance",
")",
"return",... | Acquires the NotificationManager service async. | [
"Acquires",
"the",
"NotificationManager",
"service",
"async",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_notification.py#L85-L104 | train |
codelv/enaml-native | src/enamlnative/android/android_notification.py | NotificationManager.show_notification | def show_notification(cls, channel_id, *args, **kwargs):
""" Create and show a Notification. See `Notification.Builder.update`
for a list of accepted parameters.
"""
app = AndroidApplication.instance()
builder = Notification.Builder(app, channel_id)
builder.updat... | python | def show_notification(cls, channel_id, *args, **kwargs):
""" Create and show a Notification. See `Notification.Builder.update`
for a list of accepted parameters.
"""
app = AndroidApplication.instance()
builder = Notification.Builder(app, channel_id)
builder.updat... | [
"def",
"show_notification",
"(",
"cls",
",",
"channel_id",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"app",
"=",
"AndroidApplication",
".",
"instance",
"(",
")",
"builder",
"=",
"Notification",
".",
"Builder",
"(",
"app",
",",
"channel_id",
")",
"... | Create and show a Notification. See `Notification.Builder.update`
for a list of accepted parameters. | [
"Create",
"and",
"show",
"a",
"Notification",
".",
"See",
"Notification",
".",
"Builder",
".",
"update",
"for",
"a",
"list",
"of",
"accepted",
"parameters",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_notification.py#L153-L161 | train |
codelv/enaml-native | src/enamlnative/android/android_notification.py | AndroidNotification.init_layout | def init_layout(self):
""" Create the notification in the top down pass if show = True
"""
d = self.declaration
self.create_notification()
if d.show:
self.set_show(d.show) | python | def init_layout(self):
""" Create the notification in the top down pass if show = True
"""
d = self.declaration
self.create_notification()
if d.show:
self.set_show(d.show) | [
"def",
"init_layout",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"self",
".",
"create_notification",
"(",
")",
"if",
"d",
".",
"show",
":",
"self",
".",
"set_show",
"(",
"d",
".",
"show",
")"
] | Create the notification in the top down pass if show = True | [
"Create",
"the",
"notification",
"in",
"the",
"top",
"down",
"pass",
"if",
"show",
"=",
"True"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_notification.py#L548-L554 | train |
codelv/enaml-native | src/enamlnative/android/android_notification.py | AndroidNotification.destroy | def destroy(self):
""" A reimplemented destructor that cancels
the notification before destroying.
"""
builder = self.builder
NotificationManager.cancel_notification(builder)
del self.builder
super(AndroidNotification, self).destroy() | python | def destroy(self):
""" A reimplemented destructor that cancels
the notification before destroying.
"""
builder = self.builder
NotificationManager.cancel_notification(builder)
del self.builder
super(AndroidNotification, self).destroy() | [
"def",
"destroy",
"(",
"self",
")",
":",
"builder",
"=",
"self",
".",
"builder",
"NotificationManager",
".",
"cancel_notification",
"(",
"builder",
")",
"del",
"self",
".",
"builder",
"super",
"(",
"AndroidNotification",
",",
"self",
")",
".",
"destroy",
"("... | A reimplemented destructor that cancels
the notification before destroying. | [
"A",
"reimplemented",
"destructor",
"that",
"cancels",
"the",
"notification",
"before",
"destroying",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_notification.py#L556-L564 | train |
codelv/enaml-native | src/enamlnative/android/android_notification.py | AndroidNotification.create_notification | def create_notification(self):
""" Instead of the typical create_widget we use `create_notification`
because after it's closed it needs created again.
"""
d = self.declaration
builder = self.builder = Notification.Builder(self.get_context(),
... | python | def create_notification(self):
""" Instead of the typical create_widget we use `create_notification`
because after it's closed it needs created again.
"""
d = self.declaration
builder = self.builder = Notification.Builder(self.get_context(),
... | [
"def",
"create_notification",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"builder",
"=",
"self",
".",
"builder",
"=",
"Notification",
".",
"Builder",
"(",
"self",
".",
"get_context",
"(",
")",
",",
"d",
".",
"channel_id",
")",
"d",
"=... | Instead of the typical create_widget we use `create_notification`
because after it's closed it needs created again. | [
"Instead",
"of",
"the",
"typical",
"create_widget",
"we",
"use",
"create_notification",
"because",
"after",
"it",
"s",
"closed",
"it",
"needs",
"created",
"again",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_notification.py#L569-L595 | train |
codelv/enaml-native | src/enamlnative/ios/uikit_button.py | UiKitButton.create_widget | def create_widget(self):
""" Create the toolkit widget for the proxy object.
"""
d = self.declaration
button_type = UIButton.UIButtonTypeSystem if d.flat else UIButton.UIButtonTypeRoundedRect
self.widget = UIButton(buttonWithType=button_type) | python | def create_widget(self):
""" Create the toolkit widget for the proxy object.
"""
d = self.declaration
button_type = UIButton.UIButtonTypeSystem if d.flat else UIButton.UIButtonTypeRoundedRect
self.widget = UIButton(buttonWithType=button_type) | [
"def",
"create_widget",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"button_type",
"=",
"UIButton",
".",
"UIButtonTypeSystem",
"if",
"d",
".",
"flat",
"else",
"UIButton",
".",
"UIButtonTypeRoundedRect",
"self",
".",
"widget",
"=",
"UIButton",
... | Create the toolkit widget for the proxy object. | [
"Create",
"the",
"toolkit",
"widget",
"for",
"the",
"proxy",
"object",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_button.py#L56-L61 | train |
codelv/enaml-native | src/enamlnative/ios/uikit_text_view.py | UiKitTextView.init_text | def init_text(self):
""" Init text properties for this widget """
d = self.declaration
if d.text:
self.set_text(d.text)
if d.text_color:
self.set_text_color(d.text_color)
if d.text_alignment:
self.set_text_alignment(d.text_alignment)
if... | python | def init_text(self):
""" Init text properties for this widget """
d = self.declaration
if d.text:
self.set_text(d.text)
if d.text_color:
self.set_text_color(d.text_color)
if d.text_alignment:
self.set_text_alignment(d.text_alignment)
if... | [
"def",
"init_text",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"if",
"d",
".",
"text",
":",
"self",
".",
"set_text",
"(",
"d",
".",
"text",
")",
"if",
"d",
".",
"text_color",
":",
"self",
".",
"set_text_color",
"(",
"d",
".",
"t... | Init text properties for this widget | [
"Init",
"text",
"properties",
"for",
"this",
"widget"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_text_view.py#L74-L86 | train |
codelv/enaml-native | src/enamlnative/core/hotswap/autoreload.py | update_function | def update_function(old, new):
"""Upgrade the code object of a function"""
for name in func_attrs:
try:
setattr(old, name, getattr(new, name))
except (AttributeError, TypeError):
pass | python | def update_function(old, new):
"""Upgrade the code object of a function"""
for name in func_attrs:
try:
setattr(old, name, getattr(new, name))
except (AttributeError, TypeError):
pass | [
"def",
"update_function",
"(",
"old",
",",
"new",
")",
":",
"for",
"name",
"in",
"func_attrs",
":",
"try",
":",
"setattr",
"(",
"old",
",",
"name",
",",
"getattr",
"(",
"new",
",",
"name",
")",
")",
"except",
"(",
"AttributeError",
",",
"TypeError",
... | Upgrade the code object of a function | [
"Upgrade",
"the",
"code",
"object",
"of",
"a",
"function"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/autoreload.py#L290-L296 | train |
codelv/enaml-native | src/enamlnative/core/hotswap/autoreload.py | superreload | def superreload(module, reload=reload, old_objects={}):
"""Enhanced version of the builtin reload function.
superreload remembers objects previously in the module, and
- upgrades the class dictionary of every old class in the module
- upgrades the code object of every old function and method
- cle... | python | def superreload(module, reload=reload, old_objects={}):
"""Enhanced version of the builtin reload function.
superreload remembers objects previously in the module, and
- upgrades the class dictionary of every old class in the module
- upgrades the code object of every old function and method
- cle... | [
"def",
"superreload",
"(",
"module",
",",
"reload",
"=",
"reload",
",",
"old_objects",
"=",
"{",
"}",
")",
":",
"for",
"name",
",",
"obj",
"in",
"list",
"(",
"module",
".",
"__dict__",
".",
"items",
"(",
")",
")",
":",
"if",
"not",
"hasattr",
"(",
... | Enhanced version of the builtin reload function.
superreload remembers objects previously in the module, and
- upgrades the class dictionary of every old class in the module
- upgrades the code object of every old function and method
- clears the module's namespace before reloading | [
"Enhanced",
"version",
"of",
"the",
"builtin",
"reload",
"function",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/autoreload.py#L363-L419 | train |
codelv/enaml-native | src/enamlnative/core/hotswap/autoreload.py | ModuleReloader.mark_module_skipped | def mark_module_skipped(self, module_name):
"""Skip reloading the named module in the future"""
try:
del self.modules[module_name]
except KeyError:
pass
self.skip_modules[module_name] = True | python | def mark_module_skipped(self, module_name):
"""Skip reloading the named module in the future"""
try:
del self.modules[module_name]
except KeyError:
pass
self.skip_modules[module_name] = True | [
"def",
"mark_module_skipped",
"(",
"self",
",",
"module_name",
")",
":",
"try",
":",
"del",
"self",
".",
"modules",
"[",
"module_name",
"]",
"except",
"KeyError",
":",
"pass",
"self",
".",
"skip_modules",
"[",
"module_name",
"]",
"=",
"True"
] | Skip reloading the named module in the future | [
"Skip",
"reloading",
"the",
"named",
"module",
"in",
"the",
"future"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/autoreload.py#L175-L181 | train |
codelv/enaml-native | src/enamlnative/core/hotswap/autoreload.py | ModuleReloader.aimport_module | def aimport_module(self, module_name):
"""Import a module, and mark it reloadable
Returns
-------
top_module : module
The imported module if it is top-level, or the top-level
top_name : module
Name of top_module
"""
self.mark_module_reloa... | python | def aimport_module(self, module_name):
"""Import a module, and mark it reloadable
Returns
-------
top_module : module
The imported module if it is top-level, or the top-level
top_name : module
Name of top_module
"""
self.mark_module_reloa... | [
"def",
"aimport_module",
"(",
"self",
",",
"module_name",
")",
":",
"self",
".",
"mark_module_reloadable",
"(",
"module_name",
")",
"import_module",
"(",
"module_name",
")",
"top_name",
"=",
"module_name",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"top_m... | Import a module, and mark it reloadable
Returns
-------
top_module : module
The imported module if it is top-level, or the top-level
top_name : module
Name of top_module | [
"Import",
"a",
"module",
"and",
"mark",
"it",
"reloadable"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/autoreload.py#L191-L207 | train |
codelv/enaml-native | src/enamlnative/core/hotswap/autoreload.py | Autoreloader.autoreload | def autoreload(self, parameter_s=''):
r"""%autoreload => Reload modules automatically
%autoreload
Reload all modules (except those excluded by %aimport) automatically
now.
%autoreload 0
Disable automatic reloading.
%autoreload 1
Reload all modules impor... | python | def autoreload(self, parameter_s=''):
r"""%autoreload => Reload modules automatically
%autoreload
Reload all modules (except those excluded by %aimport) automatically
now.
%autoreload 0
Disable automatic reloading.
%autoreload 1
Reload all modules impor... | [
"def",
"autoreload",
"(",
"self",
",",
"parameter_s",
"=",
"''",
")",
":",
"r",
"if",
"parameter_s",
"==",
"''",
":",
"self",
".",
"_reloader",
".",
"check",
"(",
"True",
")",
"elif",
"parameter_s",
"==",
"'0'",
":",
"self",
".",
"_reloader",
".",
"e... | r"""%autoreload => Reload modules automatically
%autoreload
Reload all modules (except those excluded by %aimport) automatically
now.
%autoreload 0
Disable automatic reloading.
%autoreload 1
Reload all modules imported with %aimport every time before executing
... | [
"r",
"%autoreload",
"=",
">",
"Reload",
"modules",
"automatically"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/autoreload.py#L439-L492 | train |
codelv/enaml-native | src/enamlnative/core/hotswap/autoreload.py | Autoreloader.aimport | def aimport(self, parameter_s='', stream=None):
"""%aimport => Import modules for automatic reloading.
%aimport
List modules to automatically import and not to import.
%aimport foo
Import module 'foo' and mark it to be autoreloaded for %autoreload 1
%aimport foo, bar
... | python | def aimport(self, parameter_s='', stream=None):
"""%aimport => Import modules for automatic reloading.
%aimport
List modules to automatically import and not to import.
%aimport foo
Import module 'foo' and mark it to be autoreloaded for %autoreload 1
%aimport foo, bar
... | [
"def",
"aimport",
"(",
"self",
",",
"parameter_s",
"=",
"''",
",",
"stream",
"=",
"None",
")",
":",
"modname",
"=",
"parameter_s",
"if",
"not",
"modname",
":",
"to_reload",
"=",
"sorted",
"(",
"self",
".",
"_reloader",
".",
"modules",
".",
"keys",
"(",... | %aimport => Import modules for automatic reloading.
%aimport
List modules to automatically import and not to import.
%aimport foo
Import module 'foo' and mark it to be autoreloaded for %autoreload 1
%aimport foo, bar
Import modules 'foo', 'bar' and mark them to be auto... | [
"%aimport",
"=",
">",
"Import",
"modules",
"for",
"automatic",
"reloading",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/autoreload.py#L494-L528 | train |
codelv/enaml-native | src/enamlnative/core/hotswap/autoreload.py | Autoreloader.post_execute | def post_execute(self):
"""Cache the modification times of any modules imported in this execution
"""
newly_loaded_modules = set(sys.modules) - self.loaded_modules
for modname in newly_loaded_modules:
_, pymtime = self._reloader.filename_and_mtime(sys.modules[modname])
... | python | def post_execute(self):
"""Cache the modification times of any modules imported in this execution
"""
newly_loaded_modules = set(sys.modules) - self.loaded_modules
for modname in newly_loaded_modules:
_, pymtime = self._reloader.filename_and_mtime(sys.modules[modname])
... | [
"def",
"post_execute",
"(",
"self",
")",
":",
"newly_loaded_modules",
"=",
"set",
"(",
"sys",
".",
"modules",
")",
"-",
"self",
".",
"loaded_modules",
"for",
"modname",
"in",
"newly_loaded_modules",
":",
"_",
",",
"pymtime",
"=",
"self",
".",
"_reloader",
... | Cache the modification times of any modules imported in this execution | [
"Cache",
"the",
"modification",
"times",
"of",
"any",
"modules",
"imported",
"in",
"this",
"execution"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/autoreload.py#L537-L546 | train |
codelv/enaml-native | src/enamlnative/android/android_spinner.py | AndroidSpinner.set_items | def set_items(self, items):
""" Generate the view cache
"""
self.adapter.clear()
self.adapter.addAll(items) | python | def set_items(self, items):
""" Generate the view cache
"""
self.adapter.clear()
self.adapter.addAll(items) | [
"def",
"set_items",
"(",
"self",
",",
"items",
")",
":",
"self",
".",
"adapter",
".",
"clear",
"(",
")",
"self",
".",
"adapter",
".",
"addAll",
"(",
"items",
")"
] | Generate the view cache | [
"Generate",
"the",
"view",
"cache"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_spinner.py#L115-L120 | train |
codelv/enaml-native | src/enamlnative/ios/app.py | ENBridge._default_objc | def _default_objc(self):
""" Load the objc library using ctypes. """
objc = ctypes.cdll.LoadLibrary(find_library('objc'))
objc.objc_getClass.restype = ctypes.c_void_p
objc.sel_registerName.restype = ctypes.c_void_p
objc.objc_msgSend.restype = ctypes.c_void_p
objc.objc_msg... | python | def _default_objc(self):
""" Load the objc library using ctypes. """
objc = ctypes.cdll.LoadLibrary(find_library('objc'))
objc.objc_getClass.restype = ctypes.c_void_p
objc.sel_registerName.restype = ctypes.c_void_p
objc.objc_msgSend.restype = ctypes.c_void_p
objc.objc_msg... | [
"def",
"_default_objc",
"(",
"self",
")",
":",
"objc",
"=",
"ctypes",
".",
"cdll",
".",
"LoadLibrary",
"(",
"find_library",
"(",
"'objc'",
")",
")",
"objc",
".",
"objc_getClass",
".",
"restype",
"=",
"ctypes",
".",
"c_void_p",
"objc",
".",
"sel_registerNam... | Load the objc library using ctypes. | [
"Load",
"the",
"objc",
"library",
"using",
"ctypes",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/app.py#L34-L41 | train |
codelv/enaml-native | src/enamlnative/ios/app.py | ENBridge._default_bridge | def _default_bridge(self):
""" Get an instance of the ENBridge object using ctypes. """
objc = self.objc
ENBridge = objc.objc_getClass('ENBridge')
return objc.objc_msgSend(ENBridge, objc.sel_registerName('instance')) | python | def _default_bridge(self):
""" Get an instance of the ENBridge object using ctypes. """
objc = self.objc
ENBridge = objc.objc_getClass('ENBridge')
return objc.objc_msgSend(ENBridge, objc.sel_registerName('instance')) | [
"def",
"_default_bridge",
"(",
"self",
")",
":",
"objc",
"=",
"self",
".",
"objc",
"ENBridge",
"=",
"objc",
".",
"objc_getClass",
"(",
"'ENBridge'",
")",
"return",
"objc",
".",
"objc_msgSend",
"(",
"ENBridge",
",",
"objc",
".",
"sel_registerName",
"(",
"'i... | Get an instance of the ENBridge object using ctypes. | [
"Get",
"an",
"instance",
"of",
"the",
"ENBridge",
"object",
"using",
"ctypes",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/app.py#L43-L47 | train |
codelv/enaml-native | src/enamlnative/ios/app.py | ENBridge.processEvents | def processEvents(self, data):
""" Sends msgpack data to the ENBridge instance
by calling the processEvents method via ctypes. """
objc = self.objc
bridge = self.bridge
#: This must come after the above as it changes the arguments!
objc.objc_msgSend.argtypes = [ctypes... | python | def processEvents(self, data):
""" Sends msgpack data to the ENBridge instance
by calling the processEvents method via ctypes. """
objc = self.objc
bridge = self.bridge
#: This must come after the above as it changes the arguments!
objc.objc_msgSend.argtypes = [ctypes... | [
"def",
"processEvents",
"(",
"self",
",",
"data",
")",
":",
"objc",
"=",
"self",
".",
"objc",
"bridge",
"=",
"self",
".",
"bridge",
"objc",
".",
"objc_msgSend",
".",
"argtypes",
"=",
"[",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_void_p",
",",
... | Sends msgpack data to the ENBridge instance
by calling the processEvents method via ctypes. | [
"Sends",
"msgpack",
"data",
"to",
"the",
"ENBridge",
"instance",
"by",
"calling",
"the",
"processEvents",
"method",
"via",
"ctypes",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/app.py#L49-L59 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/ioloop.py | IOLoop.log_stack | def log_stack(self, signal, frame):
"""Signal handler to log the stack trace of the current thread.
For use with `set_blocking_signal_threshold`.
"""
gen_log.warning('IOLoop blocked for %f seconds in\n%s',
self._blocking_signal_threshold,
... | python | def log_stack(self, signal, frame):
"""Signal handler to log the stack trace of the current thread.
For use with `set_blocking_signal_threshold`.
"""
gen_log.warning('IOLoop blocked for %f seconds in\n%s',
self._blocking_signal_threshold,
... | [
"def",
"log_stack",
"(",
"self",
",",
"signal",
",",
"frame",
")",
":",
"gen_log",
".",
"warning",
"(",
"'IOLoop blocked for %f seconds in\\n%s'",
",",
"self",
".",
"_blocking_signal_threshold",
",",
"''",
".",
"join",
"(",
"traceback",
".",
"format_stack",
"(",... | Signal handler to log the stack trace of the current thread.
For use with `set_blocking_signal_threshold`. | [
"Signal",
"handler",
"to",
"log",
"the",
"stack",
"trace",
"of",
"the",
"current",
"thread",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/ioloop.py#L394-L401 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/ioloop.py | IOLoop.handle_callback_exception | def handle_callback_exception(self, callback):
"""This method is called whenever a callback run by the `IOLoop`
throws an exception.
By default simply logs the exception as an error. Subclasses
may override this method to customize reporting of exceptions.
The exception itself... | python | def handle_callback_exception(self, callback):
"""This method is called whenever a callback run by the `IOLoop`
throws an exception.
By default simply logs the exception as an error. Subclasses
may override this method to customize reporting of exceptions.
The exception itself... | [
"def",
"handle_callback_exception",
"(",
"self",
",",
"callback",
")",
":",
"if",
"self",
".",
"_error_handler",
":",
"self",
".",
"_error_handler",
"(",
"callback",
")",
"else",
":",
"app_log",
".",
"error",
"(",
"\"Exception in callback %r\"",
",",
"callback",... | This method is called whenever a callback run by the `IOLoop`
throws an exception.
By default simply logs the exception as an error. Subclasses
may override this method to customize reporting of exceptions.
The exception itself is not passed explicitly, but is available
in `sy... | [
"This",
"method",
"is",
"called",
"whenever",
"a",
"callback",
"run",
"by",
"the",
"IOLoop",
"throws",
"an",
"exception",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/ioloop.py#L679-L692 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/ioloop.py | IOLoop.close_fd | def close_fd(self, fd):
"""Utility method to close an ``fd``.
If ``fd`` is a file-like object, we close it directly; otherwise
we use `os.close`.
This method is provided for use by `IOLoop` subclasses (in
implementations of ``IOLoop.close(all_fds=True)`` and should
not ... | python | def close_fd(self, fd):
"""Utility method to close an ``fd``.
If ``fd`` is a file-like object, we close it directly; otherwise
we use `os.close`.
This method is provided for use by `IOLoop` subclasses (in
implementations of ``IOLoop.close(all_fds=True)`` and should
not ... | [
"def",
"close_fd",
"(",
"self",
",",
"fd",
")",
":",
"try",
":",
"try",
":",
"fd",
".",
"close",
"(",
")",
"except",
"AttributeError",
":",
"os",
".",
"close",
"(",
"fd",
")",
"except",
"OSError",
":",
"pass"
] | Utility method to close an ``fd``.
If ``fd`` is a file-like object, we close it directly; otherwise
we use `os.close`.
This method is provided for use by `IOLoop` subclasses (in
implementations of ``IOLoop.close(all_fds=True)`` and should
not generally be used by application co... | [
"Utility",
"method",
"to",
"close",
"an",
"fd",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/ioloop.py#L715-L733 | train |
codelv/enaml-native | src/enamlnative/android/android_snackbar.py | AndroidSnackbar.on_widget_created | def on_widget_created(self, ref):
""" Using Snackbar.make returns async so we have to
initialize it later.
"""
d = self.declaration
self.widget = Snackbar(__id__=ref)
self.init_widget() | python | def on_widget_created(self, ref):
""" Using Snackbar.make returns async so we have to
initialize it later.
"""
d = self.declaration
self.widget = Snackbar(__id__=ref)
self.init_widget() | [
"def",
"on_widget_created",
"(",
"self",
",",
"ref",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"self",
".",
"widget",
"=",
"Snackbar",
"(",
"__id__",
"=",
"ref",
")",
"self",
".",
"init_widget",
"(",
")"
] | Using Snackbar.make returns async so we have to
initialize it later. | [
"Using",
"Snackbar",
".",
"make",
"returns",
"async",
"so",
"we",
"have",
"to",
"initialize",
"it",
"later",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_snackbar.py#L117-L124 | train |
codelv/enaml-native | src/enamlnative/android/android_snackbar.py | AndroidSnackbar.set_duration | def set_duration(self, duration):
""" Android for whatever stupid reason doesn't let you set the time
it only allows 1-long or 0-short. So we have to repeatedly call show
until the duration expires, hence this method does nothing see
`set_show`.
"""
if duration ... | python | def set_duration(self, duration):
""" Android for whatever stupid reason doesn't let you set the time
it only allows 1-long or 0-short. So we have to repeatedly call show
until the duration expires, hence this method does nothing see
`set_show`.
"""
if duration ... | [
"def",
"set_duration",
"(",
"self",
",",
"duration",
")",
":",
"if",
"duration",
"==",
"0",
":",
"self",
".",
"widget",
".",
"setDuration",
"(",
"-",
"2",
")",
"else",
":",
"self",
".",
"widget",
".",
"setDuration",
"(",
"0",
")"
] | Android for whatever stupid reason doesn't let you set the time
it only allows 1-long or 0-short. So we have to repeatedly call show
until the duration expires, hence this method does nothing see
`set_show`. | [
"Android",
"for",
"whatever",
"stupid",
"reason",
"doesn",
"t",
"let",
"you",
"set",
"the",
"time",
"it",
"only",
"allows",
"1",
"-",
"long",
"or",
"0",
"-",
"short",
".",
"So",
"we",
"have",
"to",
"repeatedly",
"call",
"show",
"until",
"the",
"duratio... | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_snackbar.py#L181-L191 | train |
codelv/enaml-native | src/enamlnative/android/android_text_view.py | AndroidTextView.set_text | def set_text(self, text):
""" Set the text in the widget.
"""
d = self.declaration
if d.input_type == 'html':
text = Spanned(__id__=Html.fromHtml(text))
self.widget.setTextKeepState(text) | python | def set_text(self, text):
""" Set the text in the widget.
"""
d = self.declaration
if d.input_type == 'html':
text = Spanned(__id__=Html.fromHtml(text))
self.widget.setTextKeepState(text) | [
"def",
"set_text",
"(",
"self",
",",
"text",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"if",
"d",
".",
"input_type",
"==",
"'html'",
":",
"text",
"=",
"Spanned",
"(",
"__id__",
"=",
"Html",
".",
"fromHtml",
"(",
"text",
")",
")",
"self",
".",... | Set the text in the widget. | [
"Set",
"the",
"text",
"in",
"the",
"widget",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_text_view.py#L209-L216 | train |
codelv/enaml-native | src/enamlnative/core/bridge.py | encode | def encode(obj):
""" Encode an object for proper decoding by Java or ObjC
"""
if hasattr(obj, '__id__'):
return msgpack.ExtType(ExtType.REF, msgpack.packb(obj.__id__))
return obj | python | def encode(obj):
""" Encode an object for proper decoding by Java or ObjC
"""
if hasattr(obj, '__id__'):
return msgpack.ExtType(ExtType.REF, msgpack.packb(obj.__id__))
return obj | [
"def",
"encode",
"(",
"obj",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'__id__'",
")",
":",
"return",
"msgpack",
".",
"ExtType",
"(",
"ExtType",
".",
"REF",
",",
"msgpack",
".",
"packb",
"(",
"obj",
".",
"__id__",
")",
")",
"return",
"obj"
] | Encode an object for proper decoding by Java or ObjC | [
"Encode",
"an",
"object",
"for",
"proper",
"decoding",
"by",
"Java",
"or",
"ObjC"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/bridge.py#L84-L89 | train |
codelv/enaml-native | src/enamlnative/core/bridge.py | get_handler | def get_handler(ptr, method):
""" Dereference the pointer and return the handler method. """
obj = CACHE.get(ptr, None)
if obj is None:
raise BridgeReferenceError(
"Reference id={} never existed or has already been destroyed"
.format(ptr))
elif not hasattr(obj, method):
... | python | def get_handler(ptr, method):
""" Dereference the pointer and return the handler method. """
obj = CACHE.get(ptr, None)
if obj is None:
raise BridgeReferenceError(
"Reference id={} never existed or has already been destroyed"
.format(ptr))
elif not hasattr(obj, method):
... | [
"def",
"get_handler",
"(",
"ptr",
",",
"method",
")",
":",
"obj",
"=",
"CACHE",
".",
"get",
"(",
"ptr",
",",
"None",
")",
"if",
"obj",
"is",
"None",
":",
"raise",
"BridgeReferenceError",
"(",
"\"Reference id={} never existed or has already been destroyed\"",
"."... | Dereference the pointer and return the handler method. | [
"Dereference",
"the",
"pointer",
"and",
"return",
"the",
"handler",
"method",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/bridge.py#L119-L129 | train |
codelv/enaml-native | src/enamlnative/core/bridge.py | BridgeMethod.suppressed | def suppressed(self, obj):
""" Suppress calls within this context to avoid feedback loops"""
obj.__suppressed__[self.name] = True
yield
obj.__suppressed__[self.name] = False | python | def suppressed(self, obj):
""" Suppress calls within this context to avoid feedback loops"""
obj.__suppressed__[self.name] = True
yield
obj.__suppressed__[self.name] = False | [
"def",
"suppressed",
"(",
"self",
",",
"obj",
")",
":",
"obj",
".",
"__suppressed__",
"[",
"self",
".",
"name",
"]",
"=",
"True",
"yield",
"obj",
".",
"__suppressed__",
"[",
"self",
".",
"name",
"]",
"=",
"False"
] | Suppress calls within this context to avoid feedback loops | [
"Suppress",
"calls",
"within",
"this",
"context",
"to",
"avoid",
"feedback",
"loops"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/bridge.py#L159-L163 | train |
codelv/enaml-native | src/enamlnative/android/android_wifi.py | WifiManager.request_permission | def request_permission(cls, permissions):
""" Requests permission and returns an future result that returns a
boolean indicating if all the given permission were granted or denied.
"""
app = AndroidApplication.instance()
f = app.create_future()
def on_result(p... | python | def request_permission(cls, permissions):
""" Requests permission and returns an future result that returns a
boolean indicating if all the given permission were granted or denied.
"""
app = AndroidApplication.instance()
f = app.create_future()
def on_result(p... | [
"def",
"request_permission",
"(",
"cls",
",",
"permissions",
")",
":",
"app",
"=",
"AndroidApplication",
".",
"instance",
"(",
")",
"f",
"=",
"app",
".",
"create_future",
"(",
")",
"def",
"on_result",
"(",
"perms",
")",
":",
"allowed",
"=",
"True",
"for"... | Requests permission and returns an future result that returns a
boolean indicating if all the given permission were granted or denied. | [
"Requests",
"permission",
"and",
"returns",
"an",
"future",
"result",
"that",
"returns",
"a",
"boolean",
"indicating",
"if",
"all",
"the",
"given",
"permission",
"were",
"granted",
"or",
"denied",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_wifi.py#L401-L417 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/concurrent.py | return_future | def return_future(f):
"""Decorator to make a function that returns via callback return a
`Future`.
The wrapped function should take a ``callback`` keyword argument
and invoke it with one argument when it has finished. To signal failure,
the function can simply raise an exception (which will be
... | python | def return_future(f):
"""Decorator to make a function that returns via callback return a
`Future`.
The wrapped function should take a ``callback`` keyword argument
and invoke it with one argument when it has finished. To signal failure,
the function can simply raise an exception (which will be
... | [
"def",
"return_future",
"(",
"f",
")",
":",
"replacer",
"=",
"ArgReplacer",
"(",
"f",
",",
"'callback'",
")",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"future",
"=",
"TracebackF... | Decorator to make a function that returns via callback return a
`Future`.
The wrapped function should take a ``callback`` keyword argument
and invoke it with one argument when it has finished. To signal failure,
the function can simply raise an exception (which will be
captured by the `.StackConte... | [
"Decorator",
"to",
"make",
"a",
"function",
"that",
"returns",
"via",
"callback",
"return",
"a",
"Future",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/concurrent.py#L419-L502 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/concurrent.py | Future.result | def result(self, timeout=None):
"""If the operation succeeded, return its result. If it failed,
re-raise its exception.
This method takes a ``timeout`` argument for compatibility with
`concurrent.futures.Future` but it is an error to call it
before the `Future` is done, so the ... | python | def result(self, timeout=None):
"""If the operation succeeded, return its result. If it failed,
re-raise its exception.
This method takes a ``timeout`` argument for compatibility with
`concurrent.futures.Future` but it is an error to call it
before the `Future` is done, so the ... | [
"def",
"result",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_clear_tb_log",
"(",
")",
"if",
"self",
".",
"_result",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_result",
"if",
"self",
".",
"_exc_info",
"is",
"not",
"None"... | If the operation succeeded, return its result. If it failed,
re-raise its exception.
This method takes a ``timeout`` argument for compatibility with
`concurrent.futures.Future` but it is an error to call it
before the `Future` is done, so the ``timeout`` is never used. | [
"If",
"the",
"operation",
"succeeded",
"return",
"its",
"result",
".",
"If",
"it",
"failed",
"re",
"-",
"raise",
"its",
"exception",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/concurrent.py#L224-L241 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/concurrent.py | Future.exception | def exception(self, timeout=None):
"""If the operation raised an exception, return the `Exception`
object. Otherwise returns None.
This method takes a ``timeout`` argument for compatibility with
`concurrent.futures.Future` but it is an error to call it
before the `Future` is do... | python | def exception(self, timeout=None):
"""If the operation raised an exception, return the `Exception`
object. Otherwise returns None.
This method takes a ``timeout`` argument for compatibility with
`concurrent.futures.Future` but it is an error to call it
before the `Future` is do... | [
"def",
"exception",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_clear_tb_log",
"(",
")",
"if",
"self",
".",
"_exc_info",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_exc_info",
"[",
"1",
"]",
"else",
":",
"self",
".",
"... | If the operation raised an exception, return the `Exception`
object. Otherwise returns None.
This method takes a ``timeout`` argument for compatibility with
`concurrent.futures.Future` but it is an error to call it
before the `Future` is done, so the ``timeout`` is never used. | [
"If",
"the",
"operation",
"raised",
"an",
"exception",
"return",
"the",
"Exception",
"object",
".",
"Otherwise",
"returns",
"None",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/concurrent.py#L243-L256 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/concurrent.py | Future.add_done_callback | def add_done_callback(self, fn):
"""Attaches the given callback to the `Future`.
It will be invoked with the `Future` as its argument when the Future
has finished running and its result is available. In Tornado
consider using `.IOLoop.add_future` instead of calling
`add_done_ca... | python | def add_done_callback(self, fn):
"""Attaches the given callback to the `Future`.
It will be invoked with the `Future` as its argument when the Future
has finished running and its result is available. In Tornado
consider using `.IOLoop.add_future` instead of calling
`add_done_ca... | [
"def",
"add_done_callback",
"(",
"self",
",",
"fn",
")",
":",
"if",
"self",
".",
"_done",
":",
"fn",
"(",
"self",
")",
"else",
":",
"self",
".",
"_callbacks",
".",
"append",
"(",
"fn",
")"
] | Attaches the given callback to the `Future`.
It will be invoked with the `Future` as its argument when the Future
has finished running and its result is available. In Tornado
consider using `.IOLoop.add_future` instead of calling
`add_done_callback` directly. | [
"Attaches",
"the",
"given",
"callback",
"to",
"the",
"Future",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/concurrent.py#L258-L269 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/concurrent.py | Future.set_exception | def set_exception(self, exception):
"""Sets the exception of a ``Future.``"""
self.set_exc_info(
(exception.__class__,
exception,
getattr(exception, '__traceback__', None))) | python | def set_exception(self, exception):
"""Sets the exception of a ``Future.``"""
self.set_exc_info(
(exception.__class__,
exception,
getattr(exception, '__traceback__', None))) | [
"def",
"set_exception",
"(",
"self",
",",
"exception",
")",
":",
"self",
".",
"set_exc_info",
"(",
"(",
"exception",
".",
"__class__",
",",
"exception",
",",
"getattr",
"(",
"exception",
",",
"'__traceback__'",
",",
"None",
")",
")",
")"
] | Sets the exception of a ``Future.`` | [
"Sets",
"the",
"exception",
"of",
"a",
"Future",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/concurrent.py#L280-L285 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/concurrent.py | Future.set_exc_info | def set_exc_info(self, exc_info):
"""Sets the exception information of a ``Future.``
Preserves tracebacks on Python 2.
.. versionadded:: 4.0
"""
self._exc_info = exc_info
self._log_traceback = True
if not _GC_CYCLE_FINALIZERS:
self._tb_logger = _Trac... | python | def set_exc_info(self, exc_info):
"""Sets the exception information of a ``Future.``
Preserves tracebacks on Python 2.
.. versionadded:: 4.0
"""
self._exc_info = exc_info
self._log_traceback = True
if not _GC_CYCLE_FINALIZERS:
self._tb_logger = _Trac... | [
"def",
"set_exc_info",
"(",
"self",
",",
"exc_info",
")",
":",
"self",
".",
"_exc_info",
"=",
"exc_info",
"self",
".",
"_log_traceback",
"=",
"True",
"if",
"not",
"_GC_CYCLE_FINALIZERS",
":",
"self",
".",
"_tb_logger",
"=",
"_TracebackLogger",
"(",
"exc_info",... | Sets the exception information of a ``Future.``
Preserves tracebacks on Python 2.
.. versionadded:: 4.0 | [
"Sets",
"the",
"exception",
"information",
"of",
"a",
"Future",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/concurrent.py#L295-L314 | train |
codelv/enaml-native | src/enamlnative/ios/uikit_view_group.py | UiKitViewGroup.destroy | def destroy(self):
""" A reimplemented destructor that destroys the layout widget.
"""
layout = self.layout
if layout is not None:
layout.removeFromSuperview()
self.layout = None
super(UiKitViewGroup, self).destroy() | python | def destroy(self):
""" A reimplemented destructor that destroys the layout widget.
"""
layout = self.layout
if layout is not None:
layout.removeFromSuperview()
self.layout = None
super(UiKitViewGroup, self).destroy() | [
"def",
"destroy",
"(",
"self",
")",
":",
"layout",
"=",
"self",
".",
"layout",
"if",
"layout",
"is",
"not",
"None",
":",
"layout",
".",
"removeFromSuperview",
"(",
")",
"self",
".",
"layout",
"=",
"None",
"super",
"(",
"UiKitViewGroup",
",",
"self",
")... | A reimplemented destructor that destroys the layout widget. | [
"A",
"reimplemented",
"destructor",
"that",
"destroys",
"the",
"layout",
"widget",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view_group.py#L108-L116 | train |
codelv/enaml-native | src/enamlnative/ios/bridge.py | ObjcMethod.pack_args | def pack_args(self, obj, *args, **kwargs):
""" Arguments must be packed according to the kwargs passed and
the signature defined.
"""
signature = self.__signature__
#: No arguments expected
if not signature:
return (self.name, [])
#: Build args, firs... | python | def pack_args(self, obj, *args, **kwargs):
""" Arguments must be packed according to the kwargs passed and
the signature defined.
"""
signature = self.__signature__
#: No arguments expected
if not signature:
return (self.name, [])
#: Build args, firs... | [
"def",
"pack_args",
"(",
"self",
",",
"obj",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"signature",
"=",
"self",
".",
"__signature__",
"if",
"not",
"signature",
":",
"return",
"(",
"self",
".",
"name",
",",
"[",
"]",
")",
"method_name",
"=",
... | Arguments must be packed according to the kwargs passed and
the signature defined. | [
"Arguments",
"must",
"be",
"packed",
"according",
"to",
"the",
"kwargs",
"passed",
"and",
"the",
"signature",
"defined",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/bridge.py#L59-L91 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/stack_context.py | _remove_deactivated | def _remove_deactivated(contexts):
"""Remove deactivated handlers from the chain"""
# Clean ctx handlers
stack_contexts = tuple([h for h in contexts[0] if h.active])
# Find new head
head = contexts[1]
while head is not None and not head.active:
head = head.old_contexts[1]
# Process... | python | def _remove_deactivated(contexts):
"""Remove deactivated handlers from the chain"""
# Clean ctx handlers
stack_contexts = tuple([h for h in contexts[0] if h.active])
# Find new head
head = contexts[1]
while head is not None and not head.active:
head = head.old_contexts[1]
# Process... | [
"def",
"_remove_deactivated",
"(",
"contexts",
")",
":",
"stack_contexts",
"=",
"tuple",
"(",
"[",
"h",
"for",
"h",
"in",
"contexts",
"[",
"0",
"]",
"if",
"h",
".",
"active",
"]",
")",
"head",
"=",
"contexts",
"[",
"1",
"]",
"while",
"head",
"is",
... | Remove deactivated handlers from the chain | [
"Remove",
"deactivated",
"handlers",
"from",
"the",
"chain"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/stack_context.py#L246-L269 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/stack_context.py | wrap | def wrap(fn):
"""Returns a callable object that will restore the current `StackContext`
when executed.
Use this whenever saving a callback to be executed later in a
different execution context (either in a different thread or
asynchronously in the same thread).
"""
# Check if function is al... | python | def wrap(fn):
"""Returns a callable object that will restore the current `StackContext`
when executed.
Use this whenever saving a callback to be executed later in a
different execution context (either in a different thread or
asynchronously in the same thread).
"""
# Check if function is al... | [
"def",
"wrap",
"(",
"fn",
")",
":",
"if",
"fn",
"is",
"None",
"or",
"hasattr",
"(",
"fn",
",",
"'_wrapped'",
")",
":",
"return",
"fn",
"cap_contexts",
"=",
"[",
"_state",
".",
"contexts",
"]",
"if",
"not",
"cap_contexts",
"[",
"0",
"]",
"[",
"0",
... | Returns a callable object that will restore the current `StackContext`
when executed.
Use this whenever saving a callback to be executed later in a
different execution context (either in a different thread or
asynchronously in the same thread). | [
"Returns",
"a",
"callable",
"object",
"that",
"will",
"restore",
"the",
"current",
"StackContext",
"when",
"executed",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/stack_context.py#L272-L368 | train |
codelv/enaml-native | src/enamlnative/android/android_list_view.py | AndroidListView.get_declared_items | def get_declared_items(self):
""" Override to do it manually
"""
for k, v in super(AndroidListView, self).get_declared_items():
if k == 'layout':
yield k, v
break | python | def get_declared_items(self):
""" Override to do it manually
"""
for k, v in super(AndroidListView, self).get_declared_items():
if k == 'layout':
yield k, v
break | [
"def",
"get_declared_items",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"super",
"(",
"AndroidListView",
",",
"self",
")",
".",
"get_declared_items",
"(",
")",
":",
"if",
"k",
"==",
"'layout'",
":",
"yield",
"k",
",",
"v",
"break"
] | Override to do it manually | [
"Override",
"to",
"do",
"it",
"manually"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L201-L208 | train |
codelv/enaml-native | src/enamlnative/android/android_list_view.py | AndroidListView.on_recycle_view | def on_recycle_view(self, index, position):
""" Update the item the view at the given index should display
"""
item = self.list_items[index]
self.item_mapping[position] = item
item.recycle_view(position) | python | def on_recycle_view(self, index, position):
""" Update the item the view at the given index should display
"""
item = self.list_items[index]
self.item_mapping[position] = item
item.recycle_view(position) | [
"def",
"on_recycle_view",
"(",
"self",
",",
"index",
",",
"position",
")",
":",
"item",
"=",
"self",
".",
"list_items",
"[",
"index",
"]",
"self",
".",
"item_mapping",
"[",
"position",
"]",
"=",
"item",
"item",
".",
"recycle_view",
"(",
"position",
")"
] | Update the item the view at the given index should display | [
"Update",
"the",
"item",
"the",
"view",
"at",
"the",
"given",
"index",
"should",
"display"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L234-L239 | train |
codelv/enaml-native | src/enamlnative/android/android_list_view.py | AndroidListView.refresh_views | def refresh_views(self, change=None):
""" Set the views that the adapter will cycle through. """
adapter = self.adapter
# Set initial ListItem state
item_mapping = self.item_mapping
for i, item in enumerate(self.list_items):
item_mapping[i] = item
item.re... | python | def refresh_views(self, change=None):
""" Set the views that the adapter will cycle through. """
adapter = self.adapter
# Set initial ListItem state
item_mapping = self.item_mapping
for i, item in enumerate(self.list_items):
item_mapping[i] = item
item.re... | [
"def",
"refresh_views",
"(",
"self",
",",
"change",
"=",
"None",
")",
":",
"adapter",
"=",
"self",
".",
"adapter",
"item_mapping",
"=",
"self",
".",
"item_mapping",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"self",
".",
"list_items",
")",
":",
"... | Set the views that the adapter will cycle through. | [
"Set",
"the",
"views",
"that",
"the",
"adapter",
"will",
"cycle",
"through",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L247-L260 | train |
codelv/enaml-native | src/enamlnative/android/android_list_view.py | AndroidListView._on_items_changed | def _on_items_changed(self, change):
""" Observe container events on the items list and update the
adapter appropriately.
"""
if change['type'] != 'container':
return
op = change['operation']
if op == 'append':
i = len(change['value'])-1
... | python | def _on_items_changed(self, change):
""" Observe container events on the items list and update the
adapter appropriately.
"""
if change['type'] != 'container':
return
op = change['operation']
if op == 'append':
i = len(change['value'])-1
... | [
"def",
"_on_items_changed",
"(",
"self",
",",
"change",
")",
":",
"if",
"change",
"[",
"'type'",
"]",
"!=",
"'container'",
":",
"return",
"op",
"=",
"change",
"[",
"'operation'",
"]",
"if",
"op",
"==",
"'append'",
":",
"i",
"=",
"len",
"(",
"change",
... | Observe container events on the items list and update the
adapter appropriately. | [
"Observe",
"container",
"events",
"on",
"the",
"items",
"list",
"and",
"update",
"the",
"adapter",
"appropriately",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L268-L290 | train |
codelv/enaml-native | src/enamlnative/android/android_list_view.py | AndroidListItem.recycle_view | def recycle_view(self, position):
""" Tell the view to render the item at the given position """
d = self.declaration
if position < len(d.parent.items):
d.index = position
d.item = d.parent.items[position]
else:
d.index = -1
d.item = None | python | def recycle_view(self, position):
""" Tell the view to render the item at the given position """
d = self.declaration
if position < len(d.parent.items):
d.index = position
d.item = d.parent.items[position]
else:
d.index = -1
d.item = None | [
"def",
"recycle_view",
"(",
"self",
",",
"position",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"if",
"position",
"<",
"len",
"(",
"d",
".",
"parent",
".",
"items",
")",
":",
"d",
".",
"index",
"=",
"position",
"d",
".",
"item",
"=",
"d",
".... | Tell the view to render the item at the given position | [
"Tell",
"the",
"view",
"to",
"render",
"the",
"item",
"at",
"the",
"given",
"position"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L351-L360 | train |
codelv/enaml-native | src/enamlnative/core/eventloop/util.py | Configurable.configured_class | def configured_class(cls):
# type: () -> type
"""Returns the currently configured class."""
base = cls.configurable_base()
# Manually mangle the private name to see whether this base
# has been configured (and not another base higher in the
# hierarchy).
if base._... | python | def configured_class(cls):
# type: () -> type
"""Returns the currently configured class."""
base = cls.configurable_base()
# Manually mangle the private name to see whether this base
# has been configured (and not another base higher in the
# hierarchy).
if base._... | [
"def",
"configured_class",
"(",
"cls",
")",
":",
"base",
"=",
"cls",
".",
"configurable_base",
"(",
")",
"if",
"base",
".",
"__dict__",
".",
"get",
"(",
"'_Configurable__impl_class'",
")",
"is",
"None",
":",
"base",
".",
"__impl_class",
"=",
"cls",
".",
... | Returns the currently configured class. | [
"Returns",
"the",
"currently",
"configured",
"class",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/util.py#L359-L368 | train |
codelv/enaml-native | src/enamlnative/android/android_toast.py | AndroidToast.child_added | def child_added(self, child):
""" Overwrite the view """
view = child.widget
if view is not None:
self.toast.setView(view) | python | def child_added(self, child):
""" Overwrite the view """
view = child.widget
if view is not None:
self.toast.setView(view) | [
"def",
"child_added",
"(",
"self",
",",
"child",
")",
":",
"view",
"=",
"child",
".",
"widget",
"if",
"view",
"is",
"not",
"None",
":",
"self",
".",
"toast",
".",
"setView",
"(",
"view",
")"
] | Overwrite the view | [
"Overwrite",
"the",
"view"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_toast.py#L89-L93 | train |
codelv/enaml-native | src/enamlnative/android/android_toast.py | AndroidToast.on_make_toast | def on_make_toast(self, ref):
""" Using Toast.makeToast returns async so we have to initialize it
later.
"""
d = self.declaration
self.toast = Toast(__id__=ref)
self.init_widget() | python | def on_make_toast(self, ref):
""" Using Toast.makeToast returns async so we have to initialize it
later.
"""
d = self.declaration
self.toast = Toast(__id__=ref)
self.init_widget() | [
"def",
"on_make_toast",
"(",
"self",
",",
"ref",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"self",
".",
"toast",
"=",
"Toast",
"(",
"__id__",
"=",
"ref",
")",
"self",
".",
"init_widget",
"(",
")"
] | Using Toast.makeToast returns async so we have to initialize it
later. | [
"Using",
"Toast",
".",
"makeToast",
"returns",
"async",
"so",
"we",
"have",
"to",
"initialize",
"it",
"later",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_toast.py#L95-L102 | train |
codelv/enaml-native | src/enamlnative/android/android_location.py | LocationManager.start | def start(cls, callback, provider='gps', min_time=1000, min_distance=0):
""" Convenience method that checks and requests permission if necessary
and if successful calls the callback with a populated `Location`
instance on updates.
Note you must have the permissions in your manifest or ... | python | def start(cls, callback, provider='gps', min_time=1000, min_distance=0):
""" Convenience method that checks and requests permission if necessary
and if successful calls the callback with a populated `Location`
instance on updates.
Note you must have the permissions in your manifest or ... | [
"def",
"start",
"(",
"cls",
",",
"callback",
",",
"provider",
"=",
"'gps'",
",",
"min_time",
"=",
"1000",
",",
"min_distance",
"=",
"0",
")",
":",
"app",
"=",
"AndroidApplication",
".",
"instance",
"(",
")",
"f",
"=",
"app",
".",
"create_future",
"(",
... | Convenience method that checks and requests permission if necessary
and if successful calls the callback with a populated `Location`
instance on updates.
Note you must have the permissions in your manifest or requests
will be denied immediately. | [
"Convenience",
"method",
"that",
"checks",
"and",
"requests",
"permission",
"if",
"necessary",
"and",
"if",
"successful",
"calls",
"the",
"callback",
"with",
"a",
"populated",
"Location",
"instance",
"on",
"updates",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_location.py#L61-L105 | train |
codelv/enaml-native | src/enamlnative/android/android_location.py | LocationManager.stop | def stop(cls):
""" Stops location updates if currently updating.
"""
manager = LocationManager.instance()
if manager:
for l in manager.listeners:
manager.removeUpdates(l)
manager.listeners = [] | python | def stop(cls):
""" Stops location updates if currently updating.
"""
manager = LocationManager.instance()
if manager:
for l in manager.listeners:
manager.removeUpdates(l)
manager.listeners = [] | [
"def",
"stop",
"(",
"cls",
")",
":",
"manager",
"=",
"LocationManager",
".",
"instance",
"(",
")",
"if",
"manager",
":",
"for",
"l",
"in",
"manager",
".",
"listeners",
":",
"manager",
".",
"removeUpdates",
"(",
"l",
")",
"manager",
".",
"listeners",
"=... | Stops location updates if currently updating. | [
"Stops",
"location",
"updates",
"if",
"currently",
"updating",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_location.py#L108-L116 | train |
codelv/enaml-native | src/enamlnative/android/android_location.py | LocationManager.request_permission | def request_permission(cls, fine=True):
""" Requests permission and returns an async result that returns
a boolean indicating if the permission was granted or denied.
"""
app = AndroidApplication.instance()
permission = (cls.ACCESS_FINE_PERMISSION
... | python | def request_permission(cls, fine=True):
""" Requests permission and returns an async result that returns
a boolean indicating if the permission was granted or denied.
"""
app = AndroidApplication.instance()
permission = (cls.ACCESS_FINE_PERMISSION
... | [
"def",
"request_permission",
"(",
"cls",
",",
"fine",
"=",
"True",
")",
":",
"app",
"=",
"AndroidApplication",
".",
"instance",
"(",
")",
"permission",
"=",
"(",
"cls",
".",
"ACCESS_FINE_PERMISSION",
"if",
"fine",
"else",
"cls",
".",
"ACCESS_COARSE_PERMISSION"... | Requests permission and returns an async result that returns
a boolean indicating if the permission was granted or denied. | [
"Requests",
"permission",
"and",
"returns",
"an",
"async",
"result",
"that",
"returns",
"a",
"boolean",
"indicating",
"if",
"the",
"permission",
"was",
"granted",
"or",
"denied",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_location.py#L132-L147 | train |
codelv/enaml-native | src/enamlnative/android/android_web_view.py | AndroidWebView.destroy | def destroy(self):
""" Destroy the client
"""
if self.client:
#: Stop listening
self.client.setWebView(self.widget, None)
del self.client
super(AndroidWebView, self).destroy() | python | def destroy(self):
""" Destroy the client
"""
if self.client:
#: Stop listening
self.client.setWebView(self.widget, None)
del self.client
super(AndroidWebView, self).destroy() | [
"def",
"destroy",
"(",
"self",
")",
":",
"if",
"self",
".",
"client",
":",
"self",
".",
"client",
".",
"setWebView",
"(",
"self",
".",
"widget",
",",
"None",
")",
"del",
"self",
".",
"client",
"super",
"(",
"AndroidWebView",
",",
"self",
")",
".",
... | Destroy the client | [
"Destroy",
"the",
"client"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_web_view.py#L95-L103 | train |
codelv/enaml-native | src/enamlnative/android/android_radio_group.py | AndroidRadioGroup.set_checked | def set_checked(self, checked):
""" Properly check the correct radio button.
"""
if not checked:
self.widget.clearCheck()
else:
#: Checked is a reference to the radio declaration
#: so we need to get the ID of it
rb = checked.proxy.widget
... | python | def set_checked(self, checked):
""" Properly check the correct radio button.
"""
if not checked:
self.widget.clearCheck()
else:
#: Checked is a reference to the radio declaration
#: so we need to get the ID of it
rb = checked.proxy.widget
... | [
"def",
"set_checked",
"(",
"self",
",",
"checked",
")",
":",
"if",
"not",
"checked",
":",
"self",
".",
"widget",
".",
"clearCheck",
"(",
")",
"else",
":",
"rb",
"=",
"checked",
".",
"proxy",
".",
"widget",
"if",
"not",
"rb",
":",
"return",
"self",
... | Properly check the correct radio button. | [
"Properly",
"check",
"the",
"correct",
"radio",
"button",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_radio_group.py#L89-L101 | train |
codelv/enaml-native | src/enamlnative/android/app.py | AndroidApplication.init_widget | def init_widget(self):
""" Initialize on the first call
"""
#: Add a ActivityLifecycleListener to update the application state
activity = self.widget
activity.addActivityLifecycleListener(activity.getId())
activity.onActivityLifecycleChanged.connect(
... | python | def init_widget(self):
""" Initialize on the first call
"""
#: Add a ActivityLifecycleListener to update the application state
activity = self.widget
activity.addActivityLifecycleListener(activity.getId())
activity.onActivityLifecycleChanged.connect(
... | [
"def",
"init_widget",
"(",
"self",
")",
":",
"activity",
"=",
"self",
".",
"widget",
"activity",
".",
"addActivityLifecycleListener",
"(",
"activity",
".",
"getId",
"(",
")",
")",
"activity",
".",
"onActivityLifecycleChanged",
".",
"connect",
"(",
"self",
".",... | Initialize on the first call | [
"Initialize",
"on",
"the",
"first",
"call"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L79-L95 | train |
codelv/enaml-native | src/enamlnative/android/app.py | AndroidApplication.has_permission | def has_permission(self, permission):
""" Return a future that resolves with the result of the permission
"""
f = self.create_future()
#: Old versions of android did permissions at install time
if self.api_level < 23:
f.set_result(True)
return f... | python | def has_permission(self, permission):
""" Return a future that resolves with the result of the permission
"""
f = self.create_future()
#: Old versions of android did permissions at install time
if self.api_level < 23:
f.set_result(True)
return f... | [
"def",
"has_permission",
"(",
"self",
",",
"permission",
")",
":",
"f",
"=",
"self",
".",
"create_future",
"(",
")",
"if",
"self",
".",
"api_level",
"<",
"23",
":",
"f",
".",
"set_result",
"(",
"True",
")",
"return",
"f",
"def",
"on_result",
"(",
"al... | Return a future that resolves with the result of the permission | [
"Return",
"a",
"future",
"that",
"resolves",
"with",
"the",
"result",
"of",
"the",
"permission"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L100-L117 | train |
codelv/enaml-native | src/enamlnative/android/app.py | AndroidApplication.request_permissions | def request_permissions(self, permissions):
""" Return a future that resolves with the results
of the permission requests
"""
f = self.create_future()
#: Old versions of android did permissions at install time
if self.api_level < 23:
f.set_result({p... | python | def request_permissions(self, permissions):
""" Return a future that resolves with the results
of the permission requests
"""
f = self.create_future()
#: Old versions of android did permissions at install time
if self.api_level < 23:
f.set_result({p... | [
"def",
"request_permissions",
"(",
"self",
",",
"permissions",
")",
":",
"f",
"=",
"self",
".",
"create_future",
"(",
")",
"if",
"self",
".",
"api_level",
"<",
"23",
":",
"f",
".",
"set_result",
"(",
"{",
"p",
":",
"True",
"for",
"p",
"in",
"permissi... | Return a future that resolves with the results
of the permission requests | [
"Return",
"a",
"future",
"that",
"resolves",
"with",
"the",
"results",
"of",
"the",
"permission",
"requests"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L119-L151 | train |
codelv/enaml-native | src/enamlnative/android/app.py | AndroidApplication.show_toast | def show_toast(self, msg, long=True):
""" Show a toast message for the given duration.
This is an android specific api.
Parameters
-----------
msg: str
Text to display in the toast message
long: bool
Display for a long or short (system defined) du... | python | def show_toast(self, msg, long=True):
""" Show a toast message for the given duration.
This is an android specific api.
Parameters
-----------
msg: str
Text to display in the toast message
long: bool
Display for a long or short (system defined) du... | [
"def",
"show_toast",
"(",
"self",
",",
"msg",
",",
"long",
"=",
"True",
")",
":",
"from",
".",
"android_toast",
"import",
"Toast",
"def",
"on_toast",
"(",
"ref",
")",
":",
"t",
"=",
"Toast",
"(",
"__id__",
"=",
"ref",
")",
"t",
".",
"show",
"(",
... | Show a toast message for the given duration.
This is an android specific api.
Parameters
-----------
msg: str
Text to display in the toast message
long: bool
Display for a long or short (system defined) duration | [
"Show",
"a",
"toast",
"message",
"for",
"the",
"given",
"duration",
".",
"This",
"is",
"an",
"android",
"specific",
"api",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L153-L171 | train |
codelv/enaml-native | src/enamlnative/android/app.py | AndroidApplication.on_back_pressed | def on_back_pressed(self):
""" Fire the `back_pressed` event with a dictionary with a 'handled'
key when the back hardware button is pressed
If 'handled' is set to any value that evaluates to True the
default event implementation will be ignored.
"""
try... | python | def on_back_pressed(self):
""" Fire the `back_pressed` event with a dictionary with a 'handled'
key when the back hardware button is pressed
If 'handled' is set to any value that evaluates to True the
default event implementation will be ignored.
"""
try... | [
"def",
"on_back_pressed",
"(",
"self",
")",
":",
"try",
":",
"event",
"=",
"{",
"'handled'",
":",
"False",
"}",
"self",
".",
"back_pressed",
"(",
"event",
")",
"return",
"bool",
"(",
"event",
".",
"get",
"(",
"'handled'",
",",
"False",
")",
")",
"exc... | Fire the `back_pressed` event with a dictionary with a 'handled'
key when the back hardware button is pressed
If 'handled' is set to any value that evaluates to True the
default event implementation will be ignored. | [
"Fire",
"the",
"back_pressed",
"event",
"with",
"a",
"dictionary",
"with",
"a",
"handled",
"key",
"when",
"the",
"back",
"hardware",
"button",
"is",
"pressed",
"If",
"handled",
"is",
"set",
"to",
"any",
"value",
"that",
"evaluates",
"to",
"True",
"the",
"d... | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L182-L196 | train |
codelv/enaml-native | src/enamlnative/android/app.py | AndroidApplication.on_configuration_changed | def on_configuration_changed(self, config):
""" Handles a screen configuration change.
"""
self.width = config['width']
self.height = config['height']
self.orientation = ('square', 'portrait', 'landscape')[
config['orientation']] | python | def on_configuration_changed(self, config):
""" Handles a screen configuration change.
"""
self.width = config['width']
self.height = config['height']
self.orientation = ('square', 'portrait', 'landscape')[
config['orientation']] | [
"def",
"on_configuration_changed",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"width",
"=",
"config",
"[",
"'width'",
"]",
"self",
".",
"height",
"=",
"config",
"[",
"'height'",
"]",
"self",
".",
"orientation",
"=",
"(",
"'square'",
",",
"'portra... | Handles a screen configuration change. | [
"Handles",
"a",
"screen",
"configuration",
"change",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L198-L205 | train |
codelv/enaml-native | src/enamlnative/android/app.py | AndroidApplication.show_view | def show_view(self):
""" Show the current `app.view`. This will fade out the previous
with the new view.
"""
if not self.build_info:
def on_build_info(info):
""" Make sure the build info is ready before we
display the view
... | python | def show_view(self):
""" Show the current `app.view`. This will fade out the previous
with the new view.
"""
if not self.build_info:
def on_build_info(info):
""" Make sure the build info is ready before we
display the view
... | [
"def",
"show_view",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"build_info",
":",
"def",
"on_build_info",
"(",
"info",
")",
":",
"self",
".",
"dp",
"=",
"info",
"[",
"'DISPLAY_DENSITY'",
"]",
"self",
".",
"width",
"=",
"info",
"[",
"'DISPLAY_WIDT... | Show the current `app.view`. This will fade out the previous
with the new view. | [
"Show",
"the",
"current",
"app",
".",
"view",
".",
"This",
"will",
"fade",
"out",
"the",
"previous",
"with",
"the",
"new",
"view",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L210-L233 | train |
codelv/enaml-native | src/enamlnative/android/app.py | AndroidApplication._on_permission_result | def _on_permission_result(self, code, perms, results):
""" Handles a permission request result by passing it to the
handler with the given code.
"""
#: Get the handler for this request
handler = self._permission_requests.get(code, None)
if handler is not None:
... | python | def _on_permission_result(self, code, perms, results):
""" Handles a permission request result by passing it to the
handler with the given code.
"""
#: Get the handler for this request
handler = self._permission_requests.get(code, None)
if handler is not None:
... | [
"def",
"_on_permission_result",
"(",
"self",
",",
"code",
",",
"perms",
",",
"results",
")",
":",
"handler",
"=",
"self",
".",
"_permission_requests",
".",
"get",
"(",
"code",
",",
"None",
")",
"if",
"handler",
"is",
"not",
"None",
":",
"del",
"self",
... | Handles a permission request result by passing it to the
handler with the given code. | [
"Handles",
"a",
"permission",
"request",
"result",
"by",
"passing",
"it",
"to",
"the",
"handler",
"with",
"the",
"given",
"code",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L246-L257 | train |
codelv/enaml-native | src/enamlnative/android/app.py | AndroidApplication._observe_keep_screen_on | def _observe_keep_screen_on(self, change):
""" Sets or clears the flag to keep the screen on.
"""
def set_screen_on(window):
from .android_window import Window
window = Window(__id__=window)
if self.keep_screen_on:
window.addFlags(Win... | python | def _observe_keep_screen_on(self, change):
""" Sets or clears the flag to keep the screen on.
"""
def set_screen_on(window):
from .android_window import Window
window = Window(__id__=window)
if self.keep_screen_on:
window.addFlags(Win... | [
"def",
"_observe_keep_screen_on",
"(",
"self",
",",
"change",
")",
":",
"def",
"set_screen_on",
"(",
"window",
")",
":",
"from",
".",
"android_window",
"import",
"Window",
"window",
"=",
"Window",
"(",
"__id__",
"=",
"window",
")",
"if",
"self",
".",
"keep... | Sets or clears the flag to keep the screen on. | [
"Sets",
"or",
"clears",
"the",
"flag",
"to",
"keep",
"the",
"screen",
"on",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L259-L271 | train |
codelv/enaml-native | src/enamlnative/android/app.py | AndroidApplication.load_plugin_factories | def load_plugin_factories(self):
""" Add any plugin toolkit widgets to the ANDROID_FACTORIES
"""
for plugin in self.get_plugins(group='enaml_native_android_factories'):
get_factories = plugin.load()
PLUGIN_FACTORIES = get_factories()
factories.ANDROI... | python | def load_plugin_factories(self):
""" Add any plugin toolkit widgets to the ANDROID_FACTORIES
"""
for plugin in self.get_plugins(group='enaml_native_android_factories'):
get_factories = plugin.load()
PLUGIN_FACTORIES = get_factories()
factories.ANDROI... | [
"def",
"load_plugin_factories",
"(",
"self",
")",
":",
"for",
"plugin",
"in",
"self",
".",
"get_plugins",
"(",
"group",
"=",
"'enaml_native_android_factories'",
")",
":",
"get_factories",
"=",
"plugin",
".",
"load",
"(",
")",
"PLUGIN_FACTORIES",
"=",
"get_factor... | Add any plugin toolkit widgets to the ANDROID_FACTORIES | [
"Add",
"any",
"plugin",
"toolkit",
"widgets",
"to",
"the",
"ANDROID_FACTORIES"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L283-L290 | train |
codelv/enaml-native | src/enamlnative/ios/uikit_edit_text.py | UiKitEditText.on_value_changed | def on_value_changed(self, text):
""" Update text field """
d = self.declaration
with self.widget.get_member('text').suppressed(self.widget):
d.text = text | python | def on_value_changed(self, text):
""" Update text field """
d = self.declaration
with self.widget.get_member('text').suppressed(self.widget):
d.text = text | [
"def",
"on_value_changed",
"(",
"self",
",",
"text",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"with",
"self",
".",
"widget",
".",
"get_member",
"(",
"'text'",
")",
".",
"suppressed",
"(",
"self",
".",
"widget",
")",
":",
"d",
".",
"text",
"=",... | Update text field | [
"Update",
"text",
"field"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_edit_text.py#L106-L110 | train |
codelv/enaml-native | src/enamlnative/__init__.py | imports | def imports():
""" Install the import hook to load python extensions from app's lib folder
during the context of this block.
This method is preferred as it's faster than using install.
"""
from .core.import_hooks import ExtensionImporter
importer = ExtensionImporter()
sys.meta_path.... | python | def imports():
""" Install the import hook to load python extensions from app's lib folder
during the context of this block.
This method is preferred as it's faster than using install.
"""
from .core.import_hooks import ExtensionImporter
importer = ExtensionImporter()
sys.meta_path.... | [
"def",
"imports",
"(",
")",
":",
"from",
".",
"core",
".",
"import_hooks",
"import",
"ExtensionImporter",
"importer",
"=",
"ExtensionImporter",
"(",
")",
"sys",
".",
"meta_path",
".",
"append",
"(",
"importer",
")",
"yield",
"sys",
".",
"meta_path",
".",
"... | Install the import hook to load python extensions from app's lib folder
during the context of this block.
This method is preferred as it's faster than using install. | [
"Install",
"the",
"import",
"hook",
"to",
"load",
"python",
"extensions",
"from",
"app",
"s",
"lib",
"folder",
"during",
"the",
"context",
"of",
"this",
"block",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/__init__.py#L17-L27 | train |
codelv/enaml-native | src/enamlnative/__init__.py | install | def install():
""" Install the import hook to load extensions from the app Lib folder.
Like imports but leaves it in the meta_path, thus it is slower.
"""
from .core.import_hooks import ExtensionImporter
importer = ExtensionImporter()
sys.meta_path.append(importer) | python | def install():
""" Install the import hook to load extensions from the app Lib folder.
Like imports but leaves it in the meta_path, thus it is slower.
"""
from .core.import_hooks import ExtensionImporter
importer = ExtensionImporter()
sys.meta_path.append(importer) | [
"def",
"install",
"(",
")",
":",
"from",
".",
"core",
".",
"import_hooks",
"import",
"ExtensionImporter",
"importer",
"=",
"ExtensionImporter",
"(",
")",
"sys",
".",
"meta_path",
".",
"append",
"(",
"importer",
")"
] | Install the import hook to load extensions from the app Lib folder.
Like imports but leaves it in the meta_path, thus it is slower. | [
"Install",
"the",
"import",
"hook",
"to",
"load",
"extensions",
"from",
"the",
"app",
"Lib",
"folder",
".",
"Like",
"imports",
"but",
"leaves",
"it",
"in",
"the",
"meta_path",
"thus",
"it",
"is",
"slower",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/__init__.py#L30-L36 | train |
codelv/enaml-native | src/enamlnative/android/http.py | AndroidHttpRequest.init_request | def init_request(self):
""" Init the native request using the okhttp3.Request.Builder """
#: Build the request
builder = Request.Builder()
builder.url(self.url)
#: Set any headers
for k, v in self.headers.items():
builder.addHeader(k, v)
#: Get the ... | python | def init_request(self):
""" Init the native request using the okhttp3.Request.Builder """
#: Build the request
builder = Request.Builder()
builder.url(self.url)
#: Set any headers
for k, v in self.headers.items():
builder.addHeader(k, v)
#: Get the ... | [
"def",
"init_request",
"(",
"self",
")",
":",
"builder",
"=",
"Request",
".",
"Builder",
"(",
")",
"builder",
".",
"url",
"(",
"self",
".",
"url",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"headers",
".",
"items",
"(",
")",
":",
"builder",
".... | Init the native request using the okhttp3.Request.Builder | [
"Init",
"the",
"native",
"request",
"using",
"the",
"okhttp3",
".",
"Request",
".",
"Builder"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/http.py#L140-L170 | train |
codelv/enaml-native | src/enamlnative/android/http.py | AndroidHttpRequest._default_body | def _default_body(self):
""" If the body is not passed in by the user try to create one
using the given data parameters.
"""
if not self.data:
return ""
if self.content_type == 'application/json':
import json
return json.dumps(self.data)
... | python | def _default_body(self):
""" If the body is not passed in by the user try to create one
using the given data parameters.
"""
if not self.data:
return ""
if self.content_type == 'application/json':
import json
return json.dumps(self.data)
... | [
"def",
"_default_body",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"data",
":",
"return",
"\"\"",
"if",
"self",
".",
"content_type",
"==",
"'application/json'",
":",
"import",
"json",
"return",
"json",
".",
"dumps",
"(",
"self",
".",
"data",
")",
... | If the body is not passed in by the user try to create one
using the given data parameters. | [
"If",
"the",
"body",
"is",
"not",
"passed",
"in",
"by",
"the",
"user",
"try",
"to",
"create",
"one",
"using",
"the",
"given",
"data",
"parameters",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/http.py#L188-L204 | train |
codelv/enaml-native | src/enamlnative/android/http.py | AndroidHttpRequest.on_finish | def on_finish(self):
""" Called regardless of success or failure """
r = self.response
r.request_time = time.time() - self.start_time
if self.callback:
self.callback(r) | python | def on_finish(self):
""" Called regardless of success or failure """
r = self.response
r.request_time = time.time() - self.start_time
if self.callback:
self.callback(r) | [
"def",
"on_finish",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"response",
"r",
".",
"request_time",
"=",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"start_time",
"if",
"self",
".",
"callback",
":",
"self",
".",
"callback",
"(",
"r",
")"
] | Called regardless of success or failure | [
"Called",
"regardless",
"of",
"success",
"or",
"failure"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/http.py#L237-L242 | train |
codelv/enaml-native | src/enamlnative/android/http.py | AsyncHttpClient._fetch | def _fetch(self, request):
""" Fetch using the OkHttpClient """
client = self.client
#: Dispatch the async call
call = Call(__id__=client.newCall(request.request))
call.enqueue(request.handler)
#: Save the call reference
request.call = call | python | def _fetch(self, request):
""" Fetch using the OkHttpClient """
client = self.client
#: Dispatch the async call
call = Call(__id__=client.newCall(request.request))
call.enqueue(request.handler)
#: Save the call reference
request.call = call | [
"def",
"_fetch",
"(",
"self",
",",
"request",
")",
":",
"client",
"=",
"self",
".",
"client",
"call",
"=",
"Call",
"(",
"__id__",
"=",
"client",
".",
"newCall",
"(",
"request",
".",
"request",
")",
")",
"call",
".",
"enqueue",
"(",
"request",
".",
... | Fetch using the OkHttpClient | [
"Fetch",
"using",
"the",
"OkHttpClient"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/http.py#L276-L285 | train |
codelv/enaml-native | src/enamlnative/core/app.py | Plugin.load | def load(self):
""" Load the object defined by the plugin entry point """
print("[DEBUG] Loading plugin {} from {}".format(self.name,
self.source))
import pydoc
path, attr = self.source.split(":")
module = pydoc.locate(path... | python | def load(self):
""" Load the object defined by the plugin entry point """
print("[DEBUG] Loading plugin {} from {}".format(self.name,
self.source))
import pydoc
path, attr = self.source.split(":")
module = pydoc.locate(path... | [
"def",
"load",
"(",
"self",
")",
":",
"print",
"(",
"\"[DEBUG] Loading plugin {} from {}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"source",
")",
")",
"import",
"pydoc",
"path",
",",
"attr",
"=",
"self",
".",
"source",
".",
"split",
... | Load the object defined by the plugin entry point | [
"Load",
"the",
"object",
"defined",
"by",
"the",
"plugin",
"entry",
"point"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L34-L41 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication._default_plugins | def _default_plugins(self):
""" Get entry points to load any plugins installed.
The build process should create an "entry_points.json" file
with all of the data from the installed entry points.
"""
plugins = {}
try:
with open('entry_points.json') as ... | python | def _default_plugins(self):
""" Get entry points to load any plugins installed.
The build process should create an "entry_points.json" file
with all of the data from the installed entry points.
"""
plugins = {}
try:
with open('entry_points.json') as ... | [
"def",
"_default_plugins",
"(",
"self",
")",
":",
"plugins",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"'entry_points.json'",
")",
"as",
"f",
":",
"entry_points",
"=",
"json",
".",
"load",
"(",
"f",
")",
"for",
"ep",
",",
"obj",
"in",
"entry_po... | Get entry points to load any plugins installed.
The build process should create an "entry_points.json" file
with all of the data from the installed entry points. | [
"Get",
"entry",
"points",
"to",
"load",
"any",
"plugins",
"installed",
".",
"The",
"build",
"process",
"should",
"create",
"an",
"entry_points",
".",
"json",
"file",
"with",
"all",
"of",
"the",
"data",
"from",
"the",
"installed",
"entry",
"points",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L104-L120 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication.start | def start(self):
""" Start the application's main event loop
using either twisted or tornado.
"""
#: Schedule a load view if given and remote debugging is not active
#: the remote debugging init call this after dev connection is ready
if self.load_view and self.d... | python | def start(self):
""" Start the application's main event loop
using either twisted or tornado.
"""
#: Schedule a load view if given and remote debugging is not active
#: the remote debugging init call this after dev connection is ready
if self.load_view and self.d... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"load_view",
"and",
"self",
".",
"dev",
"!=",
"\"remote\"",
":",
"self",
".",
"deferred_call",
"(",
"self",
".",
"load_view",
",",
"self",
")",
"self",
".",
"loop",
".",
"start",
"(",
")"
] | Start the application's main event loop
using either twisted or tornado. | [
"Start",
"the",
"application",
"s",
"main",
"event",
"loop",
"using",
"either",
"twisted",
"or",
"tornado",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L140-L150 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication.timed_call | def timed_call(self, ms, callback, *args, **kwargs):
""" Invoke a callable on the main event loop thread at a
specified time in the future.
Parameters
----------
ms : int
The time to delay, in milliseconds, before executing the
callable.
callback... | python | def timed_call(self, ms, callback, *args, **kwargs):
""" Invoke a callable on the main event loop thread at a
specified time in the future.
Parameters
----------
ms : int
The time to delay, in milliseconds, before executing the
callable.
callback... | [
"def",
"timed_call",
"(",
"self",
",",
"ms",
",",
"callback",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"loop",
".",
"timed_call",
"(",
"ms",
",",
"callback",
",",
"*",
"args",
",",
"**",
"kwargs",
")"
] | Invoke a callable on the main event loop thread at a
specified time in the future.
Parameters
----------
ms : int
The time to delay, in milliseconds, before executing the
callable.
callback : callable
The callable object to execute at some po... | [
"Invoke",
"a",
"callable",
"on",
"the",
"main",
"event",
"loop",
"thread",
"at",
"a",
"specified",
"time",
"in",
"the",
"future",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L174-L192 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication.add_done_callback | def add_done_callback(self, future, callback):
""" Add a callback on a future object put here so it can be
implemented with different event loops.
Parameters
-----------
future: Future or Deferred
Future implementation for the current EventLoop
... | python | def add_done_callback(self, future, callback):
""" Add a callback on a future object put here so it can be
implemented with different event loops.
Parameters
-----------
future: Future or Deferred
Future implementation for the current EventLoop
... | [
"def",
"add_done_callback",
"(",
"self",
",",
"future",
",",
"callback",
")",
":",
"if",
"future",
"is",
"None",
":",
"raise",
"bridge",
".",
"BridgeReferenceError",
"(",
"\"Tried to add a callback to a nonexistent Future. \"",
"\"Make sure you pass the `returns` argument t... | Add a callback on a future object put here so it can be
implemented with different event loops.
Parameters
-----------
future: Future or Deferred
Future implementation for the current EventLoop
callback: callable
Callback ... | [
"Add",
"a",
"callback",
"on",
"a",
"future",
"object",
"put",
"here",
"so",
"it",
"can",
"be",
"implemented",
"with",
"different",
"event",
"loops",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L236-L253 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication.get_view | def get_view(self):
""" Get the root view to display. Make sure it is
properly initialized.
"""
view = self.view
if not view.is_initialized:
view.initialize()
if not view.proxy_is_active:
view.activate_proxy()
return view.proxy.wid... | python | def get_view(self):
""" Get the root view to display. Make sure it is
properly initialized.
"""
view = self.view
if not view.is_initialized:
view.initialize()
if not view.proxy_is_active:
view.activate_proxy()
return view.proxy.wid... | [
"def",
"get_view",
"(",
"self",
")",
":",
"view",
"=",
"self",
".",
"view",
"if",
"not",
"view",
".",
"is_initialized",
":",
"view",
".",
"initialize",
"(",
")",
"if",
"not",
"view",
".",
"proxy_is_active",
":",
"view",
".",
"activate_proxy",
"(",
")",... | Get the root view to display. Make sure it is
properly initialized. | [
"Get",
"the",
"root",
"view",
"to",
"display",
".",
"Make",
"sure",
"it",
"is",
"properly",
"initialized",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L278-L288 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication.send_event | def send_event(self, name, *args, **kwargs):
""" Send an event to the native handler. This call is queued and
batched.
Parameters
----------
name : str
The event name to be processed by MainActivity.processMessages.
*args: args
The arguments requ... | python | def send_event(self, name, *args, **kwargs):
""" Send an event to the native handler. This call is queued and
batched.
Parameters
----------
name : str
The event name to be processed by MainActivity.processMessages.
*args: args
The arguments requ... | [
"def",
"send_event",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"n",
"=",
"len",
"(",
"self",
".",
"_bridge_queue",
")",
"self",
".",
"_bridge_queue",
".",
"append",
"(",
"(",
"name",
",",
"args",
")",
")",
"if",
"... | Send an event to the native handler. This call is queued and
batched.
Parameters
----------
name : str
The event name to be processed by MainActivity.processMessages.
*args: args
The arguments required by the event.
**kwargs: kwargs
O... | [
"Send",
"an",
"event",
"to",
"the",
"native",
"handler",
".",
"This",
"call",
"is",
"queued",
"and",
"batched",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L296-L330 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication._bridge_send | def _bridge_send(self, now=False):
""" Send the events over the bridge to be processed by the native
handler.
Parameters
----------
now: boolean
Send all pending events now instead of waiting for deferred calls
to finish. Use this when you want to updat... | python | def _bridge_send(self, now=False):
""" Send the events over the bridge to be processed by the native
handler.
Parameters
----------
now: boolean
Send all pending events now instead of waiting for deferred calls
to finish. Use this when you want to updat... | [
"def",
"_bridge_send",
"(",
"self",
",",
"now",
"=",
"False",
")",
":",
"if",
"len",
"(",
"self",
".",
"_bridge_queue",
")",
":",
"if",
"self",
".",
"debug",
":",
"print",
"(",
"\"======== Py ",
")",
"for",
"event",
"in",
"self",
".",
"_bridge_queue",
... | Send the events over the bridge to be processed by the native
handler.
Parameters
----------
now: boolean
Send all pending events now instead of waiting for deferred calls
to finish. Use this when you want to update the screen | [
"Send",
"the",
"events",
"over",
"the",
"bridge",
"to",
"be",
"processed",
"by",
"the",
"native",
"handler",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L337-L355 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication.process_events | def process_events(self, data):
""" The native implementation must use this call to """
events = bridge.loads(data)
if self.debug:
print("======== Py <-- Native ======")
for event in events:
print(event)
print("===========================")
... | python | def process_events(self, data):
""" The native implementation must use this call to """
events = bridge.loads(data)
if self.debug:
print("======== Py <-- Native ======")
for event in events:
print(event)
print("===========================")
... | [
"def",
"process_events",
"(",
"self",
",",
"data",
")",
":",
"events",
"=",
"bridge",
".",
"loads",
"(",
"data",
")",
"if",
"self",
".",
"debug",
":",
"print",
"(",
"\"======== Py <-- Native ======\"",
")",
"for",
"event",
"in",
"events",
":",
"print",
"... | The native implementation must use this call to | [
"The",
"native",
"implementation",
"must",
"use",
"this",
"call",
"to"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L363-L373 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication.handle_event | def handle_event(self, event):
""" When we get an 'event' type from the bridge
handle it by invoking the handler and if needed
sending back the result.
"""
result_id, ptr, method, args = event[1]
obj = None
result = None
try:
obj, hand... | python | def handle_event(self, event):
""" When we get an 'event' type from the bridge
handle it by invoking the handler and if needed
sending back the result.
"""
result_id, ptr, method, args = event[1]
obj = None
result = None
try:
obj, hand... | [
"def",
"handle_event",
"(",
"self",
",",
"event",
")",
":",
"result_id",
",",
"ptr",
",",
"method",
",",
"args",
"=",
"event",
"[",
"1",
"]",
"obj",
"=",
"None",
"result",
"=",
"None",
"try",
":",
"obj",
",",
"handler",
"=",
"bridge",
".",
"get_han... | When we get an 'event' type from the bridge
handle it by invoking the handler and if needed
sending back the result. | [
"When",
"we",
"get",
"an",
"event",
"type",
"from",
"the",
"bridge",
"handle",
"it",
"by",
"invoking",
"the",
"handler",
"and",
"if",
"needed",
"sending",
"back",
"the",
"result",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L375-L411 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication.handle_error | def handle_error(self, callback):
""" Called when an error occurs in an event loop callback.
By default, sets the error view.
"""
self.loop.log_error(callback)
msg = "\n".join([
"Exception in callback %r"%callback,
traceback.format_exc()
]... | python | def handle_error(self, callback):
""" Called when an error occurs in an event loop callback.
By default, sets the error view.
"""
self.loop.log_error(callback)
msg = "\n".join([
"Exception in callback %r"%callback,
traceback.format_exc()
]... | [
"def",
"handle_error",
"(",
"self",
",",
"callback",
")",
":",
"self",
".",
"loop",
".",
"log_error",
"(",
"callback",
")",
"msg",
"=",
"\"\\n\"",
".",
"join",
"(",
"[",
"\"Exception in callback %r\"",
"%",
"callback",
",",
"traceback",
".",
"format_exc",
... | Called when an error occurs in an event loop callback.
By default, sets the error view. | [
"Called",
"when",
"an",
"error",
"occurs",
"in",
"an",
"event",
"loop",
"callback",
".",
"By",
"default",
"sets",
"the",
"error",
"view",
"."
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L413-L423 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication.start_dev_session | def start_dev_session(self):
""" Start a client that attempts to connect to the dev server
running on the host `app.dev`
"""
try:
from .dev import DevServerSession
session = DevServerSession.initialize(host=self.dev)
session.start()
... | python | def start_dev_session(self):
""" Start a client that attempts to connect to the dev server
running on the host `app.dev`
"""
try:
from .dev import DevServerSession
session = DevServerSession.initialize(host=self.dev)
session.start()
... | [
"def",
"start_dev_session",
"(",
"self",
")",
":",
"try",
":",
"from",
".",
"dev",
"import",
"DevServerSession",
"session",
"=",
"DevServerSession",
".",
"initialize",
"(",
"host",
"=",
"self",
".",
"dev",
")",
"session",
".",
"start",
"(",
")",
"self",
... | Start a client that attempts to connect to the dev server
running on the host `app.dev` | [
"Start",
"a",
"client",
"that",
"attempts",
"to",
"connect",
"to",
"the",
"dev",
"server",
"running",
"on",
"the",
"host",
"app",
".",
"dev"
] | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L460-L473 | train |
codelv/enaml-native | src/enamlnative/core/app.py | BridgedApplication.load_plugin_widgets | def load_plugin_widgets(self):
""" Pull widgets added via plugins using the `enaml_native_widgets`
entry point. The entry point function must return a dictionary of
Widget declarations to add to the core api.
def install():
from charts.widgets.chart_view import BarChart, L... | python | def load_plugin_widgets(self):
""" Pull widgets added via plugins using the `enaml_native_widgets`
entry point. The entry point function must return a dictionary of
Widget declarations to add to the core api.
def install():
from charts.widgets.chart_view import BarChart, L... | [
"def",
"load_plugin_widgets",
"(",
"self",
")",
":",
"from",
"enamlnative",
".",
"widgets",
"import",
"api",
"for",
"plugin",
"in",
"self",
".",
"get_plugins",
"(",
"group",
"=",
"'enaml_native_widgets'",
")",
":",
"get_widgets",
"=",
"plugin",
".",
"load",
... | Pull widgets added via plugins using the `enaml_native_widgets`
entry point. The entry point function must return a dictionary of
Widget declarations to add to the core api.
def install():
from charts.widgets.chart_view import BarChart, LineChart
return {
... | [
"Pull",
"widgets",
"added",
"via",
"plugins",
"using",
"the",
"enaml_native_widgets",
"entry",
"point",
".",
"The",
"entry",
"point",
"function",
"must",
"return",
"a",
"dictionary",
"of",
"Widget",
"declarations",
"to",
"add",
"to",
"the",
"core",
"api",
"."
... | c33986e9eda468c508806e0a3e73c771401e5718 | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L485-L503 | train |
openxc/openxc-python | openxc/vehicle.py | Vehicle.get | def get(self, measurement_class):
"""Return the latest measurement for the given class or None if nothing
has been received from the vehicle.
"""
name = Measurement.name_from_class(measurement_class)
return self._construct_measurement(name) | python | def get(self, measurement_class):
"""Return the latest measurement for the given class or None if nothing
has been received from the vehicle.
"""
name = Measurement.name_from_class(measurement_class)
return self._construct_measurement(name) | [
"def",
"get",
"(",
"self",
",",
"measurement_class",
")",
":",
"name",
"=",
"Measurement",
".",
"name_from_class",
"(",
"measurement_class",
")",
"return",
"self",
".",
"_construct_measurement",
"(",
"name",
")"
] | Return the latest measurement for the given class or None if nothing
has been received from the vehicle. | [
"Return",
"the",
"latest",
"measurement",
"for",
"the",
"given",
"class",
"or",
"None",
"if",
"nothing",
"has",
"been",
"received",
"from",
"the",
"vehicle",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/vehicle.py#L39-L44 | train |
openxc/openxc-python | openxc/vehicle.py | Vehicle.add_source | def add_source(self, source):
"""Add a vehicle data source to the instance.
The Vehicle instance will be set as the callback of the source, and the
source will be started if it is startable. (i.e. it has a ``start()``
method).
"""
if source is not None:
self.... | python | def add_source(self, source):
"""Add a vehicle data source to the instance.
The Vehicle instance will be set as the callback of the source, and the
source will be started if it is startable. (i.e. it has a ``start()``
method).
"""
if source is not None:
self.... | [
"def",
"add_source",
"(",
"self",
",",
"source",
")",
":",
"if",
"source",
"is",
"not",
"None",
":",
"self",
".",
"sources",
".",
"add",
"(",
"source",
")",
"source",
".",
"callback",
"=",
"self",
".",
"_receive",
"if",
"hasattr",
"(",
"source",
",",... | Add a vehicle data source to the instance.
The Vehicle instance will be set as the callback of the source, and the
source will be started if it is startable. (i.e. it has a ``start()``
method). | [
"Add",
"a",
"vehicle",
"data",
"source",
"to",
"the",
"instance",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/vehicle.py#L65-L76 | train |
openxc/openxc-python | openxc/sinks/notifier.py | MeasurementNotifierSink.register | def register(self, measurement_class, callback):
"""Call the ``callback`` with any new values of ``measurement_class``
received.
"""
self.callbacks[Measurement.name_from_class(measurement_class)
].add(callback) | python | def register(self, measurement_class, callback):
"""Call the ``callback`` with any new values of ``measurement_class``
received.
"""
self.callbacks[Measurement.name_from_class(measurement_class)
].add(callback) | [
"def",
"register",
"(",
"self",
",",
"measurement_class",
",",
"callback",
")",
":",
"self",
".",
"callbacks",
"[",
"Measurement",
".",
"name_from_class",
"(",
"measurement_class",
")",
"]",
".",
"add",
"(",
"callback",
")"
] | Call the ``callback`` with any new values of ``measurement_class``
received. | [
"Call",
"the",
"callback",
"with",
"any",
"new",
"values",
"of",
"measurement_class",
"received",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/sinks/notifier.py#L26-L31 | train |
openxc/openxc-python | openxc/sinks/notifier.py | MeasurementNotifierSink.unregister | def unregister(self, measurement_class, callback):
"""Stop notifying ``callback`` of new values of ``measurement_class``.
If the callback wasn't previously registered, this method will have no
effect.
"""
self.callbacks[Measurement.name_from_class(measurement_class)
... | python | def unregister(self, measurement_class, callback):
"""Stop notifying ``callback`` of new values of ``measurement_class``.
If the callback wasn't previously registered, this method will have no
effect.
"""
self.callbacks[Measurement.name_from_class(measurement_class)
... | [
"def",
"unregister",
"(",
"self",
",",
"measurement_class",
",",
"callback",
")",
":",
"self",
".",
"callbacks",
"[",
"Measurement",
".",
"name_from_class",
"(",
"measurement_class",
")",
"]",
".",
"remove",
"(",
"callback",
")"
] | Stop notifying ``callback`` of new values of ``measurement_class``.
If the callback wasn't previously registered, this method will have no
effect. | [
"Stop",
"notifying",
"callback",
"of",
"new",
"values",
"of",
"measurement_class",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/sinks/notifier.py#L33-L40 | train |
openxc/openxc-python | openxc/controllers/usb.py | UsbControllerMixin._send_complex_request | def _send_complex_request(self, request):
"""Send a request via the USB control request endpoint, rather than as a
bulk transfer.
"""
self.device.ctrl_transfer(0x40, self.COMPLEX_CONTROL_COMMAND, 0, 0,
self.streamer.serialize_for_stream(request)) | python | def _send_complex_request(self, request):
"""Send a request via the USB control request endpoint, rather than as a
bulk transfer.
"""
self.device.ctrl_transfer(0x40, self.COMPLEX_CONTROL_COMMAND, 0, 0,
self.streamer.serialize_for_stream(request)) | [
"def",
"_send_complex_request",
"(",
"self",
",",
"request",
")",
":",
"self",
".",
"device",
".",
"ctrl_transfer",
"(",
"0x40",
",",
"self",
".",
"COMPLEX_CONTROL_COMMAND",
",",
"0",
",",
"0",
",",
"self",
".",
"streamer",
".",
"serialize_for_stream",
"(",
... | Send a request via the USB control request endpoint, rather than as a
bulk transfer. | [
"Send",
"a",
"request",
"via",
"the",
"USB",
"control",
"request",
"endpoint",
"rather",
"than",
"as",
"a",
"bulk",
"transfer",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/usb.py#L32-L37 | train |
openxc/openxc-python | openxc/controllers/usb.py | UsbControllerMixin.out_endpoint | def out_endpoint(self):
"""Open a reference to the USB device's only OUT endpoint. This method
assumes that the USB device configuration has already been set.
"""
if getattr(self, '_out_endpoint', None) is None:
config = self.device.get_active_configuration()
inte... | python | def out_endpoint(self):
"""Open a reference to the USB device's only OUT endpoint. This method
assumes that the USB device configuration has already been set.
"""
if getattr(self, '_out_endpoint', None) is None:
config = self.device.get_active_configuration()
inte... | [
"def",
"out_endpoint",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"'_out_endpoint'",
",",
"None",
")",
"is",
"None",
":",
"config",
"=",
"self",
".",
"device",
".",
"get_active_configuration",
"(",
")",
"interface_number",
"=",
"config",
"["... | Open a reference to the USB device's only OUT endpoint. This method
assumes that the USB device configuration has already been set. | [
"Open",
"a",
"reference",
"to",
"the",
"USB",
"device",
"s",
"only",
"OUT",
"endpoint",
".",
"This",
"method",
"assumes",
"that",
"the",
"USB",
"device",
"configuration",
"has",
"already",
"been",
"set",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/usb.py#L40-L59 | train |
openxc/openxc-python | openxc/controllers/base.py | ResponseReceiver.wait_for_responses | def wait_for_responses(self):
"""Block the thread and wait for the response to the given request to
arrive from the VI. If no matching response is received in
COMMAND_RESPONSE_TIMEOUT_S seconds, returns anyway.
"""
self.thread.join(self.COMMAND_RESPONSE_TIMEOUT_S)
self.r... | python | def wait_for_responses(self):
"""Block the thread and wait for the response to the given request to
arrive from the VI. If no matching response is received in
COMMAND_RESPONSE_TIMEOUT_S seconds, returns anyway.
"""
self.thread.join(self.COMMAND_RESPONSE_TIMEOUT_S)
self.r... | [
"def",
"wait_for_responses",
"(",
"self",
")",
":",
"self",
".",
"thread",
".",
"join",
"(",
"self",
".",
"COMMAND_RESPONSE_TIMEOUT_S",
")",
"self",
".",
"running",
"=",
"False",
"return",
"self",
".",
"responses"
] | Block the thread and wait for the response to the given request to
arrive from the VI. If no matching response is received in
COMMAND_RESPONSE_TIMEOUT_S seconds, returns anyway. | [
"Block",
"the",
"thread",
"and",
"wait",
"for",
"the",
"response",
"to",
"the",
"given",
"request",
"to",
"arrive",
"from",
"the",
"VI",
".",
"If",
"no",
"matching",
"response",
"is",
"received",
"in",
"COMMAND_RESPONSE_TIMEOUT_S",
"seconds",
"returns",
"anywa... | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L56-L65 | train |
openxc/openxc-python | openxc/controllers/base.py | DiagnosticResponseReceiver._response_matches_request | def _response_matches_request(self, response):
"""Return true if the response is to a diagnostic request, and the bus,
id, mode match. If the request was successful, the PID echo is also
checked.
"""
# Accept success/failure command responses
if super(DiagnosticResponseRe... | python | def _response_matches_request(self, response):
"""Return true if the response is to a diagnostic request, and the bus,
id, mode match. If the request was successful, the PID echo is also
checked.
"""
# Accept success/failure command responses
if super(DiagnosticResponseRe... | [
"def",
"_response_matches_request",
"(",
"self",
",",
"response",
")",
":",
"if",
"super",
"(",
"DiagnosticResponseReceiver",
",",
"self",
")",
".",
"_response_matches_request",
"(",
"response",
")",
":",
"return",
"True",
"if",
"(",
"'bus'",
"in",
"self",
"."... | Return true if the response is to a diagnostic request, and the bus,
id, mode match. If the request was successful, the PID echo is also
checked. | [
"Return",
"true",
"if",
"the",
"response",
"is",
"to",
"a",
"diagnostic",
"request",
"and",
"the",
"bus",
"id",
"mode",
"match",
".",
"If",
"the",
"request",
"was",
"successful",
"the",
"PID",
"echo",
"is",
"also",
"checked",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L115-L137 | train |
openxc/openxc-python | openxc/controllers/base.py | Controller.complex_request | def complex_request(self, request, wait_for_first_response=True):
"""Send a compound command request to the interface over the normal data
channel.
request - A dict storing the request to send to the VI. It will be
serialized to the currently selected output format.
wait_for... | python | def complex_request(self, request, wait_for_first_response=True):
"""Send a compound command request to the interface over the normal data
channel.
request - A dict storing the request to send to the VI. It will be
serialized to the currently selected output format.
wait_for... | [
"def",
"complex_request",
"(",
"self",
",",
"request",
",",
"wait_for_first_response",
"=",
"True",
")",
":",
"receiver",
"=",
"self",
".",
"_prepare_response_receiver",
"(",
"request",
",",
"receiver_class",
"=",
"CommandResponseReceiver",
")",
"self",
".",
"_sen... | Send a compound command request to the interface over the normal data
channel.
request - A dict storing the request to send to the VI. It will be
serialized to the currently selected output format.
wait_for_first_response - If true, this function will block waiting for
a... | [
"Send",
"a",
"compound",
"command",
"request",
"to",
"the",
"interface",
"over",
"the",
"normal",
"data",
"channel",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L159-L177 | train |
openxc/openxc-python | openxc/controllers/base.py | Controller.create_diagnostic_request | def create_diagnostic_request(self, message_id, mode, bus=None, pid=None,
frequency=None, payload=None, wait_for_ack=True,
wait_for_first_response=False, decoded_type=None):
"""Send a new diagnostic message request to the VI
Required:
message_id - The message ID (arbitr... | python | def create_diagnostic_request(self, message_id, mode, bus=None, pid=None,
frequency=None, payload=None, wait_for_ack=True,
wait_for_first_response=False, decoded_type=None):
"""Send a new diagnostic message request to the VI
Required:
message_id - The message ID (arbitr... | [
"def",
"create_diagnostic_request",
"(",
"self",
",",
"message_id",
",",
"mode",
",",
"bus",
"=",
"None",
",",
"pid",
"=",
"None",
",",
"frequency",
"=",
"None",
",",
"payload",
"=",
"None",
",",
"wait_for_ack",
"=",
"True",
",",
"wait_for_first_response",
... | Send a new diagnostic message request to the VI
Required:
message_id - The message ID (arbitration ID) for the request.
mode - the diagnostic mode (or service).
Optional:
bus - The address of the CAN bus controller to send the request, either
1 or 2 for current VI... | [
"Send",
"a",
"new",
"diagnostic",
"message",
"request",
"to",
"the",
"VI"
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L213-L263 | train |
openxc/openxc-python | openxc/controllers/base.py | Controller.set_passthrough | def set_passthrough(self, bus, enabled):
"""Control the status of CAN message passthrough for a bus.
Returns True if the command was successful.
"""
request = {
"command": "passthrough",
"bus": bus,
"enabled": enabled
}
return self._ch... | python | def set_passthrough(self, bus, enabled):
"""Control the status of CAN message passthrough for a bus.
Returns True if the command was successful.
"""
request = {
"command": "passthrough",
"bus": bus,
"enabled": enabled
}
return self._ch... | [
"def",
"set_passthrough",
"(",
"self",
",",
"bus",
",",
"enabled",
")",
":",
"request",
"=",
"{",
"\"command\"",
":",
"\"passthrough\"",
",",
"\"bus\"",
":",
"bus",
",",
"\"enabled\"",
":",
"enabled",
"}",
"return",
"self",
".",
"_check_command_response_status... | Control the status of CAN message passthrough for a bus.
Returns True if the command was successful. | [
"Control",
"the",
"status",
"of",
"CAN",
"message",
"passthrough",
"for",
"a",
"bus",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L269-L279 | train |
openxc/openxc-python | openxc/controllers/base.py | Controller.set_payload_format | def set_payload_format(self, payload_format):
"""Set the payload format for messages sent to and from the VI.
Returns True if the command was successful.
"""
request = {
"command": "payload_format",
"format": payload_format
}
status = self._check_... | python | def set_payload_format(self, payload_format):
"""Set the payload format for messages sent to and from the VI.
Returns True if the command was successful.
"""
request = {
"command": "payload_format",
"format": payload_format
}
status = self._check_... | [
"def",
"set_payload_format",
"(",
"self",
",",
"payload_format",
")",
":",
"request",
"=",
"{",
"\"command\"",
":",
"\"payload_format\"",
",",
"\"format\"",
":",
"payload_format",
"}",
"status",
"=",
"self",
".",
"_check_command_response_status",
"(",
"request",
"... | Set the payload format for messages sent to and from the VI.
Returns True if the command was successful. | [
"Set",
"the",
"payload",
"format",
"for",
"messages",
"sent",
"to",
"and",
"from",
"the",
"VI",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L281-L294 | train |
openxc/openxc-python | openxc/controllers/base.py | Controller.rtc_configuration | def rtc_configuration(self, unix_time):
"""Set the Unix time if RTC is supported on the device.
Returns True if the command was successful.
"""
request = {
"command": "rtc_configuration",
"unix_time": unix_time
}
status = self._check_command_respo... | python | def rtc_configuration(self, unix_time):
"""Set the Unix time if RTC is supported on the device.
Returns True if the command was successful.
"""
request = {
"command": "rtc_configuration",
"unix_time": unix_time
}
status = self._check_command_respo... | [
"def",
"rtc_configuration",
"(",
"self",
",",
"unix_time",
")",
":",
"request",
"=",
"{",
"\"command\"",
":",
"\"rtc_configuration\"",
",",
"\"unix_time\"",
":",
"unix_time",
"}",
"status",
"=",
"self",
".",
"_check_command_response_status",
"(",
"request",
")",
... | Set the Unix time if RTC is supported on the device.
Returns True if the command was successful. | [
"Set",
"the",
"Unix",
"time",
"if",
"RTC",
"is",
"supported",
"on",
"the",
"device",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L297-L307 | train |
openxc/openxc-python | openxc/controllers/base.py | Controller.set_acceptance_filter_bypass | def set_acceptance_filter_bypass(self, bus, bypass):
"""Control the status of CAN acceptance filter for a bus.
Returns True if the command was successful.
"""
request = {
"command": "af_bypass",
"bus": bus,
"bypass": bypass
}
return se... | python | def set_acceptance_filter_bypass(self, bus, bypass):
"""Control the status of CAN acceptance filter for a bus.
Returns True if the command was successful.
"""
request = {
"command": "af_bypass",
"bus": bus,
"bypass": bypass
}
return se... | [
"def",
"set_acceptance_filter_bypass",
"(",
"self",
",",
"bus",
",",
"bypass",
")",
":",
"request",
"=",
"{",
"\"command\"",
":",
"\"af_bypass\"",
",",
"\"bus\"",
":",
"bus",
",",
"\"bypass\"",
":",
"bypass",
"}",
"return",
"self",
".",
"_check_command_respons... | Control the status of CAN acceptance filter for a bus.
Returns True if the command was successful. | [
"Control",
"the",
"status",
"of",
"CAN",
"acceptance",
"filter",
"for",
"a",
"bus",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L322-L332 | train |
openxc/openxc-python | openxc/controllers/base.py | Controller.sd_mount_status | def sd_mount_status(self):
"""Request for SD Mount status if available.
"""
request = {
"command": "sd_mount_status"
}
responses = self.complex_request(request)
result = None
if len(responses) > 0:
result = responses[0].get('status')
... | python | def sd_mount_status(self):
"""Request for SD Mount status if available.
"""
request = {
"command": "sd_mount_status"
}
responses = self.complex_request(request)
result = None
if len(responses) > 0:
result = responses[0].get('status')
... | [
"def",
"sd_mount_status",
"(",
"self",
")",
":",
"request",
"=",
"{",
"\"command\"",
":",
"\"sd_mount_status\"",
"}",
"responses",
"=",
"self",
".",
"complex_request",
"(",
"request",
")",
"result",
"=",
"None",
"if",
"len",
"(",
"responses",
")",
">",
"0"... | Request for SD Mount status if available. | [
"Request",
"for",
"SD",
"Mount",
"status",
"if",
"available",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L368-L378 | train |
openxc/openxc-python | openxc/controllers/base.py | Controller.write | def write(self, **kwargs):
"""Serialize a raw or translated write request and send it to the VI,
following the OpenXC message format.
"""
if 'id' in kwargs and 'data' in kwargs:
result = self.write_raw(kwargs['id'], kwargs['data'],
bus=kwargs.get('bus', No... | python | def write(self, **kwargs):
"""Serialize a raw or translated write request and send it to the VI,
following the OpenXC message format.
"""
if 'id' in kwargs and 'data' in kwargs:
result = self.write_raw(kwargs['id'], kwargs['data'],
bus=kwargs.get('bus', No... | [
"def",
"write",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"'id'",
"in",
"kwargs",
"and",
"'data'",
"in",
"kwargs",
":",
"result",
"=",
"self",
".",
"write_raw",
"(",
"kwargs",
"[",
"'id'",
"]",
",",
"kwargs",
"[",
"'data'",
"]",
",",
"bus",... | Serialize a raw or translated write request and send it to the VI,
following the OpenXC message format. | [
"Serialize",
"a",
"raw",
"or",
"translated",
"write",
"request",
"and",
"send",
"it",
"to",
"the",
"VI",
"following",
"the",
"OpenXC",
"message",
"format",
"."
] | 4becb4a6310bd658c125195ef6ffea4deaf7d7e7 | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L388-L399 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.