output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
def category(self, value): """ Setter for **self.__category** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "cat...
Write a Python 3 script for setting the category of the object.
You are a Python code generator, capable of creating scripts from specifications.
def title(self, value): """ Setter for **self.__title** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "title", v...
Can you create a Python 3 function that sets the title of the object.
As a Python code translator, you convert algorithms and pseudocode into Python.
def package(self, value): """ Setter for **self.__package** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "packa...
Create a Python 3 function for setting the package of the resource.
You are a Python code generator, capable of creating scripts from specifications.
Sets the version of the object.
Here you have a function in Python 3, explain what it does def version(self, value): if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "version", value) self.__version = value
You are a Python code generator, capable of creating scripts from specifications.
def author(self, value): """ Setter for **self.__author** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "author"...
Write a Python 3 function for setting the author of the object.
You are a Python code analyst, evaluating scripts for potential improvements.
def email(self, value): """ Setter for **self.__email** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "email", v...
Implement a function in Python 3 to set the email of the log entry.
As a python code expert, you are capable of creating scripts from specifications.
Sets the url of the resource.
Here you have a function in Python 3, explain what it does def url(self, value): if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "url", value) self.__url = value
You are a Python code analyst, evaluating scripts for potential improvements.
Setter for **self. __description** attribute.
How would you explain what the following Python 3 function does def description(self, value): if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "description", value) self.__description = value
As a Python code translator, you convert algorithms and pseudocode into Python.
Initializes the Component Profile.
Here you have a function in Python 3, explain what it does def initializeProfile(self): LOGGER.debug("> Building '{0}' profile.".format(self.__file)) sections_file_parser = SectionsFileParser(self.__file) sections_file_parser.parse() if sections_file_parser.sections: fileS...
As a Python code translator, you convert algorithms and pseudocode into Python.
Setter for **self. paths ** attribute.
Can you generate the documentation for the following Python 3 function def paths(self, value): if value is not None: assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format( "paths", value) for path in value: as...
You are a Python code analyst, evaluating scripts for potential improvements.
Setter for the extension attribute.
Can you tell what is the following Python 3 function doing def extension(self, value): if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "extension", value) self.__extension = value
As a Python code translator, you convert algorithms and pseudocode into Python.
Set the categories of the orphan in the database.
Explain what the following Python 3 code does def categories(self, value): if value is not None: assert type(value) is dict, "'{0}' attribute: '{1}' type is not 'dict'!".format("categories", value) for key in value: assert type(key) is unicode, "'{0}' attribute: '{1}' ty...
As a python code expert, you are capable of creating scripts from specifications.
Registers a Component using given path.
Here you have a function in Python 3, explain what it does def register_component(self, path): component = foundations.strings.get_splitext_basename(path) LOGGER.debug("> Current Component: '{0}'.".format(component)) profile = Profile(file=path) if profile.initializeProfile(): ...
As a Python code analyst, you investigate and solve complex coding mysteries
def register_components(self): """ Registers the Components. Usage:: >>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",)) >>> manager.register_components() True >>> manager.components.keys() [u'core.test...
Can you implement a function in Python 3 that registers the Components. Usage:: >>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",)) >>> manager.register_components() True >>> manager.components.keys() [u'core.tests_component_a', u'core.tests_component_b'] :return: Method success. :rtype:...
As a Python code analyst, you investigate and solve complex coding mysteries
def reload_component(self, component): """ Reload given Component module. Usage:: >>> manager = Manager() >>> manager.register_component("tests_component_a.rc") True >>> manager.instantiate_component("core.tests_component_a") True ...
Write a Python 3 function that can reload given Component module.
You are a Python code architect, reviewing and designing scalable and efficient code
def list_components(self, dependency_order=True): """ Lists the Components by dependency resolving. Usage:: >>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",)) >>> manager.register_components() True >>> manager.lis...
Write a Python 3 function that can list the Components by dependency resolving.
As a Python code composer, you craft elegant and concise scripts.
Lists given Component dependents Components.
Here you have a function in Python 3, explain what it does def list_dependents(self, component, dependents=None): dependents = set() if dependents is None else dependents for name, profile in self: if not component in profile.require: continue dependents.add(nam...
As a Python code analyst, you investigate and solve complex coding mysteries
def filter_components(self, pattern, category=None): """ Filters the Components using given regex pattern. Usage:: >>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",)) >>> manager.register_components() True >>> mana...
How would you code a function in Python 3 to filter the Components using given regex pattern.
As a python code expert, you are capable of creating scripts from specifications.
Gets given Component profile.
Given the following Python 3 function, write the documentation def get_profile(self, component): components = self.filter_components(r"^{0}$".format(component)) if components != []: return self.__components[foundations.common.get_first_item(components)]
As a Python code translator, you convert algorithms and pseudocode into Python.
Gets given Component interface.
Can you generate a brief explanation for the following Python 3 code def get_interface(self, component): profile = self.get_profile(component) if profile: return profile.interface
As a Python code composer, you craft elegant and concise scripts.
def get_component_attribute_name(component): """ Gets given Component attribute name. Usage:: >>> Manager.get_component_attribute_name("factory.components_manager_ui") u'factoryComponentsManagerUi' :param component: Component to get the attribute name. ...
How would you code a function in Python 3 to get given Component attribute name.
As a Python code composer, you craft elegant and concise scripts.
def output_to_table(obj, olist='inputs', oformat='latex', table_ends=False, prefix=""): """ Compile the properties to a table. :param olist: list, Names of the parameters to be in the output table :param oformat: str, The type of table to be output :param table_ends: bool, Add ends to the table ...
How would you implement a function in Python 3 that compiles the properties of the object to a table.
You are a Python code architect, reviewing and designing scalable and efficient code
convert a parameter value into a formatted string with certain significant figures
Given the following Python 3 function, write the documentation def format_value(value, sf=3): if isinstance(value, str): return value elif isinstance(value, list) or isinstance(value, np.ndarray): value = list(value) for i in range(len(value)): vv = format_value(value[i]) ...
As a Python code composer, you craft elegant and concise scripts.
def add_table_ends(para, oformat='latex', caption="caption-text", label="table"): """ Adds the latex table ends :param para: :param oformat: :param caption: :param label: :return: """ fpara = "" if oformat == 'latex': fpara += "\\begin{table}[H]\n" fpara += "\\ce...
Write a Python 3 function for adding the latex table ends to the end of the latex table.
You are a Python code architect, reviewing and designing scalable and efficient code
Draw shapes as a layer in a SVG file.
Make a summary of the following Python 3 code def draw_shapes_svg_layer(df_shapes, shape_i_columns, layer_name, layer_number=1, use_svg_path=True): ''' Draw shapes as a layer in a SVG file. Args: df_shapes (pandas.DataFrame): Table of shape vertices (one row per ...
As a Python code analyst, you investigate and solve complex coding mysteries
Draw lines defined by endpoint coordinates as a layer in a SVG file.
Here you have a function in Python 3, explain what it does def draw_lines_svg_layer(df_endpoints, layer_name, layer_number=1): ''' Draw lines defined by endpoint coordinates as a layer in a SVG file. Args: df_endpoints (pandas.DataFrame) : Each row corresponds to the endpoints of a sin...
As a Python code composer, you craft elegant and concise scripts.
def dts_error(self, error_name, message=None): """ Create a DTS Error reply :param error_name: Name of the error :param message: Message of the Error :return: DTS Error Response with information (JSON) """ self.nautilus_extension.logger.info("DTS error thrown {} for {} (...
Write a Python 3 function that can create a DTS Error Response with information about the error
You are a Python code analyst, evaluating scripts for potential improvements.
def r_dts_collection(self, objectId=None): """ DTS Collection Metadata reply for given objectId :param objectId: Collection Identifier :return: JSON Format of DTS Collection """ try: j = self.resolver.getMetadata(objectId=objectId).export(Mimetypes.JSON.DTS.Std) ...
Write a Python 3 function for returning DTS Collection Metadata reply for given objectId
You are a Python code analyst, evaluating scripts for potential improvements.
Create a new run in the database and return it and the session opened.
Can you generate the documentation for the following Python 3 function def create_run(cmd, project, exp, grp): from benchbuild.utils import schema as s session = s.Session() run = s.Run( command=str(cmd), project_name=project.name, project_group=project.group, experiment_nam...
You are a Python code analyst, evaluating scripts for potential improvements.
def create_run_group(prj): """ Create a new 'run_group' in the database. This creates a new transaction in the database and creates a new run_group within this transaction. Afterwards we return both the transaction as well as the run_group itself. The user is responsible for committing it when the ...
Implement a Python 3 function for creating a new run_group in the database and return both the newly created run_group and the session object.
As a Python code composer, you craft elegant and concise scripts.
def persist_project(project): """ Persist this project in the benchbuild database. Args: project: The project we want to persist. """ from benchbuild.utils.schema import Project, Session session = Session() projects = session.query(Project) \ .filter(Project.name == project....
Write a Python 3 function for persisting this project in the benchbuild database.
As a python code expert, you are capable of creating scripts from specifications.
def persist_experiment(experiment): """ Persist this experiment in the benchbuild database. Args: experiment: The experiment we want to persist. """ from benchbuild.utils.schema import Experiment, Session session = Session() cfg_exp = experiment.id LOG.debug("Using experiment ...
Write a Python 3 script to persist this experiment in the benchbuild database.
As a Python code composer, you craft elegant and concise scripts.
def persist_time(run, session, timings): """ Persist the run results in the database. Args: run: The run we attach this timing results to. session: The db transaction we belong to. timings: The timing measurements we want to store. """ from benchbuild.utils import schema as ...
How would you code a function in Python 3 to persist the run results in the database.
You are a Python code analyst, evaluating scripts for potential improvements.
def persist_perf(run, session, svg_path): """ Persist the flamegraph in the database. The flamegraph exists as a SVG image on disk until we persist it in the database. Args: run: The run we attach these perf measurements to. session: The db transaction we belong to. svg_pat...
Implement a function in Python 3 to persist the flamegraph in the database.
As a Python code composer, you craft elegant and concise scripts.
Persist the run results in the database.
Given the following Python 3 function, write the documentation def persist_compilestats(run, session, stats): for stat in stats: stat.run_id = run.id session.add(stat)
As a Python code analyst, you investigate and solve complex coding mysteries
def persist_config(run, session, cfg): """ Persist the configuration in as key-value pairs. Args: run: The run we attach the config to. session: The db transaction we belong to. cfg: The configuration we want to persist. """ from benchbuild.utils import schema as s for ...
Write a Python 3 script to persist the configuration in as key - value pairs.
As a Python code composer, you craft elegant and concise scripts.
Extract columns from the line under Summary of all tests
Given the following Python 3 function, write the documentation def parse_results_header(cls, header): header = IORMetricsExtractor.RE_MULTIPLE_SPACES.sub(' ', header) header = header.split(' ') return header
As a Python code composer, you craft elegant and concise scripts.
def parse_result_line(cls, columns, line, metrics): """Extract metrics from a result line :param columns: list of columns specified under line "Summary of all tests:" :param line: string of results below the columns line :param metrics: output dict where metrics are written ...
Write a Python 3 function for extracting metrics from a result line
As a Python code translator, you convert algorithms and pseudocode into Python.
List of API to test
How would you explain what the following Python 3 function does def apis(self): value = self.attributes['apis'] if isinstance(value, six.string_types): value = shlex.split(value) return value
You are a Python code analyst, evaluating scripts for potential improvements.
def pre_execute(self, execution, context): """Make sure the named directory is created if possible""" path = self._fspath if path: path = path.format( benchmark=context.benchmark, api=execution['category'], **execution.get('metas', {}) ...
Write a Python 3 function that can make sure the named directory is created if possible
As a python code expert, you are capable of creating scripts from specifications.
Provides block_size and transfer_size through a list of dict for instance
Given the following Python 3 function, write the documentation def sizes(self): if self.attributes.get('sizes'): for settings in self.attributes.get('sizes'): for pair in itertools.product( shlex.split(settings['block']), shlex.split(settings['transfer']) ...
You are a Python code generator, capable of creating scripts from specifications.
Returns a set of all file mode names that are set for this IOR.
Make a summary of the following Python 3 code def file_mode(self): fms = self.attributes['file_mode'] eax = set() if isinstance(fms, six.string_types): fms = shlex.split(fms) for fm in fms: if fm == 'both': eax.add('fpp') eax.add('o...
As a Python code analyst, you investigate and solve complex coding mysteries
Contiguous bytes to write per task
How would you explain what the following Python 3 function does def block_size(self): bs = self.attributes['block_size'] if isinstance(bs, six.string_types): bs = shlex.split(bs) bs = [str(e) for e in bs] return bs
You are a Python code architect, reviewing and designing scalable and efficient code
Size of transfer in bytes
Explain what the following Python 3 code does def transfer_size(self): ts = self.attributes['transfer_size'] if isinstance(ts, six.string_types): ts = shlex.split(ts) ts = [str(e) for e in ts] return ts
As a Python code composer, you craft elegant and concise scripts.
Macro to check if this event is a tablet pad.
Can you generate a brief explanation for the following Python 3 code def is_tablet_pad(self): if self in {type(self).TABLET_PAD_BUTTON, type(self).TABLET_PAD_RING, type(self).TABLET_PAD_STRIP}: return True else: return False
You are a Python code analyst, evaluating scripts for potential improvements.
Macro to check if this event is a gesture event.
Can you generate the documentation for the following Python 3 function def is_gesture(self): if self in {type(self).GESTURE_SWIPE_BEGIN, type(self).GESTURE_SWIPE_END, type(self).GESTURE_SWIPE_UPDATE, type(self).GESTURE_PINCH_BEGIN, type(self).GESTURE_PINCH_UPDATE, type(self).GESTURE_PINCH_END}: return True ...
You are a Python code generator, capable of creating scripts from specifications.
The relative delta of the unaccelerated motion vector of the last pointer event.
Make a summary of the following Python 3 code def delta_unaccelerated(self): if self.type != EventType.POINTER_MOTION: raise AttributeError(_wrong_prop.format(self.type)) delta_x = self._libinput.libinput_event_pointer_get_dx_unaccelerated( self._handle) delta_y = self._libinput.libinput_event_pointer_get_...
You are a Python code analyst, evaluating scripts for potential improvements.
Returns the current absolute coordinates of the pointer event.
Here you have a function in Python 3, explain what it does def absolute_coords(self): if self.type != EventType.POINTER_MOTION_ABSOLUTE: raise AttributeError(_wrong_prop.format(self.type)) abs_x = self._libinput.libinput_event_pointer_get_absolute_x( self._handle) abs_y = self._libinput.libinput_event_poin...
As a Python code analyst, you investigate and solve complex coding mysteries
def transform_absolute_coords(self, width, height): """Return the current absolute coordinates of the pointer event, transformed to screen coordinates. For pointer events that are not of type :attr:`~libinput.constant.EventType.POINTER_MOTION_ABSOLUTE`, this method raises :exc:`AttributeError`. Args: w...
How would you code a function in Python 3 to return the current absolute coordinates of the pointer event and the current absolute coordinates transformed to screen coordinates.
You are a Python code architect, reviewing and designing scalable and efficient code
The button state that triggered this event.
Here you have a function in Python 3, explain what it does def button_state(self): if self.type != EventType.POINTER_BUTTON: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_pointer_get_button_state( self._handle)
As a Python code analyst, you investigate and solve complex coding mysteries
def has_axis(self, axis): """Check if the event has a valid value for the given axis. If this method returns True for an axis and :meth:`get_axis_value` returns a value of 0, the event is a scroll stop event. For pointer events that are not of type :attr:`~libinput.constant.EventType.POINTER_AXIS`, this met...
Implement a function in Python 3 to check if the event contains a valid value for the given axis.
As a python code expert, you are capable of creating scripts from specifications.
def get_axis_value(self, axis): """Return the axis value of the given axis. The interpretation of the value depends on the axis. For the two scrolling axes :attr:`~libinput.constant.PointerAxis.SCROLL_VERTICAL` and :attr:`~libinput.constant.PointerAxis.SCROLL_HORIZONTAL`, the value of the event is in relativ...
Implement a function in Python 3 to get the value of the given axis.
You are a Python code analyst, evaluating scripts for potential improvements.
Get the value of the given axis event in discrete steps.
Can you generate the documentation for the following Python 3 function def get_axis_value_discrete(self, axis): if self.type != EventType.POINTER_AXIS: raise AttributeError(_wrong_meth.format(self.type)) return self._libinput.libinput_event_pointer_get_axis_value_discrete( self._handle, axis)
As a Python code composer, you craft elegant and concise scripts.
Returns the slot of this touch event.
Can you tell what is the following Python 3 function doing def slot(self): if self.type == EventType.TOUCH_FRAME: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_touch_get_slot(self._handle)
You are a Python code generator, capable of creating scripts from specifications.
def seat_slot(self): """The seat slot of the touch event. A seat slot is a non-negative seat wide unique identifier of an active touch point. Events from single touch devices will be represented as one individual touch point per device. For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOW...
How would you code a function in Python 3 to return the seat wide identifier of the touch event.
You are a Python code generator, capable of creating scripts from specifications.
def coords(self): """The current absolute coordinates of the touch event, in mm from the top left corner of the device. To get the corresponding output screen coordinates, use :meth:`transform_coords`. For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`, :attr:`~libinput.constant.EventT...
Write a Python 3 function that can return the current absolute coordinates of the touch event.
As a Python code analyst, you investigate and solve complex coding mysteries
Return the current absolute coordinates of the touch event transformed to screen coordinates.
Explain what the following Python 3 code does def transform_coords(self, width, height): if self.type not in {EventType.TOUCH_DOWN, EventType.TOUCH_MOTION}: raise AttributeError(_wrong_meth.format(self.type)) x = self._libinput.libinput_event_touch_get_x_transformed( self._handle, width) y = self._libinput...
As a Python code translator, you convert algorithms and pseudocode into Python.
def cancelled(self): """Return if the gesture ended normally, or if it was cancelled. For gesture events that are not of type :attr:`~libinput.constant.EventType.GESTURE_SWIPE_END` or :attr:`~libinput.constant.EventType.GESTURE_PINCH_END`, this property raises :exc:`AttributeError`. Returns: bool: :obj...
Write a Python 3 script for returning if the gesture ended normally or if it was cancelled.
You are a Python code analyst, evaluating scripts for potential improvements.
The delta between the last event and the current event.
How would you explain what the following Python 3 function does def delta(self): if self.type not in {EventType.GESTURE_SWIPE_UPDATE, EventType.GESTURE_PINCH_UPDATE}: raise AttributeError(_wrong_prop.format(self.type)) delta_x = self._libinput.libinput_event_gesture_get_dx(self._handle) delta_y = self._li...
You are a Python code analyst, evaluating scripts for potential improvements.
The relative delta of the unaccelerated motion vector of the current event.
Here you have a function in Python 3, explain what it does def delta_unaccelerated(self): if self.type not in {EventType.GESTURE_SWIPE_UPDATE, EventType.GESTURE_PINCH_UPDATE}: raise AttributeError(_wrong_prop.format(self.type)) delta_x = self._libinput.libinput_event_gesture_get_dx_unaccelerated( self._h...
As a Python code translator, you convert algorithms and pseudocode into Python.
def scale(self): """The absolute scale of a pinch gesture, the scale is the division of the current distance between the fingers and the distance at the start of the gesture. The scale begins at 1.0, and if e.g. the fingers moved together by 50% then the scale will become 0.5, if they move twice as far apart...
Can you write a function in Python 3 where it returns the absolute scale of a pinch gesture.
You are a Python code generator, capable of creating scripts from specifications.
Returns the angle delta in degrees between the last and the current event.
Given the following Python 3 function, write the documentation def angle_delta(self): if self.type != EventType.GESTURE_PINCH_UPDATE: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_gesture_get_angle_delta( self._handle)
As a python code expert, you are capable of creating scripts from specifications.
Returns the x y coordinates of the tablet tool in mm from the top left corner of the tablet in mm from the top left corner of the tablet in its current logical orientation and whether they have changed in this event.
Can you generate the documentation for the following Python 3 function def coords(self): x_changed = self._libinput.libinput_event_tablet_tool_x_has_changed( self._handle) y_changed = self._libinput.libinput_event_tablet_tool_y_has_changed( self._handle) x = self._libinput.libinput_event_tablet_tool_get_x(...
As a python code expert, you are capable of creating scripts from specifications.
The relative delta between the last event and the current event.
Can you generate a brief explanation for the following Python 3 code def delta(self): delta_x = self._libinput.libinput_event_tablet_tool_get_dx(self._handle) delta_y = self._libinput.libinput_event_tablet_tool_get_dy(self._handle) return delta_x, delta_y
You are a Python code architect, reviewing and designing scalable and efficient code
Returns the current pressure of the current tool in use normalized to the range [ 0 1 ) and whether it has changed in this event.
Explain what the following Python 3 code does def pressure(self): pressure = self._libinput.libinput_event_tablet_tool_get_pressure( self._handle) changed = self._libinput. \ libinput_event_tablet_tool_pressure_has_changed(self._handle) return pressure, changed
You are a Python code architect, reviewing and designing scalable and efficient code
Returns the current distance from the tablet s sensor to the range [ 0 1 ) and whether it has changed in this event.
Given the following Python 3 function, write the documentation def distance(self): distance = self._libinput.libinput_event_tablet_tool_get_distance( self._handle) changed = self._libinput. \ libinput_event_tablet_tool_distance_has_changed(self._handle) return distance, changed
As a python code expert, you are capable of creating scripts from specifications.
Returns the current tilt along the X Y axes of the tablet s logical orientation in degrees off the tablet s Z axis.
Make a summary of the following Python 3 code def tilt_axes(self): tilt_x = self._libinput.libinput_event_tablet_tool_get_tilt_x( self._handle) tilt_y = self._libinput.libinput_event_tablet_tool_get_tilt_y( self._handle) x_changed = self._libinput. \ libinput_event_tablet_tool_tilt_x_has_changed(self._h...
As a Python code composer, you craft elegant and concise scripts.
def rotation(self): """The current Z rotation of the tool in degrees, clockwise from the tool's logical neutral position and whether it has changed in this event. For tools of type :attr:`~libinput.constant.TabletToolType.MOUSE` and :attr:`~libinput.constant.TabletToolType.LENS` the logical neutral positio...
Implement a Python 3 function for returning the current Z rotation of the tool in degrees clockwise from the tool s logical neutral position and whether it has changed in this event.
As a python code expert, you are capable of creating scripts from specifications.
Returns the current position of the slider on the tool and whether it has changed in this event.
Make a summary of the following Python 3 code def slider_position(self): position = self._libinput. \ libinput_event_tablet_tool_get_slider_position(self._handle) changed = self._libinput.libinput_event_tablet_tool_slider_has_changed( self._handle) return position, changed
You are a Python code analyst, evaluating scripts for potential improvements.
def wheel_delta(self): """The delta for the wheel in degrees and whether it has changed in this event. Returns: (float, bool): The delta of the wheel, in degrees, compared to the last event and whether it has changed. """ delta = self._libinput.libinput_event_tablet_tool_get_wheel_delta( self._hand...
Write a Python 3 function for returning the delta for the wheel in degrees and whether it has changed in this event.
As a Python code composer, you craft elegant and concise scripts.
def wheel_delta_discrete(self): """The delta for the wheel in discrete steps (e.g. wheel clicks) and whether it has changed in this event. Returns: (int, bool): The delta of the wheel, in discrete steps, compared to the last event and whether it has changed. """ delta = self._libinput. \ libinput_...
Write a Python 3 function for returning the delta for the wheel in discrete steps compared to the last event and whether it has changed in this event.
As a Python code composer, you craft elegant and concise scripts.
def transform_coords(self, width, height): """Return the current absolute (x, y) coordinates of the tablet tool event, transformed to screen coordinates and whether they have changed in this event. Note: On some devices, returned value may be negative or larger than the width of the device. See `Out-of-b...
Create a Python 3 function for returning the current absolute x y coordinates of the tablet tool event transformed to screen coordinates and whether they have changed in this event.
As a Python code translator, you convert algorithms and pseudocode into Python.
The tool that was in use during this event.
Can you generate the documentation for the following Python 3 function def tool(self): htablettool = self._libinput.libinput_event_tablet_tool_get_tool( self._handle) return TabletTool(htablettool, self._libinput)
You are a Python code analyst, evaluating scripts for potential improvements.
The button state of the event. This property is only available for tables that are not of type EventType. TABLET_TOOL_BUTTON.
Can you generate the documentation for the following Python 3 function def button_state(self): if self.type != EventType.TABLET_TOOL_BUTTON: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_tool_get_button_state( self._handle)
As a Python code analyst, you investigate and solve complex coding mysteries
The current position of the ring in degrees counterclockwise from the northern - most point of the ring in the tablet s current logical orientation.
How would you explain what the following Python 3 function does def ring_position(self): if self.type != EventType.TABLET_PAD_RING: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_ring_position( self._handle)
As a Python code translator, you convert algorithms and pseudocode into Python.
The number of the ring that has changed state.
How would you explain what the following Python 3 function does def ring_number(self): if self.type != EventType.TABLET_PAD_RING: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_ring_number( self._handle)
As a python code expert, you are capable of creating scripts from specifications.
The source of the interaction with the ring.
How would you explain what the following Python 3 function does def ring_source(self): if self.type != EventType.TABLET_PAD_RING: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_ring_source( self._handle)
As a python code expert, you are capable of creating scripts from specifications.
The current position of the strip in the current axis.
Can you generate the documentation for the following Python 3 function def strip_position(self): if self.type != EventType.TABLET_PAD_STRIP: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_strip_position( self._handle)
As a python code expert, you are capable of creating scripts from specifications.
The number of the first strip that has changed state.
Here you have a function in Python 3, explain what it does def strip_number(self): if self.type != EventType.TABLET_PAD_STRIP: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_strip_number( self._handle)
You are a Python code analyst, evaluating scripts for potential improvements.
def mode_group(self): """The mode group that the button, ring, or strip that triggered this event is considered in. The mode is a virtual grouping of functionality, usually based on some visual feedback like LEDs on the pad. See `Tablet pad modes`_ for details. Returns: ~libinput.define.TabletPadModeGr...
Can you write a function in Python 3 where it returns the mode group that the button ring or strip that triggered this event is considered in.
You are a Python code generator, capable of creating scripts from specifications.
def parse_args(args=None): """Parses arguments, returns (options, args).""" from argparse import ArgumentParser if args is None: args = sys.argv parser = ArgumentParser(description=''' Attempt to automatically find "adjacent" shapes in a SVG layer, and on a second SVG layer, draw each detected...
Implement a function in Python 3 to parse arguments returns options and args.
As a python code expert, you are capable of creating scripts from specifications.
def get_long_description(): """ Returns the Package long description. :return: Package long description. :rtype: unicode """ description = [] with open("README.rst") as file: for line in file: if ".. code:: python" in line and len(description) >= 2: bloc...
Create a Python 3 function for returning the Package long description.
You are a Python code analyst, evaluating scripts for potential improvements.
def ftp_listing_paths(ftpconn: FTP, root: str) -> Iterable[str]: """Generate the full file paths from a root path.""" for current_path, dirs, files in ftp_walk(ftpconn, root): yield from (os.path.join(current_path, file) for file in files)
Create a Python 3 function to generate the full file paths from a root path.
You are a Python code analyst, evaluating scripts for potential improvements.
def directory_listing(conn: FTP, path: str) -> Tuple[List, List]: """Return the directories and files for single FTP listing.""" entries = deque() conn.dir(path, entries.append) entries = map(parse_line, entries) grouped_entries = defaultdict(list) for key, value in entries: grouped_en...
How would you code a function in Python 3 to return the directories and files for single FTP listing.
As a Python code translator, you convert algorithms and pseudocode into Python.
def parse_line(line: str, char_index=0) -> Tuple[ListingType, str]: """Parse FTP directory listing into (type, filename).""" entry_name = str.rpartition(line, ' ')[-1] entry_type = LISTING_FLAG_MAP.get(line[char_index], ListingType.other) return entry_type, entry_name
Write a Python 3 script to parse a single line into a listing type and filename.
As a Python code translator, you convert algorithms and pseudocode into Python.
def download_ftp_url(source_url, target_uri, buffer_size=8192): """Uses urllib. thread safe?""" ensure_file_directory(target_uri) with urllib.request.urlopen(source_url) as source_file: with open(target_uri, 'wb') as target_file: shutil.copyfileobj(source_file, target_file, buffer_size...
How would you implement a function in Python 3 that downloads a file from a ftp source url to a target URI.
You are a Python code analyst, evaluating scripts for potential improvements.
def devices(self): """List of devices to test """ eax = self.attributes.get('devices') if eax is None: eax = self._all_devices if not isinstance(eax, list): eax = [eax] return [str(dev) for dev in eax]
How would you implement a function in Python 3 that lists of devices to test
As a python code expert, you are capable of creating scripts from specifications.
def exceptions(error_is_fatal=True, error_messages=None): """ Handle SQLAlchemy exceptions in a sane way. Args: func: An arbitrary function to wrap. error_is_fatal: Should we exit the program on exception? reraise: Should we reraise the exception, after logging? Only makes sense ...
Create a Python 3 function for handling SQLAlchemy exceptions in a sane way. Args: func: An arbitrary function to wrap. error_is_fatal: Should we exit the program on exception? reraise: Should we reraise the exception, after logging? Only makes sense if error_is_fatal is False. error_messages: A dictionary that assigns...
You are a Python code analyst, evaluating scripts for potential improvements.
def enforce_versioning(force=False): """Install versioning on the db.""" connect_str, repo_url = get_version_data() LOG.warning("Your database uses an unversioned benchbuild schema.") if not force and not ui.ask( "Should I enforce version control on your schema?"): LOG.error("User de...
Implement a function in Python 3 to install versioning on the db.
As a Python code composer, you craft elegant and concise scripts.
Initialize all SQL functions in the database.
Make a summary of the following Python 3 code def init_functions(connection): if settings.CFG["db"]["create_functions"]: print("Refreshing SQL functions...") for file in path.template_files("../sql/", exts=[".sql"]): func = sa.DDL(path.template_str(file)) LOG.info("Loading: '...
As a Python code analyst, you investigate and solve complex coding mysteries
Establish a connection to the database.
Can you generate the documentation for the following Python 3 function def connect_engine(self): try: self.connection = self.engine.connect() return True except sa.exc.OperationalError as opex: LOG.fatal("Could not connect to the database. The error was: '%s'", ...
You are a Python code architect, reviewing and designing scalable and efficient code
def configure_engine(self): """ Configure the databse connection. Sets appropriate transaction isolation levels and handle errors. Returns: True, if we did not encounter any unrecoverable errors, else False. """ try: self.connection.execution_opt...
Can you create a Python 3 function that configures the databse connection.
You are a Python code architect, reviewing and designing scalable and efficient code
Parse datetime. date from YYYY - MM - DD format.
Explain what the following Python 3 code does def parse_date(date_str: str, pattern=_RE_DATE) -> dt.date: groups = re.match(pattern, date_str) return dt.date(*_date_to_tuple(groups.groupdict()))
As a Python code translator, you convert algorithms and pseudocode into Python.
def _datetime_to_tuple(dt_dict): """datetime.datetime components from dictionary to tuple. Example ------- dt_dict = {'year': '2014','month': '07','day': '23', 'hour': '13','minute': '12','second': '45','microsecond': '321'} _datetime_to_tuple(dt_dict) -> (2014, 7, 23, 13, 12, 45, 321)...
Create a Python 3 function for converting a dictionary to a tuple.
As a Python code analyst, you investigate and solve complex coding mysteries
convert to datetime to UTC offset.
Can you tell what is the following Python 3 function doing def convert_2_utc(self, datetime_, timezone): datetime_ = self.tz_mapper[timezone].localize(datetime_) return datetime_.astimezone(pytz.UTC)
As a python code expert, you are capable of creating scripts from specifications.
def esearch(database, query, userhistory=True, webenv=False, query_key=False, retstart=False, retmax=False, api_key=False, email=False, **kwargs) -> Optional[EsearchResult]: """Search for a query using the Entrez ESearch API. Parameters ---------- database : str Entez database to se...
Can you implement a function in Python 3 that searches for a query using the Entrez ESearch API.
As a python code expert, you are capable of creating scripts from specifications.
def epost(database, ids: List[str], webenv=False, api_key=False, email=False, **kwargs) -> Optional[EpostResult]: """Post IDs using the Entrez ESearch API. Parameters ---------- database : str Entez database to search. ids : list List of IDs to submit to the server. webenv : str...
Create a Python 3 function for posting IDs using the Entrez ESearch API.
You are a Python code generator, capable of creating scripts from specifications.
Get document summaries using the ESearch API.
Given the following Python 3 function, write the documentation def elink(db: str, dbfrom: str, ids=False, webenv=False, query_key=False, api_key=False, email=False, **kwargs) -> Optional[ElinkResult]: """Get document summaries using the Entrez ESearch API. Parameters ---------- db : str ...
You are a Python code analyst, evaluating scripts for potential improvements.
Get document summaries using the Entrez ESearch API.
Given the following Python 3 function, write the documentation def esummary(database: str, ids=False, webenv=False, query_key=False, count=False, retstart=False, retmax=False, api_key=False, email=False, **kwargs) -> Optional[List[EsummaryResult]]: """Get document summaries using the Entrez ESearch API...
As a python code expert, you are capable of creating scripts from specifications.
Get documents using the Entrez ESearch API. gg
Explain what the following Python 3 code does def efetch(database, ids=False, webenv=False, query_key=False, count=False, retstart=False, retmax=False, rettype='full', retmode='xml', api_key=False, email=False, **kwargs) -> str: """Get documents using the Entrez ESearch API.gg Parameters -------...
As a Python code composer, you craft elegant and concise scripts.