output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidPagerFragment, self).init_widget()
d = self.declaration
if d.title:
self.set_title(d.title)
if d.icon:
self.set_icon(d.icon) | How would you code a function in Python 3 to
initialize the underlying widget. | You are a Python code architect, reviewing and designing scalable and efficient code |
Decorator for asynchronous generators. | Explain what the following Python 3 code does
def engine(func):
func = _make_coroutine_wrapper(func, replace_callback=False)
@functools.wraps(func)
def wrapper(*args, **kwargs):
future = func(*args, **kwargs)
def final_callback(future):
if future.result() is not None:
... | You are a Python code generator, capable of creating scripts from specifications. |
A function decorator that wraps a coroutine function. | Can you generate the documentation for the following Python 3 function
def _make_coroutine_wrapper(func, replace_callback):
# On Python 3.5, set the coroutine flag on our generator, to allow it
# to be used with 'await'.
wrapped = func
if hasattr(types, 'coroutine'):
func = types.coroutine(func)... | As a Python code analyst, you investigate and solve complex coding mysteries |
Adapts a callback - based asynchronous function for use in coroutines. | Can you tell what is the following Python 3 function doing
def Task(func, *args, **kwargs):
future = Future()
def handle_exception(typ, value, tb):
if future.done():
return False
future.set_exc_info((typ, value, tb))
return True
def set_result(result):
if future... | You are a Python code architect, reviewing and designing scalable and efficient code |
Returns True if children contains any YieldPoints. | How would you explain what the following Python 3 function does
def _contains_yieldpoint(children):
if isinstance(children, dict):
return any(isinstance(i, YieldPoint) for i in children.values())
if isinstance(children, list):
return any(isinstance(i, YieldPoint) for i in children)
return Fa... | You are a Python code generator, capable of creating scripts from specifications. |
def multi(children, quiet_exceptions=()):
"""Runs multiple asynchronous operations in parallel.
``children`` may either be a list or a dict whose values are
yieldable objects. ``multi()`` returns a new yieldable
object that resolves to a parallel structure containing their
results. If ``children`` ... | How would you implement a function in Python 3 that
runs multiple asynchronous operations in parallel. | You are a Python code generator, capable of creating scripts from specifications. |
Wait for multiple asynchronous futures in parallel. | Can you tell what is the following Python 3 function doing
def multi_future(children, quiet_exceptions=()):
if isinstance(children, dict):
keys = list(children.keys())
children = children.values()
else:
keys = None
children = list(map(convert_yielded, children))
assert all(is_fut... | You are a Python code generator, capable of creating scripts from specifications. |
def maybe_future(x):
"""Converts ``x`` into a `.Future`.
If ``x`` is already a `.Future`, it is simply returned; otherwise
it is wrapped in a new `.Future`. This is suitable for use as
``result = yield gen.maybe_future(f())`` when you don't know whether
``f()`` returns a `.Future` or not.
.. ... | Create a Python 3 function for
converting x into a Future. | As a Python code analyst, you investigate and solve complex coding mysteries |
Wraps a tornado. util. Future in a timeout. | Can you tell what is the following Python 3 function doing
def with_timeout(timeout, future, quiet_exceptions=()):
# TODO: allow YieldPoints in addition to other yieldables?
# Tricky to do with stack_context semantics.
#
# It's tempting to optimize this by cancelling the input future on timeout
# in... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Return a new Future that resolves after the given number of seconds. | Here you have a function in Python 3, explain what it does
def sleep(duration):
f = Future()
IOLoop.current().call_later(duration, lambda: f.set_result(None))
return f | As a Python code analyst, you investigate and solve complex coding mysteries |
Returns a function that when invoked runs callback with one argument. | How would you explain what the following Python 3 function does
def _argument_adapter(callback):
def wrapper(*args, **kwargs):
if kwargs or len(args) > 1:
callback(Arguments(args, kwargs))
elif args:
callback(args[0])
else:
callback(None)
return wrappe... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def convert_yielded(yielded):
"""Convert a yielded object into a `.Future`.
The default implementation accepts lists, dictionaries, and Futures.
If the `~functools.singledispatch` library is available, this function
may be extended to support additional types. For example::
@convert_yielded.r... | Write a Python 3 script to
convert a yielded object into a tornado. Future. | You are a Python code analyst, evaluating scripts for potential improvements. |
Returns True if this iterator has no more results. | Given the following Python 3 function, write the documentation
def done(self):
if self._finished or self._unfinished:
return False
# Clear the 'current' values when iteration is done.
self.current_index = self.current_future = None
return True | As a python code expert, you are capable of creating scripts from specifications. |
def next(self):
"""Returns a `.Future` that will yield the next available result.
Note that this `.Future` will not be the same object as any of
the inputs.
"""
self._running_future = TracebackFuture()
if self._finished:
self._return_result(self._finished.po... | Can you create a Python 3 function that
returns a. Future that will yield the next available result. | As a python code expert, you are capable of creating scripts from specifications. |
Called when the result of the iteration is done. | Given the following Python 3 function, write the documentation
def _return_result(self, done):
chain_future(done, self._running_future)
self.current_future = done
self.current_index = self._unfinished.pop(done) | You are a Python code architect, reviewing and designing scalable and efficient code |
def register_callback(self, key):
"""Adds ``key`` to the list of callbacks."""
if self.pending_callbacks is None:
# Lazily initialize the old-style YieldPoint data structures.
self.pending_callbacks = set()
self.results = {}
if key in self.pending_callbacks:
... | Implement a function in Python 3 to
add a callback to the list of pending callbacks. | You are a Python code analyst, evaluating scripts for potential improvements. |
Returns true if a result is available for key. | Can you tell what is the following Python 3 function doing
def is_ready(self, key):
if self.pending_callbacks is None or key not in self.pending_callbacks:
raise UnknownKeyError("key %r is not pending" % (key,))
return key in self.results | As a python code expert, you are capable of creating scripts from specifications. |
Sets the result for key and attempts to resume the generator. | Given the following Python 3 function, write the documentation
def set_result(self, key, result):
self.results[key] = result
if self.yield_point is not None and self.yield_point.is_ready():
try:
self.future.set_result(self.yield_point.get_result())
except:
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def pop_result(self, key):
"""Returns the result for ``key`` and unregisters it."""
self.pending_callbacks.remove(key)
return self.results.pop(key) | Write a Python 3 script to
return the result for the given key. Unregisters the callback for the given key. | You are a Python code analyst, evaluating scripts for potential improvements. |
Starts or resumes the generator until it reaches a heartbeat point. | Make a summary of the following Python 3 code
def run(self):
if self.running or self.finished:
return
try:
self.running = True
while True:
future = self.future
if not future.done():
return
self.future... | You are a Python code architect, reviewing and designing scalable and efficient code |
Create the underlying widget. | Given the following Python 3 function, write the documentation
def create_widget(self):
d = self.declaration
self.widget = RadioButton(self.get_context(), None,
d.style or '@attr/radioButtonStyle') | You are a Python code generator, capable of creating scripts from specifications. |
def write_message(self, data, binary=False):
""" Write a message to the client """
self.connection.write_message(data, binary) | Write a Python 3 script to
write a message to the client | As a python code expert, you are capable of creating scripts from specifications. |
Render the file path as accordions
| Given the following Python 3 function, write the documentation
def render_files(self, root=None):
if root is None:
tmp = os.environ.get('TMP')
root = sys.path[1 if tmp and tmp in sys.path else 0]
items = []
for filename in os.listdir(root):
# for subdirname i... | As a Python code analyst, you investigate and solve complex coding mysteries |
Try to load the previous code if we had a crash or something else return the default code | Here you have a function in Python 3, explain what it does
def render_code(self):
tmp_dir = os.environ.get('TMP','')
view_code = os.path.join(tmp_dir,'view.enaml')
if os.path.exists(view_code):
try:
with open(view_code) as f:
return f.read()
... | You are a Python code generator, capable of creating scripts from specifications. |
Render a row of all the attributes of the component. | Can you generate a brief explanation for the following Python 3 code
def render_component(self, declaration):
items = ["""<tr><td>{name}</td><td>{type}</td></tr>"""
.format(name=m.name,
type=self.render_component_types(declaration, m))
for m in self.get... | As a python code expert, you are capable of creating scripts from specifications. |
def start(self):
""" Start the dev session. Attempt to use tornado first, then try
twisted
"""
print("Starting debug client cwd: {}".format(os.getcwd()))
print("Sys path: {}".format(sys.path))
#: Initialize the hotswapper
self.hotswap = Hotswapper(debug... | Implement a function in Python 3 to
start the dev session. | You are a Python code analyst, evaluating scripts for potential improvements. |
Default websocket URL to connect to and listen for reload requests | Here you have a function in Python 3, explain what it does
def _default_url(self):
host = 'localhost' if self.mode == 'remote' else self.host
return 'ws://{}:{}/dev'.format(host, self.port) | As a Python code composer, you craft elegant and concise scripts. |
Write a message to the active client | Explain what the following Python 3 code does
def write_message(self, data, binary=False):
self.client.write_message(data, binary=binary) | As a Python code composer, you craft elegant and concise scripts. |
def do_reload(self, msg):
""" Called when the dev server wants to reload the view. """
#: TODO: This should use the autorelaoder
app = self.app
#: Show loading screen
try:
self.app.widget.showLoading("Reloading... Please wait.", now=True)
#self.app.widget... | Can you create a Python 3 function that
calls when the dev server wants to reload the view. | As a Python code analyst, you investigate and solve complex coding mysteries |
Attempt to hotswap the code | Can you tell what is the following Python 3 function doing
def do_hotswap(self, msg):
#: Show hotswap tooltip
try:
self.app.widget.showTooltip("Hot swapping...", now=True)
except:
pass
self.save_changed_files(msg)
hotswap = self.hotswap
app = self... | You are a Python code generator, capable of creating scripts from specifications. |
def _update_proxy(self, change):
""" An observer which sends the state change to the proxy.
"""
if change['type'] == 'event':
name = 'do_'+change['name']
if hasattr(self.proxy, name):
handler = getattr(self.proxy, name)
handler()
e... | Create a Python 3 function to
update the proxy state. | You are a Python code analyst, evaluating scripts for potential improvements. |
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
style = d.style or '@style/Widget.DeviceDefault.PopupMenu'
s... | Implement a Python 3 function for
creating the underlying widget. | As a Python code composer, you craft elegant and concise scripts. |
Initialize the popup widget. | Explain what the following Python 3 code does
def init_widget(self):
w = self.window
d = self.declaration
self.set_background_color(d.background_color)
self.set_touchable(d.touchable)
self.set_outside_touchable(d.outside_touchable)
# Listen for events
w.setOnDism... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def init_layout(self):
""" If a view is given show it
"""
super(AndroidPopupWindow, self).init_layout()
#: Set the content
for view in self.child_widgets():
self.window.setContentView(view)
break
#: Show it if needed
d = self.de... | Can you write a function in Python 3 where it
initializes the layout of the popup window. | As a python code expert, you are capable of creating scripts from specifications. |
def child_added(self, child):
""" Overwrite the content view """
view = child.widget
if view is not None:
self.window.setContentView(view) | Write a Python 3 function that can
overwrite the content view of the child. | As a python code expert, you are capable of creating scripts from specifications. |
A reimplemented destructor that cancels
the dialog before destroying. | Can you generate the documentation for the following Python 3 function
def destroy(self):
super(AndroidPopupWindow, self).destroy()
window = self.window
if window:
#: Clear the dismiss listener
#: (or we get an error during the callback)
window.setOnDismissLis... | You are a Python code generator, capable of creating scripts from specifications. |
def update(self):
""" Update the PopupWindow if it is currently showing. This avoids
calling update during initialization.
"""
if not self.showing:
return
d = self.declaration
self.set_show(d.show) | Implement a Python 3 function for
updating the PopupWindow if it is currently showing. | As a Python code analyst, you investigate and solve complex coding mysteries |
Refresh the items of the pattern. | Can you generate the documentation for the following Python 3 function
def refresh_items(self):
items = []
if self.condition:
for nodes, key, f_locals in self.pattern_nodes:
with new_scope(key, f_locals):
for node in nodes:
child = ... | As a Python code composer, you craft elegant and concise scripts. |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidSwipeRefreshLayout, self).init_widget()
d = self.declaration
w = self.widget
if not d.enabled:
self.set_enabled(d.enabled)
if d.indicator_background_color:
self.... | Can you implement a function in Python 3 that
initializes the underlying widget. | As a python code expert, you are capable of creating scripts from specifications. |
def load_module(self, mod):
""" Load the extension using the load_dynamic method. """
try:
return sys.modules[mod]
except KeyError:
pass
lib = ExtensionImporter.extension_modules[mod]
m = imp.load_dynamic(mod, lib)
sys.modules[mod] = m
ret... | Can you create a Python 3 function that
loads the extension module using the load_dynamic method. | You are a Python code architect, reviewing and designing scalable and efficient code |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = TabLayout(self.get_context(), None, d.style) | Create a Python 3 function for
creating the underlying widget. | You are a Python code architect, reviewing and designing scalable and efficient code |
Initialize the underlying widget. | Can you generate the documentation for the following Python 3 function
def init_widget(self):
super(AndroidTabLayout, self).init_widget()
w = self.widget
w.addOnTabSelectedListener(w.getId())
w.onTabSelected.connect(self.on_tab_selected)
w.onTabUnselected.connect(self.on_tab_unse... | You are a Python code analyst, evaluating scripts for potential improvements. |
Destroy all tabs when destroyed
| Given the following Python 3 function, write the documentation
def destroy(self):
super(AndroidTabLayout, self).destroy()
if self.tabs:
del self.tabs | As a Python code composer, you craft elegant and concise scripts. |
Update an atom member with a new one. | How would you explain what the following Python 3 function does
def update_atom_members(old, new):
old_keys = old.members().keys()
new_keys = new.members().keys()
for key in old_keys:
old_obj = getattr(old, key)
try:
new_obj = getattr(new, key)
if old_obj == new_obj:
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def update_class_by_type(old, new):
""" Update declarative classes or fallback on default """
autoreload.update_class(old, new)
if isinstance2(old, new, AtomMeta):
update_atom_members(old, new) | Write a Python 3 script to
update declarative classes or fallback on default | You are a Python code generator, capable of creating scripts from specifications. |
Check whether all modules need to be reloaded. | Given the following Python 3 function, write the documentation
def check(self, check_all=True, do_reload=True):
with enaml.imports():
super(EnamlReloader, self).check(check_all=check_all, do_reload=do_reload) | As a python code expert, you are capable of creating scripts from specifications. |
def update(self, old, new=None):
""" Update given view declaration with new declaration
Parameters
-----------
old: Declarative
The existing view instance that needs to be updated
new: Declarative or None
The new or reloaded view instance to that will be ... | How would you implement a function in Python 3 that
updates the view instance with the given declaration and new declaration. | As a python code expert, you are capable of creating scripts from specifications. |
def find_best_matching_node(self, new, old_nodes):
""" Find the node that best matches the new node given the old nodes. If no
good match exists return `None`.
"""
name = new.__class__.__name__
#: TODO: We should pick the BEST one from this list
#: based on some "mat... | Create a Python 3 function for
finding the node that best matches the new node given the old nodes. | You are a Python code analyst, evaluating scripts for potential improvements. |
def update_attrs(self, old, new):
""" Update any `attr` members.
Parameters
-----------
old: Declarative
The existing view instance that needs to be updated
new: Declarative
The new view instance that should be used for updating
... | Implement a function in Python 3 to
update any attr members. | As a python code expert, you are capable of creating scripts from specifications. |
def update_bindings(self, old, new):
""" Update any enaml operator bindings.
Parameters
-----------
old: Declarative
The existing view instance that needs to be updated
new: Declarative
The new view instance that should be used for... | Implement a Python 3 function for
updating any enaml operator bindings. | As a python code expert, you are capable of creating scripts from specifications. |
Initialize the state of the toolkit widget. | Can you generate the documentation for the following Python 3 function
def init_widget(self):
super(UiKitProgressView, self).init_widget()
d = self.declaration
if d.progress:
self.set_progress(d.progress) | As a Python code composer, you craft elegant and concise scripts. |
Create the underlying label widget. | Can you generate the documentation for the following Python 3 function
def create_widget(self):
d = self.declaration
self.widget = View(self.get_context(), None, d.style) | As a Python code analyst, you investigate and solve complex coding mysteries |
def init_widget(self):
""" Initialize the underlying widget.
This reads all items declared in the enamldef block for this node
and sets only the values that have been specified. All other values
will be left as default. Doing it this way makes atom to only create
the ... | Write a Python 3 function for
initializing the underlying widget. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_declared_items(self):
""" Get the members that were set in the enamldef block for this
Declaration. Layout keys are grouped together until the end so as
to avoid triggering multiple updates.
Returns
-------
result: List of (k,v) pairs that were defined fo... | Can you create a Python 3 function that
gets the members that were set for this widget in the enamldef block for this Declaration. | As a python code expert, you are capable of creating scripts from specifications. |
Trigger the key event | Can you generate a brief explanation for the following Python 3 code
def on_key(self, view, key, event):
d = self.declaration
r = {'key': key, 'result': False}
d.key_event(r)
return r['result'] | As a python code expert, you are capable of creating scripts from specifications. |
Trigger the touch event | How would you explain what the following Python 3 function does
def on_touch(self, view, event):
d = self.declaration
r = {'event': event, 'result': False}
d.touch_event(r)
return r['result'] | You are a Python code architect, reviewing and designing scalable and efficient code |
def set_visible(self, visible):
""" Set the visibility of the widget.
"""
v = View.VISIBILITY_VISIBLE if visible else View.VISIBILITY_GONE
self.widget.setVisibility(v) | Implement a function in Python 3 to
set the visibility of the widget. | As a Python code composer, you craft elegant and concise scripts. |
def set_layout(self, layout):
""" Sets the LayoutParams of this widget.
Since the available properties that may be set for the layout params
depends on the parent, actual creation of the params is delegated to
the parent
Parameters
----------
... | Write a Python 3 function for
setting the layout parameters of this node and the parent node. | You are a Python code generator, capable of creating scripts from specifications. |
def create_layout_params(self, child, layout):
""" Create the LayoutParams for a child with it's requested
layout parameters. Subclasses should override this as needed
to handle layout specific needs.
Parameters
----------
child: AndroidView
A view to... | How would you code a function in Python 3 to
create the LayoutParams object for a child with the requested layout parameters. Subclasses should override this as needed to handle layout specific needs. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Applies a layout to a child. | Can you generate a brief explanation for the following Python 3 code
def apply_layout(self, child, layout):
layout_params = child.layout_params
if not layout_params:
layout_params = self.create_layout_params(child, layout)
w = child.widget
if w:
dp = self.dp
... | As a python code expert, you are capable of creating scripts from specifications. |
Returns the default event loop implementation. | Here you have a function in Python 3, explain what it does
def default(cls):
with enamlnative.imports():
for impl in [
TornadoEventLoop,
TwistedEventLoop,
BuiltinEventLoop,
]:
if impl.available():
print("... | As a python code expert, you are capable of creating scripts from specifications. |
def log_error(self, callback, error=None):
""" Log the error that occurred when running the given callback. """
print("Uncaught error during callback: {}".format(callback))
print("Error: {}".format(error)) | Can you write a function in Python 3 where it
logs the error that occurred when running the given callback. | You are a Python code architect, reviewing and designing scalable and efficient code |
Call the callback with args and kwargs and return the result. | Can you tell what is the following Python 3 function doing
def deferred_call(self, callback, *args, **kwargs):
loop = self.loop
r = loop.callLater(0, callback, *args, **kwargs)
loop.wakeUp()
return r | You are a Python code generator, capable of creating scripts from specifications. |
Call the callback function every ms seconds. | Explain what the following Python 3 code does
def timed_call(self, ms, callback, *args, **kwargs):
loop = self.loop
r = loop.callLater(ms/1000.0, callback, *args, **kwargs)
loop.wakeUp()
return r | As a python code expert, you are capable of creating scripts from specifications. |
Initialize the underlying widget. | Can you generate a brief explanation for the following Python 3 code
def init_widget(self):
super(UiKitView, self).init_widget()
self.widget.yoga.isEnabled = True
# Initialize the widget by updating only the members that
# have read expressions declared. This saves a lot of time and
... | As a python code expert, you are capable of creating scripts from specifications. |
Initialize the layout of the toolkit widget. | Make a summary of the following Python 3 code
def init_layout(self):
widget = self.widget
for child_widget in self.child_widgets():
widget.addSubview(child_widget) | As a python code expert, you are capable of creating scripts from specifications. |
def update_frame(self):
""" Define the view frame for this widgets"""
d = self.declaration
if d.x or d.y or d.width or d.height:
self.frame = (d.x, d.y, d.width, d.height) | Can you create a Python 3 function that
updates the frame for this widgets | You are a Python code analyst, evaluating scripts for potential improvements. |
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)
widget = self.widg... | Write a Python 3 function that can
handle the child added event from the declaration. | You are a Python code analyst, evaluating scripts for potential improvements. |
Handle the child moved event from the declaration. | Can you generate a brief explanation for the following Python 3 code
def child_moved(self, child):
super(UiKitView, self).child_moved(child)
#: Remove and re-add in correct spot
#: TODO: Should use exchangeSubviewAtIndex
self.child_removed(child)
self.child_added(child) | As a Python code analyst, you investigate and solve complex coding mysteries |
Handle the child removed event from the declaration. | Given the following Python 3 function, write the documentation
def child_removed(self, child):
super(UiKitView, self).child_removed(child)
if child.widget is not None:
child.widget.removeFromSuperview() | As a Python code composer, you craft elegant and concise scripts. |
Initialize the layout of the view | Here you have a function in Python 3, explain what it does
def init_layout(self):
super(AndroidSurfaceView, self).init_layout()
# Force layout using the default params
if not self.layout_params:
self.set_layout({}) | As a python code expert, you are capable of creating scripts from specifications. |
Main function for the base application. | Here you have a function in Python 3, explain what it does
def main():
#: If we set the TMP env variable the dev reloader will save file
#: and load changes in this directory instead of overwriting the
#: ones installed with the app.
os.environ['TMP'] = os.path.join(sys.path[0], '../tmp')
from ena... | You are a Python code generator, capable of creating scripts from specifications. |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidViewAnimator, self).init_widget()
d = self.declaration
if d.animate_first_view:
self.set_animate_first_view(d.animate_first_view)
if d.displayed_child:
self.set_displaye... | Create a Python 3 function for
initializing the underlying widget. | You are a Python code analyst, evaluating scripts for potential improvements. |
def create_widget(self):
""" Create the underlying widget.
"""
self.widget = ViewPager(self.get_context())
self.adapter = BridgedFragmentStatePagerAdapter() | Write a Python 3 function for
creating the underlying widget. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Called by the child class when a new child is added to the pager. | Given the following Python 3 function, write the documentation
def child_added(self, child):
super(AndroidViewPager, self).child_added(child)
self._notify_count += 1
self.get_context().timed_call(
self._notify_delay, self._notify_change) | You are a Python code architect, reviewing and designing scalable and efficient code |
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(... | Write a Python 3 script to
notify Java that a change has happened | As a Python code translator, you convert algorithms and pseudocode into Python. |
Set the current index of the page. | Explain what the following Python 3 code does
def set_current_index(self, index):
# d = self.declaration
# #: We have to wait for the current_index to be ready before we can
# #: change pages
if self._notify_count > 0:
self._pending_calls.append(
lambda index=... | You are a Python code architect, reviewing and designing scalable and efficient code |
def create_layout_params(self, child, layout):
""" Override as there is no (width, height) constructor.
"""
from .android_fragment import AndroidFragment
if isinstance(child, AndroidFragment):
return super(AndroidViewPager, self).create_layout_params(child,
... | Can you implement a function in Python 3 that
overrides as there is no width height constructor. | You are a Python code analyst, evaluating scripts for potential improvements. |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = CardView(self.get_context(), None, d.style) | Create a Python 3 function for
creating the underlying widget. | As a Python code composer, you craft elegant and concise scripts. |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = TextClock(self.get_context(), None, d.style) | Write a Python 3 script to
create the underlying widget. | You are a Python code generator, capable of creating scripts from specifications. |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidTextClock, self).init_widget()
d = self.declaration
if d.format_12_hour:
self.set_format_12_hour(d.format_12_hour)
if d.format_24_hour:
self.set_format_24_hour(d.format_... | Write a Python 3 function for
initializing the underlying widget. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Create the underlying widget. | How would you explain what the following Python 3 function does
def create_widget(self):
d = self.declaration
if self.indeterminate:
#: Note: Style will only exist on activity indicators!
style = ProgressBar.STYLES[d.size]
else:
style = ProgressBar.STYLE_HORI... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Initialize the underlying widget. | Can you tell what is the following Python 3 function doing
def init_widget(self):
super(AndroidProgressBar, self).init_widget()
d = self.declaration
self.set_indeterminate(self.indeterminate)
if not self.indeterminate:
if d.max:
self.set_max(d.max)
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = Flexbox(self.get_context(), None, d.style) | How would you implement a function in Python 3 that
creates the underlying widget. | As a Python code translator, you convert algorithms and pseudocode into 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 ... | Write a Python 3 function that can
apply the flexbox specific layout. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Toggle the keyboard on and off | Make a summary of the following Python 3 code
def toggle_keyboard(cls, flag=HIDE_IMPLICIT_ONLY):
app = AndroidApplication.instance()
f = app.create_future()
def on_ready(ims):
ims.toggleSoftInput(flag, 0)
f.set_result(True)
cls.get().then(on_ready)
retur... | As a python code expert, you are capable of creating scripts from specifications. |
Hide keyboard if it s open
Returns -------- result : Future that resolves when the hide is complete
| Explain what the following Python 3 code does
def hide_keyboard(cls):
app = AndroidApplication.instance()
f = app.create_future()
def on_ready(ims):
view = app.view.proxy.widget
def on_token(__id__):
ims.hideSoftInputFromWindow(
JavaB... | You are a Python code generator, capable of creating scripts from specifications. |
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
... | Can you write a function in Python 3 where it
acquires the NotificationManager service async. | As a python code expert, you are capable of creating scripts from specifications. |
def create_channel(cls, channel_id, name, importance=IMPORTANCE_DEFAULT,
description=""):
""" Before you can deliver the notification on Android 8.0 and higher,
you must register your app's notification channel with the system by
passing an instance of NotificationChanne... | How would you implement a function in Python 3 that
creates a new NotificationChannel. | You are a Python code analyst, evaluating scripts for potential improvements. |
Create and show a Notification. | How would you explain what the following Python 3 function does
def show_notification(cls, channel_id, *args, **kwargs):
app = AndroidApplication.instance()
builder = Notification.Builder(app, channel_id)
builder.update(*args, **kwargs)
return builder.show() | You are a Python code architect, reviewing and designing scalable and efficient code |
def cancel_notification(cls, notification_or_id, tag=None):
""" Cancel the notification.
Parameters
----------
notification_or_id: Notification.Builder or int
The notification or id of a notification to clear
tag: String
The tag of the notificati... | Implement a function in Python 3 to
cancel the specified notification. | As a Python code analyst, you investigate and solve complex coding mysteries |
Create the notification in the top down pass if show = True | Can you generate a brief explanation for the following Python 3 code
def init_layout(self):
d = self.declaration
self.create_notification()
if d.show:
self.set_show(d.show) | As a Python code analyst, you investigate and solve complex coding mysteries |
Create a new Notification. | Here you have a function in Python 3, explain what it does
def create_notification(self):
d = self.declaration
builder = self.builder = Notification.Builder(self.get_context(),
d.channel_id)
d = self.declaration
# Apply any custom se... | As a Python code composer, you craft elegant and concise scripts. |
Create the toolkit widget for the proxy object. | Given the following Python 3 function, write the documentation
def create_widget(self):
d = self.declaration
button_type = UIButton.UIButtonTypeSystem if d.flat else UIButton.UIButtonTypeRoundedRect
self.widget = UIButton(buttonWithType=button_type) | You are a Python code generator, capable of creating scripts from specifications. |
This method is called by the block manager when the content of the block is changed. | Can you tell what is the following Python 3 function doing
def initialize(self):
super(Block, self).initialize()
block = self.block
if block: #: This block is setting the content of another block
#: Remove the existing blocks children
if self.mode == 'replace':
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Initialize text properties for this widget | How would you explain what the following Python 3 function does
def init_text(self):
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)... | As a python code expert, you are capable of creating scripts from specifications. |
Add all child widgets to the view and force layout using the default params | Explain what the following Python 3 code does
def init_layout(self):
super(AndroidViewGroup, self).init_layout()
widget = self.widget
i = 0
for child in self.children():
child_widget = child.widget
if child_widget:
if child.layout_params:
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Handle the child added event from the declaration. | Here you have a function in Python 3, explain what it does
def child_added(self, child):
super(AndroidViewGroup, self).child_added(child)
widget = self.widget
#: TODO: Should index be cached?
for i, child_widget in enumerate(self.child_widgets()):
if child_widget == child.wi... | As a Python code composer, you craft elegant and concise scripts. |
Handle the child moved event from the view group. | Explain what the following Python 3 code does
def child_moved(self, child):
super(AndroidViewGroup, self).child_moved(child)
#: Remove and re-add in correct spot
self.child_removed(child)
self.child_added(child) | You are a Python code generator, capable of creating scripts from specifications. |
def child_removed(self, child):
""" Handle the child removed event from the declaration.
This handler will unparent the child toolkit widget. Subclasses
which need more control should reimplement this method.
"""
super(AndroidViewGroup, self).child_removed(child)
if chi... | Implement a function in Python 3 to
handle the child removed event from the declaration. | As a Python code analyst, you investigate and solve complex coding mysteries |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.