code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def generate_new_cid(upstream_cid=None):
if upstream_cid is None:
return str(uuid.uuid4()) if getattr(settings, 'CID_GENERATE', False) else None
if (
getattr(settings, 'CID_CONCATENATE_IDS', False)
and getattr(settings, 'CID_GENERATE', False)
):
return '%s, %s' % (upstream_cid, str(uuid.uuid4()))
return upstream_cid | module function_definition identifier parameters default_parameter identifier none block if_statement comparison_operator identifier none block return_statement conditional_expression call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end false none if_statement parenthesized_expression boolean_operator call identifier argument_list identifier string string_start string_content string_end false call identifier argument_list identifier string string_start string_content string_end false block return_statement binary_operator string string_start string_content string_end tuple identifier call identifier argument_list call attribute identifier identifier argument_list return_statement identifier | Generate a new correlation id, possibly based on the given one. |
def _setup_master(self):
self.broker = mitogen.master.Broker(install_watcher=False)
self.router = mitogen.master.Router(
broker=self.broker,
max_message_size=4096 * 1048576,
)
self._setup_responder(self.router.responder)
mitogen.core.listen(self.broker, 'shutdown', self.on_broker_shutdown)
mitogen.core.listen(self.broker, 'exit', self.on_broker_exit)
self.listener = mitogen.unix.Listener(
router=self.router,
path=self.unix_listener_path,
backlog=C.DEFAULT_FORKS,
)
self._enable_router_debug()
self._enable_stack_dumps() | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier false expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier binary_operator integer integer expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Construct a Router, Broker, and mitogen.unix listener |
def address_info(self):
return {
"node_ip_address": self._node_ip_address,
"redis_address": self._redis_address,
"object_store_address": self._plasma_store_socket_name,
"raylet_socket_name": self._raylet_socket_name,
"webui_url": self._webui_url,
} | module function_definition identifier parameters identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier | Get a dictionary of addresses. |
def dependents_of_addresses(self, addresses):
seen = OrderedSet(addresses)
for address in addresses:
seen.update(self._dependent_address_map[address])
seen.update(self._implicit_dependent_address_map[address])
return seen | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier identifier return_statement identifier | Given an iterable of addresses, yield all of those addresses dependents. |
def display(self):
for pkg in self.binary:
name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version()
find = find_package("{0}{1}{2}".format(name, ver, self.meta.sp),
self.meta.pkg_path)
if find:
package = Utils().read_file(
self.meta.pkg_path + "".join(find))
print(package)
else:
message = "Can't dislpay"
if len(self.binary) > 1:
bol = eol = ""
else:
bol = eol = "\n"
self.msg.pkg_not_found(bol, pkg, message, eol)
raise SystemExit(1) | module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier if_statement identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list binary_operator attribute attribute identifier identifier identifier call attribute string string_start string_end identifier argument_list identifier expression_statement call identifier argument_list identifier else_clause block expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier assignment identifier string string_start string_end else_clause block expression_statement assignment identifier assignment identifier string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier raise_statement call identifier argument_list integer | Print the Slackware packages contents |
def sync_fetch(self, task):
if not self._running:
return self.ioloop.run_sync(functools.partial(self.async_fetch, task, lambda t, _, r: True))
wait_result = threading.Condition()
_result = {}
def callback(type, task, result):
wait_result.acquire()
_result['type'] = type
_result['task'] = task
_result['result'] = result
wait_result.notify()
wait_result.release()
wait_result.acquire()
self.ioloop.add_callback(self.fetch, task, callback)
while 'result' not in _result:
wait_result.wait()
wait_result.release()
return _result['result'] | module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier lambda lambda_parameters identifier identifier identifier true expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier 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 call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier identifier while_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement subscript identifier string string_start string_content string_end | Synchronization fetch, usually used in xmlrpc thread |
def _bed_to_bed6(orig_file, out_dir):
bed6_file = os.path.join(out_dir, "%s-bed6%s" % os.path.splitext(os.path.basename(orig_file)))
if not utils.file_exists(bed6_file):
with open(bed6_file, "w") as out_handle:
for i, region in enumerate(list(x) for x in pybedtools.BedTool(orig_file)):
region = [x for x in list(region) if x]
fillers = [str(i), "1.0", "+"]
full = region + fillers[:6 - len(region)]
out_handle.write("\t".join(full) + "\n")
return bed6_file | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement pattern_list identifier identifier call identifier generator_expression call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call identifier argument_list identifier if_clause identifier expression_statement assignment identifier list call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier binary_operator identifier subscript identifier slice binary_operator integer call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier string string_start string_content escape_sequence string_end return_statement identifier | Convert bed to required bed6 inputs. |
def site_info(request):
site = get_current_site(request)
context = {
'WAFER_CONFERENCE_NAME': site.name,
'WAFER_CONFERENCE_DOMAIN': site.domain,
}
return context | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier return_statement identifier | Expose the site's info to templates |
def _validate_xor_args(self, p):
if len(p[1]) != 2:
raise ValueError('Invalid syntax: XOR only accepts 2 arguments, got {0}: {1}'.format(len(p[1]), p)) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list subscript identifier integer integer block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list subscript identifier integer identifier | Raises ValueError if 2 arguments are not passed to an XOR |
def _HandleLegacy(self, args, token=None):
hunt_obj = aff4.FACTORY.Open(
args.hunt_id.ToURN(), aff4_type=implementation.GRRHunt, token=token)
stats = hunt_obj.GetRunner().context.usage_stats
return ApiGetHuntStatsResult(stats=stats) | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement assignment identifier attribute attribute call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier | Retrieves the stats for a hunt. |
def _announce_theta(theta):
c = 299792.458
is_a_redshift = lambda p: p == "z" or p[:2] == "z_"
for parameter, value in theta.items():
try:
value[0]
except (IndexError, TypeError):
message = "\t{0}: {1:.3f}".format(parameter, value)
if is_a_redshift(parameter):
message += " [{0:.1f} km/s]".format(value * c)
else:
message = "\t{0}: {1:.3f} ({2:+.3f}, {3:+.3f})".format(parameter,
value[0], value[1], value[2])
if is_a_redshift(parameter):
message += " [{0:.1f} ({1:+.1f}, {2:+.1f}) km/s]".format(
value[0] * c, value[1] * c, value[2] * c)
logger.info(message) | module function_definition identifier parameters identifier block expression_statement assignment identifier float expression_statement assignment identifier lambda lambda_parameters identifier boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator subscript identifier slice integer string string_start string_content string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block try_statement block expression_statement subscript identifier integer except_clause tuple identifier identifier block expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier identifier if_statement call identifier argument_list identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list binary_operator identifier identifier else_clause block expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier subscript identifier integer subscript identifier integer subscript identifier integer if_statement call identifier argument_list identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list binary_operator subscript identifier integer identifier binary_operator subscript identifier integer identifier binary_operator subscript identifier integer identifier expression_statement call attribute identifier identifier argument_list identifier | Announce theta values to the log. |
def load_bookmark(self, slot_num):
bookmarks = CONF.get('editor', 'bookmarks')
if slot_num in bookmarks:
filename, line_num, column = bookmarks[slot_num]
else:
return
if not osp.isfile(filename):
self.last_edit_cursor_pos = None
return
self.load(filename)
editor = self.get_current_editor()
if line_num < editor.document().lineCount():
linelength = len(editor.document()
.findBlockByNumber(line_num).text())
if column <= linelength:
editor.go_to_line(line_num + 1, column)
else:
editor.go_to_line(line_num + 1, linelength) | 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 string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement assignment pattern_list identifier identifier identifier subscript identifier identifier else_clause block return_statement if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment attribute identifier identifier none return_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier call attribute call attribute identifier identifier argument_list identifier argument_list block expression_statement assignment identifier call identifier argument_list call attribute call attribute call attribute identifier identifier argument_list identifier argument_list identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier integer identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator identifier integer identifier | Set cursor to bookmarked file and position. |
def toggleLongTouchPoint(self):
if not self.isLongTouchingPoint:
msg = 'Long touching point'
self.toast(msg, background=Color.GREEN)
self.statusBar.set(msg)
self.isLongTouchingPoint = True
self.coordinatesUnit = Unit.PX
else:
self.toast(None)
self.statusBar.clear()
self.isLongTouchingPoint = False | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list none expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier false | Toggles the long touch point operation. |
def master_event(type, master=None):
event_map = {'connected': '__master_connected',
'disconnected': '__master_disconnected',
'failback': '__master_failback',
'alive': '__master_alive'}
if type == 'alive' and master is not None:
return '{0}_{1}'.format(event_map.get(type), master)
return event_map.get(type, None) | module function_definition identifier parameters identifier default_parameter identifier none 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 string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier none block return_statement call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier none | Centralized master event function which will return event type based on event_map |
def innerHTML(self) -> str:
if self._inner_element:
return self._inner_element.innerHTML
return super().innerHTML | module function_definition identifier parameters identifier type identifier block if_statement attribute identifier identifier block return_statement attribute attribute identifier identifier identifier return_statement attribute call identifier argument_list identifier | Get innerHTML of the inner node. |
def full_name(self):
if self._tree.parent is None:
return self._intern.name
return self._tree.parent.full_name() + '.' + self._intern.name | module function_definition identifier parameters identifier block if_statement comparison_operator attribute attribute identifier identifier identifier none block return_statement attribute attribute identifier identifier identifier return_statement binary_operator binary_operator call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier | returns name all the way up the tree |
def cookie_length(self, domain):
cookies = self.cookie_jar._cookies
if domain not in cookies:
return 0
length = 0
for path in cookies[domain]:
for name in cookies[domain][path]:
cookie = cookies[domain][path][name]
length += len(path) + len(name) + len(cookie.value or '')
return length | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier identifier block return_statement integer expression_statement assignment identifier integer for_statement identifier subscript identifier identifier block for_statement identifier subscript subscript identifier identifier identifier block expression_statement assignment identifier subscript subscript subscript identifier identifier identifier identifier expression_statement augmented_assignment identifier binary_operator binary_operator call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list boolean_operator attribute identifier identifier string string_start string_end return_statement identifier | Return approximate length of all cookie key-values for a domain. |
def refresh_committed_offsets_if_needed(self):
if self._subscription.needs_fetch_committed_offsets:
offsets = self.fetch_committed_offsets(self._subscription.assigned_partitions())
for partition, offset in six.iteritems(offsets):
if self._subscription.is_assigned(partition):
self._subscription.assignment[partition].committed = offset.offset
self._subscription.needs_fetch_committed_offsets = False | module function_definition identifier parameters identifier block if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment attribute subscript attribute attribute identifier identifier identifier identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier false | Fetch committed offsets for assigned partitions. |
def lock(self):
if self.cache.get(self.lock_name):
return False
else:
self.cache.set(self.lock_name, timezone.now(), self.timeout)
return True | module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block return_statement false else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement true | This method sets a cache variable to mark current job as "already running". |
def build_filtered_queryset(self, query, **kwargs):
qs = self.get_queryset()
qs = qs.filter(self.get_queryset_filters(query))
return self.build_extra_filtered_queryset(qs, **kwargs) | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier dictionary_splat identifier | Build and return the fully-filtered queryset |
def _execute_commands(self, commands, fails=False):
if self._prep_statements:
prepared_commands = [prepare_sql(c) for c in tqdm(commands, total=len(commands),
desc='Prepping SQL Commands')]
print('\tCommands prepared', len(prepared_commands))
else:
prepared_commands = commands
desc = 'Executing SQL Commands' if not fails else 'Executing Failed SQL Commands'
fail, success = [], 0
for command in tqdm(prepared_commands, total=len(prepared_commands), desc=desc):
try:
self._MySQL.executemore(command)
success += 1
except:
fail.append(command)
self._MySQL._commit()
return fail, success | module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement attribute identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content escape_sequence string_end call identifier argument_list identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier conditional_expression string string_start string_content string_end not_operator identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier expression_list list integer for_statement identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement augmented_assignment identifier integer except_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list return_statement expression_list identifier identifier | Execute commands and get list of failed commands and count of successful commands |
def _load_schemas(self):
for filename in os.listdir(self.settings['SCHEMA_DIR']):
if filename[-4:] == 'json':
name = filename[:-5]
with open(self.settings['SCHEMA_DIR'] + filename) as the_file:
self.schemas[name] = json.load(the_file)
self.logger.debug("Successfully loaded " + filename + " schema") | module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end block if_statement comparison_operator subscript identifier slice unary_operator integer string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice unary_operator integer with_statement with_clause with_item as_pattern call identifier argument_list binary_operator subscript attribute identifier identifier string string_start string_content string_end identifier as_pattern_target identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end | Loads any schemas for JSON validation |
def interface_type(self):
return self.visalib.parse_resource(self._resource_manager.session,
self.resource_name)[0].interface_type | module function_definition identifier parameters identifier block return_statement attribute subscript call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier integer identifier | The interface type of the resource as a number. |
def send_post_command(self, command, body):
res = requests.post("http://{host}:{port}{command}".format(
host=self._host, port=self._receiver_port, command=command),
data=body, timeout=self.timeout)
if res.status_code == 200:
return res.text
else:
_LOGGER.error((
"Host %s returned HTTP status code %s to POST command at "
"end point %s"), self._host, res.status_code, command)
return False | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier integer block return_statement attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier attribute identifier identifier identifier return_statement false | Send command via HTTP post to receiver. |
def main():
if check_import():
sys.exit(1)
from aeneas.diagnostics import Diagnostics
errors, warnings, c_ext_warnings = Diagnostics.check_all()
if errors:
sys.exit(1)
if c_ext_warnings:
print_warning(u"All required dependencies are met but at least one Python C extension is not available")
print_warning(u"You can still run aeneas but it will be slower")
print_warning(u"Enjoy running aeneas!")
sys.exit(2)
else:
print_success(u"All required dependencies are met and all available Python C extensions are working")
print_success(u"Enjoy running aeneas!")
sys.exit(0) | module function_definition identifier parameters block if_statement call identifier argument_list block expression_statement call attribute identifier identifier argument_list integer import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list integer if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer else_clause block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer | The entry point for this module |
def configure_logging(conf):
root_logger = logging.getLogger()
root_logger.setLevel(getattr(logging, conf.loglevel.upper()))
if conf.logtostderr:
add_stream_handler(root_logger, sys.stderr)
if conf.logtostdout:
add_stream_handler(root_logger, sys.stdout) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call identifier argument_list identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call identifier argument_list identifier attribute identifier identifier | Initialize and configure logging. |
def merge(revision, branch_label, message, list_revisions=''):
alembic_command.merge(
config=get_config(),
revisions=list_revisions,
message=message,
branch_label=branch_label,
rev_id=revision
) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_end block expression_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Merge two revision together, create new revision file |
def _get_fout_go(self):
assert self.goids, "NO VALID GO IDs WERE PROVIDED AS STARTING POINTS FOR HIERARCHY REPORT"
base = next(iter(self.goids)).replace(':', '')
upstr = '_up' if 'up' in self.kws else ''
return "hier_{BASE}{UP}.{EXT}".format(BASE=base, UP=upstr, EXT='txt') | module function_definition identifier parameters identifier block assert_statement attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute call identifier argument_list call identifier argument_list attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier conditional_expression string string_start string_content string_end comparison_operator string string_start string_content string_end attribute identifier identifier string string_start string_end return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end | Get the name of an output file based on the top GO term. |
def merge(l1, l2):
x1, y1, x2, y2 = l1
xx1, yy1, xx2, yy2 = l2
comb = ((x1, y1, xx1, yy1),
(x1, y1, xx2, yy2),
(x2, y2, xx1, yy1),
(x2, y2, xx2, yy2))
d = [length(c) for c in comb]
i = argmax(d)
dist = d[i]
mid = middle(comb[i])
a = (angle(l1) + angle(l2)) * 0.5
return fromAttr(mid, a, dist) | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier identifier identifier identifier expression_statement assignment identifier tuple tuple identifier identifier identifier identifier tuple identifier identifier identifier identifier tuple identifier identifier identifier identifier tuple identifier identifier identifier identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator call identifier argument_list identifier call identifier argument_list identifier float return_statement call identifier argument_list identifier identifier identifier | merge 2 lines together |
def output(self):
return luigi.LocalTarget(path=self.path(digest=True, ext='html')) | module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier true keyword_argument identifier string string_start string_content string_end | Use the digest version, since URL can be ugly. |
def host_domains(self, ip=None, limit=None, **kwargs):
return self._results('reverse-ip', '/v1/{0}/host-domains'.format(ip), limit=limit, **kwargs) | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none 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 | Pass in an IP address. |
def from_config(cls, pyvlx, item):
name = item['name']
ident = item['id']
subtype = item['subtype']
typeid = item['typeId']
return cls(pyvlx, ident, name, subtype, typeid) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement call identifier argument_list identifier identifier identifier identifier identifier | Read roller shutter from config. |
def _initStormCmds(self):
self.addStormCmd(s_storm.MaxCmd)
self.addStormCmd(s_storm.MinCmd)
self.addStormCmd(s_storm.HelpCmd)
self.addStormCmd(s_storm.IdenCmd)
self.addStormCmd(s_storm.SpinCmd)
self.addStormCmd(s_storm.SudoCmd)
self.addStormCmd(s_storm.UniqCmd)
self.addStormCmd(s_storm.CountCmd)
self.addStormCmd(s_storm.GraphCmd)
self.addStormCmd(s_storm.LimitCmd)
self.addStormCmd(s_storm.SleepCmd)
self.addStormCmd(s_storm.DelNodeCmd)
self.addStormCmd(s_storm.MoveTagCmd)
self.addStormCmd(s_storm.ReIndexCmd) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier | Registration for built-in Storm commands. |
def send(self, data):
_LOGGER.debug("send: " + data)
self.socket.send(data.encode('ascii'))
sleep(.01) | module function_definition identifier parameters identifier identifier 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 call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list float | Send data to socket. |
def main():
from spyder.utils.qthelpers import qapplication
app = qapplication()
if os.name == 'nt':
dialog = WinUserEnvDialog()
else:
dialog = EnvDialog()
dialog.show()
app.exec_() | module function_definition identifier parameters block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list else_clause 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 | Run Windows environment variable editor |
def save_token(self, user, token):
self.config.set('auth', 'user', user)
self.config.set('auth', 'token', token)
new_config = ConfigParser(allow_no_value=True)
new_config.read(self.config_file)
self.check_sections(new_config)
new_config.set('auth', 'user', user)
new_config.set('auth', 'token', token)
filename = os.path.expanduser(self.config_file)
with open(filename, 'w') as out_file:
os.chmod(filename, 0o0600)
new_config.write(out_file) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier true expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list identifier | Save the token on the config file. |
def size_to_content(self):
new_sizing = self.copy_sizing()
new_sizing.minimum_height = 0
new_sizing.maximum_height = 0
axes = self.__axes
if axes and axes.is_valid:
if axes.x_calibration and axes.x_calibration.units:
new_sizing.minimum_height = self.font_size + 4
new_sizing.maximum_height = self.font_size + 4
self.update_sizing(new_sizing) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator identifier attribute identifier identifier block if_statement boolean_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier | Size the canvas item to the proper height. |
def require_editable(f):
def wrapper(self, *args, **kwargs):
if not self._edit:
raise RegistryKeyNotEditable("The key is not set as editable.")
return f(self, *args, **kwargs)
return wrapper | module function_definition identifier parameters identifier block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier | Makes sure the registry key is editable before trying to edit it. |
def symbol_search(self, search_terms):
self.log.debug('symbol_search: in')
if not search_terms:
self.editor.message('symbol_search_symbol_required')
return
req = {
"typehint": "PublicSymbolSearchReq",
"keywords": search_terms,
"maxResults": 25
}
self.send_request(req) | 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 if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement 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 identifier pair string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list identifier | Search for symbols matching a set of keywords |
def cluster_count_key_in_slots(self, slot):
if not isinstance(slot, int):
raise TypeError("Expected slot to be of type int, got {}"
.format(type(slot)))
return self.execute(b'CLUSTER', b'COUNTKEYSINSLOT', slot) | module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier | Return the number of local keys in the specified hash slot. |
def read_bytes(self, start_position: int, size: int) -> bytes:
return bytes(self._bytes[start_position:start_position + size]) | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block return_statement call identifier argument_list subscript attribute identifier identifier slice identifier binary_operator identifier identifier | Read a value from memory and return a fresh bytes instance |
def convert_compound_entry(self, compound):
d = OrderedDict()
d['id'] = compound.id
order = {
key: i for i, key in enumerate(
['name', 'formula', 'formula_neutral', 'charge', 'kegg',
'cas'])}
prop_keys = (
set(compound.properties) - {'boundary', 'compartment'})
for prop in sorted(prop_keys,
key=lambda x: (order.get(x, 1000), x)):
if compound.properties[prop] is not None:
d[prop] = compound.properties[prop]
return d | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier parenthesized_expression binary_operator call identifier argument_list attribute identifier identifier set string string_start string_content string_end string string_start string_content string_end for_statement identifier call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier tuple call attribute identifier identifier argument_list identifier integer identifier block if_statement comparison_operator subscript attribute identifier identifier identifier none block expression_statement assignment subscript identifier identifier subscript attribute identifier identifier identifier return_statement identifier | Convert compound entry to YAML dict. |
def _compute_mean(self, C, mag, rjb):
ffc = self._compute_finite_fault_correction(mag)
d = np.sqrt(rjb ** 2 + (C['c7'] ** 2) * (ffc ** 2))
mean = (
C['c1'] + C['c2'] * (mag - 6.) +
C['c3'] * ((mag - 6.) ** 2) -
C['c4'] * np.log(d) - C['c6'] * d
)
factor = np.log(rjb / 100.)
idx = factor > 0
mean[idx] -= (C['c5'] - C['c4']) * factor[idx]
return mean | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator identifier integer binary_operator parenthesized_expression binary_operator subscript identifier string string_start string_content string_end integer parenthesized_expression binary_operator identifier integer expression_statement assignment identifier parenthesized_expression binary_operator binary_operator binary_operator binary_operator subscript identifier string string_start string_content string_end binary_operator subscript identifier string string_start string_content string_end parenthesized_expression binary_operator identifier float binary_operator subscript identifier string string_start string_content string_end parenthesized_expression binary_operator parenthesized_expression binary_operator identifier float integer binary_operator subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier binary_operator subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier float expression_statement assignment identifier comparison_operator identifier integer expression_statement augmented_assignment subscript identifier identifier binary_operator parenthesized_expression binary_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier identifier return_statement identifier | Compute ground motion mean value. |
def find_user_emails(self, user):
user_emails = self.db_adapter.find_objects(self.UserEmailClass, user_id=user.id)
return user_emails | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement identifier | Find all the UserEmail object belonging to a user. |
def translator(self):
if self._translator is None:
languages = self.lang
if not languages:
return gettext.NullTranslations()
if not isinstance(languages, list):
languages = [languages]
translator = gettext.NullTranslations()
for name, i18n_dir in [
(
'biryani',
os.path.join(pkg_resources.get_distribution('biryani').location, 'biryani', 'i18n'),
),
(
conf['country_package'].replace('_', '-'),
os.path.join(pkg_resources.get_distribution(conf['country_package']).location,
conf['country_package'], 'i18n'),
),
]:
if i18n_dir is not None:
translator = new_translator(name, i18n_dir, languages, fallback = translator)
translator = new_translator(conf['package_name'], conf['i18n_dir'], languages, fallback = translator)
self._translator = translator
return self._translator | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute identifier identifier if_statement not_operator identifier block return_statement call attribute identifier identifier argument_list if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier list tuple string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end tuple call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list attribute call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier subscript identifier string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier | Get a valid translator object from one or several languages names. |
def option_parser():
usage =
version = "2.0.0"
parser = optparse.OptionParser(usage=usage, version=version)
parser.add_option("-l", "--links", action="store_true",
default=False, dest="links", help="links for target url")
parser.add_option("-d", "--depth", action="store", type="int",
default=30, dest="depth", help="Maximum depth traverse")
opts, args = parser.parse_args()
if len(args) < 1:
parser.print_help()
raise SystemExit(1)
return opts, args | module function_definition identifier parameters block expression_statement assignment identifier assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier false keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list raise_statement call identifier argument_list integer return_statement expression_list identifier identifier | Option Parser to give various options. |
def compare(self, range_comparison, range_objs):
range_values = [obj.value for obj in range_objs]
comparison_func = get_comparison_func(range_comparison)
return comparison_func(self.value, *range_values) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list attribute identifier identifier list_splat identifier | Compares this type against comparison filters |
def interp(self):
if self.ndim == 0:
return 'nearest'
elif all(interp == self.interp_byaxis[0]
for interp in self.interp_byaxis):
return self.interp_byaxis[0]
else:
return self.interp_byaxis | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block return_statement string string_start string_content string_end elif_clause call identifier generator_expression comparison_operator identifier subscript attribute identifier identifier integer for_in_clause identifier attribute identifier identifier block return_statement subscript attribute identifier identifier integer else_clause block return_statement attribute identifier identifier | Interpolation type of this discretization. |
def template_string(context, template):
'Return the rendered template content with the current context'
if not isinstance(context, Context):
context = Context(context)
return Template(template).render(context) | module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute call identifier argument_list identifier identifier argument_list identifier | Return the rendered template content with the current context |
def _validate_dataset_names(dataset):
def check_name(name):
if isinstance(name, str):
if not name:
raise ValueError('Invalid name for DataArray or Dataset key: '
'string must be length 1 or greater for '
'serialization to netCDF files')
elif name is not None:
raise TypeError('DataArray.name or Dataset key must be either a '
'string or None for serialization to netCDF files')
for k in dataset.variables:
check_name(k) | module function_definition identifier parameters identifier block function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block if_statement not_operator identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end elif_clause comparison_operator identifier none block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier | DataArray.name and Dataset keys must be a string or None |
def list_subnets(self, retrieve_all=True, **_params):
return self.list('subnets', self.subnets_path, retrieve_all,
**_params) | module function_definition identifier parameters identifier default_parameter identifier true dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier dictionary_splat identifier | Fetches a list of all subnets for a project. |
def VSTools(self):
paths = [r'Common7\IDE', r'Common7\Tools']
if self.vc_ver >= 14.0:
arch_subdir = self.pi.current_dir(hidex86=True, x64=True)
paths += [r'Common7\IDE\CommonExtensions\Microsoft\TestWindow']
paths += [r'Team Tools\Performance Tools']
paths += [r'Team Tools\Performance Tools%s' % arch_subdir]
return [os.path.join(self.si.VSInstallDir, path) for path in paths] | 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 if_statement comparison_operator attribute identifier identifier float block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true keyword_argument identifier true expression_statement augmented_assignment identifier list string string_start string_content string_end expression_statement augmented_assignment identifier list string string_start string_content string_end expression_statement augmented_assignment identifier list binary_operator string string_start string_content string_end identifier return_statement list_comprehension call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier identifier for_in_clause identifier identifier | Microsoft Visual Studio Tools |
def _conv_shape_tuple(self, lhs_shape, rhs_shape, strides, pads):
if isinstance(pads, str):
pads = padtype_to_pads(lhs_shape[2:], rhs_shape[2:], strides, pads)
if len(pads) != len(lhs_shape) - 2:
msg = 'Wrong number of explicit pads for conv: expected {}, got {}.'
raise TypeError(msg.format(len(lhs_shape) - 2, len(pads)))
lhs_padded = onp.add(lhs_shape[2:], onp.add(*zip(*pads)))
out_space = onp.floor_divide(
onp.subtract(lhs_padded, rhs_shape[2:]), strides) + 1
out_space = onp.maximum(0, out_space)
out_shape = (lhs_shape[0], rhs_shape[0]) + tuple(out_space)
return tuple(out_shape) | module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list subscript identifier slice integer subscript identifier slice integer identifier identifier if_statement comparison_operator call identifier argument_list identifier binary_operator call identifier argument_list identifier integer block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list call attribute identifier identifier argument_list binary_operator call identifier argument_list identifier integer call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier slice integer call attribute identifier identifier argument_list list_splat call identifier argument_list list_splat identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier subscript identifier slice integer identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list integer identifier expression_statement assignment identifier binary_operator tuple subscript identifier integer subscript identifier integer call identifier argument_list identifier return_statement call identifier argument_list identifier | Compute the shape of a conv given input shapes in canonical order. |
def paste_buffer(pymux, variables):
pane = pymux.arrangement.get_active_pane()
pane.process.write_input(get_app().clipboard.get_data().text, paste=True) | 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 attribute call attribute attribute call identifier argument_list identifier identifier argument_list identifier keyword_argument identifier true | Paste clipboard content into buffer. |
def collapse_all(self):
if implementsCollapseAPI(self._tree):
self._tree.collapse_all()
self.set_focus(self._tree.root)
self._walker.clear_cache()
self.refresh() | module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Collapse all positions; works only if the underlying tree allows it. |
def copy(self, parent=None):
new = Structure(None, parent=parent)
new.key = self.key
new.type_ = self.type_
new.val_guaranteed = self.val_guaranteed
new.key_guaranteed = self.key_guaranteed
for child in self.children:
new.children.append(child.copy(new))
return new | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list none keyword_argument identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement identifier | Copies an existing structure and all of it's children |
def delete_records(keep=20):
sql = "SELECT * from records where is_deleted<>1 ORDER BY id desc LIMIT -1 offset {}".format(keep)
assert isinstance(g.db, sqlite3.Connection)
c = g.db.cursor()
c.execute(sql)
rows = c.fetchall()
for row in rows:
name = row[1]
xmind = join(app.config['UPLOAD_FOLDER'], name)
xml = join(app.config['UPLOAD_FOLDER'], name[:-5] + 'xml')
for f in [xmind, xml]:
if exists(f):
os.remove(f)
sql = 'UPDATE records SET is_deleted=1 WHERE id = ?'
c.execute(sql, (row[0],))
g.db.commit() | module function_definition identifier parameters default_parameter identifier integer block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier assert_statement call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end binary_operator subscript identifier slice unary_operator integer string string_start string_content string_end for_statement identifier list identifier identifier block if_statement call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier tuple subscript identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list | Clean up files on server and mark the record as deleted |
def last_datetime(self):
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.lasttime)
except TypeError:
return None | module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier try_statement block return_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier except_clause identifier block return_statement none | Return the time of the last operation on the bundle as a datetime object |
def _get_gatk_opts(config, names, tmp_dir=None, memscale=None, include_gatk=True, parallel_gc=False):
if include_gatk and "gatk4" in dd.get_tools_off({"config": config}):
opts = ["-U", "LENIENT_VCF_PROCESSING", "--read_filter",
"BadCigar", "--read_filter", "NotPrimaryAlignment"]
else:
opts = []
jvm_opts = ["-Xms750m", "-Xmx2g"]
for n in names:
resources = config_utils.get_resources(n, config)
if resources and resources.get("jvm_opts"):
jvm_opts = resources.get("jvm_opts")
break
if memscale:
jvm_opts = config_utils.adjust_opts(jvm_opts, {"algorithm": {"memory_adjust": memscale}})
jvm_opts += get_default_jvm_opts(tmp_dir, parallel_gc=parallel_gc)
return jvm_opts + opts | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier true default_parameter identifier false block if_statement boolean_operator identifier comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier block expression_statement assignment 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 string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment identifier list expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end break_statement if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier expression_statement augmented_assignment identifier call identifier argument_list identifier keyword_argument identifier identifier return_statement binary_operator identifier identifier | Retrieve GATK memory specifications, moving down a list of potential specifications. |
def delete(self, *args, **kwargs):
hosted_zone = route53_backend.get_hosted_zone_by_name(
self.hosted_zone_name)
if not hosted_zone:
hosted_zone = route53_backend.get_hosted_zone(self.hosted_zone_id)
hosted_zone.delete_rrset_by_name(self.name) | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier | Not exposed as part of the Route 53 API - used for CloudFormation. args are ignored |
def remove_arg(self, arg):
self.args = [arg_.strip() for arg_ in self.args if arg_.strip()]
for arg_ in list(self.args):
if arg_.lower() == arg.lower():
self.args.remove(arg_) | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier attribute identifier identifier if_clause call attribute identifier identifier argument_list for_statement identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Remove an arg to the arg list |
def go_to_py_cookie(go_cookie):
expires = None
if go_cookie.get('Expires') is not None:
t = pyrfc3339.parse(go_cookie['Expires'])
expires = t.timestamp()
return cookiejar.Cookie(
version=0,
name=go_cookie['Name'],
value=go_cookie['Value'],
port=None,
port_specified=False,
domain=go_cookie['Domain'],
domain_specified=not go_cookie['HostOnly'],
domain_initial_dot=False,
path=go_cookie['Path'],
path_specified=True,
secure=go_cookie['Secure'],
expires=expires,
discard=False,
comment=None,
comment_url=None,
rest=None,
rfc2109=False,
) | module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier none keyword_argument identifier false keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier not_operator subscript identifier string string_start string_content string_end keyword_argument identifier false keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier false keyword_argument identifier none keyword_argument identifier none keyword_argument identifier none keyword_argument identifier false | Convert a Go-style JSON-unmarshaled cookie into a Python cookie |
def export_envars(self, env):
for k, v in env.items():
self.export_envar(k, v) | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier identifier | Export the environment variables contained in the dict env. |
def build_idx_set(branch_id, start_date):
code_set = branch_id.split("/")
code_set.insert(3, "Rates")
idx_set = {
"sec": "/".join([code_set[0], code_set[1], "Sections"]),
"mag": "/".join([code_set[0], code_set[1], code_set[2], "Magnitude"])}
idx_set["rate"] = "/".join(code_set)
idx_set["rake"] = "/".join([code_set[0], code_set[1], "Rake"])
idx_set["msr"] = "-".join(code_set[:3])
idx_set["geol"] = code_set[0]
if start_date:
idx_set["grid_key"] = "_".join(
branch_id.replace("/", "_").split("_")[:-1])
else:
idx_set["grid_key"] = branch_id.replace("/", "_")
idx_set["total_key"] = branch_id.replace("/", "|")
return idx_set | 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 expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end 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 list subscript identifier integer subscript identifier integer string string_start string_content string_end pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list list subscript identifier integer subscript identifier integer subscript identifier integer string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list list subscript identifier integer subscript identifier integer string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list subscript identifier slice integer expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier integer if_statement 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 subscript call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end slice unary_operator integer else_clause block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier 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 return_statement identifier | Builds a dictionary of keys based on the branch code |
def use_plenary_bank_view(self):
self._bank_view = PLENARY
for session in self._get_provider_sessions():
try:
session.use_plenary_bank_view()
except AttributeError:
pass | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement | Pass through to provider ItemBankSession.use_plenary_bank_view |
def reset(self):
old_value = self._value
old_raw_str_value = self.raw_str_value
self._value = not_set
self.raw_str_value = not_set
new_value = self._value
if old_value is not_set:
return
if self.section:
self.section.dispatch_event(
self.section.hooks.item_value_changed,
item=self,
old_value=old_value,
new_value=new_value,
old_raw_str_value=old_raw_str_value,
new_raw_str_value=self.raw_str_value,
) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier identifier block return_statement if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier | Resets the value of config item to its default value. |
def _float_feature(value):
if not isinstance(value, list):
value = [value]
return tf.train.Feature(float_list=tf.train.FloatList(value=value)) | module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier | Wrapper for inserting float features into Example proto. |
def neural_gpu_body(inputs, hparams, name=None):
with tf.variable_scope(name, "neural_gpu"):
def step(state, inp):
x = tf.nn.dropout(state, 1.0 - hparams.dropout)
for layer in range(hparams.num_hidden_layers):
x = common_layers.conv_gru(
x, (hparams.kernel_height, hparams.kernel_width),
hparams.hidden_size,
name="cgru_%d" % layer)
padding_inp = tf.less(tf.reduce_sum(tf.abs(inp), axis=[1, 2]), 0.00001)
new_state = tf.where(padding_inp, state, x)
return new_state
return tf.foldl(
step,
tf.transpose(inputs, [1, 0, 2, 3]),
initializer=inputs,
parallel_iterations=1,
swap_memory=True) | module function_definition identifier parameters identifier identifier default_parameter identifier none block with_statement with_clause with_item call attribute identifier identifier argument_list identifier string string_start string_content string_end block function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator float attribute identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier list integer integer float expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier return_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier list integer integer integer integer keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier true | The core Neural GPU. |
def register_animation(self, animation_class):
self.state.animationClasses.append(animation_class)
return len(self.state.animationClasses) - 1 | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier return_statement binary_operator call identifier argument_list attribute attribute identifier identifier identifier integer | Add a new animation |
def nodePush(ctxt, value):
if ctxt is None: ctxt__o = None
else: ctxt__o = ctxt._o
if value is None: value__o = None
else: value__o = value._o
ret = libxml2mod.nodePush(ctxt__o, value__o)
return ret | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier none else_clause block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier none else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier | Pushes a new element node on top of the node stack |
def copy_file(aws_access_key_id, aws_secret_access_key, bucket_name, file, s3_folder):
bucket = s3_bucket(aws_access_key_id, aws_secret_access_key, bucket_name)
key = boto.s3.key.Key(bucket)
if s3_folder:
target_name = '%s/%s' % (s3_folder, os.path.basename(file))
else:
target_name = os.path.basename(file)
key.key = target_name
print('Uploading %s to %s' % (file, target_name))
key.set_contents_from_filename(file)
print('Upload %s FINISHED: %s' % (file, dt.now())) | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier call attribute identifier identifier argument_list | copies file to bucket s3_folder |
def isRunActive(g):
if g.cpars['hcam_server_on']:
url = g.cpars['hipercam_server'] + 'summary'
response = urllib.request.urlopen(url, timeout=2)
rs = ReadServer(response.read(), status_msg=True)
if not rs.ok:
raise DriverError('isRunActive error: ' + str(rs.err))
if rs.state == 'idle':
return False
elif rs.state == 'active':
return True
else:
raise DriverError('isRunActive error, state = ' + rs.state)
else:
raise DriverError('isRunActive error: servers are not active') | module function_definition identifier parameters identifier block if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier true if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement false elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement true else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end | Polls the data server to see if a run is active |
def str_to_bitstring(data):
assert isinstance(data, bytes), "Data must be an instance of bytes"
byte_list = data_to_byte_list(data)
bit_list = [bit for data_byte in byte_list for bit in byte_to_bitstring(data_byte)]
return bit_list | module function_definition identifier parameters identifier block assert_statement call identifier argument_list identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier for_in_clause identifier call identifier argument_list identifier return_statement identifier | Convert a string to a list of bits |
def _get_location_list(interval_bed):
import pybedtools
regions = collections.OrderedDict()
for region in pybedtools.BedTool(interval_bed):
regions[str(region.chrom)] = None
return regions.keys() | module function_definition identifier parameters identifier block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment subscript identifier call identifier argument_list attribute identifier identifier none return_statement call attribute identifier identifier argument_list | Retrieve list of locations to analyze from input BED file. |
def deploy_lambda(collector):
amazon = collector.configuration['amazon']
aws_syncr = collector.configuration['aws_syncr']
find_lambda_function(aws_syncr, collector.configuration).deploy(aws_syncr, amazon) | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute call identifier argument_list identifier attribute identifier identifier identifier argument_list identifier identifier | Deploy a lambda function |
def do_DELETE(self):
self.do_initial_operations()
coap_response = self.client.delete(self.coap_uri.path)
self.client.stop()
logger.debug("Server response: %s", coap_response.pretty_print())
self.set_http_response(coap_response) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier | Perform a DELETE request |
def remove_group_role(request, role, group, domain=None, project=None):
manager = keystoneclient(request, admin=True).roles
return manager.revoke(role=role, group=group, project=project,
domain=domain) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier attribute call identifier argument_list identifier keyword_argument identifier true identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Removes a given single role for a group from a domain or project. |
def options(self, parser, env=os.environ):
super(PerfDumpPlugin, self).options(parser, env=env)
parser.add_option("", "--perfdump-html", dest="perfdump_html_file",
help="Set destination for HTML report output") | module function_definition identifier parameters identifier identifier default_parameter identifier attribute identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end | Handle parsing additional command-line options |
def do_it(self, dbg):
try:
var_objects = []
for variable in self.vars:
variable = variable.strip()
if len(variable) > 0:
if '\t' in variable:
scope, attrs = variable.split('\t', 1)
name = attrs[0]
else:
scope, attrs = (variable, None)
name = scope
var_obj = pydevd_vars.getVariable(dbg, self.thread_id, self.frame_id, scope, attrs)
var_objects.append((var_obj, name))
t = GetValueAsyncThreadDebug(dbg, self.sequence, var_objects)
t.start()
except:
exc = get_exception_traceback_str()
sys.stderr.write('%s\n' % (exc,))
cmd = dbg.cmd_factory.make_error_message(self.sequence, "Error evaluating variable %s " % exc)
dbg.writer.add_command(cmd) | module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block if_statement comparison_operator string string_start string_content escape_sequence string_end identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end integer expression_statement assignment identifier subscript identifier integer else_clause block expression_statement assignment pattern_list identifier identifier tuple identifier none expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list except_clause block expression_statement assignment identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Starts a thread that will load values asynchronously |
def _create_subplots(self, fig, layout):
num_panels = len(layout)
axsarr = np.empty((self.nrow, self.ncol), dtype=object)
i = 1
for row in range(self.nrow):
for col in range(self.ncol):
axsarr[row, col] = fig.add_subplot(self.nrow, self.ncol, i)
i += 1
if self.dir == 'h':
order = 'C'
if not self.as_table:
axsarr = axsarr[::-1]
elif self.dir == 'v':
order = 'F'
if not self.as_table:
axsarr = np.array([row[::-1] for row in axsarr])
axs = axsarr.ravel(order)
for ax in axs[num_panels:]:
fig.delaxes(ax)
axs = axs[:num_panels]
return axs | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier expression_statement assignment identifier integer for_statement identifier call identifier argument_list attribute identifier identifier block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript identifier identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier expression_statement augmented_assignment identifier integer if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end if_statement not_operator attribute identifier identifier block expression_statement assignment identifier subscript identifier slice unary_operator integer elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension subscript identifier slice unary_operator integer for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier subscript identifier slice identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier slice identifier return_statement identifier | Create suplots and return axs |
def _is_download(ending):
list = [
'PDF',
'DOC',
'TXT',
'PPT',
'XLSX',
'MP3',
'SVG',
'7Z',
'HTML',
'TEX',
'MPP',
'ODT',
'RAR',
'ZIP',
'TAR',
'EPUB',
]
list_regex = [
'PDF'
]
if ending in list:
return True
for file_type in list_regex:
if re.search(re.escape(file_type), ending):
return True
return False | 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 string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end 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 assignment identifier list string string_start string_content string_end if_statement comparison_operator identifier identifier block return_statement true for_statement identifier identifier block if_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier block return_statement true return_statement false | Check if file ending is considered as download. |
def deserialize_email_messages(messages: List[str]):
return [
pickle.loads(zlib.decompress(base64.b64decode(m)))
for m in messages
] | module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier block return_statement list_comprehension call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier for_in_clause identifier identifier | Deserialize EmailMessages passed as task argument. |
def _get_variable(vid, variables):
if isinstance(vid, six.string_types):
vid = get_base_id(vid)
else:
vid = _get_string_vid(vid)
for v in variables:
if vid == get_base_id(v["id"]):
return copy.deepcopy(v)
raise ValueError("Did not find variable %s in \n%s" % (vid, pprint.pformat(variables))) | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator identifier call identifier argument_list subscript identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple identifier call attribute identifier identifier argument_list identifier | Retrieve an input variable from our existing pool of options. |
def _split_classes_by_kind(self, class_name_to_definition):
for class_name in class_name_to_definition:
inheritance_set = self._inheritance_sets[class_name]
is_vertex = ORIENTDB_BASE_VERTEX_CLASS_NAME in inheritance_set
is_edge = ORIENTDB_BASE_EDGE_CLASS_NAME in inheritance_set
if is_vertex and is_edge:
raise AssertionError(u'Class {} appears to be both a vertex and an edge class: '
u'{}'.format(class_name, inheritance_set))
elif is_vertex:
self._vertex_class_names.add(class_name)
elif is_edge:
self._edge_class_names.add(class_name)
else:
self._non_graph_class_names.add(class_name)
self._vertex_class_names = frozenset(self._vertex_class_names)
self._edge_class_names = frozenset(self._edge_class_names)
self._non_graph_class_names = frozenset(self._non_graph_class_names) | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier comparison_operator identifier identifier expression_statement assignment identifier comparison_operator identifier identifier if_statement boolean_operator identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier elif_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier elif_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier | Assign each class to the vertex, edge or non-graph type sets based on its kind. |
def stats(path, fmt, nocolor, timezones, utc, noprogress, most_common, resolve, length):
with colorize_output(nocolor):
try:
chat_history = _process_history(
path=path, thread='', timezones=timezones,
utc=utc, noprogress=noprogress, resolve=resolve)
except ProcessingFailure:
return
statistics = ChatHistoryStatistics(
chat_history, most_common=None if most_common < 0 else most_common)
if fmt == 'text':
statistics.write_text(sys.stdout, -1 if length < 0 else length)
elif fmt == 'json':
statistics.write_json(sys.stdout)
elif fmt == 'pretty-json':
statistics.write_json(sys.stdout, pretty=True)
elif fmt == 'yaml':
statistics.write_yaml(sys.stdout) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier block with_statement with_clause with_item call identifier argument_list identifier block try_statement block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause identifier block return_statement expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier conditional_expression none comparison_operator identifier integer identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier conditional_expression unary_operator integer comparison_operator identifier integer identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier | Analysis of Facebook chat history. |
def _Ep(self):
return np.logspace(
np.log10(self.Epmin.to("GeV").value),
np.log10(self.Epmax.to("GeV").value),
int(self.nEpd * (np.log10(self.Epmax / self.Epmin))),
) | module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier call attribute identifier identifier argument_list attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier call identifier argument_list binary_operator attribute identifier identifier parenthesized_expression call attribute identifier identifier argument_list binary_operator attribute identifier identifier attribute identifier identifier | Proton energy array in GeV |
def _get_arrays(self, wavelengths, **kwargs):
x = self._validate_wavelengths(wavelengths)
y = self(x, **kwargs)
if isinstance(wavelengths, u.Quantity):
w = x.to(wavelengths.unit, u.spectral())
else:
w = x
return w, y | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier dictionary_splat identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier identifier return_statement expression_list identifier identifier | Get sampled spectrum or bandpass in user units. |
def section_end_distances(neurites, neurite_type=NeuriteType.all):
return map_sections(sectionfunc.section_end_distance, neurites, neurite_type=neurite_type) | module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block return_statement call identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier | section end to end distances in a collection of neurites |
def upload_napp(self, metadata, package):
endpoint = os.path.join(self._config.get('napps', 'api'), 'napps', '')
metadata['token'] = self._config.get('auth', 'token')
request = self.make_request(endpoint, json=metadata, package=package,
method="POST")
if request.status_code != 201:
KytosConfig().clear_token()
LOG.error("%s: %s", request.status_code, request.reason)
sys.exit(1)
username = metadata.get('username', metadata.get('author'))
name = metadata.get('name')
print("SUCCESS: NApp {}/{} uploaded.".format(username, name)) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier 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 string string_start string_content string_end string string_start string_end expression_statement assignment subscript identifier string string_start string_content string_end 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 call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute call identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier 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 expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier | Upload the napp from the current directory to the napps server. |
def intuition_module(location):
path = location.split('.')
obj = path.pop(-1)
return dna.utils.dynamic_import('.'.join(path), obj) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list unary_operator integer return_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier | Build the module path and import it |
def Validate(self):
self.pathspec.Validate()
if (self.HasField("start_time") and self.HasField("end_time") and
self.start_time > self.end_time):
raise ValueError("Start time must be before end time.")
if not self.path_regex and not self.data_regex and not self.path_glob:
raise ValueError("A Find specification can not contain both an empty "
"path regex and an empty data regex") | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement parenthesized_expression boolean_operator 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 comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement boolean_operator boolean_operator not_operator attribute identifier identifier not_operator attribute identifier identifier not_operator attribute identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end | Ensure the pathspec is valid. |
def validate_maildirs(ctx, param, value):
for path in value:
for subdir in MD_SUBDIRS:
if not os.path.isdir(os.path.join(path, subdir)):
raise click.BadParameter(
'{} is not a maildir (missing {!r} sub-directory).'.format(
path, subdir))
return value | module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block for_statement identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement identifier | Check that folders are maildirs. |
def zoomTo(self, bbox):
'set visible area to bbox, maintaining aspectRatio if applicable'
self.fixPoint(self.plotviewBox.xymin, bbox.xymin)
self.zoomlevel=max(bbox.w/self.canvasBox.w, bbox.h/self.canvasBox.h) | module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator attribute identifier identifier attribute attribute identifier identifier identifier binary_operator attribute identifier identifier attribute attribute identifier identifier identifier | set visible area to bbox, maintaining aspectRatio if applicable |
def _build_fluent_table(self):
self.fluent_table = collections.OrderedDict()
for name, size in zip(self.domain.non_fluent_ordering, self.non_fluent_size):
non_fluent = self.domain.non_fluents[name]
self.fluent_table[name] = (non_fluent, size)
for name, size in zip(self.domain.state_fluent_ordering, self.state_size):
fluent = self.domain.state_fluents[name]
self.fluent_table[name] = (fluent, size)
for name, size in zip(self.domain.action_fluent_ordering, self.action_size):
fluent = self.domain.action_fluents[name]
self.fluent_table[name] = (fluent, size)
for name, size in zip(self.domain.interm_fluent_ordering, self.interm_size):
fluent = self.domain.intermediate_fluents[name]
self.fluent_table[name] = (fluent, size) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier tuple identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier tuple identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier tuple identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier tuple identifier identifier | Builds the fluent table for each RDDL pvariable. |
def build_estimator(model_dir, model_type, model_column_fn, inter_op, intra_op, ctx):
wide_columns, deep_columns = model_column_fn()
hidden_units = [100, 75, 50, 25]
run_config = tf.estimator.RunConfig().replace(
session_config=tf.ConfigProto(device_count={'GPU': 0},
device_filters=['/job:ps', '/job:%s/task:%d' % (ctx.job_name, ctx.task_index)],
inter_op_parallelism_threads=inter_op,
intra_op_parallelism_threads=intra_op))
if model_type == 'wide':
return tf.estimator.LinearClassifier(
model_dir=model_dir,
feature_columns=wide_columns,
config=run_config)
elif model_type == 'deep':
return tf.estimator.DNNClassifier(
model_dir=model_dir,
feature_columns=deep_columns,
hidden_units=hidden_units,
config=run_config)
else:
return tf.estimator.DNNLinearCombinedClassifier(
model_dir=model_dir,
linear_feature_columns=wide_columns,
dnn_feature_columns=deep_columns,
dnn_hidden_units=hidden_units,
config=run_config) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list expression_statement assignment identifier list integer integer integer integer expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier dictionary pair string string_start string_content string_end integer keyword_argument identifier list string string_start string_content string_end binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier else_clause block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Build an estimator appropriate for the given model type. |
def parse_file(self, sourcepath):
with open(sourcepath, 'r') as logfile:
jsonstr = logfile.read()
data = {}
data['entries'] = json.loads(jsonstr)
if self.tzone:
for e in data['entries']:
e['tzone'] = self.tzone
return data | module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list 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 dictionary expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block for_statement identifier subscript identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier | Parse single JSON object into a LogData object |
def load_file(path, encoding, encoding_errors):
abs_path = abspath(path)
if exists(abs_path):
return read_unicode(abs_path, encoding, encoding_errors)
raise IOError('File %s does not exist' % (abs_path)) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier block return_statement call identifier argument_list identifier identifier identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier | Given an existing path, attempt to load it as a unicode string. |
def fetch_fieldnames(self, sql: str, *args) -> List[str]:
self.ensure_db_open()
cursor = self.db.cursor()
self.db_exec_with_cursor(cursor, sql, *args)
try:
return [i[0] for i in cursor.description]
except:
log.exception("fetch_fieldnames: SQL was: " + sql)
raise | module function_definition identifier parameters identifier typed_parameter identifier type identifier list_splat_pattern identifier type generic_type identifier type_parameter type identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier list_splat identifier try_statement block return_statement list_comprehension subscript identifier integer for_in_clause identifier attribute identifier identifier except_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier raise_statement | Executes SQL; returns just the output fieldnames. |
def _set_id_variable_by_entity_key(self) -> Dict[str, str]:
if self.id_variable_by_entity_key is None:
self.id_variable_by_entity_key = dict(
(entity.key, entity.key + '_id') for entity in self.tax_benefit_system.entities)
log.debug("Use default id_variable names:\n {}".format(self.id_variable_by_entity_key))
return self.id_variable_by_entity_key | module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier type identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier generator_expression tuple attribute identifier identifier binary_operator attribute identifier identifier string string_start string_content string_end for_in_clause identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list attribute identifier identifier return_statement attribute identifier identifier | Identify and set the good ids for the different entities |
def process_result_value(
self,
value,
dialect
):
if self.__use_json(dialect) or value is None:
return value
return self.__json_codec.loads(value) | module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator call attribute identifier identifier argument_list identifier comparison_operator identifier none block return_statement identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier | Decode data, if required. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.