code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def _param32(ins): output = _32bit_oper(ins.quad[1]) output.append('push de') output.append('push hl') return output
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_param32'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ins'}; {...
Pushes 32bit param into the stack
def lang_match_json(row, hdr, accepted_languages): if not accepted_languages: return True languages = set([row[c].get('xml:lang') for c in hdr if c in row and row[c]['type'] == 'literal']) return (not languages) or (languages & accepted_languages)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lang_match_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Find if the JSON row contains acceptable language data
def removeContinuousSet(self): self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) continuousSet = dataset.getContinuousSetByName( self._args.continuousSetName) def func(): self._updateRepo(self._repo.removeContinuousSet,...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'removeContinuousSet'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Removes a continuous set from this repo
def sort_top_targets(self, top, orders): sorted_top = collections.defaultdict(OrderedDict) for saltenv, targets in six.iteritems(top): sorted_targets = sorted(targets, key=lambda target: orders[saltenv][target]) for target in sorted_targets: so...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_top_targets'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Returns the sorted high data from the merged top files
def parseIBDatetime(s): if len(s) == 8: y = int(s[0:4]) m = int(s[4:6]) d = int(s[6:8]) dt = datetime.date(y, m, d) elif s.isdigit(): dt = datetime.datetime.fromtimestamp( int(s), datetime.timezone.utc) else: dt = datetime.datetime.strptime(s, '%Y%...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parseIBDatetime'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Parse string in IB date or datetime format to datetime.
def add_errors(self, *errors: Union[BaseSchemaError, List[BaseSchemaError]]) -> None: self.schema_loader.add_errors(*errors)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_errors'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Adds errors to the error repository in schema loader
def data_storage_dir(self): if self._data_storage_dir is None: self._data_storage_dir = tempfile.mkdtemp(prefix = "openfisca_") log.warn(( "Intermediate results will be stored on disk in {} in case of memory overflow. " "You should remove this directory on...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data_storage_dir'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Temporary folder used to store intermediate calculation data in case the memory is saturated
def _init_datastore_v3_stub(self, **stub_kwargs): task_args = dict(datastore_file=self._data_path) task_args.update(stub_kwargs) self.testbed.init_datastore_v3_stub(**task_args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_datastore_v3_stub'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []...
Initializes the datastore stub using nosegae config magic
def filter_python_files(files): "Get all python files from the list of files." py_files = [] for f in files: extension = os.path.splitext(f)[-1] if extension: if extension == '.py': py_files.append(f) elif 'python' in open(f, 'r').readline(): p...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_python_files'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Get all python files from the list of files.
def contains(self, url: str): try: self.get_one(url) except NotFound: return False else: return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'contains'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Return whether the URL is in the table.
def generate_corpus(n_issuers, n_tracks_per_issuer, n_utts_per_track, n_ll_per_utt, n_label_per_ll, rand=None): corpus = audiomate.Corpus() for issuer in generate_issuers(n_issuers, rand): corpus.import_i...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_corpus'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', '...
Generate a corpus with mock data.
def example_lab_to_ipt(): print("=== Simple Example: XYZ->IPT ===") xyz = XYZColor(0.5, 0.5, 0.5, illuminant='d65') print(xyz) ipt = convert_color(xyz, IPTColor) print(ipt) print("=== End Example ===\n")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'example_lab_to_ipt'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '10', '22', '2...
This function shows a simple conversion of an XYZ color to an IPT color.
def verify_token_type(self): try: token_type = self.payload[api_settings.TOKEN_TYPE_CLAIM] except KeyError: raise TokenError(_('Token has no type')) if self.token_type != token_type: raise TokenError(_('Token has wrong type'))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'verify_token_type'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Ensures that the token type claim is present and has the correct value.
def idat(self, lenient=False): while True: try: chunk_type, data = self.chunk(lenient=lenient) except ValueError: e = sys.exc_info()[1] raise ChunkError(e.args[0]) if chunk_type == 'IEND': break if ch...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'idat'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Iterator that yields all the ``IDAT`` chunks as strings.
def _do_layout(self): sizer_csvoptions = wx.FlexGridSizer(5, 4, 5, 5) leftpos = wx.LEFT | wx.ADJUST_MINSIZE rightpos = wx.RIGHT | wx.EXPAND current_label_margin = 0 other_label_margin = 15 for label, widget in zip(self.param_labels, self.param_widgets): sizer_...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_do_layout'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Sizer hell, returns a sizer that contains all widgets
def _process_rule(self, rule: dict, context: dict): if not rule or not self._shall_proceed(rule): return self.context.update(context) self.context.update(rule.get('context', {})) self.path = rule.get('path', None) self.source = rule.get('source', None) for ent...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_process_rule'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
process a single rule
def create_multi(cls, jid, password, msg, recipients=None, rooms=None, nick="SaltStack Bot"): obj = SendMsgBot(jid, password, None, msg) obj.recipients = [] if recipients is None else recipients obj.rooms = [] if rooms is None else rooms obj.nick = nick retur...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_multi'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '14']}; {'id': '4', 'type': 'identifier...
Alternate constructor that accept multiple recipients and rooms
def username(self): if len(self._inp_username.value.strip()) == 0: if not self.hostname is None: config = parse_sshconfig(self.hostname) if 'user' in config: return config['user'] else: return None else: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'username'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Loking for username in user's input and config file
def handle(self, *args, **options): qs = get_subscriber_model().objects.filter(djstripe_customers__isnull=True) count = 0 total = qs.count() for subscriber in qs: count += 1 perc = int(round(100 * (float(count) / float(total)))) print( "[{0}/{1} {2}%] Syncing {3} [{4}]".format( count, total, p...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Call sync_subscriber on Subscribers without customers associated to them.
def add_row(self, row_data, resize_x=True): if not resize_x: self._check_row_size(row_data) self.body(Tr()(Td()(cell) for cell in row_data)) return self
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_row'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Adds a row at the end of the table
def combine_tax_scales(node): combined_tax_scales = None for child_name in node: child = node[child_name] if not isinstance(child, AbstractTaxScale): log.info('Skipping {} with value {} because it is not a tax scale'.format(child_name, child)) continue if combined...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'combine_tax_scales'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Combine all the MarginalRateTaxScales in the node into a single MarginalRateTaxScale.
def gevent_start(self): import gevent import gevent.select self._poller_greenlet = gevent.spawn(self.poll) self._select = gevent.select.select self.heartbeat() self.update()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gevent_start'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Helper method to start the node for gevent-based applications.
def by_id(cls, _id, engine_or_session): ses, auto_close = ensure_session(engine_or_session) obj = ses.query(cls).get(_id) if auto_close: ses.close() return obj
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'by_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c...
Get one object by primary_key value.
async def prepare_conn(self, conn): client_id = str(uuid.uuid4()) monitor = functools.partial(self.send_event, client_id) self._logger.info("New client connection: %s", client_id) self.service_manager.add_monitor(monitor) self.clients[client_id] = dict(connection=conn, monitor=mo...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prepare_conn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Setup a new connection from a client.
def filter(self, f): def func(iterator): return filter(f, iterator) return self.mapPartitions(func, True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Return a new DStream containing only the elements that satisfy predicate.
def dom_table(self): if self._dom_table is None: data = defaultdict(list) for dom_id, (du, floor, _) in self.doms.items(): data['dom_id'].append(dom_id) data['du'].append(du) data['floor'].append(floor) dom_position = self.d...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dom_table'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
A `Table` containing DOM attributes
def parse_options(cls, options): cls.ignore_decorators = options.ignore_decorators cls.exclude_from_doctest = options.exclude_from_doctest if not isinstance(cls.exclude_from_doctest, list): cls.exclude_from_doctest = [cls.exclude_from_doctest]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_options'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Pass options through to this plugin.
def _get_addresses(self, text): addresses = [] matches = utils.findall( self.rules, text, flags=re.VERBOSE | re.U) if(matches): for match in matches: addresses.append(match[0].strip()) return addresses
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_addresses'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Returns a list of addresses found in text
def regex(r): if isinstance(r, stringtypes): p = re.compile(r) else: p = r msg = 'Expected to match: {}'.format(p.pattern) def match_regex(s, grm=None, pos=0): m = p.match(s) if m is not None: start, end = m.span() data = m.groupdict() if p.groupin...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'regex'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id':...
Create a PEG function to match a regular expression.
def deactivate_version(self, service_id, version_number): content = self._fetch("/service/%s/version/%d/deactivate" % (service_id, version_number), method="PUT") return FastlyVersion(self, content)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deactivate_version'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []...
Deactivate the current version.
def output(self, msg, indent, status=None): color = None if self.use_color: color = get_color_from_status(status) print_indent_msg(msg, indent, color)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'output'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Alias for print_indent_msg with color determined by status.
def repackage_hidden(self, h): if isinstance(h, Variable): return torch.tensor(h.data, device=h.device) else: return tuple(self.repackage_hidden(v) for v in h)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'repackage_hidden'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Wraps hidden states in new Variables, to detach them from their history.
def walletpassphrase(self, passphrase, timeout=99999999, mint_only=True): return self.req("walletpassphrase", [passphrase, timeout, mint_only])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'walletpassphrase'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children'...
used to unlock wallet for minting
def revoke_api_key(): build = g.build form = forms.RevokeApiKeyForm() if form.validate_on_submit(): api_key = models.ApiKey.query.get(form.id.data) if api_key.build_id != build.id: logging.debug('User does not have access to API key=%r', api_key.id) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'revoke_api_key'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '19', '123']...
Form submission handler for revoking API keys.
def _updateNamespace(item, new_namespace): temp_item = '' i = item.tag.find('}') if i >= 0: temp_item = item.tag[i+1:] else: temp_item = item.tag item.tag = '{{{0}}}{1}'.format(new_namespace, temp_item) for child in item.getiterator(): if isinstance(child.tag, six.string_...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_updateNamespace'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
helper function to recursively update the namespaces of an item
def create_image(self, image_file, caption): suffix = 'png' if image_file: img = Image.open(os.path.join(self.gallery, image_file)) width, height = img.size ratio = width/WIDTH img = img.resize((int(width // ratio), int(height...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_image'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Create an image with a caption
def _skip_frame(self): for line in self._f: if line == 'ITEM: ATOMS\n': break for i in range(self.num_atoms): next(self._f)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_skip_frame'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Skip the next time frame
def to_nibabel(image): if image.dimension != 3: raise ValueError('Only 3D images currently supported') import nibabel as nib array_data = image.numpy() affine = np.hstack([image.direction*np.diag(image.spacing),np.array(image.origin).reshape(3,1)]) affine = np.vstack([affine, np.array([0,0,0...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_nibabel'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'image'...
Convert an ANTsImage to a Nibabel image
def to_xml(self): ret = '<exif>' for k in self.__dict__: ret += '<%s>%s</%s>' % (k, self.__dict__[k], k) ret += '</exif>' return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_xml'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'...
Serialize all properties as XML
def handle_dump(self, params): print("Clients:", self.server.clients) for client in self.server.clients.values(): print(" ", client) for channel in client.channels.values(): print(" ", channel.name) print("Channels:", self.server.channels) for ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_dump'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Dump internal server information for debugging purposes.
def add_size_info (self): if self.headers and "Content-Length" in self.headers and \ "Transfer-Encoding" not in self.headers: try: self.size = int(self.getheader("Content-Length")) except (ValueError, OverflowError): pass else: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_size_info'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Get size of URL content from HTTP header.
def evict(self): logging.debug('Evicting cache for %r', self.cache_key) _clear_version_cache(self.cache_key) self.versioned_cache_key = None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'evict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Evict all caches related to these operations.
def removeNotification(self, notificationId): fn = self.function_table.removeNotification result = fn(notificationId) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'removeNotification'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Destroy a notification, hiding it first if it currently shown to the user.
def _exists(self, path): if path.endswith('/'): return True return self.storage.exists(path)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_exists'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
S3 directory is not S3Ojbect.
def include_theme_files(self, fragment): theme = self.get_theme() if not theme or 'package' not in theme: return theme_package, theme_files = theme.get('package', None), theme.get('locations', []) resource_loader = ResourceLoader(theme_package) for theme_file in theme...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'include_theme_files'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Gets theme configuration and renders theme css into fragment
async def fetch_device_list(self): url = '{}/users/me'.format(API_URL) dlist = await self.api_get(url) if dlist is None: _LOGGER.error('Unable to fetch eight devices.') else: self._devices = dlist['user']['devices'] _LOGGER.debug('Devices: %s', self._d...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch_device_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Fetch list of devices.
def verify_integrity(self): if not self.__integrity_check: if not self.__appid: raise Exception('U2F_APPID was not defined! Please define it in configuration file.') if self.__facets_enabled and not len(self.__facets_list): raise Exception( ) u...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'verify_integrity'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Verifies that all required functions been injected.
def add_child(self, child, name=None, index=None): self.m1.add_child(child, name, index) if index is None: index = len(self.m2._children) self.children_for_m2.append((child, name, index))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_child'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Add object `child` to the first map and store it for the second.
def add_adjust(self, data, prehashed=False): subtrees = self._get_whole_subtrees() new_node = Node(data, prehashed=prehashed) self.leaves.append(new_node) for node in reversed(subtrees): new_parent = Node(node.val + new_node.val) node.p, new_node.p = new_parent, n...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_adjust'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Add a new leaf, and adjust the tree, without rebuilding the whole thing.
def append(self, data): for k in self._entries.keys(): self._entries[k].append(data._entries[k])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'append'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Append a Data instance to self
def extract_status_code(error): try: return int(error.code) except (AttributeError, TypeError, ValueError): try: return int(error.status_code) except (AttributeError, TypeError, ValueError): try: return int(error.errno) except (Attribut...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_status_code'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Extract an error code from a message.
def init_nvidia(self): if import_error_tag: self.nvml_ready = False try: pynvml.nvmlInit() self.device_handles = get_device_handles() self.nvml_ready = True except Exception: logger.debug("pynvml could not be initialized.") ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init_nvidia'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Init the NVIDIA API.
def action_spatial(self, action): if self.surf.surf_type & SurfType.FEATURE: return action.action_feature_layer elif self.surf.surf_type & SurfType.RGB: return action.action_render else: assert self.surf.surf_type & (SurfType.RGB | SurfType.FEATURE)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'action_spatial'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Given an Action, return the right spatial action.
def transpose(self, rows): res = OrderedDict() for row, cols in rows.items(): for col, cell in cols.items(): if col not in res: res[col] = OrderedDict() res[col][row] = cell return res
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transpose'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Transposes the grid to allow for cols
def _postprocess_variants(record_file, data, ref_file, out_file): if not utils.file_uptodate(out_file, record_file): with file_transaction(data, out_file) as tx_out_file: cmd = ["dv_postprocess_variants.py", "--ref", ref_file, "--infile", record_file, "--outfile", tx_out_file]...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_postprocess_variants'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'child...
Post-process variants, converting into standard VCF file.
def track_list(self,*args): noargs = len(args) == 0 return np.unique(self.track) if noargs else np.unique(self.track.compress(args[0]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'track_list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
return the list of tracks contained if the dataset
def signed_cell_areas(self): assert ( self.node_coords.shape[1] == 2 ), "Signed areas only make sense for triangles in 2D." if self._signed_cell_areas is None: p = self.node_coords[self.cells["nodes"]].T self._signed_cell_areas = ( +p[0][2] * (...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'signed_cell_areas'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Signed area of a triangle in 2D.
def _apply_mask(self, roi_mask): rows_to_delete = list() if isinstance(roi_mask, np.ndarray): self._set_roi_mask(roi_mask) rows_roi = np.where(self.roi_mask.flatten() == cfg.background_value) self.carpet = np.delete(self.carpet, rows_roi, axis=0)...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_apply_mask'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Removes voxels outside the given mask or ROI set.
def _next_job(self): if self.__job_queue: job = self.__job_queue.pop() job.process()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_next_job'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
execute the next job from the top of the queue
def to_xdr_object(self): return Xdr.types.Memo(type=Xdr.const.MEMO_ID, id=self.memo_id)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_xdr_object'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Creates an XDR Memo object for a transaction with MEMO_ID.
def calculate_dimensions(self): x_coordinates = np.sort(self.grid['x'][:, 0]) self.nr_nodes_z = np.where(x_coordinates == x_coordinates[0])[0].size self.nr_elements_x = self.elements.shape[0] / (self.nr_nodes_z - 1) self.nr_nodes_x = self.nr_elements_x + 1 self.nr_elements_z = se...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calculate_dimensions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
For a regular grid, calculate the element and node dimensions
def datapoint_indices_for_tensor(self, tensor_index): if tensor_index >= self._num_tensors: raise ValueError('Tensor index %d is greater than the number of tensors (%d)' %(tensor_index, self._num_tensors)) return self._file_num_to_indices[tensor_index]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'datapoint_indices_for_tensor'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children...
Returns the indices for all datapoints in the given tensor.
def type_last(self, obj: JsonObj) -> JsonObj: def _tl_list(v: List) -> List: return [self.type_last(e) if isinstance(e, JsonObj) else _tl_list(e) if isinstance(e, list) else e for e in v if e is not None] rval = JsonObj() for k in as_dict(obj).keys(...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'type_last'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Move the type identifiers to the end of the object for print purposes
def write_training_metrics(self): with open(self.path, 'w') as file: writer = csv.writer(file) writer.writerow(FIELD_NAMES) for row in self.rows: writer.writerow(row)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_training_metrics'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Write Training Metrics to CSV
def chown(dirs, user=None, group=None): if isinstance(dirs, basestring): dirs = [dirs] args = ' '.join(dirs) if user and group: return sudo('chown {}:{} {}'.format(user, group, args)) elif user: return sudo('chown {} {}'.format(user, args)) elif group: return sudo('ch...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'chown'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
User sudo to set user and group ownership
def window_open(dev, temp, duration): click.echo("Window open: %s" % dev.window_open) if temp and duration: click.echo("Setting window open conf, temp: %s duration: %s" % (temp, duration)) dev.window_open_config(temp, duration)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'window_open'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Gets and sets the window open settings.
def reset_status(self): for row in range(self.table.rowCount()): status_item = self.table.item(row, 1) status_item.setText(self.tr(''))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reset_status'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Set all scenarios' status to empty in the table.
def parsemsg(s): prefix = '' trailing = [] if not s: raise Exception("Empty line.") if s[0] == ':': prefix, s = s[1:].split(' ', 1) if s.find(' :') != -1: s, trailing = s.split(' :', 1) args = s.split() args.append(trailing) else: args =...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parsemsg'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's'}; {'i...
Breaks a message from an IRC server into its prefix, command, and arguments.
def reach_process_json(): if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) json_str = body.get('json') rp = reach.process_json_str(json_str) return _stmts_from_proc(rp)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reach_process_json'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '29', '3...
Process REACH json and return INDRA Statements.
def resolved_task(cls, task): for t in cls.tasks: if t is task or t.execute is task: return t
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resolved_task'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Task instance representing 'task', if any
def compute_agreement_score(num_matches, num1, num2): denom = num1 + num2 - num_matches if denom == 0: return 0 return num_matches / denom
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_agreement_score'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children...
Agreement score is used as a criteria to match unit1 and unit2.
def generate(engine, database, models, **kwargs): validate_args(engine, database, models) generator = Generator(engine, database, models) generator.run()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Generate the migrations by introspecting the db
def mode(dev, target): click.echo("Current mode: %s" % dev.mode_readable) if target: click.echo("Setting mode: %s" % target) dev.mode = target
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dev'}; ...
Gets or sets the active mode.
def rebuild_app(app_name, quiet=False, force=True, without_exec=False, restart=False): user = 'cozy-{app_name}'.format(app_name=app_name) home = '{prefix}/{app_name}'.format(prefix=PREFIX, app_name=app_name) command_line = 'cd {home}'.format(home=home) command_line += ' && git pull' ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rebuild_app'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'childre...
Rebuild cozy apps with deletion of npm directory & new npm build
def make_statistics_information(info): if not info.splits.total_num_examples: return "None computed" stats = [(info.splits.total_num_examples, "ALL")] for split_name, split_info in info.splits.items(): stats.append((split_info.num_examples, split_name.upper())) stats.sort(reverse=True) stats = "\n".jo...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_statistics_information'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],...
Make statistics information table.
def run_fba_minimized(self, reaction): epsilon = self._args.epsilon solver = self._get_solver() p = fluxanalysis.FluxBalanceProblem(self._mm, solver) start_time = time.time() try: p.maximize(reaction) except fluxanalysis.FluxBalanceError as e: self...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_fba_minimized'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Run normal FBA and flux minimization on model.
def _connect(cls): post_save.connect( notify_items, sender=cls, dispatch_uid='knocker_{0}'.format(cls.__name__) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_connect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {...
Connect signal to current model
def runRmFile(self, path, timeout=None, **kwargs): cmd_args = {'path': path, 'logEnviron': self.logEnviron} if timeout: cmd_args['timeout'] = timeout if self.workerVersionIsOlderThan('rmfile', '3.1'): cmd_args['dir'] = os.path.abspath(path) return self.runRemo...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'runRmFile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], '...
remove a file from the worker
def sort(line): x0, y0, x1, y1 = line turn = False if abs(x1 - x0) > abs(y1 - y0): if x1 < x0: turn = True elif y1 < y0: turn = True if turn: return (x1, y1, x0, y0) return line
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id...
change point position if x1,y0 < x0,y0
def load_config(options): global opts, pform opts = options pform = options.pform global_ns = globals() if pform.hicolor: global_ns['dim_templ'] = ansi.dim8t global_ns['swap_clr_templ'] = ansi.csi8_blk % ansi.blu8 else: global_ns['dim_templ'] = ansi.dim4t global_n...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'optio...
Load options, platform, colors, and icons.
def _download_py2(link, path, __hdr__): try: req = urllib2.Request(link, headers=__hdr__) u = urllib2.urlopen(req) except Exception as e: raise Exception(' Download failed with the error:\n{}'.format(e)) with open(path, 'wb') as outf: for l in u: outf.write(l) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_download_py2'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Download a file from a link in Python 2.
def process_objects(kls): if 'Meta' not in kls.__dict__: kls.Meta = type('Meta', (object,), {}) if 'unique_together' not in kls.Meta.__dict__: kls.Meta.unique_together = [] if 'verbose_name' not in kls.Meta.__dict__: kls.Meta.verbose_name = kls.__name__ ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_objects'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'k...
Applies default Meta properties.
def add_automation_link(testcase): automation_link = ( '<a href="{}">Test Source</a>'.format(testcase["automation_script"]) if testcase.get("automation_script") else "" ) testcase["description"] = "{}<br/>{}".format(testcase.get("description") or "", automation_link)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_automation_link'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Appends link to automation script to the test description.
def prettyprint(datastr): maxwidth = WPToolsQuery.MAXWIDTH rpad = WPToolsQuery.RPAD extent = maxwidth - (rpad + 2) for line in datastr: if len(line) >= maxwidth: line = line[:extent] + '...' utils.stderr(line)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prettyprint'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'datas...
Print page data strings to stderr
def bulk_add_units(unit_list, **kwargs): added_units = [] for unit in unit_list: added_units.append(add_unit(unit, **kwargs)) return JSONObject({"units": added_units})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bulk_add_units'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Save all the units contained in the passed list, with the name of their dimension.
def daterange_(self, datecol, date_start, op, **args): df = self._daterange(datecol, date_start, op, **args) if df is None: self.err("Can not select date range data") return self._duplicate_(df)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'daterange_'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children':...
Returns a DataSwim instance with rows in a date range
def up(force=True, env=None, **kwargs): "Starts a new experiment" inventory = os.path.join(os.getcwd(), "hosts") conf = Configuration.from_dictionnary(provider_conf) provider = Enos_vagrant(conf) roles, networks = provider.init() check_networks(roles, networks) env["roles"] = roles env["...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'up'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6'...
Starts a new experiment
def broadcast_status(self, status): self._broadcast( "transient.status", json.dumps(status), headers={"expires": str(int((15 + time.time()) * 1000))}, )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'broadcast_status'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Broadcast transient status information to all listeners
def convert_to_unit(self, unit): self._values = self._header.data_type.to_unit( self._values, unit, self._header.unit) self._header._unit = unit
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_to_unit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Convert the Data Collection to the input unit.
def hash(value): if not value: return elif len(value) == 32: type = 'md5' elif len(value) == 40: type = 'sha1' elif len(value) == 64: type = 'sha256' else: return None return {'type': type, 'value': value}
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hash'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {'i...
Detect an hash type
def items(self): query = self.get_queryset() fields = self.get_model_config().get_list_fields() for item in query.iterator(): row = OrderedDict() for field_name in self.get_current_fields(): field = fields.get(field_name) if not field_name:...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'items'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Get all list items
def visit_Num(self, node: AST, dfltChaining: bool = True) -> str: return str(node.n)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_Num'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Return `node`s number as string.
def Operate(self, values): for val in values: try: if self.Operation(val, self.right_operand): return True except (TypeError, ValueError): pass return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Operate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Takes a list of values and if at least one matches, returns True.
def import_from_dict(session, data, sync=[]): if isinstance(data, dict): logging.info('Importing %d %s', len(data.get(DATABASES_KEY, [])), DATABASES_KEY) for database in data.get(DATABASES_KEY, []): Database.import_from_dict(session, database, sy...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_from_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Imports databases and druid clusters from dictionary
def object_version_choices(obj): choices = BLANK_CHOICE_DASH + [(PublishAction.UNPUBLISH_CHOICE, 'Unpublish current version')] if obj is not None: saved_versions = Version.objects.filter( content_type=ContentType.objects.get_for_model(obj), object_id=obj.pk, ).exclude( ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'object_version_choices'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Return a list of form choices for versions of this object which can be published.
def analysis_title_header_element(feature, parent): _ = feature, parent header = analysis_title_header['string_format'] return header.capitalize()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'analysis_title_header_element'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childre...
Retrieve analysis title header string from definitions.
def save(self, commit=True, **kwargs): org = super(OrganizationForm, self).save(commit=False, **kwargs) if not org.id: user = current_user._get_current_object() member = Member(user=user, role='admin') org.members.append(member) if commit: org.save...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Register the current user as admin on creation
def fastaWrite(fileHandleOrFile, name, seq, mode="w"): fileHandle = _getFileHandle(fileHandleOrFile, mode) valid_chars = {x for x in string.ascii_letters + "-"} try: assert any([isinstance(seq, unicode), isinstance(seq, str)]) except AssertionError: raise RuntimeError("Sequence is not un...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fastaWrite'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Writes out fasta file
def requeue(self): job_requeue_interval = float( self.config.get('sharq', 'job_requeue_interval')) while True: self.sq.requeue() gevent.sleep(job_requeue_interval / 1000.00)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'requeue'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
Loop endlessly and requeue expired jobs.
def render(file): with file.open() as fp: encoding = detect_encoding(fp, default='utf-8') file_content = fp.read().decode(encoding) json_data = json.loads(file_content, object_pairs_hook=OrderedDict) return json.dumps(json_data, indent=4, separators=(',', ': '))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'file'}; {'...
Pretty print the JSON file for rendering.