code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def gen_source(self, ast, name, customize, is_lambda=False, returnNone=False): rn = self.return_none self.return_none = returnNone old_name = self.name self.name = name if len(ast) == 0: self.println(self.indent, 'pass') else: self.customize(customize) if is_lambda: self.write(self.traverse(ast, is_lambda=is_lambda)) else: self.text = self.traverse(ast, is_lambda=is_lambda) self.println(self.text) self.name = old_name self.return_none = rn
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier false default_parameter identifier false block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
convert SyntaxTree to Python source code
def OnMouse( self, event ): node = HotMapNavigator.findNodeAtPosition(self.hot_map, event.GetPosition()) self.SetHighlight( node, event.GetPosition() )
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list
Handle mouse-move event by selecting a given element
def check_sim_out(self): now = time.time() if now - self.last_sim_send_time < 0.02 or self.rc_channels_scaled is None: return self.last_sim_send_time = now servos = [] for ch in range(1,9): servos.append(self.scale_channel(ch, getattr(self.rc_channels_scaled, 'chan%u_scaled' % ch))) servos.extend([0,0,0, 0,0,0]) buf = struct.pack('<14H', *servos) try: self.sim_out.send(buf) except socket.error as e: if not e.errno in [ errno.ECONNREFUSED ]: raise return
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator binary_operator identifier attribute identifier identifier float comparison_operator attribute identifier identifier none block return_statement expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier list for_statement identifier call identifier argument_list integer integer block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call identifier argument_list attribute identifier identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list list integer integer integer integer integer integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list_splat identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block if_statement not_operator comparison_operator attribute identifier identifier list attribute identifier identifier block raise_statement return_statement
check if we should send new servos to flightgear
def pip_remove(self, name=None, prefix=None, pkgs=None): logger.debug(str((prefix, pkgs))) if isinstance(pkgs, (list, tuple)): pkg = ' '.join(pkgs) else: pkg = pkgs extra_args = ['uninstall', '--yes', pkg] return self._call_pip(name=name, prefix=prefix, extra_args=extra_args)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement call attribute identifier identifier argument_list call identifier argument_list tuple identifier identifier if_statement call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Remove a pip package in given environment by `name` or `prefix`.
def _ir_calibrate(self, data): fk1 = float(self["planck_fk1"]) fk2 = float(self["planck_fk2"]) bc1 = float(self["planck_bc1"]) bc2 = float(self["planck_bc2"]) res = (fk2 / xu.log(fk1 / data + 1) - bc1) / bc2 res.attrs = data.attrs res.attrs['units'] = 'K' res.attrs['standard_name'] = 'toa_brightness_temperature' return res
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier call attribute identifier identifier argument_list binary_operator binary_operator identifier identifier integer identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier
Calibrate IR channels to BT.
def mouse_press_event(self, x, y, button): if button == 1: print("Left mouse button pressed @", x, y) if button == 2: print("Right mouse button pressed @", x, y)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier integer block expression_statement call identifier argument_list string string_start string_content string_end identifier identifier if_statement comparison_operator identifier integer block expression_statement call identifier argument_list string string_start string_content string_end identifier identifier
Reports left and right mouse button presses + position
def _file_local_list(self, dest): if os.path.isdir(dest): destdir = dest else: destdir = os.path.dirname(dest) filelist = set() for root, dirs, files in salt.utils.path.os_walk(destdir, followlinks=True): for name in files: path = os.path.join(root, name) filelist.add(path) return filelist
module function_definition identifier parameters identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier keyword_argument identifier true block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Helper util to return a list of files in a directory
def start(self): if self.stream is None: from pyaudio import PyAudio, paInt16 self.pa = PyAudio() self.stream = self.pa.open( 16000, 1, paInt16, True, frames_per_buffer=self.chunk_size ) self._wrap_stream_read(self.stream) self.engine.start() self.running = True self.is_paused = False self.thread = Thread(target=self._handle_predictions) self.thread.daemon = True self.thread.start()
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block import_from_statement dotted_name identifier dotted_name identifier dotted_name identifier expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list integer integer identifier true keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list
Start listening from stream
def str2listtuple(self, string_message): "Covert a string that is ready to be sent to graphite into a tuple" if type(string_message).__name__ not in ('str', 'unicode'): raise TypeError("Must provide a string or unicode") if not string_message.endswith('\n'): string_message += "\n" tpl_list = [] for line in string_message.split('\n'): line = line.strip() if not line: continue path, metric, timestamp = (None, None, None) try: (path, metric, timestamp) = line.split() except ValueError: raise ValueError( "message must contain - metric_name, value and timestamp '%s'" % line) try: timestamp = float(timestamp) except ValueError: raise ValueError("Timestamp must be float or int") tpl_list.append((path, (timestamp, metric))) if len(tpl_list) == 0: raise GraphiteSendException("No messages to send") payload = pickle.dumps(tpl_list) header = struct.pack("!L", len(payload)) message = header + payload return message
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement comparison_operator attribute call identifier argument_list identifier identifier tuple string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block continue_statement expression_statement assignment pattern_list identifier identifier identifier tuple none none none try_statement block expression_statement assignment tuple_pattern identifier identifier identifier call attribute identifier identifier argument_list except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list tuple identifier tuple identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier identifier return_statement identifier
Covert a string that is ready to be sent to graphite into a tuple
def append(self, item): validated_value = self.get_validated_object(item) if validated_value is not None: self.__modified_data__.append(validated_value)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Appending elements to our list
def trace(msg): if os.environ.get('JARN_TRACE') == '1': print('TRACE:', msg, file=sys.stderr)
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier attribute identifier identifier
Print a trace message to stderr if environment variable is set.
def agents(): print 'The following LiveSync agents are active:' agent_list = LiveSyncAgent.find().order_by(LiveSyncAgent.backend_name, db.func.lower(LiveSyncAgent.name)).all() table_data = [['ID', 'Name', 'Backend', 'Initial Export', 'Queue']] for agent in agent_list: initial = (cformat('%{green!}done%{reset}') if agent.initial_data_exported else cformat('%{yellow!}pending%{reset}')) if agent.backend is None: backend_title = cformat('%{red!}invalid backend ({})%{reset}').format(agent.backend_name) else: backend_title = agent.backend.title table_data.append([unicode(agent.id), agent.name, backend_title, initial, unicode(agent.queue.filter_by(processed=False).count())]) table = AsciiTable(table_data) table.justify_columns[4] = 'right' print table.table if not all(a.initial_data_exported for a in agent_list): print print "You need to perform the initial data export for some agents." print cformat("To do so, run " "%{yellow!}indico livesync initial_export %{reset}%{yellow}<agent_id>%{reset} for those agents.")
module function_definition identifier parameters block print_statement string string_start string_content string_end expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier argument_list expression_statement assignment identifier list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier parenthesized_expression conditional_expression call identifier argument_list string string_start string_content string_end attribute identifier identifier call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute call identifier argument_list string string_start string_content string_end identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list list call identifier argument_list attribute identifier identifier attribute identifier identifier identifier identifier call identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier false identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier integer string string_start string_content string_end print_statement attribute identifier identifier if_statement not_operator call identifier generator_expression attribute identifier identifier for_in_clause identifier identifier block expression_statement identifier print_statement string string_start string_content string_end print_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end
Lists the currently active agents
def print_unfinished_line(self): if self.state is STATE_RUNNING: if not callbacks.process(self.read_buffer): self.print_lines(self.read_buffer) self.read_buffer = b''
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier identifier block if_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier string string_start string_end
The unfinished line stayed long enough in the buffer to be printed
def keys(self): keys = [] for val in self.form.scales.values(): keys += val.dtype.fields.keys() return keys
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement augmented_assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list return_statement identifier
List of reader's keys.
def match(self, chars): start_index = self.next_index for char in self: if char not in chars: self.next_index -= 1 break return self[start_index:self.next_index]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer break_statement return_statement subscript identifier slice identifier attribute identifier identifier
Return all next characters that are listed in `chars` as a string
async def async_init(self) -> None: if not self._client_established: await self.request( 'put', 'clients/{0}'.format(self.client_uuid), data={ 'app_id': DEFAULT_APP_ID, 'app_version': DEFAULT_APP_VERSION, 'locale': self._locale }) self._client_established = True resp = await self.request( 'post', 'clients/{0}/sessions'.format(self.client_uuid), data={ 'email': self._email, 'password': self._password }) if not self.user_uuid: self.user_uuid = resp['result']['user']['user_uuid'] self._session_expiry = resp['result']['session_expiration_timestamp'] self.tiles = Tile(self.request, self.user_uuid)
module function_definition identifier parameters identifier type none block if_statement not_operator attribute identifier identifier block expression_statement await call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier true expression_statement assignment identifier await call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier
Create a Tile session.
def _getLPA( self ): " Provides line, pos and absPosition line as string " return str( self.line ) + ":" + \ str( self.pos ) + ":" + \ str( self.absPosition )
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end return_statement binary_operator binary_operator binary_operator binary_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end line_continuation call identifier argument_list attribute identifier identifier string string_start string_content string_end line_continuation call identifier argument_list attribute identifier identifier
Provides line, pos and absPosition line as string
def sshpull(host, maildir, localmaildir, noop=False, verbose=False, filterfile=None): store = _SSHStore(host, maildir) _pull(store, localmaildir, noop, verbose, filterfile)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false default_parameter identifier false default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier identifier identifier identifier identifier
Pull a remote maildir to the local one.
def derive_resource_name(name): if name.startswith("Anon"): name = name[4:] if name.endswith("Handler"): name = name[:-7] if name == "Maas": name = "MAAS" return name
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice integer if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice unary_operator integer if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end return_statement identifier
A stable, human-readable name and identifier for a resource.
def _bsecurate_cli_get_reader_formats(args): all_formats = curate.get_reader_formats() if args.no_description: liststr = all_formats.keys() else: liststr = format_columns(all_formats.items()) return '\n'.join(liststr)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
Handles the get-file-types subcommand
def update_topic_counter(sender, topic, user, request, response, **kwargs): topic.__class__._default_manager.filter(id=topic.id).update(views_count=F('views_count') + 1)
module function_definition identifier parameters identifier identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier identifier argument_list keyword_argument identifier binary_operator call identifier argument_list string string_start string_content string_end integer
Handles the update of the views counter associated with topics.
def _onInstanceAttribute(self, name, line, pos, absPosition, level): attributes = self.objectsStack[level - 1].instanceAttributes for item in attributes: if item.name == name: return attributes.append(InstanceAttribute(name, line, pos, absPosition))
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier attribute subscript attribute identifier identifier binary_operator identifier integer identifier for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier identifier
Memorizes a class instance attribute
def to_dict(self): d = super(TargetPort, self).to_dict() d['portName'] = self.port_name return d
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier
Save this target port into a dictionary.
def take_column(self, keys, *extra_keys): import utool as ut keys = ut.ensure_iterable(keys) + list(extra_keys) key_to_list = ut.dict_subset(self._key_to_list, keys) newself = self.__class__(key_to_list, self._meta.copy()) return newself
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list return_statement identifier
Takes a subset of columns
def restore_checkpoint(filename): with gzip.open(filename) as f: generation, config, population, species_set, rndstate = pickle.load(f) random.setstate(rndstate) return Population(config, (population, species_set, generation))
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier as_pattern_target identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier tuple identifier identifier identifier
Resumes the simulation from a previous saved point.
def start_stress(self, stress_cmd): with open(os.devnull, 'w') as dev_null: try: stress_proc = subprocess.Popen(stress_cmd, stdout=dev_null, stderr=dev_null) self.set_stress_process(psutil.Process(stress_proc.pid)) except OSError: logging.debug("Unable to start stress")
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Starts a new stress process with a given cmd
def _build_server_url(server_host, server_path) -> str: server_url = urljoin(server_host, server_path) if server_url[-1] == '/': return server_url return '{}/'.format(server_url)
module function_definition identifier parameters identifier identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator subscript identifier unary_operator integer string string_start string_content string_end block return_statement identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Build the server url making sure it ends in a trailing slash.
def x10_housecode(self): housecode = None if self.is_x10: housecode = insteonplm.utils.byte_to_housecode(self.addr[1]) return housecode
module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier integer return_statement identifier
Emit the X10 house code.
def add_to_path(p): old_path = sys.path if p not in sys.path: sys.path = sys.path[:] sys.path.insert(0, p) try: yield finally: sys.path = old_path
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice expression_statement call attribute attribute identifier identifier identifier argument_list integer identifier try_statement block expression_statement yield finally_clause block expression_statement assignment attribute identifier identifier identifier
Adds a path to python paths and removes it after the 'with' block ends
def backup(self): count = 0 name = "{}.bkp".format(self.filename) backup = os.path.join(self.cwd, name) while os.path.exists(backup): count += 1 name = "{}.bkp{}".format(self.filename, count) backup = os.path.join(self.cwd, name) self.hey("Moving existing {} to {}".format(self.filename, name)) os.rename(os.path.join(self.cwd, self.filename), backup)
module function_definition identifier parameters identifier block expression_statement assignment identifier integer expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier while_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement augmented_assignment identifier integer expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier
Backups files with the same name of the instance filename
def on_change(self, value): self._modifier(self.inst, self.prop, value)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier
Calles modifier on instance with passed value
def labels(self, text=None, coordinates=None, colorlist=None, sizes=None, fonts=None, opacity=1.0): if coordinates is None: coordinates=self.coordinates l=len(coordinates) if text is None: if len(self.topology.get('atom_types'))==l: text=[self.topology['atom_types'][i]+str(i+1) for i in range(l)] else: text=[str(i+1) for i in range(l)] text_representation = self.add_representation('text', {'coordinates': coordinates, 'text': text, 'colors': colorlist, 'sizes': sizes, 'fonts': fonts, 'opacity': opacity}) def update(self=self, text_representation=text_representation): self.update_representation(text_representation, {'coordinates': coordinates}) self.update_callbacks.append(update)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier float block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block if_statement comparison_operator call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier list_comprehension binary_operator subscript subscript attribute identifier identifier string string_start string_content string_end identifier call identifier argument_list binary_operator identifier integer for_in_clause identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier list_comprehension call identifier argument_list binary_operator identifier integer for_in_clause identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier function_definition identifier parameters default_parameter identifier identifier default_parameter identifier identifier block expression_statement call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Display atomic labels for the system
def declare(queues): current_queues.declare(queues=queues) click.secho( 'Queues {} have been declared.'.format( queues or current_queues.queues.keys()), fg='green' )
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list boolean_operator identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end
Initialize the given queues.
def _validated(self, data): try: return self.convert(data) except (TypeError, ValueError) as ex: raise NotValid(*ex.args)
module function_definition identifier parameters identifier identifier block try_statement block return_statement call attribute identifier identifier argument_list identifier except_clause as_pattern tuple identifier identifier as_pattern_target identifier block raise_statement call identifier argument_list list_splat attribute identifier identifier
Convert data or die trying.
def gui(): sel = psidialogs.multi_choice(libraries(), 'select libraries to remove from %s!' % libraries_dir(), title='remove boards') print('%s selected' % sel) if sel: if psidialogs.ask_yes_no('Do you really want to remove selected libraries?\n' + '\n'.join(sel)): for x in sel: remove_lib(x) print('%s was removed' % x)
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement identifier block if_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
remove libraries by GUI.
def merge_from(self, other): if other.country_code is not None: self.country_code = other.country_code if other.national_number is not None: self.national_number = other.national_number if other.extension is not None: self.extension = other.extension if other.italian_leading_zero is not None: self.italian_leading_zero = other.italian_leading_zero if other.number_of_leading_zeros is not None: self.number_of_leading_zeros = other.number_of_leading_zeros if other.raw_input is not None: self.raw_input = other.raw_input if other.country_code_source is not CountryCodeSource.UNSPECIFIED: self.country_code_source = other.country_code_source if other.preferred_domestic_carrier_code is not None: self.preferred_domestic_carrier_code = other.preferred_domestic_carrier_code
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier attribute identifier identifier
Merge information from another PhoneNumber object into this one.
def jinja_extensions_feature(app): app.jinja_env.globals['momentjs'] = MomentJsFilters app.jinja_env.filters.update(MomentJsFilters().get_filters()) app.jinja_env.filters.update(DateFilters().get_filters()) app.jinja_env.filters.update(HumanizeFilters().get_filters()) app.jinja_env.globals.update(dict( asset=functions.asset, dev_proxy=functions.dev_proxy ))
module function_definition identifier parameters identifier block expression_statement assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute call identifier argument_list identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute call identifier argument_list identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute call identifier argument_list identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Enables custom templating extensions
def folder2db(folder_name, debug, energy_limit, skip_folders, goto_reaction): folder_name = folder_name.rstrip('/') skip = [] for s in skip_folders.split(', '): for sk in s.split(','): skip.append(sk) pub_id = _folder2db.main(folder_name, debug, energy_limit, skip, goto_reaction) if pub_id: print('') print('') print('Ready to release the data?') print( " Send it to the Catalysis-Hub server with 'cathub db2server {folder_name}/{pub_id}.db'.".format(**locals())) print(" Then log in at www.catalysis-hub.org/upload/ to verify and release. ")
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier if_statement identifier block expression_statement call identifier argument_list string string_start string_end expression_statement call identifier argument_list string string_start string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list dictionary_splat call identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end
Read folder and collect data in local sqlite3 database
def atlas_node_stop( atlas_state ): for component in atlas_state.keys(): log.debug("Stopping Atlas component '%s'" % component) atlas_state[component].ask_join() atlas_state[component].join() return True
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute subscript identifier identifier identifier argument_list expression_statement call attribute subscript identifier identifier identifier argument_list return_statement true
Stop the atlas node threads
def upsert_result(client_site_url, apikey, resource_id, result): url = client_site_url + u"deadoralive/upsert" params = result.copy() params["resource_id"] = resource_id requests.post(url, headers=dict(Authorization=apikey), params=params)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Post the given link check result to the client site.
def gen_sites(path): " Seek sites by path. " for root, _, _ in walklevel(path, 2): try: yield Site(root) except AssertionError: continue
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end for_statement pattern_list identifier identifier identifier call identifier argument_list identifier integer block try_statement block expression_statement yield call identifier argument_list identifier except_clause identifier block continue_statement
Seek sites by path.
def _map_query_path_to_outputs(construct_result, query_path_to_location_info): query_path_to_output_fields = {} for output_name, field in six.iteritems(construct_result.fields): field_name = field.location.field output_query_path = field.location.query_path output_field_info = constants.SqlOutput( field_name=field_name, output_name=output_name, graphql_type=query_path_to_location_info[output_query_path].type) output_field_mapping = query_path_to_output_fields.setdefault(output_query_path, []) output_field_mapping.append(output_field_info) return query_path_to_output_fields
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute subscript identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier list expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Assign the output fields of a ConstructResult block to their respective query_path.
def table_ensure(cls, rr): dbs = rr.db_list().run() if not rr.dbname in dbs: logging.info('creating rethinkdb database %s', repr(rr.dbname)) rr.db_create(rr.dbname).run() tables = rr.table_list().run() if not cls.table in tables: logging.info( 'creating rethinkdb table %s in database %s', repr(cls.table), repr(rr.dbname)) cls.table_create(rr)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement not_operator comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement not_operator comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Creates the table if it doesn't exist.
def update_admin_object_resource(name, server=None, **kwargs): if 'jndiName' in kwargs: del kwargs['jndiName'] return _update_element(name, 'resources/admin-object-resource', kwargs, server)
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator string string_start string_content string_end identifier block delete_statement subscript identifier string string_start string_content string_end return_statement call identifier argument_list identifier string string_start string_content string_end identifier identifier
Update a JMS destination
def init1(self, dae): self.v0 = matrix(dae.y[self.v])
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list subscript attribute identifier identifier attribute identifier identifier
Set initial voltage for time domain simulation
def _iter_over_selections(obj, dim, values): from .groupby import _dummy_copy dummy = None for value in values: try: obj_sel = obj.sel(**{dim: value}) except (KeyError, IndexError): if dummy is None: dummy = _dummy_copy(obj) obj_sel = dummy yield obj_sel
module function_definition identifier parameters identifier identifier identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier none for_statement identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat dictionary pair identifier identifier except_clause tuple identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier identifier expression_statement yield identifier
Iterate over selections of an xarray object in the provided order.
def create_lzma(archive, compression, cmd, verbosity, interactive, filenames): return _create(archive, compression, cmd, 'alone', verbosity, filenames)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block return_statement call identifier argument_list identifier identifier identifier string string_start string_content string_end identifier identifier
Create an LZMA archive with the lzma Python module.
def _setup(self): default_settings.reload() environment_variable = self._kwargs.get( "ENVVAR_FOR_DYNACONF", default_settings.ENVVAR_FOR_DYNACONF ) settings_module = os.environ.get(environment_variable) self._wrapped = Settings( settings_module=settings_module, **self._kwargs ) self.logger.debug("Lazy Settings _setup ...")
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier identifier dictionary_splat attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Initial setup, run once.
def delete(self, for_update=False): hash_key = self.get_hash_id() try: original_instance = self.load(hash_key, convert_key=False) except KeyError: return all_index = self._query.all_index() all_index.remove(hash_key) for field in self._indexes: for index in field.get_indexes(): index.remove(original_instance) if not for_update: for field in self._fields.values(): if isinstance(field, _ContainerField): field._delete(self) self.__database__.delete(hash_key)
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier false except_clause identifier block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Delete the given model instance.
def extract_images_generic(pike, root, log, options): jpegs = [] pngs = [] for _, xref, ext in extract_images(pike, root, log, options, extract_image_generic): log.debug('xref = %s ext = %s', xref, ext) if ext == '.png': pngs.append(xref) elif ext == '.jpg': jpegs.append(xref) log.debug("Optimizable images: JPEGs: %s PNGs: %s", len(jpegs), len(pngs)) return jpegs, pngs
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier call identifier argument_list identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier call identifier argument_list identifier return_statement expression_list identifier identifier
Extract any >=2bpp image we think we can improve
def spacings(self): result_invsq = (self.reciprocal**2).sum(axis=0) result = np.zeros(3, float) for i in range(3): if result_invsq[i] > 0: result[i] = result_invsq[i]**(-0.5) return result
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute parenthesized_expression binary_operator attribute identifier identifier integer identifier argument_list keyword_argument identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list integer identifier for_statement identifier call identifier argument_list integer block if_statement comparison_operator subscript identifier identifier integer block expression_statement assignment subscript identifier identifier binary_operator subscript identifier identifier parenthesized_expression unary_operator float return_statement identifier
Computes the distances between neighboring crystal planes
def remove_class(self, ioclass): current_ioclasses = self.ioclasses new_ioclasses = filter(lambda x: x.name != ioclass.name, current_ioclasses) self.modify(new_ioclasses=new_ioclasses)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier comparison_operator attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
Remove VNXIOClass instance from policy.
def count_channels(self): merge = self.index['merge'] if len(self.idx_chan.selectedItems()) > 1: if merge.isEnabled(): return else: merge.setEnabled(True) else: self.index['merge'].setCheckState(Qt.Unchecked) self.index['merge'].setEnabled(False)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list call attribute attribute identifier identifier identifier argument_list integer block if_statement call attribute identifier identifier argument_list block return_statement else_clause block expression_statement call attribute identifier identifier argument_list true else_clause block expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list false
If more than one channel selected, activate merge checkbox.
def _dict_increment(self, dictionary, key): if key in dictionary: dictionary[key] += 1 else: dictionary[key] = 1
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier identifier block expression_statement augmented_assignment subscript identifier identifier integer else_clause block expression_statement assignment subscript identifier identifier integer
Increments the value of the dictionary at the specified key.
def adj_nodes_ali(ali_nodes): for node in ali_nodes: node.cloud = "alicloud" node.cloud_disp = "AliCloud" node.private_ips = ip_to_str(node.extra['vpc_attributes']['private_ip_address']) node.public_ips = ip_to_str(node.public_ips) node.zone = node.extra['zone_id'] node.size = node.extra['instance_type'] if node.size.startswith('ecs.'): node.size = node.size[len('ecs.'):] return ali_nodes
module function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice call identifier argument_list string string_start string_content string_end return_statement identifier
Adjust details specific to AliCloud.
def move(self, dst): "Closes then moves the file to dst." self.close() shutil.move(self.path, dst)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
Closes then moves the file to dst.
def NotifyAboutEnd(self): flow_ref = None if self.runner_args.client_id: flow_ref = rdf_objects.FlowReference( client_id=self.client_id, flow_id=self.urn.Basename()) num_results = len(self.ResultCollection()) notification_lib.Notify( self.creator, rdf_objects.UserNotification.Type.TYPE_FLOW_RUN_COMPLETED, "Flow %s completed with %d %s" % (self.__class__.__name__, num_results, num_results == 1 and "result" or "results"), rdf_objects.ObjectReference( reference_type=rdf_objects.ObjectReference.Type.FLOW, flow=flow_ref))
module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier binary_operator string string_start string_content string_end tuple attribute attribute identifier identifier identifier identifier boolean_operator boolean_operator comparison_operator identifier integer string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier keyword_argument identifier identifier
Send out a final notification about the end of this flow.
def use_comparative_objective_view(self): self._object_views['objective'] = COMPARATIVE for session in self._get_provider_sessions(): try: session.use_comparative_objective_view() except AttributeError: pass
module function_definition identifier parameters identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement
Pass through to provider ObjectiveLookupSession.use_comparative_objective_view
def word_under_cursor_pos(self): self._vim.command('normal e') end = self.cursor() self._vim.command('normal b') beg = self.cursor() return beg, end
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list return_statement expression_list identifier identifier
Return start and end positions of the cursor respectively.
def log_assist_request_without_audio(assist_request): if logging.getLogger().isEnabledFor(logging.DEBUG): resp_copy = embedded_assistant_pb2.AssistRequest() resp_copy.CopyFrom(assist_request) if len(resp_copy.audio_in) > 0: size = len(resp_copy.audio_in) resp_copy.ClearField('audio_in') logging.debug('AssistRequest: audio_in (%d bytes)', size) return logging.debug('AssistRequest: %s', resp_copy)
module function_definition identifier parameters identifier block if_statement call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Log AssistRequest fields without audio data.
def dismissWorkers(self, num_workers): for i in range(min(num_workers, len(self.workers))): worker = self.workers.pop() worker.dismiss()
module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list call identifier argument_list identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Tell num_workers worker threads to quit after their current task.
def start(self): if (self.cf.link is not None): if (self._added is False): self.create() logger.debug('First time block is started, add block') else: logger.debug('Block already registered, starting logging' ' for id=%d', self.id) pk = CRTPPacket() pk.set_header(5, CHAN_SETTINGS) pk.data = (CMD_START_LOGGING, self.id, self.period) self.cf.send_packet(pk, expected_reply=( CMD_START_LOGGING, self.id))
module function_definition identifier parameters identifier block if_statement parenthesized_expression comparison_operator attribute attribute identifier identifier identifier none block if_statement parenthesized_expression comparison_operator attribute identifier identifier false block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list integer identifier expression_statement assignment attribute identifier identifier tuple identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier tuple identifier attribute identifier identifier
Start the logging for this entry
async def _connect(self): self.waiting = True await self.client.start(self.ip) self.waiting = False if self.client.protocol is None: raise IOError("Could not connect to '{}'.".format(self.ip)) self.open = True
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier true expression_statement await call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier false if_statement comparison_operator attribute attribute identifier identifier identifier none block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier true
Start asynchronous reconnect loop.
def rastrigin(self, x): if not isscalar(x[0]): N = len(x[0]) return [10 * N + sum(xi**2 - 10 * np.cos(2 * np.pi * xi)) for xi in x] N = len(x) return 10 * N + sum(x**2 - 10 * np.cos(2 * np.pi * x))
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list subscript identifier integer block expression_statement assignment identifier call identifier argument_list subscript identifier integer return_statement list_comprehension binary_operator binary_operator integer identifier call identifier argument_list binary_operator binary_operator identifier integer binary_operator integer call attribute identifier identifier argument_list binary_operator binary_operator integer attribute identifier identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement binary_operator binary_operator integer identifier call identifier argument_list binary_operator binary_operator identifier integer binary_operator integer call attribute identifier identifier argument_list binary_operator binary_operator integer attribute identifier identifier identifier
Rastrigin test objective function
def _resolve(self): endpoints = {} r = self.resolver.query(self.service, 'SRV') for rec in r.response.additional: name = rec.name.to_text() addr = rec.items[0].address endpoints[name] = {'addr': addr} for rec in r.response.answer[0].items: name = '.'.join(rec.target.labels) endpoints[name]['port'] = rec.port return [ 'http://{ip}:{port}'.format( ip=v['addr'], port=v['port'] ) for v in endpoints.values() ]
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier attribute subscript attribute identifier identifier integer identifier expression_statement assignment subscript identifier identifier dictionary pair string string_start string_content string_end identifier for_statement identifier attribute subscript attribute attribute identifier identifier identifier integer identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment subscript subscript identifier identifier string string_start string_content string_end attribute identifier identifier return_statement list_comprehension call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end for_in_clause identifier call attribute identifier identifier argument_list
Query the consul DNS server for the service IP and port
def _http_date(_date_str: str) -> Optional[datetime.datetime]: if _date_str is not None: timetuple = parsedate(_date_str) if timetuple is not None: return datetime.datetime(*timetuple[:6], tzinfo=datetime.timezone.utc) return None
module function_definition identifier parameters typed_parameter identifier type identifier type generic_type identifier type_parameter type attribute identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block return_statement call attribute identifier identifier argument_list list_splat subscript identifier slice integer keyword_argument identifier attribute attribute identifier identifier identifier return_statement none
Process a date string, return a datetime object
def makeControlModePacket(ID, mode): pkt = makeWritePacket(ID, xl320.XL320_CONTROL_MODE, le(mode)) return pkt
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier call identifier argument_list identifier return_statement identifier
Sets the xl-320 to either servo or wheel mode
def to_attrs(args, nocreate_if_none=['id', 'for', 'class']): if not args: return '' s = [''] for k, v in sorted(args.items()): k = u_str(k) v = u_str(v) if k.startswith('_'): k = k[1:] if v is None: if k not in nocreate_if_none: s.append(k) else: if k.lower() in __noescape_attrs__: t = u_str(v) else: t = cgi.escape(u_str(v)) t = '"%s"' % t.replace('"', '&quot;') s.append('%s=%s' % (k, t)) return ' '.join(s)
module function_definition identifier parameters identifier default_parameter identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block if_statement not_operator identifier block return_statement string string_start string_end expression_statement assignment identifier list string string_start string_end for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice integer if_statement comparison_operator identifier none block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block if_statement comparison_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Make python dict to k="v" format
def versions(self): versions = [] for v, _ in self.restarts: if len(versions) == 0 or v != versions[-1]: versions.append(v) return versions
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier attribute identifier identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator identifier subscript identifier unary_operator integer block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return all version changes.
def sqrt(n): if isinstance(n, Rational): n = Constructible(n) elif not isinstance(n, Constructible): raise ValueError('the square root is not implemented for the type %s' % type(n)) r = n._try_sqrt() if r is not None: return r return Constructible(Constructible.lift_rational_field(0, n.field), Constructible.lift_rational_field(1, n.field), (n, n.field))
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier elif_clause not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block return_statement identifier return_statement call identifier argument_list call attribute identifier identifier argument_list integer attribute identifier identifier call attribute identifier identifier argument_list integer attribute identifier identifier tuple identifier attribute identifier identifier
return the square root of n in an exact representation
def callback(request): message_id = request.GET.get('messageId') status_id = request.GET.get('status') status_msg = NEXMO_STATUSES.get(status_id, UNKNOWN_STATUS) error_id = int(request.GET.get('err-code')) error_msg = NEXMO_MESSAGES.get(error_id, UNKNOWN_MESSAGE) logger.info(u'Nexmo callback: Sms = %s, Status = %s, message = %s' % ( message_id, status_msg, error_msg )) return HttpResponse('')
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier return_statement call identifier argument_list string string_start string_end
Callback URL for Nexmo.
def form_valid(self, form): response = self.ulogin_response(form.cleaned_data['token'], self.request.get_host()) if 'error' in response: return render(self.request, self.error_template_name, {'json': response}) if user_is_authenticated(get_user(self.request)): user, identity, registered = \ self.handle_authenticated_user(response) else: user, identity, registered = \ self.handle_anonymous_user(response) assign.send(sender=ULoginUser, user=get_user(self.request), request=self.request, registered=registered, ulogin_user=identity, ulogin_data=response) return redirect(self.request.GET.get(REDIRECT_FIELD_NAME) or '/')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier dictionary pair string string_start string_content string_end identifier if_statement call identifier argument_list call identifier argument_list attribute identifier identifier block expression_statement assignment pattern_list identifier identifier identifier line_continuation call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment pattern_list identifier identifier identifier line_continuation call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call identifier argument_list boolean_operator call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end
The request from ulogin service is correct
def find(self, entry_id, query=None): if query is None: query = {} if self.content_type_id is not None: query['content_type'] = self.content_type_id normalize_select(query) return super(EntriesProxy, self).find(entry_id, query=query)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier keyword_argument identifier identifier
Gets a single entry by ID.
def incrementSub(self, amount=1): self._subProgressBar.setValue(self.subValue() + amount) QApplication.instance().processEvents()
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator call attribute identifier identifier argument_list identifier expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list
Increments the sub-progress bar by amount.
def parse(cls, key): try: if isinstance(key, int): return key elif re.match('[<]KEY_.*[>]', key): return getattr(curses, key[1:-1]) elif re.match('[<].*[>]', key): return getattr(curses.ascii, key[1:-1]) elif key.startswith('0x'): return int(key, 16) elif len(key) == 2: return tuple(cls.parse(k) for k in key) else: code = ord(key) if 0 <= code <= 255: return code raise exceptions.ConfigError('Invalid configuration! `%s` is ' 'not in the ascii range' % key) except (AttributeError, ValueError, TypeError): raise exceptions.ConfigError('Invalid configuration! "%s" is not a ' 'valid key' % key)
module function_definition identifier parameters identifier identifier block try_statement block if_statement call identifier argument_list identifier identifier block return_statement identifier elif_clause call attribute identifier identifier argument_list string string_start string_content string_end identifier block return_statement call identifier argument_list identifier subscript identifier slice integer unary_operator integer elif_clause call attribute identifier identifier argument_list string string_start string_content string_end identifier block return_statement call identifier argument_list attribute identifier identifier subscript identifier slice integer unary_operator integer elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call identifier argument_list identifier integer elif_clause comparison_operator call identifier argument_list identifier integer block return_statement call identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator integer identifier integer block return_statement identifier raise_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier except_clause tuple identifier identifier identifier block raise_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier
Parse a key represented by a string and return its character code.
def connect(self, **kwargs): try: self.gce = get_driver(Provider.GCE)( self.user_id, self.key, project=self.project, **kwargs) except: raise ComputeEngineManagerException("Unable to connect to Google Compute Engine.")
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block try_statement block expression_statement assignment attribute identifier identifier call call identifier argument_list attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier dictionary_splat identifier except_clause block raise_statement call identifier argument_list string string_start string_content string_end
Connect to Google Compute Engine.
def get(cls, name, definition, output_dir): if 'url' in definition: return URLResource(name, definition, output_dir) elif 'pypi' in definition: return PyPIResource(name, definition, output_dir) else: return Resource(name, definition, output_dir)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block return_statement call identifier argument_list identifier identifier identifier elif_clause comparison_operator string string_start string_content string_end identifier block return_statement call identifier argument_list identifier identifier identifier else_clause block return_statement call identifier argument_list identifier identifier identifier
Dispatch to the right subclass based on the definition.
def done(self): logger.info('Marking %s as done', self) fn = self.get_path() try: os.makedirs(os.path.dirname(fn)) except OSError: pass open(fn, 'w').close()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block pass_statement expression_statement call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list
Creates temporary file to mark the task as `done`
def avl_release_kids(node): left, right = node.left, node.right if left is not None: left.parent = None if right is not None: right.parent = None node.balance = 0 node.left = None node.right = None return node, left, right
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier none if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none return_statement expression_list identifier identifier identifier
splits a node from its kids maintaining parent pointers
def match(self, name): for pat in self.pats: if fnmatch.fnmatch(name, pat): return True return False
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list identifier identifier block return_statement true return_statement false
Returns True if name matches one of the patterns.
def find_gui_and_backend(): matplotlib = sys.modules['matplotlib'] backend = matplotlib.rcParams['backend'] gui = backend2gui.get(backend, None) return gui, backend
module function_definition identifier parameters block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier none return_statement expression_list identifier identifier
Return the gui and mpl backend.
def joined(self, a, b): mapping = self._mapping try: return mapping[a] is mapping[b] except KeyError: return False
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier try_statement block return_statement comparison_operator subscript identifier identifier subscript identifier identifier except_clause identifier block return_statement false
Returns True if a and b are members of the same set.
def _deduce_security(kwargs) -> nmcli.SECURITY_TYPES: sec_translation = { 'wpa-psk': nmcli.SECURITY_TYPES.WPA_PSK, 'none': nmcli.SECURITY_TYPES.NONE, 'wpa-eap': nmcli.SECURITY_TYPES.WPA_EAP, } if not kwargs.get('securityType'): if kwargs.get('psk') and kwargs.get('eapConfig'): raise ConfigureArgsError( 'Cannot deduce security type: psk and eap both passed') elif kwargs.get('psk'): kwargs['securityType'] = 'wpa-psk' elif kwargs.get('eapConfig'): kwargs['securityType'] = 'wpa-eap' else: kwargs['securityType'] = 'none' try: return sec_translation[kwargs['securityType']] except KeyError: raise ConfigureArgsError('securityType must be one of {}' .format(','.join(sec_translation.keys())))
module function_definition identifier parameters identifier type attribute identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end try_statement block return_statement subscript identifier subscript identifier string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list
Make sure that the security_type is known, or throw.
def output_file_name(self): safe_path = re.sub(r":|/", "_", self.source_urn.Path().lstrip("/")) return "results_%s%s" % (safe_path, self.output_file_extension)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end return_statement binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier
Name of the file where plugin's output should be written to.
def main(): p = argparse.ArgumentParser(add_help="Recursively list interesting files.") p.add_argument( 'directory', nargs="?", default="", help="The directory to process (current dir if omitted)." ) p.add_argument( '--verbose', '-v', action='store_true', help="Increase verbosity." ) args = p.parse_args() args.curdir = os.getcwd() if not args.directory: args.direcotry = args.curdir if args.verbose: print(args) for chsm, fname in list_files(args.directory): print(chsm, fname)
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement call identifier argument_list identifier identifier
Print checksum and file name for all files in the directory.
def xor(*variables): sum_ = False for value in variables: sum_ = sum_ ^ bool(value) return sum_
module function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment identifier false for_statement identifier identifier block expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier return_statement identifier
XOR definition for multiple variables
def job_file(self): job_file_name = '%s.job' % (self.name) job_file_path = os.path.join(self.initial_dir, job_file_name) self._job_file = job_file_path return self._job_file
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier
The path to the submit description file representing this job.
def collection(self, attribute): return { "dependencies": self.dependencies, "publics": self.publics, "members": self.members, "types": self.types, "executables": self.executables, "interfaces": self.interfaces }[attribute]
module function_definition identifier parameters identifier identifier block return_statement subscript dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier identifier
Returns the collection corresponding the attribute name.
def save_config(self): self.config_section['match_fuzzy'] = self.model_completer.match_fuzzy self.config_section['enable_vi_bindings'] = self.enable_vi_bindings self.config_section['show_completion_columns'] = \ self.show_completion_columns self.config_section['show_help'] = self.show_help self.config_section['theme'] = self.theme self.config_obj.write()
module function_definition identifier parameters identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end line_continuation attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Save the config to the config file.
def setTopRight(self, loc): offset = self.getTopRight().getOffset(loc) return self.setLocation(self.getTopLeft().offset(offset))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier return_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list identifier
Move this region so its top right corner is on ``loc``
def itermonthdays2(cls, year, month): for day in NepCal.itermonthdates(year, month): if day.month == month: yield (day.day, day.weekday()) else: yield (0, day.weekday())
module function_definition identifier parameters identifier identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement yield tuple attribute identifier identifier call attribute identifier identifier argument_list else_clause block expression_statement yield tuple integer call attribute identifier identifier argument_list
Similar to itermonthdays2 but returns tuples of day and weekday.
def send_rgb(dev, red, green, blue, dimmer): cv = [0 for v in range(0, 512)] cv[0] = red cv[1] = green cv[2] = blue cv[6] = dimmer sent = dev.send_multi_value(1, cv) return sent
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier list_comprehension integer for_in_clause identifier call identifier argument_list integer integer expression_statement assignment subscript identifier integer identifier expression_statement assignment subscript identifier integer identifier expression_statement assignment subscript identifier integer identifier expression_statement assignment subscript identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer identifier return_statement identifier
Send a set of RGB values to the light
def update(self, dist): assert isinstance(dist, DDist) for k, c in iteritems(dist.counts): self.counts[k] += c self.total += dist.total
module function_definition identifier parameters identifier identifier block assert_statement call identifier argument_list identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement augmented_assignment subscript attribute identifier identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier
Adds the given distribution's counts to the current distribution.
def _getSectionIds(self, server, sections): if not sections: return [] allSectionIds = {} machineIdentifier = server.machineIdentifier if isinstance(server, PlexServer) else server url = self.PLEXSERVERS.replace('{machineId}', machineIdentifier) data = self.query(url, self._session.get) for elem in data[0]: allSectionIds[elem.attrib.get('id', '').lower()] = elem.attrib.get('id') allSectionIds[elem.attrib.get('title', '').lower()] = elem.attrib.get('id') allSectionIds[elem.attrib.get('key', '').lower()] = elem.attrib.get('id') log.debug(allSectionIds) sectionIds = [] for section in sections: sectionKey = section.key if isinstance(section, LibrarySection) else section sectionIds.append(allSectionIds[sectionKey.lower()]) return sectionIds
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator identifier block return_statement list expression_statement assignment identifier dictionary expression_statement assignment identifier conditional_expression attribute identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute attribute identifier identifier identifier for_statement identifier subscript identifier integer block expression_statement assignment subscript identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier conditional_expression attribute identifier identifier call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list subscript identifier call attribute identifier identifier argument_list return_statement identifier
Converts a list of section objects or names to sectionIds needed for library sharing.
def _construct_module(info, target): for path in paths: real_path = os.path.abspath(os.path.join(target, path.format(**info))) log("Making directory '%s'" % real_path) os.makedirs(real_path) for item in templates.values(): source = os.path.join('dev/templates', item[0]) filename = os.path.abspath( os.path.join(target, item[1].format(**info))) log("Creating file from template '%s'" % filename, emitter='MANAGE') write_template_file(source, filename, info)
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end subscript identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier call attribute subscript identifier integer identifier argument_list dictionary_splat identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list identifier identifier identifier
Build a module from templates and user supplied information
def CreateUser(username, password=None, is_admin=False): grr_api = maintenance_utils.InitGRRRootAPI() try: user_exists = grr_api.GrrUser(username).Get() is not None except api_errors.ResourceNotFoundError: user_exists = False if user_exists: raise UserAlreadyExistsError("User '%s' already exists." % username) user_type, password = _GetUserTypeAndPassword( username, password=password, is_admin=is_admin) grr_api.CreateGrrUser( username=username, user_type=user_type, password=password)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier comparison_operator call attribute call attribute identifier identifier argument_list identifier identifier argument_list none except_clause attribute identifier identifier block expression_statement assignment identifier false if_statement identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Creates a new GRR user.
def send_up(self, count): for i in range(count): self.interface.send_key(Key.UP)
module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Sends the given number of up key presses.
def thumb(self, obj): format, created = Format.objects.get_or_create(name='newman_thumb', defaults={ 'max_width': 100, 'max_height': 100, 'flexible_height': False, 'stretch': False, 'nocrop': True, }) if created: format.sites = Site.objects.all() info = obj.get_formated_photo(format) return '<a href="%(href)s"><img src="%(src)s"></a>' % { 'href': '%s/' % obj.pk, 'src': info['url'] }
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end false pair string string_start string_content string_end false pair string string_start string_content string_end true if_statement identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement binary_operator string string_start string_content string_end dictionary pair string string_start string_content string_end binary_operator string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end subscript identifier string string_start string_content string_end
Generates html and thumbnails for admin site.
def unplug(self): if not self.__plugged: return members = set([method for _, method in inspect.getmembers(self, predicate=inspect.ismethod)]) for message in global_callbacks: global_callbacks[message] -= members self.__plugged = False
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment identifier call identifier argument_list list_comprehension identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier for_statement identifier identifier block expression_statement augmented_assignment subscript identifier identifier identifier expression_statement assignment attribute identifier identifier false
Remove the actor's methods from the callback registry.
def error_retry_codes(self, value): if isinstance(value, six.string_types): value = [int(x) for x in value.split(",")] self._set_option("error_retry_codes", value)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Set value for error_retry_codes.