sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def get_connection_info(cls):
""" Get info about current wifi connection (if any). Returns
info such as the IP address, BSSID, link speed, signal, etc..
Returns
--------
result: future
A future that resolves with a dict of the connection info
... | Get info about current wifi connection (if any). Returns
info such as the IP address, BSSID, link speed, signal, etc..
Returns
--------
result: future
A future that resolves with a dict of the connection info
or None if an error occurre... | entailment |
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... | Requests permission and returns an future result that returns a
boolean indicating if all the given permission were granted or denied. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidActionMenuView, self).init_widget()
d = self.declaration
w = self.widget
#: Kinda hackish, but when we get the menu back, load it
w.getMenu().then(self.on_menu)
w.setOnMenuItem... | Initialize the underlying widget. | entailment |
def _update_proxy(self, change):
""" An observer which sends the state change to the proxy.
"""
if change['type'] == 'event':
self.proxy.set_refreshed(True)
else:
super(SwipeRefreshLayout, self)._update_proxy(change) | An observer which sends the state change to the proxy. | entailment |
def _update_proxy(self, change):
""" An observer which sends the state change to the proxy.
"""
if change['type'] in ['event', 'update'] and self.proxy_is_active:
handler = getattr(self.proxy, 'set_' + change['name'], None)
if handler is not None:
handler... | An observer which sends the state change to the proxy. | entailment |
def run_on_executor(*args, **kwargs):
"""Decorator to run a synchronous method asynchronously on an executor.
The decorated method may be called with a ``callback`` keyword
argument and returns a future.
The executor to be used is determined by the ``executor``
attributes of ``self``. To use a dif... | Decorator to run a synchronous method asynchronously on an executor.
The decorated method may be called with a ``callback`` keyword
argument and returns a future.
The executor to be used is determined by the ``executor``
attributes of ``self``. To use a different attribute name, pass a
keyword arg... | entailment |
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
... | 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... | entailment |
def chain_future(a, b):
"""Chain two futures together so that when one completes, so does the other.
The result (success or failure) of ``a`` will be copied to ``b``, unless
``b`` has already been completed or cancelled by the time ``a`` finishes.
"""
def copy(future):
assert future is a
... | Chain two futures together so that when one completes, so does the other.
The result (success or failure) of ``a`` will be copied to ``b``, unless
``b`` has already been completed or cancelled by the time ``a`` finishes. | entailment |
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 ... | 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. | entailment |
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... | 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. | entailment |
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... | 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. | entailment |
def set_exception(self, exception):
"""Sets the exception of a ``Future.``"""
self.set_exc_info(
(exception.__class__,
exception,
getattr(exception, '__traceback__', None))) | Sets the exception of a ``Future.`` | entailment |
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... | Sets the exception information of a ``Future.``
Preserves tracebacks on Python 2.
.. versionadded:: 4.0 | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = CoordinatorLayout(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidCompoundButton, self).init_widget()
w = self.widget
w.setOnCheckedChangeListener(w.getId())
w.onCheckedChanged.connect(self.on_checked) | Initialize the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = RelativeLayout(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidRelativeLayout, self).init_widget()
d = self.declaration
if d.gravity:
self.set_gravity(d.gravity)
if d.horizontal_gravity:
self.set_horizontal_gravity(d.horizontal_grav... | Initialize the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidTextureView, self).__init__(self)
w = self.widget
w.setSurfaceTextureListener(w.getId())
w.onSurfaceTextureAvailable.connect(self.on_surface_texture_available)
w.onSurfaceTextureDestroy... | Initialize the underlying widget. | entailment |
def init_layout(self):
""" Add all child widgets to the view
"""
super(AndroidTextureView, self).init_layout()
# Force layout using the default params
if not self.layout_params:
self.set_layout({}) | Add all child widgets to the view | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = DrawerLayout(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidDrawerLayout, self).init_widget()
d = self.declaration
if d.title:
self.set_title(d.title)
if d.drawer_elevation:
self.set_drawer_elevation(d.drawer_elevation)
i... | Initialize the underlying widget. | entailment |
def init_layout(self):
""" Initialize the layout of the toolkit widget.
This method is called during the bottom-up pass. This method
should initialize the layout of the widget. The child widgets
will be fully initialized and layed out when this is called.
This
"""... | Initialize the layout of the toolkit widget.
This method is called during the bottom-up pass. This method
should initialize the layout of the widget. The child widgets
will be fully initialized and layed out when this is called.
This | entailment |
def child_added(self, child):
""" Handle the child added event from the declaration.
This handler will unparent the child toolkit widget. Subclasses
which need more control should reimplement this method.
"""
super(UiKitView, self).child_added(child)
layout = self.layo... | Handle the child added event from the declaration.
This handler will unparent the child toolkit widget. Subclasses
which need more control should reimplement this method. | entailment |
def child_removed(self, child):
""" Handle the child removed event from the declaration.
The child must be both removed from the arrangement and removed
normally.
"""
layout = self.layout
if child.widget is not None:
layout.removeArrangedSubview(child.widge... | Handle the child removed event from the declaration.
The child must be both removed from the arrangement and removed
normally. | entailment |
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() | A reimplemented destructor that destroys the layout widget. | entailment |
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... | Arguments must be packed according to the kwargs passed and
the signature defined. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = RatingBar(self.get_context(), None,
d.style or '@attr/ratingBarStyle') | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidRatingBar, self).init_widget()
d = self.declaration
self.set_rating(d.rating)
w = self.widget
w.setOnRatingBarChangeListener(w.getId())
w.onRatingChanged.connect(self.on_rating_... | Initialize the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = LinearLayout(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = FrameLayout(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
context = self.get_context()
d = self.declaration
style = d.style or '@attr/autoCompleteTextViewStyle'
self.widget = AutoCompleteTextView(context, None, style)
self.adapter = ArrayAdapter(context, '@l... | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidAutoCompleteTextView, self).init_widget()
self.widget.setAdapter(self.adapter) | Initialize the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = Icon(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
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... | Remove deactivated handlers from the chain | entailment |
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... | 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). | entailment |
def get(cls, sensor_type):
""" Shortcut that acquires the default Sensor of a given type.
Parameters
----------
sensor_type: int
Type of sensor to get.
Returns
-------
result: Future
A future that resolve... | Shortcut that acquires the default Sensor of a given type.
Parameters
----------
sensor_type: int
Type of sensor to get.
Returns
-------
result: Future
A future that resolves to an instance of the Sensor or None
... | entailment |
def start(self, callback, rate=SENSOR_DELAY_NORMAL):
""" Start listening to sensor events. Sensor event data depends
on the type of sensor that was given to
Parameters
----------
callback: Callable
A callback that takes one argument that will be pass... | Start listening to sensor events. Sensor event data depends
on the type of sensor that was given to
Parameters
----------
callback: Callable
A callback that takes one argument that will be passed
the sensor data. Sensor data is a dict with da... | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidListView, self).init_widget()
d = self.declaration
self.set_arrangement(d.arrangement) | Initialize the underlying widget. | entailment |
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 | Override to do it manually | entailment |
def init_layout(self):
""" Initialize the underlying widget.
"""
super(AndroidListView, self).init_layout()
d = self.declaration
w = self.widget
# Prepare adapter
adapter = self.adapter = BridgedRecyclerAdapter(w)
# I'm sure this will make someone upset... | Initialize the underlying widget. | entailment |
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) | Update the item the view at the given index should display | entailment |
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... | Set the views that the adapter will cycle through. | entailment |
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
... | Observe container events on the items list and update the
adapter appropriately. | entailment |
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 | Tell the view to render the item at the given position | entailment |
def errno_from_exception(e):
# type: (BaseException) -> Optional[int]
"""Provides the errno from an Exception object.
There are cases that the errno attribute was not set so we pull
the errno out of the args but if someone instantiates an Exception
without any args you will get a tuple error. So th... | Provides the errno from an Exception object.
There are cases that the errno attribute was not set so we pull
the errno out of the args but if someone instantiates an Exception
without any args you will get a tuple error. So this function
abstracts all that behavior to give you a safe way to get the
... | entailment |
def _websocket_mask_python(mask, data):
# type: (bytes, bytes) -> bytes
"""Websocket masking function.
`mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length.
Returns a `bytes` object of the same length as `data` with the mask applied
as specified in section 5.3 of RFC 645... | Websocket masking function.
`mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length.
Returns a `bytes` object of the same length as `data` with the mask applied
as specified in section 5.3 of RFC 6455.
This pure-python implementation may be replaced by an optimized version whe... | entailment |
def configure(cls, impl, **kwargs):
# type: (Any, **Any) -> None
"""Sets the class to use when the base class is instantiated.
Keyword arguments will be saved and added to the arguments passed
to the constructor. This can be used to set global defaults for
some parameters.
... | Sets the class to use when the base class is instantiated.
Keyword arguments will be saved and added to the arguments passed
to the constructor. This can be used to set global defaults for
some parameters. | entailment |
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._... | Returns the currently configured class. | entailment |
def get_old_value(self, args, kwargs, default=None):
# type: (List[Any], Dict[str, Any], Any) -> Any
"""Returns the old value of the named argument without replacing it.
Returns ``default`` if the argument is not present.
"""
if self.arg_pos is not None and len(args) > self.arg_... | Returns the old value of the named argument without replacing it.
Returns ``default`` if the argument is not present. | entailment |
def replace(self, new_value, args, kwargs):
# type: (Any, List[Any], Dict[str, Any]) -> Tuple[Any, List[Any], Dict[str, Any]]
"""Replace the named argument in ``args, kwargs`` with ``new_value``.
Returns ``(old_value, args, kwargs)``. The returned ``args`` and
``kwargs`` objects may no... | Replace the named argument in ``args, kwargs`` with ``new_value``.
Returns ``(old_value, args, kwargs)``. The returned ``args`` and
``kwargs`` objects may not be the same as the input objects, or
the input objects may be mutated.
If the named argument was not found, ``new_value`` will... | entailment |
def popup(self):
""" Show the notification from code. This will initialize and activate
if needed.
Notes
------
This does NOT block. Callbacks should be used to handle click events
or the `show` state should be observed to know when it is closed.
... | Show the notification from code. This will initialize and activate
if needed.
Notes
------
This does NOT block. Callbacks should be used to handle click events
or the `show` state should be observed to know when it is closed. | entailment |
def create_widget(self):
""" Create the underlying widget.
A toast is not a subclass of view, hence we don't set name as widget
or children will try to use it as their parent (which crashes).
"""
d = self.declaration
if d.text:
Toast.makeText(self.get_contex... | Create the underlying widget.
A toast is not a subclass of view, hence we don't set name as widget
or children will try to use it as their parent (which crashes). | entailment |
def init_widget(self):
""" Our widget may not exist yet so we have to diverge from the normal
way of doing initialization. See `update_widget`
"""
if not self.toast:
return
super(AndroidToast, self).init_widget()
d = self.declaration
if not ... | Our widget may not exist yet so we have to diverge from the normal
way of doing initialization. See `update_widget` | entailment |
def init_layout(self):
""" If a view is given show it """
super(AndroidToast, self).init_layout()
if not self.made_toast:
for view in self.child_widgets():
self.toast.setView(view)
break | If a view is given show it | entailment |
def child_added(self, child):
""" Overwrite the view """
view = child.widget
if view is not None:
self.toast.setView(view) | Overwrite the view | entailment |
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() | Using Toast.makeToast returns async so we have to initialize it
later. | entailment |
def _refresh_show(self, dt):
""" While the toast.show is true, keep calling .show() until the
duration `dt` expires.
Parameters
------------
dt: int
Time left to keep showing
"""
d = self.declaration
if dt <= 0:
#: Done, hide
... | While the toast.show is true, keep calling .show() until the
duration `dt` expires.
Parameters
------------
dt: int
Time left to keep showing | entailment |
def create_widget(self):
""" Create the underlying widget.
A dialog is not a subclass of view, hence we don't set name as widget
or children will try to use it as their parent.
"""
d = self.declaration
self.dialog = Dialog(self.get_context(), d.style) | Create the underlying widget.
A dialog is not a subclass of view, hence we don't set name as widget
or children will try to use it as their parent. | entailment |
def init_widget(self):
""" Set the listeners
"""
w = self.dialog
# Listen for events
w.setOnDismissListener(w.getId())
w.onDismiss.connect(self.on_dismiss)
w.setOnCancelListener(w.getId())
w.onCancel.connect(self.on_cancel)
super(AndroidDialog, sel... | Set the listeners | entailment |
def init_layout(self):
""" If a view is given show it
"""
super(AndroidDialog, self).init_layout()
#: Set the content
for view in self.child_widgets():
self.dialog.setContentView(view)
break
#: Show it if needed
d = self.declara... | If a view is given show it | entailment |
def child_added(self, child):
""" Overwrite the content view """
view = child.widget
if view is not None:
self.dialog.setContentView(view) | Overwrite the content view | entailment |
def destroy(self):
""" A reimplemented destructor that cancels
the dialog before destroying.
"""
dialog = self.dialog
if dialog:
#: Clear the dismiss listener
#: (or we get an error during the callback)
dialog.setOnDismissListener(No... | A reimplemented destructor that cancels
the dialog before destroying. | entailment |
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 ... | 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. | entailment |
def stop(cls):
""" Stops location updates if currently updating.
"""
manager = LocationManager.instance()
if manager:
for l in manager.listeners:
manager.removeUpdates(l)
manager.listeners = [] | Stops location updates if currently updating. | entailment |
def check_permission(cls, fine=True):
""" Returns a future that returns a boolean indicating if permission
is currently granted or denied. If permission is denied, you can
request using `LocationManager.request_permission()` below.
"""
app = AndroidApplication.instance()
... | Returns a future that returns a boolean indicating if permission
is currently granted or denied. If permission is denied, you can
request using `LocationManager.request_permission()` below. | entailment |
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
... | Requests permission and returns an async result that returns
a boolean indicating if the permission was granted or denied. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = WebView(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
# Create and init the client
c = self.client = BridgedWebViewClient()
c.setWebView(self.widget, c.getId())
c.onLoadResource.connect(self.on_load_resource)
c.onPageFinished.connect(self.on_page_finis... | Initialize the underlying widget. | entailment |
def destroy(self):
""" Destroy the client
"""
if self.client:
#: Stop listening
self.client.setWebView(self.widget, None)
del self.client
super(AndroidWebView, self).destroy() | Destroy the client | entailment |
def init_widget(self):
""" Bind the on property to the checked state """
super(UiKitSlider, self).init_widget()
d = self.declaration
if d.min:
self.set_min(d.min)
if d.max:
self.set_max(d.max)
if d.progress:
self.set_progress(d.progres... | Bind the on property to the checked state | entailment |
def on_checked_changed(self, value):
""" See https://stackoverflow.com/questions/19628310/ """
#: Since iOS decides to call this like 100 times for each defer it
d = self.declaration
with self.widget.setValue.suppressed():
d.progress = int(value) | See https://stackoverflow.com/questions/19628310/ | entailment |
def init_layout(self):
""" Set the checked state after all children have
been populated.
"""
super(AndroidRadioGroup, self).init_layout()
d = self.declaration
w = self.widget
if d.checked:
self.set_checked(d.checked)
else:
... | Set the checked state after all children have
been populated. | entailment |
def on_checked_changed(self, group, checked_id):
""" Set the checked property based on the checked state
of all the children
"""
d = self.declaration
if checked_id < 0:
with self.widget.clearCheck.suppressed():
d.checked = None
ret... | Set the checked property based on the checked state
of all the children | entailment |
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
... | Properly check the correct radio button. | entailment |
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(
... | Initialize on the first call | entailment |
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... | Return a future that resolves with the result of the permission | entailment |
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... | Return a future that resolves with the results
of the permission requests | entailment |
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... | 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 | entailment |
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... | 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. | entailment |
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']] | Handles a screen configuration change. | entailment |
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
... | Show the current `app.view`. This will fade out the previous
with the new view. | entailment |
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:
... | Handles a permission request result by passing it to the
handler with the given code. | entailment |
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... | Sets or clears the flag to keep the screen on. | entailment |
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... | Add any plugin toolkit widgets to the ANDROID_FACTORIES | entailment |
def init_widget(self):
""" Bind the on property to the checked state """
super(UiKitEditText, self).init_widget()
#: Init font properties etc...
self.init_text()
d = self.declaration
if d.placeholder:
self.set_placeholder(d.placeholder)
if d.input_ty... | Bind the on property to the checked state | entailment |
def on_value_changed(self, text):
""" Update text field """
d = self.declaration
with self.widget.get_member('text').suppressed(self.widget):
d.text = text | Update text field | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = DatePicker(self.get_context(), None,
d.style or "@attr/datePickerStyle") | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
d = self.declaration
w = self.widget
date = d.date
w.init(date.year, date.month-1, date.day, w.getId())
super(AndroidDatePicker, self).init_widget()
w.onDateChanged.connect(self.on_date_chan... | Initialize the underlying widget. | entailment |
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.... | 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. | entailment |
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) | 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. | entailment |
def source_from_cache(path):
"""Given the path to a .pyc. file, return the path to its .py file.
The .pyc file does not need to exist; this simply returns the path to
the .py file calculated to correspond to the .pyc file. If path does
not conform to PEP 3147/488 format, ValueError will be raised. If
... | Given the path to a .pyc. file, return the path to its .py file.
The .pyc file does not need to exist; this simply returns the path to
the .py file calculated to correspond to the .pyc file. If path does
not conform to PEP 3147/488 format, ValueError will be raised. If
sys.implementation.cache_tag is N... | entailment |
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 ... | Init the native request using the okhttp3.Request.Builder | entailment |
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)
... | If the body is not passed in by the user try to create one
using the given data parameters. | entailment |
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) | Called regardless of success or failure | entailment |
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 | Fetch using the OkHttpClient | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = CheckBox(self.get_context(), None,
d.style or "@attr/checkboxStyle") | Create the underlying widget. | entailment |
def fetch(self, url, callback=None, raise_error=True, **kwargs):
""" Fetch the given url and fire the callback when ready. Optionally
pass a `streaming_callback` to handle data from large requests.
Parameters
----------
url: string
The url to access.... | Fetch the given url and fire the callback when ready. Optionally
pass a `streaming_callback` to handle data from large requests.
Parameters
----------
url: string
The url to access.
callback: callable
The callback to invoke when th... | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = GridLayout(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = Switch(self.get_context(), None,
d.style or '@attr/switchStyle') | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidSwitch, self).init_widget()
d = self.declaration
self.set_show_text(d.show_text)
if d.split_track:
self.set_split_track(d.split_track)
if d.text_off:
self.set_te... | Initialize the underlying widget. | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.