common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
1242
|
Train/png/1242.png
|
def b2u(string):
if (isinstance(string, bytes) or
(PY2 and isinstance(string, str))):
return string.decode('utf-8')
return string
|
5798
|
Train/png/5798.png
|
def _config_options(self):
self._config_sortable(self._sortable)
self._config_drag_cols(self._drag_cols)
|
5043
|
Train/png/5043.png
|
def list_sdbs(self):
sdb_raw = self.get_sdbs()
sdbs = []
for s in sdb_raw:
sdbs.append(s['name'])
return sdbs
|
4673
|
Train/png/4673.png
|
def _cursor_forward(self, count=1):
self.x = min(self.size[1] - 1, self.x + count)
|
1578
|
Train/png/1578.png
|
def load_all_aldb(self, clear=True):
for addr in self.plm.devices:
await self.load_device_aldb(addr, clear)
|
5702
|
Train/png/5702.png
|
def incoming(self):
msg = await self._queue.get()
self._queue.task_done()
return msg
|
5345
|
Train/png/5345.png
|
def pop_log(self):
self._check_receive_loop()
res = self.log_queue.get()
self._check_error(res)
return res
|
681
|
Train/png/681.png
|
def _get_soup(page):
request = requests.get(page)
data = request.text
return bs4.BeautifulSoup(data)
|
9275
|
Train/png/9275.png
|
def _attach(cls, iface_id, vm_id):
oper = cls.call('hosting.vm.iface_attach', vm_id, iface_id)
return oper
|
9169
|
Train/png/9169.png
|
def _remove_keywords(d):
return {k: v for k, v in iteritems(d) if k not in RESERVED}
|
863
|
Train/png/863.png
|
def Tag(self, key, value):
if not self._tags:
self._tags = {}
self._tags[key] = value
|
5910
|
Train/png/5910.png
|
def get_text(self):
return u''.join(u'{0}'.format(b) for b in self.text)
|
1691
|
Train/png/1691.png
|
def encode(self):
return self.attrs.encode() + self.delay.encode() + self.cmd.encode()
|
2651
|
Train/png/2651.png
|
def records(self):
return [self._records[i] for i in range(len(self._records))]
|
4772
|
Train/png/4772.png
|
def unpause(self):
res = librtmp.RTMP_Pause(self.client.rtmp, 0)
if res < 1:
raise RTMPError("Failed to unpause")
|
1093
|
Train/png/1093.png
|
def on_any_event(self, event):
if os.path.isfile(event.src_path):
self.callback(event.src_path, **self.kwargs)
|
1638
|
Train/png/1638.png
|
def prepend_schema(self, name):
return '.'.join([self.schema, name]) if self.schema else name
|
7845
|
Train/png/7845.png
|
def tostr(self, object, indent=-2):
history = []
return self.process(object, history, indent)
|
2924
|
Train/png/2924.png
|
def decode_csr(self, csr):
response = self.request(E.decodeCsrSslCertRequest(
E.csr(csr)
))
return response.data
|
9165
|
Train/png/9165.png
|
def _elapsed(self):
self.last_time = time.time()
return self.last_time - self.start
|
7750
|
Train/png/7750.png
|
def convert(self, value, _type):
return self.type_convertors.get(_type, lambda x: x)(value)
|
5986
|
Train/png/5986.png
|
def as_bin(self, as_spendable=False):
f = io.BytesIO()
self.stream(f, as_spendable=as_spendable)
return f.getvalue()
|
3805
|
Train/png/3805.png
|
def translate_v3(vec, amount):
return Vec3(vec.x+amount, vec.y+amount, vec.z+amount)
|
6552
|
Train/png/6552.png
|
def erase_line(self): # <ESC>[2K
self.fill_region(self.cur_r, 1, self.cur_r, self.cols)
|
7703
|
Train/png/7703.png
|
def size(self):
if self._instrs is []:
return None
return sum([instr.size for instr in self._instrs])
|
2349
|
Train/png/2349.png
|
def connect_db(config):
rv = sqlite3.connect(config["database"]["uri"])
rv.row_factory = sqlite3.Row
return rv
|
2352
|
Train/png/2352.png
|
def save(self, doc):
self.log.debug('save()')
self.docs.append(doc)
self.commit()
|
822
|
Train/png/822.png
|
def validate(self, vat_deets):
request = self._get('validation', vat_deets)
return self.responder(request)
|
7360
|
Train/png/7360.png
|
def remove(self, entry):
try:
list = self.cache[entry.key]
list.remove(entry)
except:
pass
|
5566
|
Train/png/5566.png
|
def items(self):
return {dep.task: value for dep, value in self._result.items()}.items()
|
3184
|
Train/png/3184.png
|
def command(state, args):
state.cache_manager.teardown()
state.cache_manager.setup()
EpisodeTypes.forget(state.db)
del state.file_picker
|
2068
|
Train/png/2068.png
|
def average_gradient(data, *kwargs):
return np.average(np.array(np.gradient(data))**2)
|
2465
|
Train/png/2465.png
|
def dist_sq(self, other=None):
v = self - other if other else self
return sum(map(lambda a: a * a, v))
|
9752
|
Train/png/9752.png
|
def _file_default_fields():
return [
files.c.name,
files.c.created_at,
files.c.parent_name,
]
|
1803
|
Train/png/1803.png
|
def is_local_replica(pid):
return d1_gmn.app.models.LocalReplica.objects.filter(pid__did=pid).exists()
|
2548
|
Train/png/2548.png
|
def template(config_file):
config = _load_config(config_file)
print(get_cfn_template(config, pretty=True))
|
4425
|
Train/png/4425.png
|
def setnx(self, key, value):
return self.set(key, value, nx=True)
|
1404
|
Train/png/1404.png
|
def run(cmd, filename=None, threads=True, verbose=False):
_run(threads, verbose, 'run', filename, cmd)
|
2143
|
Train/png/2143.png
|
def close(self):
if self._close and self._fh:
self._fh.close()
self._fh = None
|
4911
|
Train/png/4911.png
|
def ranks(self, key, value):
return [normalize_rank(el) for el in force_list(value.get('a'))]
|
2038
|
Train/png/2038.png
|
def extract_terms(self, nb):
emt = ExtractMetatabTerms()
emt.preprocess(nb, {})
return emt.terms
|
9630
|
Train/png/9630.png
|
def concat(dfs):
ds = reduce((lambda x, y: x.concat(y)), dfs)
return ds
|
2015
|
Train/png/2015.png
|
def call_set_attr(node: Node, key: str, value):
node.set_attr(key, value)
|
3304
|
Train/png/3304.png
|
def iter_causes(self):
curr = self._cause
while curr is not None:
yield curr
curr = curr._cause
|
1327
|
Train/png/1327.png
|
def get_users_for_assigned_to():
User = get_user_model()
return User.objects.filter(is_active=True, is_staff=True)
|
2353
|
Train/png/2353.png
|
def init_edge_number(self) -> int:
return len(frozenset(frozenset(edge) for edge in self.initial_edges()))
|
5443
|
Train/png/5443.png
|
def q(self, val):
self._q = np.asarray(val)
self.Q = cumsum(val)
|
5476
|
Train/png/5476.png
|
def to_flat(coord):
if coord is None:
return go.N * go.N
return go.N * coord[0] + coord[1]
|
9977
|
Train/png/9977.png
|
def tag(version=__version__):
build = local("git tag {0}".format(version))
if build.succeeded:
local("git push --tags")
|
3890
|
Train/png/3890.png
|
def form_valid(self, form):
form.send_email(to=self.to_addr)
return super(EmailView, self).form_valid(form)
|
4493
|
Train/png/4493.png
|
def delete_item(key):
CACHED_KEY_FILE = os.path.join(CURRENT_DIR, key)
if os.path.isfile(CACHED_KEY_FILE):
os.remove(CACHED_KEY_FILE)
|
4646
|
Train/png/4646.png
|
def __update_keywords(uid, inkeywords):
entry = TabPost.update(keywords=inkeywords).where(TabPost.uid == uid)
entry.execute()
|
8064
|
Train/png/8064.png
|
def set_base_dir(self, base_dir):
self._base_dir = base_dir
self.icon_cache.set_base_dir(base_dir)
|
10084
|
Train/png/10084.png
|
def t_LESSTHAN(self, t):
r"\<"
t.endlexpos = t.lexpos + len(t.value)
return t
|
98
|
Train/png/98.png
|
def create_zip_from_file(zip_file, fname):
with zipfile.ZipFile(zip_file, 'w') as myzip:
myzip.write(fname)
|
7637
|
Train/png/7637.png
|
def match_all_in(self, matches, item):
for i, match in enumerate(matches):
self.match(match, item + "[" + str(i) + "]")
|
7380
|
Train/png/7380.png
|
def convert_items(self, items):
return ((key, self.convert(value, self)) for key, value in items)
|
3600
|
Train/png/3600.png
|
def protoFast():
r, x = blind(m)
y, kw, tTilde = eval(w, t, x, msk, s)
z = deblind(r, y)
|
4438
|
Train/png/4438.png
|
def is_integer(obj):
if PYTHON3:
return isinstance(obj, int)
return isinstance(obj, (int, long))
|
3440
|
Train/png/3440.png
|
def memoize(f):
@wraps(f)
def w(*args, **kw):
memoize.mem[f] = v = f(*args, **kw)
return v
return w
|
6725
|
Train/png/6725.png
|
def on_first_registration(self):
self.main.tabify_plugins(self.main.help, self)
self.dockwidget.hide()
|
3499
|
Train/png/3499.png
|
def create_relay(self, orgid, data):
return self.api_call(
ENDPOINTS['relays']['new'],
dict(orgid=orgid), body=data)
|
8103
|
Train/png/8103.png
|
def rhochange(self):
self.lu, self.piv = sl.cho_factor(self.D, self.rho)
self.lu = np.asarray(self.lu, dtype=self.dtype)
|
7345
|
Train/png/7345.png
|
def render(self, screen):
self.rect.render(screen)
super(MenuElement, self).render(screen)
|
1823
|
Train/png/1823.png
|
def desk_locale(self, locale):
locale = locale.lower().replace('-', '_')
return self.vendor_locale_map.get(locale, locale)
|
6333
|
Train/png/6333.png
|
def display_message(pymux, variables):
" Display a message. "
message = variables['<message>']
client_state = pymux.get_client_state()
client_state.message = message
|
6101
|
Train/png/6101.png
|
def pass_time(self, t):
cont = time.time() + t
while time.time() < cont:
time.sleep(0)
|
7282
|
Train/png/7282.png
|
def source_lines(self, filename):
with self.filesystem.open(filename) as f:
return f.readlines()
|
9271
|
Train/png/9271.png
|
def keys_info(cls, fqdn, key):
return cls.json_get('%s/domains/%s/keys/%s' %
(cls.api_url, fqdn, key))
|
7925
|
Train/png/7925.png
|
def pitch(self):
x, y, z, w = self.x, self.y, self.z, self.w
return math.atan2(2*x*w - 2*y*z, 1 - 2*x*x - 2*z*z)
|
8193
|
Train/png/8193.png
|
def list_ape(archive, compression, cmd, verbosity, interactive):
return stripext(cmd, archive, verbosity, extension=".wav")
|
5391
|
Train/png/5391.png
|
def send_chat_messages(self, messages):
self._parallel.run(
(c.chat, message) for c, message in zip(self._controllers, messages))
|
4187
|
Train/png/4187.png
|
def delete_lbaas_l7rule(self, l7rule, l7policy):
return self.delete(self.lbaas_l7rule_path % (l7policy, l7rule))
|
6536
|
Train/png/6536.png
|
def visit_Assign(self, node, **kwargs):
self.visit(node.node, **kwargs)
self.visit(node.target, **kwargs)
|
4702
|
Train/png/4702.png
|
def _sample(probability_vec):
return map(int,
numpy.random.random(probability_vec.size) <= probability_vec)
|
5767
|
Train/png/5767.png
|
def pp_xml(body):
pretty = xml.dom.minidom.parseString(body)
return pretty.toprettyxml(indent=" ")
|
8564
|
Train/png/8564.png
|
def add_flag_values(self, entry, flag):
if flag in self.flags:
self.flags[flag].append(entry)
|
7618
|
Train/png/7618.png
|
def add_info(self, s):
if s not in self.info:
self.info.append(s)
|
3679
|
Train/png/3679.png
|
def auto():
try:
Style.enabled = False
Style.enabled = sys.stdout.isatty()
except (AttributeError, TypeError):
pass
|
3839
|
Train/png/3839.png
|
def draw(self):
if not self.visible:
return
self.window.blit(self.textImage, self.loc)
|
18
|
Train/png/18.png
|
def data(self):
d = super(CommunityForm, self).data
d.pop('csrf_token', None)
return d
|
7935
|
Train/png/7935.png
|
def split(self, text):
text = cleanup(text)
return self.sent_detector.tokenize(text.strip())
|
9442
|
Train/png/9442.png
|
def get_bounding_box(self, crs):
return self.from_bounds(*self.get_bounds(crs), crs=crs)
|
7222
|
Train/png/7222.png
|
def all(self, query=None, **kwargs):
return super(SpacesProxy, self).all(query=query)
|
3071
|
Train/png/3071.png
|
def output(self):
return luigi.LocalTarget(path=self.path(digest=True, ext='html'))
|
7422
|
Train/png/7422.png
|
def safe_log_info(self, *info: str):
self.__do_safe(lambda: self.logger.info(*info))
|
202
|
Train/png/202.png
|
def compute_fwhm_1d_simple(Y, xc, X=None):
return compute_fw_at_frac_max_1d_simple(Y, xc, X=X, f=0.5)
|
9610
|
Train/png/9610.png
|
def _remove_dict_keys_with_value(dict_, val):
return {k: v for k, v in dict_.items() if v is not val}
|
3992
|
Train/png/3992.png
|
def get_soup(self, *args, **kwargs):
return BeautifulSoup(self.get(*args, **kwargs).text)
|
5508
|
Train/png/5508.png
|
def Start(self):
self.CallClient(
server_stubs.PlistQuery,
request=self.args.request,
next_state="Receive")
|
4083
|
Train/png/4083.png
|
def has_value(cls, value: int) -> bool:
return any(value == item.value for item in cls)
|
795
|
Train/png/795.png
|
def after(self, i, sibling, name=None):
self.parent._insert(sibling, idx=self._own_index + 1 + i, name=name)
return self
|
8414
|
Train/png/8414.png
|
def snapshot(self):
return dict((n, self._slots[n].get()) for n in self._slots.keys())
|
3369
|
Train/png/3369.png
|
def destroy(self, job_ids):
for job_id in job_ids:
self.client.resource_groups.delete(self.resource_group)
|
9403
|
Train/png/9403.png
|
def get_valid_fns(self) -> Tuple[List[str], List[str]]:
return self.prefixes_to_fns(self.valid_prefixes)
|
3637
|
Train/png/3637.png
|
def redef(obj, key, value, **kwargs):
return Redef(obj, key, value=value, **kwargs)
|
3639
|
Train/png/3639.png
|
def strip_tags(cls, html):
s = cls()
s.feed(html)
return s.get_data()
|
691
|
Train/png/691.png
|
def cmd(send, msg, args):
result = args['db'].query(Urls).order_by(func.random()).first()
send("%s" % result.url)
|
4249
|
Train/png/4249.png
|
def tbfuncs(frames):
'this takes the frames array returned by tbframes'
return ['%s:%s:%s' % (os.path.split(f.f_code.co_filename)[-1], f.f_code.co_name, f.f_lineno) for f in frames]
|
8429
|
Train/png/8429.png
|
def _dotify(cls, data):
return ''.join(char if char in cls.PRINTABLE_DATA else '.' for char in data)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.