code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def copy(self, new_fn):
new_file = self.__class__(fn=str(new_fn))
new_file.write(data=self.read())
new_file.utime(self.atime, self.mtime)
return new_file | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement identifier | copy the file to the new_fn, preserving atime and mtime |
def validate_gaslimit(self, header: BlockHeader) -> None:
parent_header = self.get_block_header_by_hash(header.parent_hash)
low_bound, high_bound = compute_gas_limit_bounds(parent_header)
if header.gas_limit < low_bound:
raise ValidationError(
"The gas limit on block {0} is too low: {1}. It must be at least {2}".format(
encode_hex(header.hash), header.gas_limit, low_bound))
elif header.gas_limit > high_bound:
raise ValidationError(
"The gas limit on block {0} is too high: {1}. It must be at most {2}".format(
encode_hex(header.hash), header.gas_limit, high_bound)) | module function_definition identifier parameters identifier typed_parameter identifier type identifier type none block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement comparison_operator attribute identifier 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 attribute identifier identifier attribute identifier identifier identifier elif_clause comparison_operator attribute identifier 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 attribute identifier identifier attribute identifier identifier identifier | Validate the gas limit on the given header. |
def readAxes(self):
for axisElement in self.root.findall(".axes/axis"):
axis = {}
axis['name'] = name = axisElement.attrib.get("name")
axis['tag'] = axisElement.attrib.get("tag")
axis['minimum'] = float(axisElement.attrib.get("minimum"))
axis['maximum'] = float(axisElement.attrib.get("maximum"))
axis['default'] = float(axisElement.attrib.get("default"))
axis['map'] = []
for warpPoint in axisElement.findall(".map"):
inputValue = float(warpPoint.attrib.get("input"))
outputValue = float(warpPoint.attrib.get("output"))
axis['map'].append((inputValue, outputValue))
self.axes[name] = axis
self.axesOrder.append(axis['name']) | module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content 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 expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list tuple identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end | Read the axes element. |
def buffer(self, item):
key = self.get_key_from_item(item)
if not self.grouping_info.is_first_file_item(key):
self.items_group_files.add_item_separator_to_file(key)
self.grouping_info.ensure_group_info(key)
self.items_group_files.add_item_to_file(item, key) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier | Receive an item and write it. |
def _structure_unicode(self, obj, cl):
if not isinstance(obj, (bytes, unicode)):
return cl(str(obj))
else:
return obj | module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier tuple identifier identifier block return_statement call identifier argument_list call identifier argument_list identifier else_clause block return_statement identifier | Just call ``cl`` with the given ``obj`` |
def do_exit(self, arg):
if self.current:
self.current.close()
self.resource_manager.close()
del self.resource_manager
return True | module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list delete_statement attribute identifier identifier return_statement true | Exit the shell session. |
def _proxy_process(proxyname, test):
changes_old = []
changes_new = []
if not _is_proxy_running(proxyname):
if not test:
__salt__['cmd.run_all'](
'salt-proxy --proxyid={0} -l info -d'.format(salt.ext.six.moves.shlex_quote(proxyname)),
timeout=5)
changes_new.append('Salt Proxy: Started proxy process for {0}'
.format(proxyname))
else:
changes_new.append('Salt Proxy: process {0} will be started'
.format(proxyname))
else:
changes_old.append('Salt Proxy: already running for {0}'
.format(proxyname))
return True, changes_new, changes_old | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list if_statement not_operator call identifier argument_list identifier block if_statement not_operator identifier block expression_statement call subscript identifier string string_start string_content string_end argument_list call attribute string string_start string_content string_end identifier argument_list call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement expression_list true identifier identifier | Check and execute proxy process |
def cloneWindow(self):
settings = QtCore.QSettings()
settings.beginGroup(self.argosApplication.windowGroupName(self.windowNumber))
try:
self.saveProfile(settings)
name = self.inspectorRegItem.fullName
newWindow = self.argosApplication.addNewMainWindow(settings=settings,
inspectorFullName=name)
finally:
settings.endGroup()
currentItem, _currentIndex = self.repoWidget.repoTreeView.getCurrentItem()
if currentItem:
newWindow.trySelectRtiByPath(currentItem.nodePath)
newGeomRect = newWindow.geometry()
logger.debug("newGeomRect: x={}".format(newGeomRect.x()))
newGeomRect.moveTo(newGeomRect.x() + 24, newGeomRect.y() + 24)
newWindow.setGeometry(newGeomRect)
logger.debug("newGeomRect: x={}".format(newGeomRect.x()))
newWindow.raise_() | 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 attribute attribute identifier identifier identifier argument_list attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier finally_clause block expression_statement call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list integer binary_operator call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Opens a new window with the same inspector as the current window. |
def show_command(parameter):
section = "cli"
if "." in parameter:
section, parameter = parameter.split(".", 1)
value = lookup_option(parameter, section=section)
if value is None:
safeprint("{} not set".format(parameter))
else:
safeprint("{} = {}".format(parameter, value)) | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator identifier none block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier | Executor for `globus config show` |
def check_for_stalled_tasks():
from api.models.tasks import Task
for task in Task.objects.filter(status_is_running=True):
if not task.is_responsive():
task.system_error()
if task.is_timed_out():
task.timeout_error() | module function_definition identifier parameters block import_from_statement dotted_name identifier identifier identifier dotted_name identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true block if_statement not_operator call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list | Check for tasks that are no longer sending a heartbeat |
def min_heapify(arr, start, simulation, iteration):
end = len(arr) - 1
last_parent = (end - start - 1) // 2
for parent in range(last_parent, -1, -1):
current_parent = parent
while current_parent <= last_parent:
child = 2 * current_parent + 1
if child + 1 <= end - start and arr[child + start] > arr[
child + 1 + start]:
child = child + 1
if arr[child + start] < arr[current_parent + start]:
arr[current_parent + start], arr[child + start] = \
arr[child + start], arr[current_parent + start]
current_parent = child
if simulation:
iteration = iteration + 1
print("iteration",iteration,":",*arr)
else:
break
return iteration | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier identifier integer integer for_statement identifier call identifier argument_list identifier unary_operator integer unary_operator integer block expression_statement assignment identifier identifier while_statement comparison_operator identifier identifier block expression_statement assignment identifier binary_operator binary_operator integer identifier integer if_statement boolean_operator comparison_operator binary_operator identifier integer binary_operator identifier identifier comparison_operator subscript identifier binary_operator identifier identifier subscript identifier binary_operator binary_operator identifier integer identifier block expression_statement assignment identifier binary_operator identifier integer if_statement comparison_operator subscript identifier binary_operator identifier identifier subscript identifier binary_operator identifier identifier block expression_statement assignment pattern_list subscript identifier binary_operator identifier identifier subscript identifier binary_operator identifier identifier line_continuation expression_list subscript identifier binary_operator identifier identifier subscript identifier binary_operator identifier identifier expression_statement assignment identifier identifier if_statement identifier block expression_statement assignment identifier binary_operator identifier integer expression_statement call identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end list_splat identifier else_clause block break_statement return_statement identifier | Min heapify helper for min_heap_sort |
def _raise_fail(self, response, expected):
try:
if self.logger:
self.logger.error("Status code "
"{} != {}. \n\n "
"Payload: {}".format(response.status_code,
expected,
response.content))
raise TestStepFail("Status code {} != {}.".format(response.status_code, expected))
except TestStepFail:
raise
except:
if self.logger:
self.logger.error("Status code "
"{} != {}. \n\n "
"Payload: {}".format(response.status_code,
expected,
"Unable to parse payload"))
raise TestStepFail("Status code {} != {}.".format(response.status_code, expected)) | module function_definition identifier parameters identifier identifier identifier block try_statement block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end string string_start string_content string_end identifier argument_list attribute identifier identifier identifier attribute identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier except_clause identifier block raise_statement except_clause block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end string string_start string_content string_end identifier argument_list attribute identifier identifier identifier string string_start string_content string_end raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier | Raise a TestStepFail with neatly formatted error message |
def run(self):
channel = self._ssh_client.get_transport().open_session()
self._channel = channel
channel.exec_command("gerrit stream-events")
stdout = channel.makefile()
stderr = channel.makefile_stderr()
while not self._stop.is_set():
try:
if channel.exit_status_ready():
if channel.recv_stderr_ready():
error = stderr.readline().strip()
else:
error = "Remote server connection closed"
self._error_event(error)
self._stop.set()
else:
data = stdout.readline()
self._gerrit.put_event(data)
except Exception as e:
self._error_event(repr(e))
self._stop.set() | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list while_statement not_operator call attribute attribute identifier identifier identifier argument_list block try_statement block if_statement call attribute identifier identifier argument_list block if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list | Listen to the stream and send events to the client. |
async def info(self) -> Optional[JobDef]:
info = await self.result_info()
if not info:
v = await self._redis.get(job_key_prefix + self.job_id, encoding=None)
if v:
info = unpickle_job(v)
if info:
info.score = await self._redis.zscore(queue_name, self.job_id)
return info | module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier await call attribute identifier identifier argument_list if_statement not_operator identifier block expression_statement assignment identifier await call attribute attribute identifier identifier identifier argument_list binary_operator identifier attribute identifier identifier keyword_argument identifier none if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment attribute identifier identifier await call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier return_statement identifier | All information on a job, including its result if it's available, does not wait for the result. |
async def listCronJobs(self):
crons = []
for iden, cron in self.cell.agenda.list():
useriden = cron['useriden']
if not (self.user.admin or useriden == self.user.iden):
continue
user = self.cell.auth.user(useriden)
cron['username'] = '<unknown>' if user is None else user.name
crons.append((iden, cron))
return crons | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement not_operator parenthesized_expression boolean_operator attribute attribute identifier identifier identifier comparison_operator identifier attribute attribute identifier identifier identifier block continue_statement expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end conditional_expression string string_start string_content string_end comparison_operator identifier none attribute identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier return_statement identifier | Get information about all the cron jobs accessible to the current user |
async def _read_rowdata_packet(self):
rows = []
while True:
packet = await self.connection._read_packet()
if self._check_packet_is_eof(packet):
self.connection = None
break
rows.append(self._read_row_from_packet(packet))
self.affected_rows = len(rows)
self.rows = tuple(rows) | module function_definition identifier parameters identifier block expression_statement assignment identifier list while_statement true block expression_statement assignment identifier await call attribute attribute identifier identifier identifier argument_list if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment attribute identifier identifier none break_statement expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier | Read a rowdata packet for each data row in the result set. |
def _ask_for_ledger_status(self, node_name: str, ledger_id):
self.request_msg(LEDGER_STATUS, {f.LEDGER_ID.nm: ledger_id},
[node_name, ])
logger.info("{} asking {} for ledger status of ledger {}".format(self, node_name, ledger_id)) | module function_definition identifier parameters identifier typed_parameter identifier type identifier identifier block expression_statement call attribute identifier identifier argument_list identifier dictionary pair attribute attribute identifier identifier identifier identifier list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier | Ask other node for LedgerStatus |
def _parse_args(arg):
yaml_args = salt.utils.args.yamlify_arg(arg)
if yaml_args is None:
return []
elif not isinstance(yaml_args, list):
return [yaml_args]
else:
return yaml_args | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement list elif_clause not_operator call identifier argument_list identifier identifier block return_statement list identifier else_clause block return_statement identifier | yamlify `arg` and ensure it's outermost datatype is a list |
def check_dependee_order(depender, dependee, dependee_id):
shutit_global.shutit_global_object.yield_to_draw()
if dependee.run_order > depender.run_order:
return 'depender module id:\n\n' + depender.module_id + '\n\n(run order: ' + str(depender.run_order) + ') ' + 'depends on dependee module_id:\n\n' + dependee_id + '\n\n(run order: ' + str(dependee.run_order) + ') ' + 'but the latter is configured to run after the former'
return '' | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator string string_start string_content escape_sequence escape_sequence string_end attribute identifier identifier string string_start string_content escape_sequence escape_sequence string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end identifier string string_start string_content escape_sequence escape_sequence string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end return_statement string string_start string_end | Checks whether run orders are in the appropriate order. |
def delete_all_possible_task_files(self, courseid, taskid):
if not id_checker(courseid):
raise InvalidNameException("Course with invalid name: " + courseid)
if not id_checker(taskid):
raise InvalidNameException("Task with invalid name: " + taskid)
task_fs = self.get_task_fs(courseid, taskid)
for ext in self.get_available_task_file_extensions():
try:
task_fs.delete("task."+ext)
except:
pass | module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier except_clause block pass_statement | Deletes all possibles task files in directory, to allow to change the format |
def _initialize_from_model(self, model):
for name, value in model.__dict__.items():
if name in self._properties:
setattr(self, name, value) | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call identifier argument_list identifier identifier identifier | Loads a model from |
def _fullqualname_method_py2(obj):
if obj.__self__ is None:
module = obj.im_class.__module__
cls = obj.im_class.__name__
else:
if inspect.isclass(obj.__self__):
module = obj.__self__.__module__
cls = obj.__self__.__name__
else:
module = obj.__self__.__class__.__module__
cls = obj.__self__.__class__.__name__
return module + '.' + cls + '.' + obj.__func__.__name__ | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier else_clause block if_statement call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier else_clause block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier return_statement binary_operator binary_operator binary_operator binary_operator identifier string string_start string_content string_end identifier string string_start string_content string_end attribute attribute identifier identifier identifier | Fully qualified name for 'instancemethod' objects in Python 2. |
def index(self, strictindex):
return self._select(self._pointer.index(self.ruamelindex(strictindex))) | module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier | Return a chunk in a sequence referenced by index. |
def cli(yamlfile, format, output, context):
print(RDFGenerator(yamlfile, format).serialize(output=output, context=context)) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call identifier argument_list call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier | Generate an RDF representation of a biolink model |
def StopPreviousService(self):
StopService(
service_name=config.CONFIG["Nanny.service_name"],
service_binary_name=config.CONFIG["Nanny.service_binary_name"])
if not config.CONFIG["Client.fleetspeak_enabled"]:
return
StopService(service_name=config.CONFIG["Client.fleetspeak_service_name"])
key_path = config.CONFIG["Client.fleetspeak_unsigned_services_regkey"]
regkey = OpenRegkey(key_path)
try:
winreg.DeleteValue(regkey, config.CONFIG["Client.name"])
logging.info("Deleted value '%s' of key '%s'.",
config.CONFIG["Client.name"], key_path)
except OSError as e:
if e.errno != errno.ENOENT:
raise | module function_definition identifier parameters identifier block expression_statement call identifier argument_list keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end if_statement not_operator subscript attribute identifier identifier string string_start string_content string_end block return_statement expression_statement call identifier argument_list keyword_argument 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 assignment identifier call identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement | Stops the Windows service hosting the GRR process. |
def user_name(self, user_id):
user = self.users.get(user_id)
if user is None:
return "Unknown user ({})".format(user_id)
return user["name"] | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement call attribute string string_start string_content string_end identifier argument_list identifier return_statement subscript identifier string string_start string_content string_end | Return name for user. |
def start(queue, profile=None, tag='salt/engine/sqs', owner_acct_id=None):
if __opts__.get('__role') == 'master':
fire_master = salt.utils.event.get_master_event(
__opts__,
__opts__['sock_dir'],
listen=False).fire_event
else:
fire_master = __salt__['event.send']
message_format = __opts__.get('sqs.message_format', None)
sqs = _get_sqs_conn(profile)
q = None
while True:
if not q:
q = sqs.get_queue(queue, owner_acct_id=owner_acct_id)
q.set_message_class(boto.sqs.message.RawMessage)
_process_queue(q, queue, fire_master, tag=tag, owner_acct_id=owner_acct_id, message_format=message_format) | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier none block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier attribute call attribute attribute attribute identifier identifier identifier identifier argument_list identifier subscript identifier string string_start string_content string_end keyword_argument identifier false identifier else_clause block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier none while_statement true block if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier expression_statement call identifier argument_list identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Listen to sqs and fire message on event bus |
def _to_numpy(nd4j_array):
buff = nd4j_array.data()
address = buff.pointer().address()
dtype = get_context_dtype()
mapping = {
'double': ctypes.c_double,
'float': ctypes.c_float
}
Pointer = ctypes.POINTER(mapping[dtype])
pointer = ctypes.cast(address, Pointer)
np_array = np.ctypeslib.as_array(pointer, tuple(nd4j_array.shape()))
return np_array | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier call identifier argument_list 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 expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call identifier argument_list call attribute identifier identifier argument_list return_statement identifier | Convert nd4j array to numpy array |
def from_points(cls, point1, point2):
if isinstance(point1, Point) and isinstance(point2, Point):
displacement = point1.substract(point2)
return cls(displacement.x, displacement.y, displacement.z)
raise TypeError | module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier raise_statement identifier | Return a Vector instance from two given points. |
def _endmsg(self, rd):
msg = ""
s = ""
if rd.hours > 0:
if rd.hours > 1:
s = "s"
msg += colors.bold(str(rd.hours)) + " hour" + s + " "
s = ""
if rd.minutes > 0:
if rd.minutes > 1:
s = "s"
msg += colors.bold(str(rd.minutes)) + " minute" + s + " "
milliseconds = int(rd.microseconds / 1000)
if milliseconds > 0:
msg += colors.bold(str(rd.seconds) + "." + str(milliseconds))
msg += " seconds"
return msg | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier string string_start string_end if_statement comparison_operator attribute identifier identifier integer block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier binary_operator binary_operator binary_operator call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_end if_statement comparison_operator attribute identifier identifier integer block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier binary_operator binary_operator binary_operator call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list binary_operator attribute identifier identifier integer if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end call identifier argument_list identifier expression_statement augmented_assignment identifier string string_start string_content string_end return_statement identifier | Returns an end message with elapsed time |
def get(self, action, version=None):
by_version = self._by_action[action]
if version in by_version:
return by_version[version]
else:
return by_version[None] | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier else_clause block return_statement subscript identifier none | Get the method class handing the given action and version. |
def _guess_name(desc, taken=None):
taken = taken or []
name = ""
for word in desc.split():
c = word[0].lower()
if not c.isalnum():
continue
name += c
if name not in taken:
break
count = 2
while name in taken:
name = name + str(count)
count += 1
return name | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier list expression_statement assignment identifier string string_start string_end for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list if_statement not_operator call attribute identifier identifier argument_list block continue_statement expression_statement augmented_assignment identifier identifier if_statement comparison_operator identifier identifier block break_statement expression_statement assignment identifier integer while_statement comparison_operator identifier identifier block expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier expression_statement augmented_assignment identifier integer return_statement identifier | Attempts to guess the menu entry name from the function name. |
def _verify_same_spaces(self):
if self._envs is None:
raise ValueError("Environments not initialized.")
if not isinstance(self._envs, list):
tf.logging.warning("Not checking observation and action space "
"compatibility across envs, since there is just one.")
return
if not all(
str(env.observation_space) == str(self.observation_space)
for env in self._envs):
err_str = ("All environments should have the same observation space, but "
"don't.")
tf.logging.error(err_str)
for i, env in enumerate(self._envs):
tf.logging.error("Env[%d] has observation space [%s]", i,
env.observation_space)
raise ValueError(err_str)
if not all(
str(env.action_space) == str(self.action_space) for env in self._envs):
err_str = "All environments should have the same action space, but don't."
tf.logging.error(err_str)
for i, env in enumerate(self._envs):
tf.logging.error("Env[%d] has action space [%s]", i, env.action_space)
raise ValueError(err_str) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement if_statement not_operator call identifier generator_expression comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier for_in_clause identifier attribute identifier identifier block expression_statement assignment identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier raise_statement call identifier argument_list identifier if_statement not_operator call identifier generator_expression comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier for_in_clause identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier raise_statement call identifier argument_list identifier | Verifies that all the envs have the same observation and action space. |
def rate_limits(self):
if not self._rate_limits:
self._rate_limits = utilities.get_rate_limits(self._response)
return self._rate_limits | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement attribute identifier identifier | Returns list of rate limit information from the response |
def cmd_gyrocal(self, args):
mav = self.master
mav.mav.command_long_send(mav.target_system, mav.target_component,
mavutil.mavlink.MAV_CMD_PREFLIGHT_CALIBRATION, 0,
1, 0, 0, 0, 0, 0, 0) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute attribute identifier identifier identifier integer integer integer integer integer integer integer integer | do a full gyro calibration |
def meta_set(self, key, metafield, value):
self._meta.setdefault(key, {})[metafield] = value | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment subscript call attribute attribute identifier identifier identifier argument_list identifier dictionary identifier identifier | Set the meta field for a key to a new value. |
def _extract_conjuction_elements_from_expression(expression):
if isinstance(expression, BinaryComposition) and expression.operator == u'&&':
for element in _extract_conjuction_elements_from_expression(expression.left):
yield element
for element in _extract_conjuction_elements_from_expression(expression.right):
yield element
else:
yield expression | module function_definition identifier parameters identifier block if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator attribute identifier identifier string string_start string_content string_end block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement yield identifier for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement yield identifier else_clause block expression_statement yield identifier | Return a generator for expressions that are connected by `&&`s in the given expression. |
def read_cf1_config(self):
target = self._cload.targets[0xFF]
config_page = target.flash_pages - 1
return self._cload.read_flash(addr=0xFF, page=config_page) | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier integer expression_statement assignment identifier binary_operator attribute identifier identifier integer return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier identifier | Read a flash page from the specified target |
def extract_ape (archive, compression, cmd, verbosity, interactive, outdir):
outfile = util.get_single_outfile(outdir, archive, extension=".wav")
return [cmd, archive, outfile, '-d'] | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end return_statement list identifier identifier identifier string string_start string_content string_end | Decompress an APE archive to a WAV file. |
def start(self):
self._poll_thread = threading.Thread(target=self._run_poll_server,
name='Vera Poll Thread')
self._poll_thread.deamon = True
self._poll_thread.start() | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list | Start a thread to handle Vera blocked polling. |
def _add_path(dir_name, payload_info_list):
for payload_info_dict in payload_info_list:
file_name = payload_info_dict['filename'] or payload_info_dict['pid']
payload_info_dict['path'] = d1_common.utils.filesystem.gen_safe_path(
dir_name, 'data', file_name
) | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier boolean_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end identifier | Add a key with the path to each payload_info_dict. |
def modify_filename_id(filename):
split_filename = os.path.splitext(filename)
id_num_re = re.compile('(\(\d\))')
id_num = re.findall(id_num_re, split_filename[-2])
if id_num:
new_id_num = int(id_num[-1].lstrip('(').rstrip(')')) + 1
filename = ''.join((re.sub(id_num_re, '({0})'.format(new_id_num),
split_filename[-2]), split_filename[-1]))
else:
split_filename = os.path.splitext(filename)
filename = ''.join(('{0} (2)'.format(split_filename[-2]),
split_filename[-1]))
return filename | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier 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 identifier subscript identifier unary_operator integer if_statement identifier block expression_statement assignment identifier binary_operator call identifier argument_list call attribute call attribute subscript identifier unary_operator integer identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call attribute string string_start string_end identifier argument_list tuple call attribute identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier subscript identifier unary_operator integer subscript identifier unary_operator integer else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_end identifier argument_list tuple call attribute string string_start string_content string_end identifier argument_list subscript identifier unary_operator integer subscript identifier unary_operator integer return_statement identifier | Modify filename to have a unique numerical identifier. |
def viable_source_types_for_generator (generator):
assert isinstance(generator, Generator)
if generator not in __viable_source_types_cache:
__vstg_cached_generators.append(generator)
__viable_source_types_cache[generator] = viable_source_types_for_generator_real (generator)
return __viable_source_types_cache[generator] | module function_definition identifier parameters identifier block assert_statement call identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier call identifier argument_list identifier return_statement subscript identifier identifier | Caches the result of 'viable_source_types_for_generator'. |
def _step_end(self, log=True):
if log:
step_end_time = self.log(u"STEP %d END (%s)" % (self.step_index, self.step_label))
diff = (step_end_time - self.step_begin_time)
diff = float(diff.seconds + diff.microseconds / 1000000.0)
self.step_total += diff
self.log(u"STEP %d DURATION %.3f (%s)" % (self.step_index, diff, self.step_label))
self.step_index += 1 | module function_definition identifier parameters identifier default_parameter identifier true block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier expression_statement assignment identifier parenthesized_expression binary_operator identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator attribute identifier identifier binary_operator attribute identifier identifier float expression_statement augmented_assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer | Log end of a step |
def choices(self):
if self._choices:
return self._choices
for n in os.listdir(self._voicedir):
if len(n) == 1 and os.path.isdir(os.path.join(self._voicedir, n)):
self._choices.append(n)
return self._choices | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement attribute identifier identifier | Available choices for characters to be generated. |
def dup_token(th):
sec_attr = win32security.SECURITY_ATTRIBUTES()
sec_attr.bInheritHandle = True
return win32security.DuplicateTokenEx(
th,
win32security.SecurityImpersonation,
win32con.MAXIMUM_ALLOWED,
win32security.TokenPrimary,
sec_attr,
) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier | duplicate the access token |
def headloss_kozeny(Length, Diam, Vel, Porosity, Nu):
ut.check_range([Length, ">0", "Length"], [Diam, ">0", "Diam"],
[Vel, ">0", "Velocity"], [Nu, ">0", "Nu"],
[Porosity, "0-1", "Porosity"])
return (K_KOZENY * Length * Nu
/ gravity.magnitude * (1-Porosity)**2
/ Porosity**3 * 36 * Vel
/ Diam ** 2) | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier string string_start string_content string_end string string_start string_content string_end list identifier string string_start string_content string_end string string_start string_content string_end list identifier string string_start string_content string_end string string_start string_content string_end list identifier string string_start string_content string_end string string_start string_content string_end list identifier string string_start string_content string_end string string_start string_content string_end return_statement parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator identifier identifier identifier attribute identifier identifier binary_operator parenthesized_expression binary_operator integer identifier integer binary_operator identifier integer integer identifier binary_operator identifier integer | Return the Carmen Kozeny Sand Bed head loss. |
def gen_url_regex(resource):
" URL regex for resource class generator. "
if resource._meta.parent:
yield resource._meta.parent._meta.url_regex.rstrip('/$').lstrip('^')
for p in resource._meta.url_params:
yield '%(name)s/(?P<%(name)s>[^/]+)' % dict(name=p)
if resource._meta.prefix:
yield resource._meta.prefix
yield '%(name)s/(?P<%(name)s>[^/]+)?' % dict(name=resource._meta.name) | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement attribute attribute identifier identifier identifier block expression_statement yield call attribute call attribute attribute attribute attribute attribute identifier identifier identifier identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end for_statement identifier attribute attribute identifier identifier identifier block expression_statement yield binary_operator string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier if_statement attribute attribute identifier identifier identifier block expression_statement yield attribute attribute identifier identifier identifier expression_statement yield binary_operator string string_start string_content string_end call identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier | URL regex for resource class generator. |
def _serialize(cls, key, value, fields):
converter = cls._get_converter_for_field(key, None, fields)
return converter.serialize(value) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier none identifier return_statement call attribute identifier identifier argument_list identifier | Marshal outgoing data into Taskwarrior's JSON format. |
def identity(self):
if self.dataset is None:
s = object_session(self)
ds = s.query(Dataset).filter(Dataset.id_ == self.d_id).one()
else:
ds = self.dataset
d = {
'id': self.id,
'vid': self.vid,
'name': self.name,
'vname': self.vname,
'ref': self.ref,
'space': self.space,
'time': self.time,
'table': self.table_name,
'grain': self.grain,
'variant': self.variant,
'segment': self.segment,
'format': self.format if self.format else 'db'
}
return PartitionIdentity.from_dict(dict(list(ds.dict.items()) + list(d.items()))) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list identifier identifier argument_list comparison_operator attribute identifier identifier attribute identifier identifier identifier argument_list else_clause block expression_statement assignment identifier attribute identifier 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 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 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 conditional_expression attribute identifier identifier attribute identifier identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list call identifier argument_list binary_operator call identifier argument_list call attribute attribute identifier identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list | Return this partition information as a PartitionId. |
def create_alias(self, alias_name):
return self._es_conn.indices.put_alias(index=self._es_index, name=alias_name) | module function_definition identifier parameters identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier | Creates an alias pointing to the index configured in this connection |
def value(self, value, *args, **kwargs):
from datetime import datetime
value = self.obj.value(value, *args, **kwargs)
try:
rv = datetime.strptime(value, self.format)
except ValueError as _:
rv = None
return rv | module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier none return_statement identifier | Takes a string value and returns the Date based on the format |
def printBasicInfo(onto):
rdfGraph = onto.rdfGraph
print("_" * 50, "\n")
print("TRIPLES = %s" % len(rdfGraph))
print("_" * 50)
print("\nNAMESPACES:\n")
for x in onto.ontologyNamespaces:
print("%s : %s" % (x[0], x[1]))
print("_" * 50, "\n")
print("ONTOLOGY METADATA:\n")
for x, y in onto.ontologyAnnotations():
print(
"%s: \n %s" % (uri2niceString(x, onto.ontologyNamespaces), uri2niceString(y, onto.ontologyNamespaces)))
print("_" * 50, "\n")
print("CLASS TAXONOMY:\n")
onto.printClassTree()
print("_" * 50, "\n") | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end integer string string_start string_content escape_sequence string_end expression_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end integer expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple subscript identifier integer subscript identifier integer expression_statement call identifier argument_list binary_operator string string_start string_content string_end integer string string_start string_content escape_sequence string_end expression_statement call identifier argument_list string string_start string_content escape_sequence string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple call identifier argument_list identifier attribute identifier identifier call identifier argument_list identifier attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end integer string string_start string_content escape_sequence string_end expression_statement call identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list binary_operator string string_start string_content string_end integer string string_start string_content escape_sequence string_end | Terminal printing of basic ontology information |
def register(self):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(self._register()) | 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 identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list | Pair client with tv. |
def clean(self):
clean_files = ['blotImage','crmaskImage','finalMask',
'staticMask','singleDrizMask','outSky',
'outSContext','outSWeight','outSingle',
'outMedian','dqmask','tmpmask',
'skyMatchMask']
log.info('Removing intermediate files for %s' % self._filename)
util.removeFileSafely(self.outputNames['outMedian'])
for chip in self.returnAllChips(extname='SCI'):
for fname in clean_files:
if fname in chip.outputNames:
util.removeFileSafely(chip.outputNames[fname]) | 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 expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end block for_statement identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier identifier | Deletes intermediate products generated for this imageObject. |
def turn_right(self):
self.at(ardrone.at.pcmd, True, 0, 0, 0, self.speed) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier true integer integer integer attribute identifier identifier | Make the drone rotate right. |
def filter(self, filter):
if hasattr(filter, '__call__'):
return [entry for entry in self.entries if filter(entry)]
else:
pattern = re.compile(filter, re.IGNORECASE)
return [entry for entry in self.entries if pattern.match(entry)] | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause call identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause call attribute identifier identifier argument_list identifier | Filter entries by calling function or applying regex. |
def root_sync(args, l, config):
from requests.exceptions import ConnectionError
all_remote_names = [ r.short_name for r in l.remotes ]
if args.all:
remotes = all_remote_names
else:
remotes = args.refs
prt("Sync with {} remotes or bundles ".format(len(remotes)))
if not remotes:
return
for ref in remotes:
l.commit()
try:
if ref in all_remote_names:
l.sync_remote(l.remote(ref))
else:
l.checkin_remote_bundle(ref)
except NotFoundError as e:
warn(e)
continue
except ConnectionError as e:
warn(e)
continue | module function_definition identifier parameters identifier identifier identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier if_statement not_operator identifier block return_statement for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list try_statement block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier continue_statement except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier continue_statement | Sync with the remote. For more options, use library sync |
def _evaluate(self):
retrieved_records = SortedDict()
for record_id, record in six.iteritems(self._elements):
if record is self._field._unset:
try:
record = self.target_app.records.get(id=record_id)
except SwimlaneHTTP400Error:
logger.debug("Received 400 response retrieving record '{}', ignoring assumed orphaned record")
continue
retrieved_records[record_id] = record
self._elements = retrieved_records
return self._elements.values() | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier attribute attribute identifier identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end continue_statement expression_statement assignment subscript identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list | Scan for orphaned records and retrieve any records that have not already been grabbed |
def stream_fastq(file_handler):
next_element = ''
for i, line in enumerate(file_handler):
next_element += line
if i % 4 == 3:
yield next_element
next_element = '' | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier identifier if_statement comparison_operator binary_operator identifier integer integer block expression_statement yield identifier expression_statement assignment identifier string string_start string_end | Generator which gives all four lines if a fastq read as one string |
def contrib_inline_aff(contrib_tag):
aff_tags = []
for child_tag in contrib_tag:
if child_tag and child_tag.name and child_tag.name == "aff":
aff_tags.append(child_tag)
return aff_tags | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement boolean_operator boolean_operator identifier attribute identifier identifier comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Given a contrib tag, look for an aff tag directly inside it |
def run_command_orig(cmd):
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if process.returncode == 0:
os.killpg(os.getpgid(pro.pid), signal.SIGTERM)
else:
raise BadRCError("Bad rc (%s) for cmd '%s': %s" % (process.returncode, cmd, stdout + stderr))
return stdout | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier binary_operator identifier identifier return_statement identifier | No idea how th f to get this to work |
def intent(self, intent):
def _handler(func):
self._handlers['IntentRequest'][intent] = func
return func
return _handler | module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end identifier identifier return_statement identifier return_statement identifier | Decorator to register intent handler |
def _build_session_metric_values(self, session_name):
result = []
metric_infos = self._experiment.metric_infos
for metric_info in metric_infos:
metric_name = metric_info.name
try:
metric_eval = metrics.last_metric_eval(
self._context.multiplexer,
session_name,
metric_name)
except KeyError:
continue
result.append(api_pb2.MetricValue(name=metric_name,
wall_time_secs=metric_eval[0],
training_step=metric_eval[1],
value=metric_eval[2]))
return result | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement identifier identifier block expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier identifier except_clause identifier block continue_statement expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier subscript identifier integer keyword_argument identifier subscript identifier integer keyword_argument identifier subscript identifier integer return_statement identifier | Builds the session metric values. |
def requestCreateDetails(self):
createReq = sc_pb.RequestCreateGame(
realtime = self.realtime,
disable_fog = self.fogDisabled,
random_seed = int(time.time()),
local_map = sc_pb.LocalMap(map_path=self.mapLocalPath,
map_data=self.mapData))
for player in self.players:
reqPlayer = createReq.player_setup.add()
playerObj = PlayerPreGame(player)
if playerObj.isComputer:
reqPlayer.difficulty = playerObj.difficulty.gameValue()
reqPlayer.type = c.types.PlayerControls(playerObj.control).gameValue()
reqPlayer.race = playerObj.selectedRace.gameValue()
return createReq | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list return_statement identifier | add configuration to the SC2 protocol create request |
def _validate_annotation(self, annotation):
required_keys = set(self._required_keys)
keys = set(key for key, val in annotation.items() if val)
missing_keys = required_keys.difference(keys)
if missing_keys:
error = 'Annotation missing required fields: {0}'.format(
missing_keys)
raise AnnotationError(error) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier generator_expression identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier raise_statement call identifier argument_list identifier | Ensures that the annotation has the right fields. |
def _combine_attribute(attr_1, attr_2, len_1, len_2):
if isinstance(attr_1, list) or isinstance(attr_2, list):
attribute = np.concatenate((attr_1, attr_2), axis=0)
attribute_changes = True
else:
if isinstance(attr_1, list) and isinstance(attr_2, list) and np.allclose(attr_1, attr_2):
attribute = attr_1
attribute_changes = False
else:
attribute = [attr_1.copy()] * len_1 if type(attr_1) != list else attr_1.copy()
attribute.extend([attr_2.copy()] * len_2 if type(attr_2 != list) else attr_2.copy())
attribute_changes = True
return attribute, attribute_changes | module function_definition identifier parameters identifier identifier identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier keyword_argument identifier integer expression_statement assignment identifier true else_clause block if_statement boolean_operator boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier false else_clause block expression_statement assignment identifier conditional_expression binary_operator list call attribute identifier identifier argument_list identifier comparison_operator call identifier argument_list identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list conditional_expression binary_operator list call attribute identifier identifier argument_list identifier call identifier argument_list comparison_operator identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier true return_statement expression_list identifier identifier | Helper function to combine trajectory properties such as site_properties or lattice |
def __find_and_remove_value(list, compare):
try:
found = next(value for value in list
if value['name'] == compare['name'] and value['switch'] ==
compare['switch'])
except:
return None
list.remove(found)
return found | module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call identifier generator_expression identifier for_in_clause identifier identifier if_clause boolean_operator comparison_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end except_clause block return_statement none expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Finds the value in the list that corresponds with the value of compare. |
def _node_info(conn):
raw = conn.getInfo()
info = {'cpucores': raw[6],
'cpumhz': raw[3],
'cpumodel': six.text_type(raw[0]),
'cpus': raw[2],
'cputhreads': raw[7],
'numanodes': raw[4],
'phymemory': raw[1],
'sockets': raw[5]}
return info | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer return_statement identifier | Internal variant of node_info taking a libvirt connection as parameter |
def update(self):
if self.input_method == 'local':
stats = self.update_local()
elif self.input_method == 'snmp':
stats = self.update_snmp()
else:
stats = self.get_init_value()
self.stats = stats
return self.stats | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier | Update CPU stats using the input method. |
def verify_log(opts):
level = LOG_LEVELS.get(str(opts.get('log_level')).lower(), logging.NOTSET)
if level < logging.INFO:
log.warning('Insecure logging configuration detected! Sensitive data may be logged.') | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | If an insecre logging configuration is found, show a warning |
def regex(self) -> Pattern:
if self._regex is None:
self._regex = re.compile(self.regex_text,
re.IGNORECASE | re.DOTALL)
return self._regex | module function_definition identifier parameters identifier type identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement attribute identifier identifier | Returns a compiled regex for this drug. |
def content_disposition(self) -> Optional[ContentDispositionHeader]:
try:
return cast(ContentDispositionHeader,
self[b'content-disposition'][0])
except (KeyError, IndexError):
return None | module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block try_statement block return_statement call identifier argument_list identifier subscript subscript identifier string string_start string_content string_end integer except_clause tuple identifier identifier block return_statement none | The ``Content-Disposition`` header. |
def pointcloud2ply(vertices, normals, out_file=None):
from pathlib import Path
import pandas as pd
from pyntcloud import PyntCloud
df = pd.DataFrame(np.hstack((vertices, normals)))
df.columns = ['x', 'y', 'z', 'nx', 'ny', 'nz']
cloud = PyntCloud(df)
if out_file is None:
out_file = Path('pointcloud.ply').resolve()
cloud.to_file(str(out_file))
return out_file | module function_definition identifier parameters identifier identifier default_parameter identifier none block import_from_statement dotted_name identifier dotted_name identifier import_statement aliased_import dotted_name identifier identifier import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list tuple identifier identifier expression_statement assignment attribute identifier 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 expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute call identifier argument_list string string_start string_content string_end identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier | Converts the file to PLY format |
def run(self, test=False):
self._request = self._parse_request()
log.debug('Handling incoming request for %s', self.request.path)
items = self._dispatch(self.request.path)
if hasattr(self, '_unsynced_storages'):
for storage in self._unsynced_storages.values():
log.debug('Saving a %s storage to disk at "%s"',
storage.file_format, storage.filename)
storage.close()
return items | module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block for_statement identifier call attribute attribute identifier identifier identifier argument_list block 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 return_statement identifier | The main entry point for a plugin. |
def update_evt_types(self):
self.event_types = self.parent.notes.annot.event_types
self.idx_evt_type.clear()
self.frequency['norm_evt_type'].clear()
for ev in self.event_types:
self.idx_evt_type.addItem(ev)
self.frequency['norm_evt_type'].addItem(ev) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier attribute attribute attribute attribute identifier identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier | Update the event types list when dialog is opened. |
def _init_incremental_search(self, searchfun, init_event):
u
log("init_incremental_search")
self.subsearch_query = u''
self.subsearch_fun = searchfun
self.subsearch_old_line = self.l_buffer.get_line_text()
queue = self.process_keyevent_queue
queue.append(self._process_incremental_search_keyevent)
self.subsearch_oldprompt = self.prompt
if (self.previous_func != self.reverse_search_history and
self.previous_func != self.forward_search_history):
self.subsearch_query = self.l_buffer[0:Point].get_line_text()
if self.subsearch_fun == self.reverse_search_history:
self.subsearch_prompt = u"reverse-i-search%d`%s': "
else:
self.subsearch_prompt = u"forward-i-search%d`%s': "
self.prompt = self.subsearch_prompt%(self._history.history_cursor, "")
if self.subsearch_query:
self.line = self._process_incremental_search_keyevent(init_event)
else:
self.line = u"" | module function_definition identifier parameters identifier identifier identifier block expression_statement identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement parenthesized_expression boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute subscript attribute identifier identifier slice integer identifier identifier argument_list if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier tuple attribute attribute identifier identifier identifier string string_start string_end if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment attribute identifier identifier string string_start string_end | u"""Initialize search prompt |
def _render_border_line(self, t, settings):
s = self._es(settings, self.SETTING_WIDTH, self.SETTING_MARGIN, self.SETTING_MARGIN_LEFT, self.SETTING_MARGIN_RIGHT)
w = self.calculate_width_widget(**s)
s = self._es(settings, self.SETTING_BORDER_STYLE, self.SETTING_BORDER_FORMATING)
border_line = self.fmt_border(w, t, **s)
s = self._es(settings, self.SETTING_MARGIN, self.SETTING_MARGIN_LEFT, self.SETTING_MARGIN_RIGHT, self.SETTING_MARGIN_CHAR)
border_line = self.fmt_margin(border_line, **s)
return border_line | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier return_statement identifier | Render box border line. |
def iter_code_cells(self):
for ws in self.nb.worksheets:
for cell in ws.cells:
if cell.cell_type == 'code':
yield cell | module function_definition identifier parameters identifier block for_statement identifier attribute attribute identifier identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement yield identifier | Iterate over the notebook cells containing code. |
def depthtospace(attrs, inputs, proto_obj):
new_attrs = translation_utils._fix_attribute_names(attrs, {'blocksize':'block_size'})
return "depth_to_space", new_attrs, inputs | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end string string_start string_content string_end return_statement expression_list string string_start string_content string_end identifier identifier | Rearranges data from depth into blocks of spatial data. |
def _load_matcher(self) -> None:
for id_key in self._rule_lst:
if self._rule_lst[id_key].active:
pattern_lst = [a_pattern.spacy_token_lst for a_pattern in self._rule_lst[id_key].patterns]
for spacy_rule_id, spacy_rule in enumerate(itertools.product(*pattern_lst)):
self._matcher.add(self._construct_key(id_key, spacy_rule_id), None, list(spacy_rule)) | module function_definition identifier parameters identifier type none block for_statement identifier attribute identifier identifier block if_statement attribute subscript attribute identifier identifier identifier identifier block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute subscript attribute identifier identifier identifier identifier for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list list_splat identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier none call identifier argument_list identifier | Add constructed spacy rule to Matcher |
def format_custom_fields(list_of_custom_fields):
output_payload = {}
if list_of_custom_fields:
for custom_field in list_of_custom_fields:
for key, value in custom_field.items():
output_payload["custom_fields[" + key + "]"] = value
return output_payload | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary if_statement identifier block for_statement identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end identifier return_statement identifier | Custom fields formatting for submission |
def _get_tab(cls):
if not cls._tabs['dec_cobs']:
cls._tabs['dec_cobs']['\xff'] = (255, '')
cls._tabs['dec_cobs'].update(dict((chr(l), (l, '\0'))
for l in range(1, 255)))
cls._tabs['enc_cobs'] = [(255, '\xff'),
dict((l, chr(l))
for l in range(1, 255)),
]
return cls._tabs['dec_cobs'], cls._tabs['enc_cobs'] | module function_definition identifier parameters identifier block if_statement not_operator subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content escape_sequence string_end tuple integer string string_start string_end expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list call identifier generator_expression tuple call identifier argument_list identifier tuple identifier string string_start string_content escape_sequence string_end for_in_clause identifier call identifier argument_list integer integer expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end list tuple integer string string_start string_content escape_sequence string_end call identifier generator_expression tuple identifier call identifier argument_list identifier for_in_clause identifier call identifier argument_list integer integer return_statement expression_list subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end | Generate and return the COBS table. |
def _wait(jid):
if jid is None:
jid = salt.utils.jid.gen_jid(__opts__)
states = _prior_running_states(jid)
while states:
time.sleep(1)
states = _prior_running_states(jid) | module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier while_statement identifier block expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list identifier | Wait for all previously started state jobs to finish running |
def strip_label(mapper, connection, target):
if target.label is not None:
target.label = target.label.strip() | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list | Strip labels at ORM level so the unique=True means something. |
def strip_html(text):
def reply_to(text):
replying_to = []
split_text = text.split()
for index, token in enumerate(split_text):
if token.startswith('@'): replying_to.append(token[1:])
else:
message = split_text[index:]
break
rply_msg = ""
if len(replying_to) > 0:
rply_msg = "Replying to "
for token in replying_to[:-1]: rply_msg += token+","
if len(replying_to)>1: rply_msg += 'and '
rply_msg += replying_to[-1]+". "
return rply_msg + " ".join(message)
text = reply_to(text)
text = text.replace('@', ' ')
return " ".join([token for token in text.split()
if ('http:' not in token) and ('https:' not in token)]) | module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier slice integer else_clause block expression_statement assignment identifier subscript identifier slice identifier break_statement expression_statement assignment identifier string string_start string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier string string_start string_content string_end for_statement identifier subscript identifier slice unary_operator integer block expression_statement augmented_assignment identifier binary_operator identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier binary_operator subscript identifier unary_operator integer string string_start string_content string_end return_statement binary_operator identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause boolean_operator parenthesized_expression comparison_operator string string_start string_content string_end identifier parenthesized_expression comparison_operator string string_start string_content string_end identifier | Get rid of ugly twitter html |
def user_has_super_roles():
member = api.get_current_user()
super_roles = ["LabManager", "Manager"]
diff = filter(lambda role: role in super_roles, member.getRoles())
return len(diff) > 0 | module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier comparison_operator identifier identifier call attribute identifier identifier argument_list return_statement comparison_operator call identifier argument_list identifier integer | Return whether the current belongs to superuser roles |
def safe_url(url):
parsed = urlparse(url)
if parsed.password is not None:
pwd = ':%s@' % parsed.password
url = url.replace(pwd, ':*****@')
return url | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement identifier | Remove password from printed connection URLs. |
def dump(self, *args, **kwargs):
lxml.etree.dump(self._obj, *args, **kwargs) | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier list_splat identifier dictionary_splat identifier | Dumps a representation of the Model on standard output. |
def sunRelation(obj, sun):
if obj.id == const.SUN:
return None
dist = abs(angle.closestdistance(sun.lon, obj.lon))
if dist < 0.2833: return CAZIMI
elif dist < 8.0: return COMBUST
elif dist < 16.0: return UNDER_SUN
else:
return None | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement none expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier float block return_statement identifier elif_clause comparison_operator identifier float block return_statement identifier elif_clause comparison_operator identifier float block return_statement identifier else_clause block return_statement none | Returns an object's relation with the sun. |
def remove_feature(self, feature_name):
self.clear_feature_symlinks(feature_name)
if os.path.exists(self.install_directory(feature_name)):
self.__remove_path(self.install_directory(feature_name)) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier | Remove an feature from the environment root folder. |
def explain_prediction_lightning(estimator, doc, vec=None, top=None,
target_names=None, targets=None,
feature_names=None, vectorized=False,
coef_scale=None):
return explain_weights_lightning_not_supported(estimator, doc) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier none block return_statement call identifier argument_list identifier identifier | Return an explanation of a lightning estimator predictions |
def types(gandi):
options = {}
types = gandi.paas.type_list(options)
for type_ in types:
gandi.echo(type_['name'])
return types | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier | List types PaaS instances. |
def b(self):
b = Point(self.center)
if self.xAxisIsMinor:
b.x += self.minorRadius
else:
b.y += self.minorRadius
return b | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier else_clause block expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier return_statement identifier | Positive antipodal point on the minor axis, Point class. |
def _should_run(het_file):
has_hets = False
with open(het_file) as in_handle:
for i, line in enumerate(in_handle):
if i > 1:
has_hets = True
break
return has_hets | module function_definition identifier parameters identifier block expression_statement assignment identifier false with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier true break_statement return_statement identifier | Check for enough input data to proceed with analysis. |
def setSignalName(self, name: str):
self.isHook = False
self.messengerName = name | module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier identifier | Specify that the message will be delivered with the signal ``name``. |
def _set_id_from_xml_frameid(self, xml, xmlpath, var):
e = xml.find(xmlpath)
if e is not None:
setattr(self, var, e.attrib['frameid']) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier identifier subscript attribute identifier identifier string string_start string_content string_end | Set a single variable with the frameids of matching entity |
def runcall(self, func, *args, **kw):
self.enable_by_count()
try:
return func(*args, **kw)
finally:
self.disable_by_count() | module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier finally_clause block expression_statement call attribute identifier identifier argument_list | Profile a single function call. |
def openSheet(self, name):
if name not in self.__sheetNameDict:
sheet = self.__workbook.add_sheet(name)
self.__sheetNameDict[name] = sheet
self.__sheet = self.__sheetNameDict[name] | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier subscript attribute identifier identifier identifier | set a sheet to write |
def cosh(x, context=None):
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_cosh,
(BigFloat._implicit_convert(x),),
context,
) | module function_definition identifier parameters identifier default_parameter identifier none block return_statement call identifier argument_list identifier attribute identifier identifier tuple call attribute identifier identifier argument_list identifier identifier | Return the hyperbolic cosine of x. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.