code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def _change_color(self, event):
h = self.bar.get()
self.square.set_hue(h)
(r, g, b), (h, s, v), sel_color = self.square.get()
self.red.set(r)
self.green.set(g)
self.blue.set(b)
self.hue.set(h)
self.saturation.set(s)
self.value.set(v)
self.hexa.delete(0, "end")
self.hexa.insert(0, sel_color.upper())
if self.alpha_channel:
self.alphabar.set_color((r, g, b))
self.hexa.insert('end',
("%2.2x" % self.alpha.get()).upper())
self._update_preview() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment pattern_list tuple_pattern identifier identifier identifier tuple_pattern identifier identifier identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list integer string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list integer call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call attribute parenthesized_expression binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list | Respond to motion of the hsv cursor. |
def create(cls, name, size, type, quantity, duration, datacenter, vhosts,
password, snapshot_profile, background, sshkey):
if not background and not cls.intty():
background = True
datacenter_id_ = int(Datacenter.usable_id(datacenter))
paas_params = {
'name': name,
'size': size,
'type': type,
'duration': duration,
'datacenter_id': datacenter_id_,
}
if password:
paas_params['password'] = password
if quantity:
paas_params['quantity'] = quantity
paas_params.update(cls.convert_sshkey(sshkey))
if snapshot_profile:
paas_params['snapshot_profile'] = snapshot_profile
result = cls.call('paas.create', paas_params)
if not background:
cls.echo('Creating your PaaS instance.')
cls.display_progress(result)
cls.echo('Your PaaS instance %s has been created.' % name)
if vhosts:
paas_info = cls.info(name)
Vhost.create(paas_info, vhosts, True, background)
return result | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier block if_statement boolean_operator not_operator identifier not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier true expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment 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 identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier true identifier return_statement identifier | Create a new PaaS instance. |
def send_login_email(app_id, token, hook, email=None, user_id=None, lang="en_US",
url_login='https://pswdless.appspot.com/rest/login'):
return SendLoginEmail(app_id, token, hook, email, user_id, lang, url_login) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block return_statement call identifier argument_list identifier identifier identifier identifier identifier identifier identifier | Contact password-less server to send user a email containing the login link |
def add_success(self, group=None, type_='', field='', description=''):
group = group or '(200)'
group = int(group.lower()[1:-1])
self.retcode = self.retcode or group
if group != self.retcode:
raise ValueError('Two or more retcodes!')
type_ = type_ or '{String}'
p = Param(type_, field, description)
self.params['responce'][p.field] = p | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier boolean_operator identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript call attribute identifier identifier argument_list slice integer unary_operator integer expression_statement assignment attribute identifier identifier boolean_operator attribute identifier identifier identifier if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier boolean_operator identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier identifier | parse and append a success data param |
def kill_process(procname, scriptname):
import signal
import subprocess
p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
out, err = p.communicate()
for line in out.decode().splitlines():
if procname in line and scriptname in line:
pid = int(line.split()[1])
info('Stopping %s %s %d' % (procname, scriptname, pid))
os.kill(pid, signal.SIGKILL) | module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list for_statement identifier call attribute call attribute identifier identifier argument_list identifier argument_list block if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list subscript call attribute identifier identifier argument_list integer expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier | kill WSGI processes that may be running in development |
def _get_headers(self):
headers = {
'user-agent': 'IPinfoClient/Python{version}/1.0'.format(version=sys.version_info[0]),
'accept': 'application/json'
}
if self.access_token:
headers['authorization'] = 'Bearer {}'.format(self.access_token)
return headers | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier subscript attribute identifier identifier integer pair string string_start string_content string_end string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement identifier | Built headers for request to IPinfo API. |
def to_dict(self):
d = {
'model_type': 'regression',
'name': self.name,
'fit_filters': self.fit_filters,
'predict_filters': self.predict_filters,
'model_expression': self.model_expression,
'ytransform': YTRANSFORM_MAPPING[self.ytransform],
'fitted': self.fitted,
'fit_parameters': None,
'fit_rsquared': None,
'fit_rsquared_adj': None
}
if self.fitted:
d['fit_parameters'] = yamlio.frame_to_yaml_safe(
self.fit_parameters)
d['fit_rsquared'] = float(self.model_fit.rsquared)
d['fit_rsquared_adj'] = float(self.model_fit.rsquared_adj)
return d | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end 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 subscript identifier attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end none pair string string_start string_content string_end none pair string string_start string_content string_end none if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list attribute attribute identifier identifier identifier return_statement identifier | Returns a dictionary representation of a RegressionModel instance. |
def flatMap(f: Callable, xs: Iterable) -> List:
return flatten(lmap(f, xs)) | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block return_statement call identifier argument_list call identifier argument_list identifier identifier | Map a function onto an iterable and flatten the result. |
def publish_scene_remove(self, scene_id):
self.sequence_number += 1
self.publisher.send_multipart(msgs.MessageBuilder.scene_remove(self.sequence_number, scene_id))
return self.sequence_number | module function_definition identifier parameters identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier return_statement attribute identifier identifier | publish the removal of a scene |
def start(self, *args, **kwargs):
self._stop = False
super(ReadProbes, self).start(*args, **kwargs) | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier false expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier | start the read_probe thread |
def plot_discrete(self, show=False, annotations=True):
import matplotlib.pyplot as plt
axis = plt.axes()
axis.set_aspect('equal', 'datalim')
for i, points in enumerate(self.discrete):
color = ['g', 'k'][i in self.root]
axis.plot(*points.T, color=color)
if annotations:
for e in self.entities:
if not hasattr(e, 'plot'):
continue
e.plot(self.vertices)
if show:
plt.show()
return axis | module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier true block import_statement aliased_import dotted_name identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript list string string_start string_content string_end string string_start string_content string_end comparison_operator identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list list_splat attribute identifier identifier keyword_argument identifier identifier if_statement identifier block for_statement identifier attribute identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block continue_statement expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list return_statement identifier | Plot the closed curves of the path. |
def getAudioData(self):
with self.preload_mutex:
cache_url = self.buildUrl(cache_friendly=True)
if cache_url in __class__.cache:
logging.getLogger().debug("Got data for URL '%s' from cache" % (cache_url))
audio_data = __class__.cache[cache_url]
assert(audio_data)
else:
real_url = self.buildUrl()
audio_data = self.download(real_url)
assert(audio_data)
__class__.cache[cache_url] = audio_data
return audio_data | module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier true if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier expression_statement assignment identifier subscript attribute identifier identifier identifier assert_statement parenthesized_expression identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier assert_statement parenthesized_expression identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier | Fetch the audio data. |
def sample_wr(lst):
arr = np.array(lst)
indices = np.random.randint(len(lst), size=len(lst))
sample = np.empty(arr.shape, dtype=arr.dtype)
for i, ix in enumerate(indices):
sample[i] = arr[ix]
return list(sample) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier subscript identifier identifier return_statement call identifier argument_list identifier | Sample from lst, with replacement |
def _read_last_geometry(self):
header_pattern = r"\s+Optimization\sCycle:\s+" + \
str(len(self.data.get("energy_trajectory"))) + \
r"\s+Coordinates \(Angstroms\)\s+ATOM\s+X\s+Y\s+Z"
table_pattern = r"\s+\d+\s+\w+\s+([\d\-\.]+)\s+([\d\-\.]+)\s+([\d\-\.]+)"
footer_pattern = r"\s+Point Group\:\s+[\d\w\*]+\s+Number of degrees of freedom\:\s+\d+"
parsed_last_geometry = read_table_pattern(
self.text, header_pattern, table_pattern, footer_pattern)
if parsed_last_geometry == [] or None:
self.data["last_geometry"] = None
else:
self.data["last_geometry"] = process_parsed_coords(
parsed_last_geometry[0])
if self.data.get('charge') != None:
self.data["molecule_from_last_geometry"] = Molecule(
species=self.data.get('species'),
coords=self.data.get('last_geometry'),
charge=self.data.get('charge'),
spin_multiplicity=self.data.get('multiplicity')) | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end line_continuation call identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier identifier identifier if_statement boolean_operator comparison_operator identifier list none block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end none else_clause block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list subscript identifier integer if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end | Parses the last geometry from an optimization trajectory for use in a new input file. |
def slowlog_get(self, length=None):
if length is not None:
if not isinstance(length, int):
raise TypeError("length must be int or None")
return self.execute(b'SLOWLOG', b'GET', length)
else:
return self.execute(b'SLOWLOG', b'GET') | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier else_clause block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end | Returns the Redis slow queries log. |
def args(self):
return (self.base, self.item, self.leng, self.refs,
self.both, self.kind, self.type) | module function_definition identifier parameters identifier block return_statement tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier | Return all attributes as arguments tuple. |
def pick(self):
v = random.uniform(0, self.ub)
d = self.dist
c = self.vc - 1
s = self.vc
while True:
s = s / 2
if s == 0:
break
if v <= d[c][1]:
c -= s
else:
c += s
while len(d) <= c:
s = s / 2
c -= s
if s == 0:
break
if c == len(d) or v <= d[c][1]:
c -= 1
return d[c][0] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier attribute identifier identifier while_statement true block expression_statement assignment identifier binary_operator identifier integer if_statement comparison_operator identifier integer block break_statement if_statement comparison_operator identifier subscript subscript identifier identifier integer block expression_statement augmented_assignment identifier identifier else_clause block expression_statement augmented_assignment identifier identifier while_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator identifier integer expression_statement augmented_assignment identifier identifier if_statement comparison_operator identifier integer block break_statement if_statement boolean_operator comparison_operator identifier call identifier argument_list identifier comparison_operator identifier subscript subscript identifier identifier integer block expression_statement augmented_assignment identifier integer return_statement subscript subscript identifier identifier integer | picks a value accoriding to the given density |
def exists(self, **kwargs):
kwargs.pop('partition', None)
kwargs['transform_name'] = True
return self._exists(**kwargs) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment subscript identifier string string_start string_content string_end true return_statement call attribute identifier identifier argument_list dictionary_splat identifier | Providing a partition is not necessary on topology; causes errors |
def _init_read_gz(self):
self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS)
self.dbuf = b""
if self.__read(2) != b"\037\213":
raise ReadError("not a gzip file")
if self.__read(1) != b"\010":
raise CompressionError("unsupported compression method")
flag = ord(self.__read(1))
self.__read(6)
if flag & 4:
xlen = ord(self.__read(1)) + 256 * ord(self.__read(1))
self.read(xlen)
if flag & 8:
while True:
s = self.__read(1)
if not s or s == NUL:
break
if flag & 16:
while True:
s = self.__read(1)
if not s or s == NUL:
break
if flag & 2:
self.__read(2) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list unary_operator attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier string string_start string_end if_statement comparison_operator call attribute identifier identifier argument_list integer string string_start string_content escape_sequence escape_sequence string_end block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator call attribute identifier identifier argument_list integer string string_start string_content escape_sequence string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list integer if_statement binary_operator identifier integer block expression_statement assignment identifier binary_operator call identifier argument_list call attribute identifier identifier argument_list integer binary_operator integer call identifier argument_list call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier if_statement binary_operator identifier integer block while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement boolean_operator not_operator identifier comparison_operator identifier identifier block break_statement if_statement binary_operator identifier integer block while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement boolean_operator not_operator identifier comparison_operator identifier identifier block break_statement if_statement binary_operator identifier integer block expression_statement call attribute identifier identifier argument_list integer | Initialize for reading a gzip compressed fileobj. |
def start(self):
logging.info("Fixedconf watcher plugin: Started")
cidr = self.conf['fixed_cidr']
hosts = self.conf['fixed_hosts'].split(":")
route_spec = {cidr : hosts}
try:
common.parse_route_spec_config(route_spec)
self.q_route_spec.put(route_spec)
except Exception as e:
logging.warning("Fixedconf watcher plugin: "
"Invalid route spec: %s" % str(e)) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list 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 subscript attribute identifier identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary pair identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_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 call identifier argument_list identifier | Start the config watch thread or process. |
def render(self, rect, data):
size = self.element.get_minimum_size(data)
x = rect.x
y = rect.y
w = size.x
h = size.y
extra_width = rect.w - w
extra_height = rect.h - h
if self.horizontal_align == AlignLM.ALIGN_CENTER:
x += extra_width * 0.5
elif self.horizontal_align == AlignLM.ALIGN_RIGHT:
x += extra_width
elif self.horizontal_align == AlignLM.GROW_X:
w = rect.w
if self.vertical_align == AlignLM.ALIGN_MIDDLE:
y += extra_height * 0.5
elif self.vertical_align == AlignLM.ALIGN_TOP:
y += extra_height
elif self.vertical_align == AlignLM.GROW_Y:
h = rect.h
self.element.render(datatypes.Rectangle(x, y, w, h), data) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement augmented_assignment identifier binary_operator identifier float elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement augmented_assignment identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement augmented_assignment identifier binary_operator identifier float elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement augmented_assignment identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier identifier identifier | Draws the managed element in the correct alignment. |
def execute(self):
relevant_targets = self._get_non_synthetic_targets(self.get_targets())
if self.sideeffecting:
self._execute_for(relevant_targets)
else:
with self.invalidated(relevant_targets) as invalidation_check:
self._execute_for([vt.target for vt in invalidation_check.invalid_vts]) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier | Runs the tool on all source files that are located. |
def format_name_for_ext(metadata, ext, cm_default_formats=None, explicit_default=True):
text_repr = metadata.get('jupytext', {}).get('text_representation', {})
if text_repr.get('extension', '').endswith(ext) and text_repr.get('format_name'):
return text_repr.get('format_name')
formats = metadata.get('jupytext', {}).get('formats', '') or cm_default_formats
formats = long_form_multiple_formats(formats)
for fmt in formats:
if fmt['extension'] == ext:
if (not explicit_default) or fmt.get('format_name'):
return fmt.get('format_name')
if (not explicit_default) or ext in ['.Rmd', '.md']:
return None
return get_format_implementation(ext).format_name | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end dictionary if_statement boolean_operator call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier boolean_operator call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end string string_start string_end identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block if_statement boolean_operator parenthesized_expression not_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator parenthesized_expression not_operator identifier comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block return_statement none return_statement attribute call identifier argument_list identifier identifier | Return the format name for that extension |
def context_processor(self, fn):
self._defer(lambda app: app.context_processor(fn))
return fn | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list identifier return_statement identifier | Registers a template context processor function. |
def _display_status(normalized_data, stream):
if 'Pull complete' in normalized_data['status'] or 'Download complete' in normalized_data['status']:
stream.write("\n")
if 'id' in normalized_data:
stream.write("%s - " % normalized_data['id'])
stream.write("{0}\n".format(normalized_data['status'])) | module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list subscript identifier string string_start string_content string_end | print status message from docker-py stream. |
def _read(self, size):
data = ''
while len(data) < size:
try:
chunk = self.socket.recv(size-len(data))
except socket.error as (err, msg):
self.connected = False
raise ScratchError("[Errno %d] %s" % (err, msg))
if chunk == '':
self.connected = False
raise ScratchConnectionError("Connection broken")
data += chunk
return data | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end while_statement comparison_operator call identifier argument_list identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator identifier call identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target tuple identifier identifier block expression_statement assignment attribute identifier identifier false raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier if_statement comparison_operator identifier string string_start string_end block expression_statement assignment attribute identifier identifier false raise_statement call identifier argument_list string string_start string_content string_end expression_statement augmented_assignment identifier identifier return_statement identifier | Reads size number of bytes from Scratch and returns data as a string |
def _addDBParam(self, name, value):
if name[-4:] == '__OP':
return self._setComparasionOperator(name[:-4], value)
if name[-3:] == '.op':
return self._setComparasionOperator(name[:-3], value)
if name.find('__') != -1:
import re
name = name.replace('__','::')
elif name.find('.') != -1:
name = name.replace('.','::')
self._dbParams.append(
[name, value]
) | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator subscript identifier slice unary_operator integer string string_start string_content string_end block return_statement call attribute identifier identifier argument_list subscript identifier slice unary_operator integer identifier if_statement comparison_operator subscript identifier slice unary_operator integer string string_start string_content string_end block return_statement call attribute identifier identifier argument_list subscript identifier slice unary_operator integer identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end elif_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer 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 expression_statement call attribute attribute identifier identifier identifier argument_list list identifier identifier | Adds a database parameter |
def on_next_button(self, event):
self.do_auto_save()
self.selected_meas = []
index = self.specimens.index(self.s)
try:
fit_index = self.pmag_results_data['specimens'][self.s].index(
self.current_fit)
except KeyError:
fit_index = None
except ValueError:
fit_index = None
if index == len(self.specimens)-1:
index = 0
else:
index += 1
self.initialize_CART_rot(str(self.specimens[index]))
self.specimens_box.SetStringSelection(str(self.s))
if fit_index != None and self.s in self.pmag_results_data['specimens']:
try:
self.current_fit = self.pmag_results_data['specimens'][self.s][fit_index]
except IndexError:
self.current_fit = None
else:
self.current_fit = None
if self.ie_open:
self.ie.change_selected(self.current_fit)
self.update_selection() | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier try_statement block expression_statement assignment identifier call attribute subscript subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier identifier argument_list attribute identifier identifier except_clause identifier block expression_statement assignment identifier none except_clause identifier block expression_statement assignment identifier none if_statement comparison_operator identifier binary_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier integer else_clause block expression_statement augmented_assignment identifier integer expression_statement call attribute identifier identifier argument_list call identifier argument_list subscript attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier if_statement boolean_operator comparison_operator identifier none comparison_operator attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end block try_statement block expression_statement assignment attribute identifier identifier subscript subscript subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier identifier except_clause identifier block expression_statement assignment attribute identifier identifier none else_clause block expression_statement assignment attribute identifier identifier none if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list | update figures and text when a next button is selected |
def _attributeStr(self, name):
return "{}={}".format(
_encodeAttr(name),
",".join([_encodeAttr(v) for v in self.attributes[name]])) | module function_definition identifier parameters identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier subscript attribute identifier identifier identifier | Return name=value for a single attribute |
def basename(self, suffix=''):
return os.path.basename(self._file, suffix) if self._file else None | module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block return_statement conditional_expression call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier attribute identifier identifier none | The basename of the template file. |
def _get_visualization_classes():
visualization_attr = vars(import_module('picasso.visualizations'))
visualization_submodules = [
visualization_attr[x]
for x in visualization_attr
if isinstance(visualization_attr[x], ModuleType)]
visualization_classes = []
for submodule in visualization_submodules:
attrs = vars(submodule)
for attr_name in attrs:
attr = attrs[attr_name]
if (inspect.isclass(attr)
and issubclass(attr, BaseVisualization)
and attr is not BaseVisualization):
visualization_classes.append(attr)
return visualization_classes | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list_comprehension subscript identifier identifier for_in_clause identifier identifier if_clause call identifier argument_list subscript identifier identifier identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement parenthesized_expression boolean_operator boolean_operator call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Import visualizations classes dynamically |
def collect(self):
start = time()
self._collect_copy_specs()
self._collect_cmd_output()
self._collect_strings()
fields = (self.name(), time() - start)
self._log_debug("collected plugin '%s' in %s" % fields) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier tuple call attribute identifier identifier argument_list binary_operator call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier | Collect the data for a plugin. |
def rc4(data, key):
S, j, out = list(range(256)), 0, []
for i in range(256):
j = (j + S[i] + ord(key[i % len(key)])) % 256
S[i], S[j] = S[j], S[i]
i = j = 0
for ch in data:
i = (i + 1) % 256
j = (j + S[i]) % 256
S[i], S[j] = S[j], S[i]
out.append(chr(ord(ch) ^ S[(S[i] + S[j]) % 256]))
return "".join(out) | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier expression_list call identifier argument_list call identifier argument_list integer integer list for_statement identifier call identifier argument_list integer block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier subscript identifier identifier call identifier argument_list subscript identifier binary_operator identifier call identifier argument_list identifier integer expression_statement assignment pattern_list subscript identifier identifier subscript identifier identifier expression_list subscript identifier identifier subscript identifier identifier expression_statement assignment identifier assignment identifier integer for_statement identifier identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier subscript identifier identifier integer expression_statement assignment pattern_list subscript identifier identifier subscript identifier identifier expression_list subscript identifier identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list binary_operator call identifier argument_list identifier subscript identifier binary_operator parenthesized_expression binary_operator subscript identifier identifier subscript identifier identifier integer return_statement call attribute string string_start string_end identifier argument_list identifier | RC4 encryption and decryption method. |
def validate_positive_integer(option, value):
val = validate_integer(option, value)
if val <= 0:
raise ValueError("The value of %s must be "
"a positive integer" % (option,))
return val | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier integer block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier return_statement identifier | Validate that 'value' is a positive integer, which does not include 0. |
def ngram(n, iter_tokens):
z = len(iter_tokens)
return (iter_tokens[i:i+n] for i in range(z-n+1)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement generator_expression subscript identifier slice identifier binary_operator identifier identifier for_in_clause identifier call identifier argument_list binary_operator binary_operator identifier identifier integer | Return a generator of n-gram from an iterable |
def data_item_path(cls, project, dataset, data_item):
return google.api_core.path_template.expand(
"projects/{project}/datasets/{dataset}/dataItems/{data_item}",
project=project,
dataset=dataset,
data_item=data_item,
) | module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Return a fully-qualified data_item string. |
def main(port=8000, n_output=10, use_segmenter=False):
global n
global use_segmenter_flag
n = n_output
use_segmenter_flag = use_segmenter
logging.info("Start webserver...")
app.run(port=port) | module function_definition identifier parameters default_parameter identifier integer default_parameter identifier integer default_parameter identifier false block global_statement identifier global_statement identifier expression_statement assignment identifier identifier expression_statement assignment 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 keyword_argument identifier identifier | Main function starting the webserver. |
def _check_exception(self):
if self._saved_exception is not None:
x = self._saved_exception
self._saved_exception = None
raise x | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier none raise_statement identifier | if there's a saved exception, raise & clear it |
def _parse_wikiheadlines(path):
lang_match = re.match(r".*\.([a-z][a-z])-([a-z][a-z])$", path)
assert lang_match is not None, "Invalid Wikiheadlines filename: %s" % path
l1, l2 = lang_match.groups()
with tf.io.gfile.GFile(path) as f:
for line in f:
s1, s2 = line.split("|||")
yield {
l1: s1.strip(),
l2: s2.strip()
} | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier assert_statement comparison_operator identifier none binary_operator string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier as_pattern_target identifier block for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement yield dictionary pair identifier call attribute identifier identifier argument_list pair identifier call attribute identifier identifier argument_list | Generates examples from Wikiheadlines dataset file. |
def digested_line(line, digest_types):
digested_line = []
for i, ele in enumerate(line):
try:
digest_key = digest_types[i]
except IndexError:
digest_key = digest_types[0]
digest = Digest(acceptable_types=[digest_key])
try:
digested_line.append(repr(digest(ele)))
except Exception:
digested_line.append("")
return digested_line | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block try_statement block expression_statement assignment identifier subscript identifier identifier except_clause identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list keyword_argument identifier list identifier try_statement block expression_statement call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_end return_statement identifier | Returns list of digested values in line |
def _remove_blank(l):
ret = []
for i, _ in enumerate(l):
if l[i] == 0:
break
ret.append(l[i])
return ret | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator subscript identifier identifier integer block break_statement expression_statement call attribute identifier identifier argument_list subscript identifier identifier return_statement identifier | Removes trailing zeros in the list of integers and returns a new list of integers |
def entry_point():
try:
provider_group_factory()
notifiers_cli(obj={})
except NotifierException as e:
click.secho(f"ERROR: {e.message}", bold=True, fg="red")
exit(1) | module function_definition identifier parameters block try_statement block expression_statement call identifier argument_list expression_statement call identifier argument_list keyword_argument identifier dictionary except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation attribute identifier identifier string_end keyword_argument identifier true keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list integer | The entry that CLI is executed from |
def xclaim(self, stream, group_name, consumer_name, min_idle_time,
id, *ids):
fut = self.execute(
b'XCLAIM', stream, group_name, consumer_name, min_idle_time,
id, *ids
)
return wait_convert(fut, parse_messages) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier identifier identifier list_splat identifier return_statement call identifier argument_list identifier identifier | Claim a message for a given consumer |
def volume_down(self):
try:
return bool(self.send_get_command(self._urls.command_volume_down))
except requests.exceptions.RequestException:
_LOGGER.error("Connection error: volume down command not sent.")
return False | module function_definition identifier parameters identifier block try_statement block return_statement call identifier argument_list call attribute identifier identifier argument_list attribute attribute identifier identifier identifier except_clause attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement false | Volume down receiver via HTTP get command. |
def reset(self):
self.reset_bars()
self.url_progressbar.reset()
for prop in dir(self):
if prop.startswith("__"):
continue
prop_obj = getattr(self, prop)
if prop_obj is not None and hasattr(prop_obj, "reset"):
prop_obj.reset()
properties = (
getattr(self.__class__, prop)
for prop in self._property_list
if hasattr(self.__class__, prop)
)
for prop in properties:
if hasattr(prop, "reset"):
prop.reset()
elif hasattr(prop, "__set__"):
prop.__set__(None, "")
self.additional_info = None | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list for_statement identifier call identifier argument_list identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block continue_statement expression_statement assignment identifier call identifier argument_list identifier identifier if_statement boolean_operator comparison_operator identifier none call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier generator_expression call identifier argument_list attribute identifier identifier identifier for_in_clause identifier attribute identifier identifier if_clause call identifier argument_list attribute identifier identifier identifier for_statement identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list none string string_start string_end expression_statement assignment attribute identifier identifier none | Reset all inputs back to default. |
def stop(self):
yield from self._stop_ubridge()
if self.is_running():
self._terminate_process()
if self._process.returncode is None:
try:
yield from wait_for_process_termination(self._process, timeout=3)
except asyncio.TimeoutError:
if self._process.returncode is None:
try:
self._process.kill()
except OSError as e:
log.error("Cannot stop the VPCS process: {}".format(e))
if self._process.returncode is None:
log.warn('VPCS VM "{}" with PID={} is still running'.format(self._name, self._process.pid))
self._process = None
self._started = False
yield from super().stop() | module function_definition identifier parameters identifier block expression_statement yield call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator attribute attribute identifier identifier identifier none block try_statement block expression_statement yield call identifier argument_list attribute identifier identifier keyword_argument identifier integer except_clause attribute identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier none block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier false expression_statement yield call attribute call identifier argument_list identifier argument_list | Stops the VPCS process. |
def try_eval_metadata(metadata, name):
value = metadata[name]
if not isinstance(value, (str, unicode)):
return
if (value.startswith('"') and value.endswith('"')) or (value.startswith("'") and value.endswith("'")):
if name in ['active', 'magic_args', 'language']:
metadata[name] = value[1:-1]
return
if value.startswith('c(') and value.endswith(')'):
value = '[' + value[2:-1] + ']'
elif value.startswith('list(') and value.endswith(')'):
value = '[' + value[5:-1] + ']'
try:
metadata[name] = ast.literal_eval(value)
except (SyntaxError, ValueError):
return | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement not_operator call identifier argument_list identifier tuple identifier identifier block return_statement if_statement boolean_operator parenthesized_expression 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 parenthesized_expression 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 if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier identifier subscript identifier slice integer unary_operator integer return_statement 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 expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end subscript identifier slice integer unary_operator integer string string_start string_content string_end elif_clause 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 expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end subscript identifier slice integer unary_operator integer string string_start string_content string_end try_statement block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier block return_statement | Evaluate given metadata to a python object, if possible |
def hardmax(attrs, inputs, proto_obj):
input_tensor_data = proto_obj.model_metadata.get('input_tensor_data')[0]
input_shape = input_tensor_data[1]
axis = int(attrs.get('axis', 1))
axis = axis if axis >= 0 else len(input_shape) + axis
if axis == len(input_shape) - 1:
amax = symbol.argmax(inputs[0], axis=-1)
one_hot = symbol.one_hot(amax, depth=input_shape[-1])
return one_hot, attrs, inputs
new_shape = (int(np.prod(input_shape[:axis])),
int(np.prod(input_shape[axis:])))
reshape_op = symbol.reshape(inputs[0], new_shape)
amax = symbol.argmax(reshape_op, axis=-1)
one_hot = symbol.one_hot(amax, depth=new_shape[-1])
hardmax_op = symbol.reshape(one_hot, input_shape)
return hardmax_op, attrs, inputs | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier conditional_expression identifier comparison_operator identifier integer binary_operator call identifier argument_list identifier identifier if_statement comparison_operator identifier binary_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer keyword_argument identifier unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier subscript identifier unary_operator integer return_statement expression_list identifier identifier identifier expression_statement assignment identifier tuple call identifier argument_list call attribute identifier identifier argument_list subscript identifier slice identifier call identifier argument_list call attribute identifier identifier argument_list subscript identifier slice identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier subscript identifier unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement expression_list identifier identifier identifier | Returns batched one-hot vectors. |
def call(self, callname, arguments=None):
action = getattr(self.api, callname, None)
if action is None:
try:
action = self.api.ENDPOINT_OVERRIDES.get(callname, None)
except AttributeError:
action = callname
if not callable(action):
request = self._generate_request(action, arguments)
if action is None:
return self._generate_result(
callname, self.api.call(*call_args(callname, arguments)))
return self._generate_result(
callname, self.api.call(*call_args(action, arguments)))
request = self._generate_request(callname, arguments)
return self._generate_result(callname, action(request)) | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier none if_statement comparison_operator identifier none block try_statement block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier none except_clause identifier block expression_statement assignment identifier identifier if_statement not_operator call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block return_statement call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list list_splat call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list list_splat call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier call identifier argument_list identifier | Executed on each scheduled iteration |
def hosting_history(self, query, **kwargs):
return self._results('hosting-history', '/v1/{0}/hosting-history'.format(query), cls=GroupedIterable, **kwargs) | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement 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 identifier keyword_argument identifier identifier dictionary_splat identifier | Returns the hosting history from the given domain name |
def _apply_summaries(self):
def as_frame(r):
if isinstance(r, pd.Series):
return r.to_frame()
else:
return r
df = self.data
if df.index.nlevels > 1:
raise ValueError(
"You cannot currently have both summary rows and columns on a "
"MultiIndex."
)
_df = df
if self.summary_rows:
rows = pd.concat([agg.apply(_df)
for agg in self._cleaned_summary_rows], axis=1).T
df = pd.concat([df, as_frame(rows)], axis=0)
if self.summary_cols:
cols = pd.concat([agg.apply(_df)
for agg in self._cleaned_summary_cols], axis=1)
df = pd.concat([df, as_frame(cols)], axis=1)
return df | module function_definition identifier parameters identifier block function_definition identifier parameters identifier block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list else_clause block return_statement identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier integer block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier keyword_argument identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list list identifier call identifier argument_list identifier keyword_argument identifier integer if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier keyword_argument identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list list identifier call identifier argument_list identifier keyword_argument identifier integer return_statement identifier | Add all summary rows and columns. |
def mark_dead(self, proxy, _time=None):
if proxy not in self.proxies:
logger.warn("Proxy <%s> was not found in proxies list" % proxy)
return
if proxy in self.good:
logger.debug("GOOD proxy became DEAD: <%s>" % proxy)
else:
logger.debug("Proxy <%s> is DEAD" % proxy)
self.unchecked.discard(proxy)
self.good.discard(proxy)
self.dead.add(proxy)
now = _time or time.time()
state = self.proxies[proxy]
state.backoff_time = self.backoff(state.failed_attempts)
state.next_check = now + state.backoff_time
state.failed_attempts += 1 | module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier boolean_operator identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer | Mark a proxy as dead |
def _bytes_to_str(lines):
if len(lines) >= 1 and hasattr(lines[0], 'decode'):
return [line.decode('utf-8') for line in lines]
else:
return lines | module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer call identifier argument_list subscript identifier integer string string_start string_content string_end block return_statement list_comprehension call attribute identifier identifier argument_list string string_start string_content string_end for_in_clause identifier identifier else_clause block return_statement identifier | Convert all lines from byte string to unicode string, if necessary |
def _find_usage_applications(self):
applications = self.conn.describe_applications()
self.limits['Applications']._add_current_usage(
len(applications['Applications']),
aws_type='AWS::ElasticBeanstalk::Application',
) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end | find usage for ElasticBeanstalk applications |
def check_pil(func):
def __wrapper(*args, **kwargs):
root = kwargs.get('root')
if not Image:
if root and root.get_opt('warn'):
warn("Images manipulation require PIL")
return 'none'
return func(*args, **kwargs)
return __wrapper | module function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block if_statement boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call identifier argument_list string string_start string_content string_end return_statement string string_start string_content string_end return_statement call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier | PIL module checking decorator. |
def order_manually(sub_commands):
order = [
"start",
"projects",
]
ordered = []
commands = dict(zip([cmd for cmd in sub_commands], sub_commands))
for k in order:
ordered.append(commands.get(k, ""))
if k in commands:
del commands[k]
for k in commands:
ordered.append(commands[k])
return ordered | module function_definition identifier parameters identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list call identifier argument_list list_comprehension identifier for_in_clause identifier identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_end if_statement comparison_operator identifier identifier block delete_statement subscript identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier identifier return_statement identifier | Order sub-commands for display |
def layers(self):
if self._layers is None:
self.__init()
self._getLayers()
return self._layers | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement attribute identifier identifier | gets the layers for the feature service |
def pyname(self):
if self.pymodule.endswith('__init__'):
return self.pymodule.split('.')[-2]
else:
return self.pymodule.split('.')[-1] | module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block return_statement subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end unary_operator integer else_clause block return_statement subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end unary_operator integer | Name of the compiled module. |
def _create_sending_stream(self, pub_addr):
sock = self._zmq_context.socket(zmq.PUB)
sock.setsockopt(zmq.IDENTITY, self.sender_id)
sock.connect(pub_addr)
stream = ZMQStream(sock, io_loop=self.io_loop)
return stream | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier return_statement identifier | Create a `ZMQStream` for sending responses back to Mongrel2. |
def do_copy_file(self, args):
path, prefixed_path, source_storage = args
reset_connection(self.storage)
if self.collectfast_enabled and not self.dry_run:
try:
if not should_copy_file(
self.storage, path, prefixed_path, source_storage):
return False
except Exception as e:
if settings.debug:
raise
self.stdout.write(smart_str(
"Ignored error in Collectfast:\n%s\n--> Continuing using "
"default collectstatic." % e))
self.num_copied_files += 1
return super(Command, self).copy_file(
path, prefixed_path, source_storage) | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier expression_statement call identifier argument_list attribute identifier identifier if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block try_statement block if_statement not_operator call identifier argument_list attribute identifier identifier identifier identifier identifier block return_statement false except_clause as_pattern identifier as_pattern_target identifier block if_statement attribute identifier identifier block raise_statement expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list binary_operator concatenated_string string string_start string_content escape_sequence escape_sequence string_end string string_start string_content string_end identifier expression_statement augmented_assignment attribute identifier identifier integer return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier | Determine if file should be copied or not and handle exceptions. |
def _translate_cond(self, c):
if isinstance(c, claripy.ast.Base) and not c.singlevalued:
raise SimFastMemoryError("size not supported")
if c is None:
return True
else:
return self.state.solver.eval_upto(c, 1)[0] | module function_definition identifier parameters identifier identifier block if_statement boolean_operator call identifier argument_list identifier attribute attribute identifier identifier identifier not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block return_statement true else_clause block return_statement subscript call attribute attribute attribute identifier identifier identifier identifier argument_list identifier integer integer | Checks whether this condition can be supported by FastMemory." |
def join_session(self, sid):
self._rest.add_header('X-STC-API-Session', sid)
self._sid = sid
try:
status, data = self._rest.get_request('objects', 'system1',
['version', 'name'])
except resthttp.RestHttpError as e:
self._rest.del_header('X-STC-API-Session')
self._sid = None
raise RuntimeError('failed to join session "%s": %s' % (sid, e))
return data['version'] | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier identifier try_statement block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier none raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement subscript identifier string string_start string_content string_end | Attach to an existing session. |
def count_rows(self, table, cols='*'):
query = 'SELECT COUNT({0}) FROM {1}'.format(join_cols(cols), wrap(table))
result = self.fetch(query)
return result if result is not None else 0 | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement conditional_expression identifier comparison_operator identifier none integer | Get the number of rows in a particular table. |
def _route(self):
self._app.route('/',
method='GET',
callback=self._get_logger_list)
self._app.route('/stats',
method='GET',
callback=self._fetch_handler_stats)
self._app.route('/<name>/start',
method='POST',
callback=self._add_logger_by_name)
self._app.route('/<name>/stop',
method='DELETE',
callback=self._stop_logger_by_name)
self._app.route('/<name>/config',
method='GET',
callback=self._get_logger_conf)
self._app.route('/<name>/rotate',
method='POST',
callback=self._rotate_capturer_log) | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier | Handles server route instantiation. |
def consume_value(self, ctx, opts):
value = click.Option.consume_value(self, ctx, opts)
if not value:
gandi = ctx.obj
value = gandi.get(self.name)
if value is not None:
self.display_value(ctx, value)
else:
if self.default is None and self.required:
metavar = ''
if self.type.name not in ['integer', 'text']:
metavar = self.make_metavar()
prompt = '%s %s' % (self.help, metavar)
gandi.echo(prompt)
return value | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier identifier else_clause block if_statement boolean_operator comparison_operator attribute identifier identifier none attribute identifier identifier block expression_statement assignment identifier string string_start string_end if_statement comparison_operator attribute attribute identifier identifier identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Retrieve default value and display it when prompt is disabled. |
def shell_sqlalchemy(session: SqlalchemySession, backend: ShellBackend):
namespace = {
'session': session
}
namespace.update(backend.get_namespace())
embed(user_ns=namespace, header=backend.header) | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier | This command includes SQLAlchemy DB Session |
def _error_is_decreasing(self, last_error):
current_error = self._compute_error()
is_decreasing = current_error < last_error
return is_decreasing, current_error | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier comparison_operator identifier identifier return_statement expression_list identifier identifier | True if current error is less than last_error. |
def np_hash(a):
if a is None:
return hash(None)
a = np.ascontiguousarray(a)
return int(hashlib.sha1(a.view(a.dtype)).hexdigest(), 16) | module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block return_statement call identifier argument_list none expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list integer | Return a hash of a NumPy array. |
def picard_reorder(picard, in_bam, ref_file, out_file):
if not file_exists(out_file):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, out_file) as tx_out_file:
opts = [("INPUT", in_bam),
("OUTPUT", tx_out_file),
("REFERENCE", ref_file),
("ALLOW_INCOMPLETE_DICT_CONCORDANCE", "true"),
("TMP_DIR", tmp_dir)]
picard.run("ReorderSam", opts)
return out_file | module function_definition identifier parameters identifier identifier identifier identifier block if_statement not_operator call identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier as_pattern_target identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier identifier as_pattern_target identifier block expression_statement assignment identifier list tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier | Reorder BAM file to match reference file ordering. |
def _override_size(vm_):
vm_size = get_size(vm_)
if 'cores' in vm_:
vm_size['cores'] = vm_['cores']
if 'ram' in vm_:
vm_size['ram'] = vm_['ram']
return vm_size | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement identifier | Apply any extra component overrides to VM from the cloud profile. |
def QueueNotification(self, notification=None, timestamp=None, **kw):
if notification is None:
notification = rdf_flows.GrrNotification(**kw)
session_id = notification.session_id
if session_id:
if timestamp is None:
timestamp = self.frozen_timestamp
notification.timestamp = timestamp
if timestamp is None:
ts_str = "None"
else:
ts_str = int(timestamp)
key = "%s!%s" % (session_id, ts_str)
existing = self.notifications.get(key)
if existing is not None:
if existing.last_status < notification.last_status:
self.notifications[key] = notification
else:
self.notifications[key] = notification | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier attribute identifier identifier if_statement identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier identifier identifier | Queues a notification for a flow. |
def task(func):
def task_wrapper(*args, **kwargs):
return spawn(func, *args, **kwargs)
return task_wrapper | module function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier | Decorator to run the decorated function as a Task |
def ReadIDsForAllSignedBinaries(self, cursor=None
):
cursor.execute(
"SELECT binary_type, binary_path FROM signed_binary_references")
return [
rdf_objects.SignedBinaryID(binary_type=binary_type, path=binary_path)
for binary_type, binary_path in cursor.fetchall()
] | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement list_comprehension call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list | Returns ids for all signed binaries in the DB. |
def known(self, node):
ref = node.get('type', Namespace.xsins)
if ref is None:
return None
qref = qualify(ref, node, node.namespace())
query = BlindQuery(qref)
return query.execute(self.schema) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier call identifier argument_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier | resolve type referenced by @xsi:type |
def controller(self):
if hasattr(self, 'controllers'):
if len(self.controllers) > 1:
raise TypeError("Only one controller per account.")
return self.controllers[0]
raise AttributeError("There is no controller assigned.") | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end return_statement subscript attribute identifier identifier integer raise_statement call identifier argument_list string string_start string_content string_end | Show current linked controllers. |
def annotate_subplot(ax, ncols=1, nrows=1, letter='a',
linear_offset=0.075, fontsize=8):
ax.text(-ncols*linear_offset, 1+nrows*linear_offset, letter,
horizontalalignment='center',
verticalalignment='center',
fontsize=fontsize, fontweight='demibold',
transform=ax.transAxes) | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier string string_start string_content string_end default_parameter identifier float default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list binary_operator unary_operator identifier identifier binary_operator integer binary_operator identifier identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier | add a subplot annotation number |
def updateMovie(self, imageFile):
try:
photo = ImageTk.PhotoImage(Image.open(imageFile))
except:
print("photo error")
print('-'*60)
traceback.print_exc(file=sys.stdout)
print('-'*60)
self.label.configure(image = photo, height=288)
self.label.image = photo | module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier except_clause block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list binary_operator string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end integer expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier integer expression_statement assignment attribute attribute identifier identifier identifier identifier | Update the image file as video frame in the GUI. |
def add_fact(term, fact, author=''):
logger.info('Adding new fact %s: %s', term, fact)
if not db.facts.find({'term': term_regex(term)}).count():
db.facts.insert({
'term': term,
'fact': fact,
'set_by': author,
'set_date': time.time()
})
db.facts.ensure_index('term') | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier if_statement not_operator call attribute call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end call identifier argument_list identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list 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 call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end | Records a new fact with a given term. Optionally can set an author |
def gen_locustfile(testcase_file_path):
locustfile_path = 'locustfile.py'
template_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"templates",
"locustfile_template"
)
with io.open(template_path, encoding='utf-8') as template:
with io.open(locustfile_path, 'w', encoding='utf-8') as locustfile:
template_content = template.read()
template_content = template_content.replace("$TESTCASE_FILE", testcase_file_path)
locustfile.write(template_content)
return locustfile_path | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | generate locustfile from template. |
def recompress_archive(archive, verbosity=0, interactive=True):
util.check_existing_filename(archive)
util.check_writable_filename(archive)
if verbosity >= 0:
util.log_info("Recompressing %s ..." % (archive,))
res = _recompress_archive(archive, verbosity=verbosity, interactive=interactive)
if res and verbosity >= 0:
util.log_info(res)
return 0 | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier true block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement boolean_operator identifier comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list identifier return_statement integer | Recompress an archive to hopefully smaller size. |
def _onCoreModuleLoad(self, event):
if not self._modelRuntsByBuid:
return
self._modelRuntsByBuid = {}
self._modelRuntsByPropValu = collections.defaultdict(list) | module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier | Clear the cached model rows and rebuild them only if they have been loaded already. |
async def __check_last_ping(self, run_listen):
if self.__last_ping < time.time()-10:
self._logger.warning("Last ping too old. Restarting the agent.")
run_listen.cancel()
self.__cancel_remaining_safe_tasks()
else:
self._loop.call_later(1, self._create_safe_task, self.__check_last_ping(run_listen)) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier binary_operator call attribute identifier identifier argument_list integer block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list integer attribute identifier identifier call attribute identifier identifier argument_list identifier | Check if the last timeout is too old. If it is, kills the run_listen task |
def parse_dformat(dformat, check=True):
if check and dformat not in ['dense', 'sparse']:
raise IOError(
"{} is a bad features format, please choose 'dense' or 'sparse'"
.format(dformat))
return dformat | module function_definition identifier parameters identifier default_parameter identifier true block if_statement boolean_operator identifier comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier | Return `dformat` or raise if it is not 'dense' or 'sparse |
def alter_poms(pom_dir, additional_params, repo_url=None, mvn_repo_local=None):
work_dir = os.getcwd()
os.chdir(pom_dir)
try:
if repo_url:
settings_filename = create_mirror_settings(repo_url)
else:
settings_filename = None
args = ["mvn", "clean"]
if mvn_repo_local:
args.extend(["-s", settings_filename])
if mvn_repo_local:
args.append("-Dmaven.repo.local=%s" % mvn_repo_local)
param_list = additional_params.split(" ")
args.extend(param_list)
logging.debug("Running command: %s", " ".join(args))
command = Popen(args, stdout=PIPE, stderr=STDOUT)
stdout = command.communicate()[0]
if command.returncode:
logging.error("POM manipulation failed. Output:\n%s" % stdout)
else:
logging.debug("POM manipulation succeeded. Output:\n%s" % stdout)
finally:
os.chdir(work_dir) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier try_statement block if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier none expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end 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 attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier finally_clause block expression_statement call attribute identifier identifier argument_list identifier | Runs mvn clean command with provided additional parameters to perform pom updates by pom-manipulation-ext. |
def __get_button_events(self, state, timeval=None):
changed_buttons = self.__detect_button_events(state)
events = self.__emulate_buttons(changed_buttons, timeval)
return events | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier | Get the button events from xinput. |
def _adjust_for_new_root(self, path):
if self.new_root is None:
return path
elif path.startswith(self.new_root):
return path[len(self.new_root):]
else:
return path | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block return_statement identifier elif_clause call attribute identifier identifier argument_list attribute identifier identifier block return_statement subscript identifier slice call identifier argument_list attribute identifier identifier else_clause block return_statement identifier | Adjust a path given the new root directory of the output. |
def parse_querystring(msg):
'parse a querystring into keys and values'
for part in msg.querystring.strip().lstrip('?').split('&'):
key, value = part.split('=')
yield key, value | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end for_statement identifier call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement yield expression_list identifier identifier | parse a querystring into keys and values |
def read_int(nbytes: int, *, byteorder: str = "big", from_=None) -> int:
return (yield (Traps._read_int, nbytes, byteorder, from_)) | module function_definition identifier parameters typed_parameter identifier type identifier keyword_separator typed_default_parameter identifier type identifier string string_start string_content string_end default_parameter identifier none type identifier block return_statement parenthesized_expression yield tuple attribute identifier identifier identifier identifier identifier | read some bytes as integer |
def _machine_bytes():
machine_hash = hashlib.md5()
if PY3:
machine_hash.update(socket.gethostname().encode())
else:
machine_hash.update(socket.gethostname())
return machine_hash.digest()[0:3] | module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement subscript call attribute identifier identifier argument_list slice integer integer | Get the machine portion of an ObjectId. |
def beautify_file(self, path):
error = False
if(path == '-'):
data = sys.stdin.read()
result, error = self.beautify_string(data, '(stdin)')
sys.stdout.write(result)
else:
data = self.read_file(path)
result, error = self.beautify_string(data, path)
if(data != result):
if(self.check_only):
if not error:
error = (result != data)
else:
if(self.backup):
self.write_file(path+'.bak', data)
self.write_file(path, result)
return error | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier false if_statement parenthesized_expression comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier if_statement parenthesized_expression comparison_operator identifier identifier block if_statement parenthesized_expression attribute identifier identifier block if_statement not_operator identifier block expression_statement assignment identifier parenthesized_expression comparison_operator identifier identifier else_clause block if_statement parenthesized_expression attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier | Beautify bash script file. |
def print_code_table(self, out=sys.stdout):
out.write(u'bits code (value) symbol\n')
for symbol, (bitsize, value) in sorted(self._table.items()):
out.write(u'{b:4d} {c:10} ({v:5d}) {s!r}\n'.format(
b=bitsize, v=value, s=symbol, c=bin(value)[2:].rjust(bitsize, '0')
)) | module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute subscript call identifier argument_list identifier slice integer identifier argument_list identifier string string_start string_content string_end | Print code table overview |
def resolve_colors(self, colorstack):
'Returns the curses attribute for the colorstack, a list of color option names sorted highest-precedence color first.'
attr = CursesAttr()
for coloropt in colorstack:
c = self.get_color(coloropt)
attr = attr.update_attr(c)
return attr | module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier | Returns the curses attribute for the colorstack, a list of color option names sorted highest-precedence color first. |
def export_module_spec_with_checkpoint(module_spec,
checkpoint_path,
export_path,
scope_prefix=""):
with tf.Graph().as_default():
m = hub.Module(module_spec)
assign_map = {
scope_prefix + name: value for name, value in m.variable_map.items()
}
tf.train.init_from_checkpoint(checkpoint_path, assign_map)
init_op = tf.initializers.global_variables()
with tf.Session() as session:
session.run(init_op)
m.export(export_path, session) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_end block with_statement with_clause with_item call attribute call attribute identifier identifier argument_list identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary_comprehension pair binary_operator identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier | Exports given checkpoint as tfhub module with given spec. |
def seek_to_position(position):
message = command(protobuf.CommandInfo_pb2.SeekToPlaybackPosition)
send_command = message.inner()
send_command.options.playbackPosition = position
return message | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier identifier return_statement identifier | Seek to an absolute position in stream. |
def remove_redis_keyword(self, keyword):
redisvr.srem(CMS_CFG['redis_kw'] + self.userinfo.user_name, keyword)
return json.dump({}, self) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier identifier return_statement call attribute identifier identifier argument_list dictionary identifier | Remove the keyword for redis. |
def write(self, data):
if data == '\n':
return self.stream.write(data)
else:
bytes_ = 0
for line in data.splitlines(True):
nl = ''
if line.endswith('\n'):
line = line[:-1]
nl = '\n'
bytes_ += self.stream.write(
f'{self.start}{line}{self.default}{nl}'
) or 0
return bytes_ | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content escape_sequence string_end block return_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier integer for_statement identifier call attribute identifier identifier argument_list true block expression_statement assignment identifier string string_start string_end if_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement assignment identifier subscript identifier slice unary_operator integer expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier boolean_operator call attribute attribute identifier identifier identifier argument_list string string_start interpolation attribute identifier identifier interpolation identifier interpolation attribute identifier identifier interpolation identifier string_end integer return_statement identifier | This could be a bit less clumsy. |
def textContent(self, text: str) -> None:
self._set_text_content(text)
if self.connected:
self._set_text_content_web(text) | module function_definition identifier parameters identifier typed_parameter identifier type identifier type none block expression_statement call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier | Set textContent both on this node and related browser node. |
def closed_sets(C, mincount_connectivity=0):
n = np.shape(C)[0]
S = connected_sets(C, mincount_connectivity=mincount_connectivity, strong=True)
closed = []
for s in S:
mask = np.zeros(n, dtype=bool)
mask[s] = True
if C[np.ix_(mask, ~mask)].sum() == 0:
closed.append(s)
return closed | module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment subscript identifier identifier true if_statement comparison_operator call attribute subscript identifier call attribute identifier identifier argument_list identifier unary_operator identifier identifier argument_list integer block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Computes the strongly connected closed sets of C |
def LoadState( self, config_parser ):
if not config_parser:
return
if (
not config_parser.has_section( 'window' ) or (
config_parser.has_option( 'window','maximized' ) and
config_parser.getboolean( 'window', 'maximized' )
)
):
self.Maximize(True)
try:
width,height,x,y = [
config_parser.getint( 'window',key )
for key in ['width','height','x','y']
]
self.SetPosition( (x,y))
self.SetSize( (width,height))
except ConfigParser.NoSectionError, err:
pass
except Exception, err:
log.error(
"Unable to load window preferences, ignoring: %s", traceback.format_exc()
)
try:
font_size = config_parser.getint('window', 'font_size')
except Exception:
pass
else:
font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
font.SetPointSize(font_size)
for ctrl in self.ProfileListControls:
ctrl.SetFont(font)
for control in self.ProfileListControls:
control.LoadState( config_parser )
self.config = config_parser
wx.EVT_CLOSE( self, self.OnCloseWindow ) | module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement if_statement parenthesized_expression boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end parenthesized_expression boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end 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 block expression_statement call attribute identifier identifier argument_list true try_statement block expression_statement assignment pattern_list identifier identifier identifier identifier list_comprehension call attribute identifier identifier argument_list string string_start string_content string_end identifier for_in_clause identifier 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 expression_statement call attribute identifier identifier argument_list tuple identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier except_clause attribute identifier identifier identifier block pass_statement except_clause identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list try_statement 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 except_clause identifier block pass_statement else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier | Set our window state from the given config_parser instance |
def register(self, switch, signal=signals.switch_registered):
if not switch.name:
raise ValueError('Switch name cannot be blank')
switch.manager = self
self.__persist(switch)
signal.call(switch) | module function_definition identifier parameters identifier identifier default_parameter identifier attribute identifier identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier | Register a switch and persist it to the storage. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.