output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
This function will iterate over a dictionary and return a list of objects found at all trajectories at the given path.
Can you generate the documentation for the following Python 3 function def iterate_dictionary(d, path, squash_single = False): path_parts = path.split("/") return_list = [] if len(path_parts) == 0: #no search string return d else: try: sub_dicts = [d] #BFS, start with ro...
As a Python code translator, you convert algorithms and pseudocode into Python.
def get_snmp_service(self): """ Enable/Disable snmp :param snmp_parameters: :return: :rtype: SnmpContextManager """ return SnmpContextManager(self.enable_flow, self.disable_flow, self._snmp_parameters, self._logger)
Write a Python 3 function for returning a SnmpContextManager instance for the given enable disable and snmp_parameters.
You are a Python code analyst, evaluating scripts for potential improvements.
def purge_stale_services(argv=None): """Command-line utility to periodically purge stale entries from the "services" table. It is designed to be used in conjunction with cron. """ argv = argv or sys.argv arg_parser = argparse.ArgumentParser( prog=os.path.basename(argv[0]), description=(...
Write a Python 3 script for commanding - line utility to periodically purge stale entries from the services table.
You are a Python code architect, reviewing and designing scalable and efficient code
Insert a batch of tasks into the specified queue.
Make a summary of the following Python 3 code def _insert_tasks(tasks, queue, transactional=False, retry_transient_errors=True, retry_delay=RETRY_SLEEP_SECS): """Insert a batch of tasks into the specified queue. If an error occurs during insertion, split the batch and retry u...
You are a Python code generator, capable of creating scripts from specifications.
Return a list of tasks that should be reinserted based on the was_enqueued property and whether the insert is transactional or not.
How would you explain what the following Python 3 function does def _tasks_to_reinsert(tasks, transactional): if transactional: return tasks return [task for task in tasks if not task.was_enqueued]
As a Python code analyst, you investigate and solve complex coding mysteries
def _task_batcher(tasks, batch_size=None): """Batches large task lists into groups of 100 so that they can all be inserted. """ from itertools import izip_longest if not batch_size: batch_size = DEFAULT_TASK_BATCH_SIZE # Ensure the batch size is under the task api limit. batch_size...
Create a Python 3 function to batch large task lists into groups of 100 so that they can all be inserted.
As a Python code composer, you craft elegant and concise scripts.
Convert all Async s into tasks then insert them into queues.
Here you have a function in Python 3, explain what it does def _handle_tasks_insert(self, batch_size=None): if self._tasks_inserted: raise errors.ContextAlreadyStartedError( "This Context has already had its tasks inserted.") task_map = self._get_tasks_by_queue() # ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Return the tasks for this Context grouped by queue.
Explain what the following Python 3 code does def _get_tasks_by_queue(self): task_map = {} _checker = None # Ask the persistence engine for an Async to use for checking if the # context is complete. if self._persistence_engine: _checker = self._persistence_engine.con...
As a python code expert, you are capable of creating scripts from specifications.
def set_event_handler(self, event, handler): """Add an Async to be run on event.""" # QUESTION: Should we raise an exception if `event` is not in some # known event-type list? self._prepare_persistence_engine() callbacks = self._options.get('callbacks', {}) callbacks[ev...
How would you code a function in Python 3 to add an Async to be run on event.
As a Python code composer, you craft elegant and concise scripts.
Execute the Async set to be run on event.
Can you tell what is the following Python 3 function doing def exec_event_handler(self, event, transactional=False): # QUESTION: Should we raise an exception if `event` is not in some # known event-type list? callbacks = self._options.get('callbacks', {}) handler = callbacks.get(event)...
As a python code expert, you are capable of creating scripts from specifications.
Adds an Async object to this context.
Make a summary of the following Python 3 code def add(self, target, args=None, kwargs=None, **options): from furious.async import Async from furious.batcher import Message if self._tasks_inserted: raise errors.ContextAlreadyStartedError( "This Context has already had...
As a Python code translator, you convert algorithms and pseudocode into Python.
def load(cls, context_id, persistence_engine=None): """Load and instantiate a Context from the persistence_engine.""" if not persistence_engine: from furious.config import get_default_persistence_engine persistence_engine = get_default_persistence_engine() if not persist...
Write a Python 3 function for loading and instantiate a Context from the persistence_engine.
As a Python code translator, you convert algorithms and pseudocode into Python.
def to_dict(self): """Return this Context as a dict suitable for json encoding.""" import copy options = copy.deepcopy(self._options) if self._insert_tasks: options['insert_tasks'] = reference_to_path(self._insert_tasks) if self._persistence_engine: opt...
Write a Python 3 function for returning this Context as a dict suitable for json encoding.
You are a Python code generator, capable of creating scripts from specifications.
def from_dict(cls, context_options_dict): """Return a context job from a dict output by Context.to_dict.""" import copy context_options = copy.deepcopy(context_options_dict) tasks_inserted = context_options.pop('_tasks_inserted', False) insert_tasks = context_options.pop('inse...
Can you implement a function in Python 3 that returns a context job from a dict output by Context. to_dict.
As a Python code composer, you craft elegant and concise scripts.
Return the context result object pulled from the persistence_engine if it has been set.
Given the following Python 3 function, write the documentation def result(self): if not self._result: if not self._persistence_engine: return None self._result = self._persistence_engine.get_context_result(self) return self._result
As a Python code translator, you convert algorithms and pseudocode into Python.
Insert a batch of tasks into a specific queue ignoring duplicate names.
Can you generate the documentation for the following Python 3 function def insert_tasks_ignore_duplicate_names(tasks, queue, *args, **kwargs): from google.appengine.api import taskqueue try: inserted = _insert_tasks(tasks, queue, *args, **kwargs) return inserted except taskqueue.Duplicate...
As a Python code analyst, you investigate and solve complex coding mysteries
This function performs the actual grep on a given file.
Can you tell what is the following Python 3 function doing def grep_file(query, item): return ['%s: %s' % (item, line) for line in open(item) if re.search(query, line)]
You are a Python code analyst, evaluating scripts for potential improvements.
def _get_configured_module(option_name, known_modules=None): """Get the module specified by the value of option_name. The value of the configuration option will be used to load the module by name from the known module list or treated as a path if not found in known_modules. Args: option_name: na...
Write a Python 3 script to get the module that is configured by the value of option_name.
You are a Python code architect, reviewing and designing scalable and efficient code
def find_furious_yaml(config_file=__file__): """ Traverse directory trees to find a furious.yaml file Begins with the location of this file then checks the working directory if not found Args: config_file: location of this file, override for testing Returns: the path of...
Implement a function in Python 3 to traverse the directory trees to find a furious. yaml file and return the path of the furious. yaml file or None if not found
As a Python code analyst, you investigate and solve complex coding mysteries
def _find_furious_yaml(start, checked): """Traverse the directory tree identified by start until a directory already in checked is encountered or the path of furious.yaml is found. Checked is present both to make the loop termination easy to reason about and so the same directories do not get r...
Implement a function in Python 3 to traverse the directory tree identified by start and check if a furious. yaml file is found.
As a Python code composer, you craft elegant and concise scripts.
def _load_yaml_config(path=None): """Open and return the yaml contents.""" furious_yaml_path = path or find_furious_yaml() if furious_yaml_path is None: logging.debug("furious.yaml not found.") return None with open(furious_yaml_path) as yaml_file: return yaml_file.read()
How would you code a function in Python 3 to open and return the yaml contents.
You are a Python code analyst, evaluating scripts for potential improvements.
def _parse_yaml_config(config_data=None): """ Gets the configuration from the found furious.yaml file and parses the data. Returns: a dictionary parsed from the yaml file """ data_map = default_config() # If we were given config data to use, use it. Otherwise, see if there is #...
Implement a function in Python 3 to return the configuration from the found furious. yaml file and parses the data.
As a Python code analyst, you investigate and solve complex coding mysteries
Minimizing of joins. Left and right are only inner join.
How would you explain what the following Python 3 function does def _minimize_joins(self): joins_group = [] for join in self._joins: append_new = True for join_group in joins_group: if join_group[0]['table'] == join['table'] and join_group[0]['ons'] == join['ons']...
You are a Python code analyst, evaluating scripts for potential improvements.
def run_code(node: Code, parent_node: Node = None, node_globals: InheritedDict = None, **args): #pylint: disable=unused-argument '''Executes node content as python module and adds its definitions to globals''' if not node.xml_node.text: return code = node.xml_node.text try: globs = node_...
Write a Python 3 function for executing node content as python module and adds its definitions to globals
As a python code expert, you are capable of creating scripts from specifications.
def merge(left, right): """ Merge two mappings objects together, combining overlapping Mappings, and favoring right-values left: The left Mapping object. right: The right (favored) Mapping object. NOTE: This is not commutative (merge(a,b) != merge(b,a)). """ merged = {} left_keys ...
How would you code a function in Python 3 to merge two mappings objects together and favoring right - values
You are a Python code architect, reviewing and designing scalable and efficient code
def pelt(cost, length, pen=None): """ PELT algorithm to compute changepoints in time series Ported from: https://github.com/STOR-i/Changepoints.jl https://github.com/rkillick/changepoint/ Reference: Killick R, Fearnhead P, Eckley IA (2012) Optimal detection of changepoin...
Create a Python 3 function for pelting algorithm to compute changepoints in time series Ported from: https://github.com/STOR-i/Changepoints.jl https://github.com/rkillick/changepoint/ Reference: Killick R, Fearnhead P, Eckley IA (2012) Optimal detection of changepoints with a linear computational cost, JASA 107(500), 1...
You are a Python code generator, capable of creating scripts from specifications.
Returns a cost function for a time series with normal distribution with changing mean
Make a summary of the following Python 3 code def normal_mean(data, variance): if not isinstance(data, np.ndarray): data = np.array(data) i_variance_2 = 1 / (variance ** 2) cmm = [0.0] cmm.extend(np.cumsum(data)) cmm2 = [0.0] cmm2.extend(np.cumsum(np.abs(data))) def cost(start, en...
You are a Python code architect, reviewing and designing scalable and efficient code
Returns a function that calculates the cost of a time series with changing variance.
Make a summary of the following Python 3 code def normal_var(data, mean): if not isinstance(data, np.ndarray): data = np.array(data) cumm = [0.0] cumm.extend(np.cumsum(np.power(np.abs(data - mean), 2))) def cost(s, t): """ Cost function for normal distribution with variable variance ...
You are a Python code generator, capable of creating scripts from specifications.
def normal_meanvar(data): """ Creates a segment cost function for a time series with a Normal distribution with changing mean and variance Args: data (:obj:`list` of float): 1D time series data Returns: function: Function with signature (int, int) -> float wh...
Can you write a function in Python 3 where it returns a cost function for a 1D time series with changing mean and variance.
As a Python code translator, you convert algorithms and pseudocode into Python.
def poisson(data): """ Creates a segment cost function for a time series with a poisson distribution with changing mean Args: data (:obj:`list` of float): 1D time series data Returns: function: Function with signature (int, int) -> float where the first arg i...
Implement a Python 3 function for returning a function that calculates the cost of a 1D time series with poisson distribution with changing mean .
As a Python code translator, you convert algorithms and pseudocode into Python.
Creates a function that calculates the cost of a 1D time series with exponential distribution with changing mean .
Can you generate the documentation for the following Python 3 function def exponential(data): data = np.hstack(([0.0], np.array(data))) cumm = np.cumsum(data) def cost(s, t): """ Cost function for exponential distribution with changing mean Args: start (int): start index ...
As a Python code translator, you convert algorithms and pseudocode into Python.
def _get_layer_min_max(self, oid_field_name): """ Find the min and max values for the OID field. """ query_args = self._build_query_args({ 'f': 'json', 'outFields': '', 'outStatistics': json.dumps([ dict(statisticType='min', onStatisticField=oid_field_...
Implement a Python 3 function for getting the min and max values for the given OID field.
As a Python code translator, you convert algorithms and pseudocode into Python.
Determines if a polygon ring is clockwise.
Here you have a function in Python 3, explain what it does def ring_is_clockwise(ring): total = 0 for (pt1, pt2) in pairwise(ring): total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]) return total >= 0
As a Python code composer, you craft elegant and concise scripts.
Takes a date as either a datetime. date or a string and return it as an iso8601 formatted value
Can you tell what is the following Python 3 function doing def format_date_argument(date_element): if not isinstance(date_element, (datetime.datetime, datetime.date)): # TODO: if "T" in date_element: _date = datetime.datetime.strptime(date_element, "%Y-%m-%dT%H:%M:%S") else: ...
As a Python code analyst, you investigate and solve complex coding mysteries
def make_url(*args, **kwargs): """Makes a URL from component parts""" base = "/".join(args) if kwargs: return "%s?%s" % (base, urlencode(kwargs)) else: return base
Create a Python 3 function to make a URL from component parts
As a Python code analyst, you investigate and solve complex coding mysteries
Get additional keyword arguments for the URL query string.
Can you generate a brief explanation for the following Python 3 code def _querystring(self): kw = {} for key in self.KNOWN_QUERY_OPTIONS: val = getattr(self, key) if val is not None: kw[key] = val return kw
As a Python code analyst, you investigate and solve complex coding mysteries
def _querystring(self): """Additional keyword arguments""" kw = {} if self.status: kw["status"] = "all" if self.links: kw["links"] = "all" if self.include is not None: kw["include"] = self.include if self.subject_key_type != "SubjectN...
Can you create a Python 3 function that returns a dictionary of keyword arguments that can be used to construct the query string for the URL.
As a python code expert, you are capable of creating scripts from specifications.
Qualify the dataset_name with the dataset_format
Can you generate the documentation for the following Python 3 function def dataset(self): if self.dataset_format: return ".".join([self.dataset_name, self.dataset_format]) return self.dataset_name
You are a Python code analyst, evaluating scripts for potential improvements.
def check_dataset_format(ds_format): """ Ensure dataset format is XML or CSV :param str ds_format: Format of the Dataset (expected to be one of `csv` or `xml`) """ if ds_format.lower() not in DATASET_FORMATS.keys(): raise ValueError( "dataset_format is expected to be one of %s. ...
Implement a Python 3 function for checking that dataset format is valid.
As a Python code analyst, you investigate and solve complex coding mysteries
Returns the preferred Dataset format extension
Can you generate a brief explanation for the following Python 3 code def dataset_format_to_extension(ds_format): try: return DATASET_FORMATS[ds_format] except KeyError: raise ValueError( "dataset_format is expected to be one of %s. '%s' is not valid" % (", ".join(DATASET_...
As a Python code analyst, you investigate and solve complex coding mysteries
Get the current data for a specific study environment subject
Can you generate a brief explanation for the following Python 3 code def get_data(ctx, study, environment, subject): cfg = GetDataConfigurableDataset(GET_DATA_DATASET, study, environment, subject, ...
As a Python code analyst, you investigate and solve complex coding mysteries
def rws_call(ctx, method, default_attr=None): """Make request to RWS""" try: response = ctx.obj['RWS'].send_request(method) if ctx.obj['RAW']: # use response from RWS result = ctx.obj['RWS'].last_result.text elif default_attr is not None: # human-readable summary ...
Write a Python 3 function that can make a request to RWS and return the result.
As a Python code analyst, you investigate and solve complex coding mysteries
List EDC data for Study and Study Subject
Make a summary of the following Python 3 code def data(ctx, path): _rws = partial(rws_call, ctx) if len(path) == 0: _rws(ClinicalStudiesRequest(), default_attr='oid') elif len(path) == 1: _rws(StudySubjectsRequest(path[0], 'Prod'), default_attr='subjectkey') elif len(path) == 2: ...
You are a Python code generator, capable of creating scripts from specifications.
Post clinical data to the ODM
Explain what the following Python 3 code does def post(ctx, odm): try: ctx.obj['RWS'].send_request(PostDataRequest(odm.read())) if ctx.obj['RAW']: click.echo(ctx.obj['RWS'].last_result.text) except RWSException as e: click.echo(e.message)
You are a Python code architect, reviewing and designing scalable and efficient code
List metadata for the given Study.
Given the following Python 3 function, write the documentation def metadata(ctx, drafts, path): _rws = partial(rws_call, ctx) if len(path) == 0: _rws(MetadataStudiesRequest(), default_attr='oid') elif len(path) == 1: if drafts: _rws(StudyDraftsRequest(path[0]), default_attr='oid'...
As a Python code translator, you convert algorithms and pseudocode into Python.
Make direct call to RWS
How would you explain what the following Python 3 function does def direct(ctx, path): try: url = make_url(ctx.obj['RWS'].base_url, path) resp = requests.get(url, auth=HTTPBasicAuth(ctx.obj['USERNAME'], ctx.obj['PASSWORD'])) click.echo(resp.text) except RWSException as e: click.e...
As a Python code composer, you craft elegant and concise scripts.
def autofill(ctx, steps, metadata, fixed, study, environment, subject): """Request enterable data for a subject, generate data values and post back to Rave. Requires 'rwscmd_getdata' configurable dataset to be installed on the Rave URL.""" if metadata is not None: # Read metadata from file, if supplied ...
Write a Python 3 function for requesting enterable data for a subject generate data values and post back to Rave.
You are a Python code generator, capable of creating scripts from specifications.
def build(self, builder): """Build XML by appending to builder""" params = dict(OID=self.oid) params["mdsol:ProjectType"] = self.project_type builder.start("Study", params) # Ask children if self.global_variables is not None: self.global_variables.build(buil...
Can you create a Python 3 function that builds the XML by appending to the given XML builder
As a Python code translator, you convert algorithms and pseudocode into Python.
def build(self, builder): """Build XML by appending to builder""" builder.start("GlobalVariables", {}) make_element(builder, "StudyName", self.name) make_element(builder, "StudyDescription", self.description) make_element(builder, "ProtocolName", self.protocol_name) build...
Implement a Python 3 function for building XML by appending to builder
You are a Python code architect, reviewing and designing scalable and efficient code
Build XML by appending to builder
Here you have a function in Python 3, explain what it does def build(self, builder): builder.start("BasicDefinitions", {}) for child in self.measurement_units: child.build(builder) builder.end("BasicDefinitions")
As a Python code analyst, you investigate and solve complex coding mysteries
def build(self, builder): """Build XML by appending to builder""" params = dict(OID=self.oid, Name=self.name) if self.unit_dictionary_name: params["mdsol:UnitDictionaryName"] = self.unit_dictionary_name for suffix in ["A", "B", "C", "K"]: val = getattr(self, "c...
Implement a function in Python 3 to build XML by appending to builder
You are a Python code generator, capable of creating scripts from specifications.
Build XML by appending to builder
Can you tell what is the following Python 3 function doing def build(self, builder): builder.start("Symbol", {}) for child in self.translations: child.build(builder) builder.end("Symbol")
As a Python code composer, you craft elegant and concise scripts.
Build XML by appending to builder
How would you explain what the following Python 3 function does def build(self, builder): params = {} if self.lang is not None: params["xml:lang"] = self.lang builder.start("TranslatedText", params) builder.data(self.text) builder.end("TranslatedText")
You are a Python code architect, reviewing and designing scalable and efficient code
Builds the MetaDataVersion XML by appending it to the given XML builder.
Can you generate the documentation for the following Python 3 function def build(self, builder): params = dict(OID=self.oid, Name=self.name) if self.description is not None: params["Description"] = self.description if self.signature_prompt is not None: params["mdsol:Si...
As a python code expert, you are capable of creating scripts from specifications.
def build(self, builder): """Build XML by appending to builder""" builder.start("Protocol", {}) for child in self.study_event_refs: child.build(builder) for alias in self.aliases: alias.build(builder) builder.end("Protocol")
Create a Python 3 function to build XML by appending to builder
As a python code expert, you are capable of creating scripts from specifications.
def build(self, builder): """Build XML by appending to builder""" params = dict(StudyEventOID=self.oid, Mandatory=bool_to_yes_no(self.mandatory)) if self._order_number is not None: params["OrderNumber"] = self._order_number builder.start("StudyEventRef", params) build...
How would you implement a function in Python 3 that builds XML by appending to builder
You are a Python code generator, capable of creating scripts from specifications.
Builds the XML by appending it to the given XML builder object.
Make a summary of the following Python 3 code def build(self, builder): params = dict( OID=self.oid, Name=self.name, Repeating=bool_to_yes_no(self.repeating), Type=self.event_type, ) if self.category is not None: params["Category"] = ...
You are a Python code architect, reviewing and designing scalable and efficient code
def build(self, builder): """Build XML by appending to builder""" params = dict( OID=self.oid, Name=self.name, Repeating=bool_to_yes_no(self.repeating) ) if self.order_number is not None: params["mdsol:OrderNumber"] = str(self.order_number) if self.activ...
Implement a function in Python 3 to build the XML by appending to the given XML builder
You are a Python code architect, reviewing and designing scalable and efficient code
Builds the XML by appending to the given XML builder
Here you have a function in Python 3, explain what it does def build(self, builder): params = dict( OID=self.oid, Name=self.name, Repeating=bool_to_yes_no(self.repeating), IsReferenceData=bool_to_yes_no(self.is_reference_data), ) if self.sas_data...
As a Python code translator, you convert algorithms and pseudocode into Python.
Builds the XML by appending to builder
How would you explain what the following Python 3 function does def build(self, builder): params = dict(ItemOID=self.oid, Mandatory=bool_to_yes_no(self.mandatory)) if self.order_number is not None: params["OrderNumber"] = str(self.order_number) if self.key_sequence is not None: ...
You are a Python code analyst, evaluating scripts for potential improvements.
Builds the XML by appending to the given XML builder.
Can you generate the documentation for the following Python 3 function def build(self, builder): params = dict( OID=self.oid, Name=self.name, DataType=self.datatype.value, Length=str(self.length), ) if self.date_time_format is not None: ...
As a Python code analyst, you investigate and solve complex coding mysteries
def build(self, builder): """ Build XML by appending to builder .. note:: Questions can contain translations """ builder.start("Question", {}) for translation in self.translations: translation.build(builder) builder.end("Question")
Write a Python 3 function for building the XML representation of the object into the given builder.
You are a Python code generator, capable of creating scripts from specifications.
def comparator(self, value): """sets the comparator (with validation of input)""" if not isinstance(value, RangeCheckComparatorType): raise AttributeError("%s comparator is invalid in RangeCheck." % (value,)) self._comparator = value
Write a Python 3 function that can set the comparator (with validation of input)
You are a Python code generator, capable of creating scripts from specifications.
def soft_hard(self, value): """sets the Soft or Hard range setting (with validation of input)""" if not isinstance(value, RangeCheckType): raise AttributeError("%s soft_hard invalid in RangeCheck." % (value,)) self._soft_hard = value
How would you code a function in Python 3 to set the Soft or Hard range setting
As a python code expert, you are capable of creating scripts from specifications.
def build(self, builder): """Build XML by appending to builder""" params = dict(SoftHard=self.soft_hard.value, Comparator=self.comparator.value) builder.start("RangeCheck", params) if self.check_value is not None: self.check_value.build(builder) if self.measurement_un...
Implement a function in Python 3 to build the ISO - 8601 range check XML by appending to builder
As a Python code translator, you convert algorithms and pseudocode into Python.
def build(self, builder): """Build XML by appending to builder""" builder.start("CheckValue", {}) builder.data(str(self.value)) builder.end("CheckValue")
Write a Python 3 script to build XML by appending to builder
As a Python code translator, you convert algorithms and pseudocode into Python.
Builds the XML by appending to builder
Can you generate a brief explanation for the following Python 3 code def build(self, builder): params = dict(OID=self.oid, Name=self.name, DataType=self.datatype.value) if self.sas_format_name is not None: params["SASFormatName"] = self.sas_format_name builder.start("CodeList", param...
As a Python code composer, you craft elegant and concise scripts.
Builds the XML by appending to builder
Here you have a function in Python 3, explain what it does def build(self, builder): params = dict(CodedValue=self.coded_value) if self.order_number is not None: params["mdsol:OrderNumber"] = str(self.order_number) if self.specify: params["mdsol:Specify"] = "Yes" ...
You are a Python code generator, capable of creating scripts from specifications.
def build(self, builder): """ Build this item :param builder: :return: """ params = dict(Context=self.context, Name=self.name) builder.start("Alias", params) builder.end("Alias")
Write a Python 3 script for building this item : param builder : Induce the tree structure of the item
You are a Python code architect, reviewing and designing scalable and efficient code
Build XML by appending to builder
Explain what the following Python 3 code does def build(self, builder): params = dict(LabelOID=self.oid, OrderNumber=str(self.order_number)) builder.start("mdsol:LabelRef", params) builder.end("mdsol:LabelRef")
As a Python code translator, you convert algorithms and pseudocode into Python.
def build(self, builder): """Build XML by appending to builder""" params = dict( Namespace=self.namespace, Name=self.name, Value=self.value, TransactionType=self.transaction_type, ) builder.start("mdsol:Attribute", params) builder....
Write a Python 3 function for appending this attribute to the XML builder.
You are a Python code analyst, evaluating scripts for potential improvements.
def build(self, builder): """Build XML by appending to builder""" params = dict(OID=self.oid, Language=self.language) builder.start("mdsol:CustomFunctionDef", params) builder.data(self.code) builder.end("mdsol:CustomFunctionDef")
Write a Python 3 function that can append this custom function definition to an xml. Builder object.
As a python code expert, you are capable of creating scripts from specifications.
def build(self, builder): """Build XML by appending to builder""" params = dict( OID=self.oid, Active=bool_to_true_false(self.active), BypassDuringMigration=bool_to_true_false(self.bypass_during_migration), NeedsRetesting=bool_to_true_false(self.needs_rete...
Can you create a Python 3 function that builds the XML by appending to the given XML builder.
As a python code expert, you are capable of creating scripts from specifications.
Builds the XML by appending to the given XML builder
Given the following Python 3 function, write the documentation def build(self, builder): params = dict() if self.variable_oid is not None: params["VariableOID"] = self.variable_oid if self.data_format is not None: params["DataFormat"] = self.data_format if self...
You are a Python code analyst, evaluating scripts for potential improvements.
def check_action_type(self, value): """Set the value for the CheckActionType, validating input""" if value is not None: if not isinstance(value, ActionType): raise AttributeError("Invalid check action %s" % value) self._check_action_type = value
Write a Python 3 script for setting the value for the CheckActionType validating input
As a Python code analyst, you investigate and solve complex coding mysteries
def build(self, builder): """Build XML by appending to builder""" params = dict( OID=self.oid, Active=bool_to_true_false(self.active), BypassDuringMigration=bool_to_true_false(self.bypass_during_migration), NeedsRetesting=bool_to_true_false(self.needs_rete...
Can you create a Python 3 function that builds the xml by appending it to the given XML builder
As a Python code analyst, you investigate and solve complex coding mysteries
def build(self, builder): """Build XML by appending to builder""" params = dict(OID=self.oid, Name=self.name) if self.field_number is not None: params["FieldNumber"] = str(self.field_number) builder.start("mdsol:LabelDef", params) for translation in self.translatio...
How would you code a function in Python 3 to build the XML by appending to builder
You are a Python code architect, reviewing and designing scalable and efficient code
Build the XML by appending to builder
Here you have a function in Python 3, explain what it does def build(self, builder): builder.start("mdsol:ReviewGroup", {}) builder.data(self.name) builder.end("mdsol:ReviewGroup")
As a Python code translator, you convert algorithms and pseudocode into Python.
Build XML by appending to builder
Explain what the following Python 3 code does def build(self, builder): params = dict(MetaDataVersionOID=str(self.metadata_version_oid), StudyOID="%s (%s)" % (self.projectname, self.environment,), ) # mixins self.mixin_params(params) builder....
You are a Python code generator, capable of creating scripts from specifications.
def build(self, builder): """Build XML by appending to builder""" params = dict(SubjectKey=self.subject_key) params['mdsol:SubjectKeyType'] = self.subject_key_type if self.transaction_type is not None: params["TransactionType"] = self.transaction_type # mixins ...
Can you create a Python 3 function that builds the SubjectData XML by appending to builder
As a Python code translator, you convert algorithms and pseudocode into Python.
def build(self, builder): """Build XML by appending to builder :Example: <StudyEventData StudyEventOID="SCREENING" StudyEventRepeatKey="1" TransactionType="Update"> """ params = dict(StudyEventOID=self.study_event_oid) if self.transaction_type is not None: p...
Can you create a Python 3 function that builds an XML string by appending to builder
As a Python code composer, you craft elegant and concise scripts.
def build(self, builder): """Build XML by appending to builder :Example: <FormData FormOID="MH" TransactionType="Update"> """ params = dict(FormOID=self.formoid) if self.transaction_type is not None: params["TransactionType"] = self.transaction_type ...
Can you write a function in Python 3 where it builds XML by appending to builder
As a Python code composer, you craft elegant and concise scripts.
Builds the XML by appending to builder
Make a summary of the following Python 3 code def build(self, builder, formname=None): params = dict(ItemGroupOID=formname if formname else self.itemgroupoid) if self.transaction_type is not None: params["TransactionType"] = self.transaction_type if self.item_group_repeat_key is n...
As a Python code translator, you convert algorithms and pseudocode into Python.
Builds the XML by appending to the given XML builder.
Can you tell what is the following Python 3 function doing def build(self, builder): params = dict(ItemOID=self.itemoid) if self.transaction_type is not None: params["TransactionType"] = self.transaction_type if self.value in [None, '']: params['IsNull'] = 'Yes' ...
You are a Python code generator, capable of creating scripts from specifications.
Builds the contents of this object into the XML builder.
How would you explain what the following Python 3 function does def build(self, builder): params = {} if self.signature_id is not None: # If a Signature element is contained within a Signatures element, the ID attribute is required. params['ID'] = self.signature_id buil...
As a python code expert, you are capable of creating scripts from specifications.
Set the ID for this object.
Can you generate a brief explanation for the following Python 3 code def annotation_id(self, value): if value in [None, ''] or str(value).strip() == '': raise AttributeError("Invalid ID value supplied") self._id = value
As a Python code translator, you convert algorithms and pseudocode into Python.
Set the SeqNum of the object for this object.
Explain what the following Python 3 code does def seqnum(self, value): if not re.match(r'\d+', str(value)) or value < 0: raise AttributeError("Invalid SeqNum value supplied") self._seqnum = value
As a Python code analyst, you investigate and solve complex coding mysteries
def build(self, builder): """ Build XML by appending to builder """ params = {} # Add in the transaction type if self.transaction_type is not None: params["TransactionType"] = self.transaction_type if self.seqnum is None: # SeqNum is not ...
How would you implement a function in Python 3 that builds the XML by appending to the given XML builder.
You are a Python code analyst, evaluating scripts for potential improvements.
def build(self, builder): """ Build XML by appending to builder """ builder.start("Annotations") # populate the flags for annotation in self.annotations: annotation.build(builder) builder.end("Annotations")
Write a Python 3 script for building the XML by appending it to the given XML builder.
You are a Python code generator, capable of creating scripts from specifications.
def text(self, value): """Set Text content for Comment (validation of input)""" if value in (None, '') or value.strip() == "": raise AttributeError("Empty text value is invalid.") self._text = value
Write a Python 3 function that can set the text content for Comment
You are a Python code generator, capable of creating scripts from specifications.
Set Originator with validation of input
Given the following Python 3 function, write the documentation def sponsor_or_site(self, value): if value not in Comment.VALID_SPONSOR_OR_SITE_RESPONSES: raise AttributeError("%s sponsor_or_site value of %s is not valid" % (self.__class__.__name__, ...
You are a Python code generator, capable of creating scripts from specifications.
Builds the XML by appending to builder
Given the following Python 3 function, write the documentation def build(self, builder): if self.text is None: raise ValueError("Text is not set.") params = {} if self.sponsor_or_site is not None: params['SponsorOrSite'] = self.sponsor_or_site builder.start("Comm...
As a Python code composer, you craft elegant and concise scripts.
def build(self, builder): """ Build XML by appending to builder """ builder.start("Flag", {}) if self.flag_type is not None: self.flag_type.build(builder) if self.flag_value is None: raise ValueError('FlagValue is not set.') self.flag_val...
Implement a Python 3 function for building the object into an XML string.
As a Python code analyst, you investigate and solve complex coding mysteries
def build(self, builder): """ Build XML by appending to builder """ if self.codelist_oid is None: raise ValueError("CodeListOID not set.") builder.start("FlagValue", dict(CodeListOID=self.codelist_oid)) builder.data(self.flag_value) builder.end("FlagVa...
Can you create a Python 3 function that builds the object to XML by appending it to the given XML builder.
As a Python code composer, you craft elegant and concise scripts.
def build(self, builder): """ Build XML by appending to builder """ builder.start("UserRef", dict(UserOID=self.oid)) builder.end("UserRef")
Create a Python 3 function to build the ASN. 1 User Ref element into the given XML builder.
As a Python code translator, you convert algorithms and pseudocode into Python.
Build an XML string representing this object into the given XML builder.
Can you generate a brief explanation for the following Python 3 code def build(self, builder): builder.start("LocationRef", dict(LocationOID=str(self.oid))) builder.end("LocationRef")
You are a Python code analyst, evaluating scripts for potential improvements.
def build(self, builder): """ Build XML by appending to builder """ params = dict(LocationOID=self.oid) # mixins self.mixin() self.mixin_params(params) builder.start("SiteRef", params) builder.end("SiteRef")
Write a Python 3 function for building the XML by appending to builder
As a Python code translator, you convert algorithms and pseudocode into Python.
Build the XML for this object into the given builder.
Explain what the following Python 3 code does def build(self, builder): builder.start("SignatureRef", dict(SignatureOID=self.oid)) builder.end("SignatureRef")
As a python code expert, you are capable of creating scripts from specifications.
def build(self, builder): """ Build XML by appending to builder """ builder.start("ReasonForChange", {}) builder.data(self.reason) builder.end("ReasonForChange")
Write a Python 3 function for building the XML description of this object into the given XML builder.
As a python code expert, you are capable of creating scripts from specifications.
Builds the ISO - 8601 date time entry into the XML builder.
Can you tell what is the following Python 3 function doing def build(self, builder): builder.start("DateTimeStamp", {}) if isinstance(self.date_time, datetime): builder.data(dt_to_iso8601(self.date_time)) else: builder.data(self.date_time) builder.end("DateTimeSta...
As a Python code analyst, you investigate and solve complex coding mysteries