common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
9311
|
Train/png/9311.png
|
def make_arg(key, annotation=None):
arg = ast.arg(key, annotation)
arg.lineno, arg.col_offset = 0, 0
return arg
|
8269
|
Train/png/8269.png
|
def bind_client(self, new):
top = self._stack[-1]
self._stack[-1] = (new, top[1])
|
4971
|
Train/png/4971.png
|
def findall(self, string, *args, **kwargs):
return self._pattern.findall(string, *args, **kwargs)
|
7830
|
Train/png/7830.png
|
def comma_list(cls, string):
items = string.split(',')
items = list([item.strip() for item in items])
return items
|
608
|
Train/png/608.png
|
def click(self, x: int, y: int) -> None:
self._execute('-s', self.device_sn, 'shell',
'input', 'tap', str(x), str(y))
|
9479
|
Train/png/9479.png
|
def defaults(self):
return {k: v.default for k, v in self.options().items()}
|
40
|
Train/png/40.png
|
def broker_url(self):
return 'amqp://{}:{}@{}/{}'.format(
self.user, self.password, self.name, self.vhost)
|
9301
|
Train/png/9301.png
|
def trigger(self, event, *args):
for handler in self._event_handlers[event]:
handler(*args)
|
5142
|
Train/png/5142.png
|
def _child_inst_names(self) -> Set[InstanceName]:
return frozenset([c.iname() for c in self.data_children()])
|
9132
|
Train/png/9132.png
|
def add_to_current_action(self, controller):
item = self.current_item
self._history[self._index] = item + (controller,)
|
2239
|
Train/png/2239.png
|
def new_event_type(self, name, mergeable=False):
self.event_types[name] = self.EventType(name, mergeable)
|
4548
|
Train/png/4548.png
|
def Diag(a):
r = np.zeros(2 * a.shape, dtype=a.dtype)
for idx, v in np.ndenumerate(a):
r[2 * idx] = v
return r,
|
4603
|
Train/png/4603.png
|
def parse_timestamp(x):
dt = dateutil.parser.parse(x)
if dt.tzinfo is None:
dt = dt.replace(tzinfo=pytz.utc)
return dt
|
4427
|
Train/png/4427.png
|
def hget(self, hashkey, attribute):
redis_hash = self._get_hash(hashkey, 'HGET')
return redis_hash.get(self._encode(attribute))
|
2515
|
Train/png/2515.png
|
def pkg_not_found(self, bol, pkg, message, eol):
print("{0}No such package {1}: {2}{3}".format(bol, pkg, message, eol))
|
3663
|
Train/png/3663.png
|
def drafts(files, stack):
"Filter out any files marked 'draft'"
for path, post in list(files.items()):
if post.get('draft'):
del files[path]
|
2891
|
Train/png/2891.png
|
def path(filename):
filename = unmap_file(filename)
if filename not in file_cache:
return None
return file_cache[filename].path
|
7199
|
Train/png/7199.png
|
def getfields(comm):
fields = []
for field in comm:
if 'field' in field:
fields.append(field)
return fields
|
7934
|
Train/png/7934.png
|
def unread(thread, user):
return bool(thread.userthread_set.filter(user=user, unread=True))
|
5696
|
Train/png/5696.png
|
def showStatus(self, msg):
log.debug(msg)
self.statusBar().showMessage(msg)
|
7741
|
Train/png/7741.png
|
def quit_all(editor, force=False):
quit(editor, all_=True, force=force)
|
8843
|
Train/png/8843.png
|
def pprint(self, stream=None, indent=1, width=80, depth=None):
pp.pprint(to_literal(self), stream, indent, width, depth)
|
8650
|
Train/png/8650.png
|
def to_xdr_object(self):
return Xdr.types.Memo(type=Xdr.const.MEMO_HASH, hash=self.memo_hash)
|
2368
|
Train/png/2368.png
|
def parse_tablature(lines):
lines = [parse_line(l) for l in lines]
return Tablature(lines=lines)
|
4779
|
Train/png/4779.png
|
def __pop_top_frame(self):
popped = self.__stack.pop()
if self.__stack:
self.__stack[-1].process_subframe(popped)
|
820
|
Train/png/820.png
|
def create_customer(self, customer_deets):
request = self._post('customers', customer_deets)
return self.responder(request)
|
835
|
Train/png/835.png
|
def now_millis(absolute=False) -> int:
millis = int(time.time() * 1e3)
if absolute:
return millis
return millis - EPOCH_MICROS // 1000
|
4678
|
Train/png/4678.png
|
def join(self, timeout=None, raise_error=False):
self._workers.join(timeout, raise_error)
|
7916
|
Train/png/7916.png
|
def move_to_start(self, column_label):
self._columns.move_to_end(column_label, last=False)
return self
|
7258
|
Train/png/7258.png
|
def socket_close(self):
if self.sock != NC.INVALID_SOCKET:
self.sock.close()
self.sock = NC.INVALID_SOCKET
|
5686
|
Train/png/5686.png
|
def roster(team_id):
data = mlbgame.info.roster(team_id)
return mlbgame.info.Roster(data)
|
8597
|
Train/png/8597.png
|
def remove_nones(**kwargs):
return dict((k, v) for k, v in kwargs.iteritems() if v is not None)
|
411
|
Train/png/411.png
|
def Run(self):
"Execute the action"
inputs = self.GetInput()
return SendInput(
len(inputs),
ctypes.byref(inputs),
ctypes.sizeof(INPUT))
|
3024
|
Train/png/3024.png
|
def add_hash(self, value):
self.leaves.append(Node(codecs.decode(value, 'hex_codec'), prehashed=True))
|
6806
|
Train/png/6806.png
|
def ip_to_int(ip):
ret = 0
for octet in ip.split('.'):
ret = ret * 256 + int(octet)
return ret
|
9492
|
Train/png/9492.png
|
def irreducible_effects(self):
return tuple(link for link in self
if link.direction is Direction.EFFECT)
|
1708
|
Train/png/1708.png
|
def publish(self):
if self.config.publish:
logger.info('Publish')
self.execute(self.config.publish)
|
9462
|
Train/png/9462.png
|
def check(definition, data, *args, **kwargs):
checker = checker_factory(definition)
return checker(data, *args, **kwargs)
|
8436
|
Train/png/8436.png
|
def to_np(*args):
if len(args) > 1:
return (cp.asnumpy(x) for x in args)
else:
return cp.asnumpy(args[0])
|
9743
|
Train/png/9743.png
|
def mins(self, value):
self.x_min, self.y_min, self.z_min = value
|
5095
|
Train/png/5095.png
|
def get_concepts(sts: List[Influence]) -> Set[str]:
return set(flatMap(nameTuple, sts))
|
9331
|
Train/png/9331.png
|
def _get_target_index(self):
return (self.index + self.source_window * (not self.overlapping) +
self.offset)
|
7480
|
Train/png/7480.png
|
def parser_from_buffer(cls, fp):
yaml = YAML(typ="safe")
return cls(yaml.load(fp))
|
1266
|
Train/png/1266.png
|
def We(self):
We = trapz_loglog(self._gam * self._nelec, self._gam * mec2)
return We
|
8577
|
Train/png/8577.png
|
def add_usable_app(name, app):
'Add app to local registry by name'
name = slugify(name)
global usable_apps # pylint: disable=global-statement
usable_apps[name] = app
return name
|
1988
|
Train/png/1988.png
|
def soft_break(self, el, text):
if el.name == 'p' and el.namespace and el.namespace == self.namespaces["text"]:
text.append('\n')
|
2398
|
Train/png/2398.png
|
def safe_eval(source, *args, **kwargs):
source = source.replace('import', '') # import is not allowed
return eval(source, *args, **kwargs)
|
7447
|
Train/png/7447.png
|
def new_pos(self, html_div):
pos = self.Position(self, html_div)
pos.bind_mov()
self.positions.append(pos)
return pos
|
8408
|
Train/png/8408.png
|
def delete_archive_dir(self):
logger.debug("Deleting: " + self.archive_dir)
shutil.rmtree(self.archive_dir, True)
|
4593
|
Train/png/4593.png
|
def street_address(anon, obj, field, val):
return anon.faker.street_address(field=field)
|
8983
|
Train/png/8983.png
|
def partialReleaseComplete():
a = TpPd(pd=0x6)
b = MessageType(mesType=0xf) # 00001111
packet = a / b
return packet
|
3917
|
Train/png/3917.png
|
def run(argv=None):
cli = InfrascopeCLI()
return cli.run(sys.argv[1:] if argv is None else argv)
|
6256
|
Train/png/6256.png
|
def insert_param(self, param):
self._current_params = tuple([param] + list(self._current_params))
|
9080
|
Train/png/9080.png
|
def _getEventsByWeek(self, request, year, month):
return getAllEventsByWeek(request, year, month, home=self)
|
1746
|
Train/png/1746.png
|
def delete(self):
res = self.rest_client.session.delete(self.rest_self)
_handle_http_errors(res)
|
385
|
Train/png/385.png
|
def to_str(obj):
if isinstance(obj, str):
return obj
if isinstance(obj, unicode):
return obj.encode('utf-8')
return str(obj)
|
9035
|
Train/png/9035.png
|
def option(self, key=None):
if key is None:
return self._args.options()
return self._args.option(key)
|
6558
|
Train/png/6558.png
|
def roots(g):
"Get nodes from graph G with indegree 0"
return set(n for n, d in iteritems(g.in_degree()) if d == 0)
|
8078
|
Train/png/8078.png
|
def normalize_value(value):
cast = str
if six.PY2:
cast = unicode # noqa
return cast(value).lower()
|
7687
|
Train/png/7687.png
|
def open(self):
self._geometry.lid_status = self._module.open()
self._ctx.deck.recalculate_high_z()
return self._geometry.lid_status
|
5634
|
Train/png/5634.png
|
def stars_list(self, **kwargs) -> SlackResponse:
self._validate_xoxp_token()
return self.api_call("stars.list", http_verb="GET", params=kwargs)
|
1779
|
Train/png/1779.png
|
def shared(self) -> typing.Union[None, SharedCache]:
return self._project.shared if self._project else None
|
5118
|
Train/png/5118.png
|
def to_python(self, value):
if value in self.empty_values:
return ""
value = force_text(value).strip()
return value
|
2770
|
Train/png/2770.png
|
def indent(text, amount, ch=' '):
padding = amount * ch
return ''.join(padding+line for line in text.splitlines(True))
|
4974
|
Train/png/4974.png
|
def create_information(self):
info = self._info_type()(origin=self, contents=self._contents())
return info
|
1814
|
Train/png/1814.png
|
def disconnect(self):
for signal, kwargs in self.connections:
signal.disconnect(self, **kwargs)
|
1416
|
Train/png/1416.png
|
def privmsg_many(self, targets, text):
target = ','.join(targets)
return self.privmsg(target, text)
|
4363
|
Train/png/4363.png
|
def is_reseller(self):
return self.role == self.roles.reseller.value and self.state == State.approved
|
4029
|
Train/png/4029.png
|
def field_exists(self, well_x, well_y, field_x, field_y):
"Check if field exists ScanFieldArray."
return self.field(well_x, well_y, field_x, field_y) != None
|
6344
|
Train/png/6344.png
|
def heappushpop(heap, item):
if heap and heap[0] < item:
item, heap[0] = heap[0], item
_siftup(heap, 0)
return item
|
4444
|
Train/png/4444.png
|
def get_attribute_name_id(attr):
return attr.value.id if isinstance(attr.value, ast.Name) else None
|
5398
|
Train/png/5398.png
|
def assoc(m, key, val):
cpy = deepcopy(m)
cpy[key] = val
return cpy
|
4724
|
Train/png/4724.png
|
def cancel(ctx, orders, account):
print_tx(ctx.bitshares.cancel(orders, account=account))
|
7617
|
Train/png/7617.png
|
def add(self, item):
if not item in self.items:
self.items.append(item)
|
8786
|
Train/png/8786.png
|
def getInstNameByIndex(self, colId, *indices):
return self.name + (colId,) + self.getInstIdFromIndices(*indices)
|
8659
|
Train/png/8659.png
|
def merge(directory, message, branch_label, rev_id, revisions):
_merge(directory, revisions, message, branch_label, rev_id)
|
9678
|
Train/png/9678.png
|
def finish(self):
self.status = 'completed'
self.time_completed = timestamp()
self.thing.action_notify(self)
|
8512
|
Train/png/8512.png
|
def clamp(value, lower=0, upper=sys.maxsize):
return max(lower, min(upper, value))
|
1239
|
Train/png/1239.png
|
def reverse(d):
r = {}
for k in d:
r[d[k]] = k
return r
|
3616
|
Train/png/3616.png
|
def api_url(self):
return pathjoin(Bin.path, self.name, url=self.service.url)
|
2718
|
Train/png/2718.png
|
def cannot(user, action, subject):
ability = Ability(user, get_authorization_method())
return ability.cannot(action, subject)
|
4868
|
Train/png/4868.png
|
def __run_delta_py(self, delta):
self.__run_py_file(delta.get_file(), delta.get_name())
self.__update_upgrades_table(delta)
|
1543
|
Train/png/1543.png
|
def qual(obj):
return u'{}.{}'.format(obj.__class__.__module__, obj.__class__.__name__)
|
8862
|
Train/png/8862.png
|
def stop(self):
for p in self.primitives[:]:
p.stop()
StoppableLoopThread.stop(self)
|
354
|
Train/png/354.png
|
def param(self, key, default=None):
if key in self.parameters:
return self.parameters[key]
return default
|
4196
|
Train/png/4196.png
|
def show_member(self, member, **_params):
return self.get(self.member_path % (member), params=_params)
|
3936
|
Train/png/3936.png
|
def protocol_names(self):
l = self.protocols()
retval = [str(k.name) for k in l]
return retval
|
2455
|
Train/png/2455.png
|
def remove(self, row):
self._rows.remove(row)
self._deleted_rows.add(row)
|
8439
|
Train/png/8439.png
|
def resume(self):
for child in chain(self.consumers.values(), self.workers):
child.resume()
|
7836
|
Train/png/7836.png
|
def decode(self, pdu):
while pdu.pduData:
self.tagList.append(Tag(pdu))
|
8266
|
Train/png/8266.png
|
def _start_primary(self):
self.em.start()
self.em.set_secondary_state(_STATE_RUNNING)
self._set_shared_instances()
|
8240
|
Train/png/8240.png
|
def onerror(self, message, source, lineno, colno):
return (message, source, lineno, colno)
|
2219
|
Train/png/2219.png
|
def parseStr(self, st):
self.data = st.replace('\r', '\n')
self.data = self.data.replace('\n\n', '\n')
self.data = self.data.split('\n')
|
9177
|
Train/png/9177.png
|
def same_domain(self, fun2):
return np.allclose(self.domain(), fun2.domain(), rtol=1e-14, atol=1e-14)
|
3768
|
Train/png/3768.png
|
def stop(context):
config = context.obj["config"]
pidfile = select(config, "application.pidfile", DEFAULT_PIDFILE)
daemon_stop(pidfile)
|
409
|
Train/png/409.png
|
def store_many(self, sql, values):
cursor = self.get_cursor()
cursor.executemany(sql, values)
self.conn.commit()
|
1871
|
Train/png/1871.png
|
def count_results(cube, q):
q = select(columns=[func.count(True)], from_obj=q.alias())
return cube.engine.execute(q).scalar()
|
1346
|
Train/png/1346.png
|
def minor_extent(self) -> complex:
return min((self.max() - self.null, self.null - self.min()))
|
2404
|
Train/png/2404.png
|
def board_names(hwpack='arduino'):
ls = list(boards(hwpack).keys())
ls.sort()
return ls
|
1111
|
Train/png/1111.png
|
def set_as_boot_disk(self):
await self._handler.set_boot_disk(
system_id=self.node.system_id, id=self.id)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.