code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def serialize_instance(instance):
model_name = force_text(instance._meta)
return '{}:{}'.format(model_name, instance.pk) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier | Serialize Django model instance |
def use_comparative_relationship_view(self):
self._object_views['relationship'] = COMPARATIVE
for session in self._get_provider_sessions():
try:
session.use_comparative_relationship_view()
except AttributeError:
pass | module function_definition identifier parameters identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement | Pass through to provider RelationshipLookupSession.use_comparative_relationship_view |
def gen_send_version_url(ip, port):
return '{0}:{1}{2}{3}/{4}/{5}'.format(BASE_URL.format(ip), port, API_ROOT_URL, VERSION_API, NNI_EXP_ID, NNI_TRIAL_JOB_ID) | module function_definition identifier parameters identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier | Generate send error url |
def print_languages_and_exit(lst, status=1, header=True):
if header:
print("Available languages:")
for lg in lst:
print("- %s" % lg)
sys.exit(status) | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier true block if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier | print a list of languages and exit |
def read_PIA0_A_control(self, cpu_cycles, op_address, address):
value = 0xb3
log.error(
"%04x| read $%04x (PIA 0 A side Control reg.) send $%02x (%s) back.\t|%s",
op_address, address, value, byte2bit_string(value),
self.cfg.mem_info.get_shortest(op_address)
)
return value | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end identifier identifier identifier call identifier argument_list identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier return_statement identifier | read from 0xff01 -> PIA 0 A side control register |
def add(self, *tokens: str) -> None:
from wdom.web_node import WdomElement
_new_tokens = []
for token in tokens:
self._validate_token(token)
if token and token not in self:
self._list.append(token)
_new_tokens.append(token)
if isinstance(self._owner, WdomElement) and _new_tokens:
self._owner.js_exec('addClass', _new_tokens) | module function_definition identifier parameters identifier typed_parameter list_splat_pattern identifier type identifier type none block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator identifier comparison_operator identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator call identifier argument_list attribute identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier | Add new tokens to list. |
def send_reminder(self, user, sender=None, **kwargs):
if user.is_active:
return False
token = RegistrationTokenGenerator().make_token(user)
kwargs.update({"token": token})
self.email_message(
user, self.reminder_subject, self.reminder_body, sender, **kwargs
).send() | module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement attribute identifier identifier block return_statement false expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier expression_statement call attribute call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier identifier dictionary_splat identifier identifier argument_list | Sends a reminder email to the specified user |
def _return_result(self, result, comparison_vectors=None):
return_type = cf.get_option('classification.return_type')
if type(result) != np.ndarray:
raise ValueError("numpy.ndarray expected.")
if return_type == 'index':
return comparison_vectors.index[result.astype(bool)]
elif return_type == 'series':
return pandas.Series(
result,
index=comparison_vectors.index,
name='classification')
elif return_type == 'array':
return result
else:
raise ValueError(
"return_type {} unknown. Choose 'index', 'series' or "
"'array'".format(return_type)) | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block return_statement subscript attribute identifier identifier call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement identifier else_clause block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier | Return different formatted classification results. |
def _unquote(self, value):
if not value:
raise SyntaxError
if (value[0] == value[-1]) and (value[0] in ('"', "'")):
value = value[1:-1]
return value | module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block raise_statement identifier if_statement boolean_operator parenthesized_expression comparison_operator subscript identifier integer subscript identifier unary_operator integer parenthesized_expression comparison_operator subscript identifier integer tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice integer unary_operator integer return_statement identifier | Return an unquoted version of a value |
def toys(self) -> Tuple[timetools.TOY, ...]:
return tuple(toy for (toy, _) in self) | module function_definition identifier parameters identifier type generic_type identifier type_parameter type attribute identifier identifier type ellipsis block return_statement call identifier generator_expression identifier for_in_clause tuple_pattern identifier identifier identifier | A sorted |tuple| of all contained |TOY| objects. |
def _serialize_zebra_family_prefix(prefix):
if ip.valid_ipv4(prefix):
family = socket.AF_INET
prefix_addr, prefix_num = prefix.split('/')
return family, struct.pack(
_ZEBRA_FAMILY_IPV4_PREFIX_FMT,
family,
addrconv.ipv4.text_to_bin(prefix_addr),
int(prefix_num))
elif ip.valid_ipv6(prefix):
family = socket.AF_INET6
prefix_addr, prefix_num = prefix.split('/')
return family, struct.pack(
_ZEBRA_FAMILY_IPV6_PREFIX_FMT,
family,
addrconv.ipv6.text_to_bin(prefix_addr),
int(prefix_num))
raise ValueError('Invalid prefix: %s' % prefix) | module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_list identifier call attribute identifier identifier argument_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier call identifier argument_list identifier elif_clause call attribute identifier identifier argument_list identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_list identifier call attribute identifier identifier argument_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier call identifier argument_list identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier | Serializes family and prefix in Zebra format. |
def validatetag(context):
"Check to make sure that a tag exists for the current HEAD and it looks like a valid version number"
result = context.run("git describe --exact-match --tags $(git log -n1 --pretty='%h')")
tag = result.stdout.rstrip()
ver_regex = re.compile('(\d+)\.(\d+)\.(\d+)')
match = ver_regex.fullmatch(tag)
if match is None:
print('Tag {!r} does not appear to be a valid version number'.format(tag))
sys.exit(-1)
else:
print('Tag {!r} appears to be a valid version number'.format(tag)) | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list 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 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 expression_statement call attribute identifier identifier argument_list unary_operator integer else_clause block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier | Check to make sure that a tag exists for the current HEAD and it looks like a valid version number |
def add_rulegroup(self, rulegroup):
body = rulegroup
response = self._post("/segments/%s/rules.json" %
self.segment_id, json.dumps(body)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier call attribute identifier identifier argument_list identifier | Adds a rulegroup to this segment. |
def run(self):
paths = [x for x in practices.__dict__.values()
if hasattr(x, 'code')]
for node in ast.walk(self.tree):
try:
lineno, col_offset = node.lineno, node.col_offset
except AttributeError:
continue
for checker in paths:
if checker(node):
message = self.build_message(checker)
yield lineno, col_offset, message, type(self) | module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list if_clause call identifier argument_list identifier string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block try_statement block expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier attribute identifier identifier except_clause identifier block continue_statement for_statement identifier identifier block if_statement call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement yield expression_list identifier identifier identifier call identifier argument_list identifier | Primary entry point to the plugin, runs once per file. |
def regs(self):
regs = set()
for operand in self.operands:
if not operand.type.has_reg:
continue
regs.update(operand.regs)
return regs | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block if_statement not_operator attribute attribute identifier identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier | Names of all registers used by the instruction. |
def create_ports(port, mpi, rank):
if port == "random" or port is None:
ports = {}
else:
port = int(port)
ports = {
"REQ": port + 0,
"PUSH": port + 1,
"SUB": port + 2
}
if mpi == 'all':
for port in ports:
ports[port] += (rank * 3)
return ports | module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier none block expression_statement assignment identifier dictionary else_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end binary_operator identifier integer pair string string_start string_content string_end binary_operator identifier integer pair string string_start string_content string_end binary_operator identifier integer if_statement comparison_operator identifier string string_start string_content string_end block for_statement identifier identifier block expression_statement augmented_assignment subscript identifier identifier parenthesized_expression binary_operator identifier integer return_statement identifier | create a list of ports for the current rank |
def _log_length_error(self, key, length):
extra = {
"max_detail_length": settings.defaults["max_detail_length"],
"len": length
}
if self.key_name:
extra[self.key_name] = key
msg = "Length of data in %s is too long." % self.__class__.__name__
log.error(msg, extra=extra) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end pair string string_start string_content string_end identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier | Helper function for logging a response length error. |
def _fixedpoint(D, tol=1e-7, maxiter=None):
N, K = D.shape
logp = log(D).mean(axis=0)
a0 = _init_a(D)
if maxiter is None:
maxiter = MAXINT
for i in xrange(maxiter):
a1 = _ipsi(psi(a0.sum()) + logp)
if abs(loglikelihood(D, a1)-loglikelihood(D, a0)) < tol:
return a1
a0 = a1
raise Exception('Failed to converge after {} iterations, values are {}.'
.format(maxiter, a1)) | module function_definition identifier parameters identifier default_parameter identifier float default_parameter identifier none block expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list keyword_argument identifier integer expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list binary_operator call identifier argument_list call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list binary_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier identifier block return_statement identifier expression_statement assignment identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier | Simple fixed point iteration method for MLE of Dirichlet distribution |
def tmpfile(*args, **kwargs):
(fd, fname) = tempfile.mkstemp(*args, **kwargs)
try:
yield fname
finally:
os.close(fd)
if os.path.exists(fname):
os.remove(fname) | module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier try_statement block expression_statement yield identifier finally_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier | Make a tempfile, safely cleaning up file descriptors on completion. |
def go_to_line(self, line=None):
editorstack = self.get_current_editorstack()
if editorstack is not None:
editorstack.go_to_line(line) | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier | Open 'go to line' dialog |
def generate_uppercase_key(key, namespace=None):
if namespace:
namespace = [part for part in listify(namespace) if part]
key = '_'.join(namespace + [key])
key = key.upper()
return key | module function_definition identifier parameters identifier default_parameter identifier none block if_statement identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call identifier argument_list identifier if_clause identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list binary_operator identifier list identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier | Given a key and a namespace, generates a final uppercase key. |
def exec_module(self, module):
path = [os.path.dirname(module.__file__)]
file = None
try:
file, pathname, description = imp.find_module(module.__name__.rpartition('.')[-1], path)
module = imp.load_module(module.__name__, file, pathname, description)
finally:
if file:
file.close() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier none try_statement block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end unary_operator integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier identifier identifier finally_clause block if_statement identifier block expression_statement call attribute identifier identifier argument_list | Execute the module using the old imp. |
def recvline(sock):
reply = io.BytesIO()
while True:
c = sock.recv(1)
if not c:
return None
if c == b'\n':
break
reply.write(c)
result = reply.getvalue()
log.debug('-> %r', result)
return result | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement not_operator identifier block return_statement none if_statement comparison_operator identifier string string_start string_content escape_sequence string_end block break_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier | Receive a single line from the socket. |
def off(self):
self._send_method(StandardSend(self._address,
COMMAND_LIGHT_OFF_0X13_0X00),
self._off_message_received) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier identifier attribute identifier identifier | Send OFF command to device. |
def make_structure_from_geos(geos):
model_structure=initialize_res(geos[0])
for i in range(1,len(geos)):
model_structure=add_residue(model_structure, geos[i])
return model_structure | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list subscript identifier integer for_statement identifier call identifier argument_list integer call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier subscript identifier identifier return_statement identifier | Creates a structure out of a list of geometry objects. |
def group(self, groupId):
url = "%s/%s" % (self.root, groupId)
return Group(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initalize=False) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier false | gets a group based on it's ID |
def as_bel(self) -> str:
return 'pmod({}{})'.format(
str(self[IDENTIFIER]),
''.join(', {}'.format(self[x]) for x in PMOD_ORDER[2:] if x in self)
) | module function_definition identifier parameters identifier type identifier block return_statement call attribute string string_start string_content string_end identifier argument_list call identifier argument_list subscript identifier identifier call attribute string string_start string_end identifier generator_expression call attribute string string_start string_content string_end identifier argument_list subscript identifier identifier for_in_clause identifier subscript identifier slice integer if_clause comparison_operator identifier identifier | Return this protein modification variant as a BEL string. |
def sound_mode(self):
sound_mode_matched = self._parent_avr.match_sound_mode(
self._parent_avr.sound_mode_raw)
return sound_mode_matched | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier return_statement identifier | Return the matched current sound mode as a string. |
def write(self, data):
self._check_not_closed()
if not data:
return 0
enc_data = self.encryptor.update(data)
self.next_fp.write(enc_data)
self.offset += len(data)
return len(data) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement not_operator identifier block return_statement integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier call identifier argument_list identifier return_statement call identifier argument_list identifier | Encrypt and write the given bytes |
def export_to_dicts(table, *args, **kwargs):
field_names = table.field_names
return [{key: getattr(row, key) for key in field_names} for row in table] | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier attribute identifier identifier return_statement list_comprehension dictionary_comprehension pair identifier call identifier argument_list identifier identifier for_in_clause identifier identifier for_in_clause identifier identifier | Export a `rows.Table` to a list of dicts |
def on_batch_begin(self, last_input, last_target, **kwargs):
"accumulate samples and batches"
self.acc_samples += last_input.shape[0]
self.acc_batches += 1 | module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier subscript attribute identifier identifier integer expression_statement augmented_assignment attribute identifier identifier integer | accumulate samples and batches |
def observe_all(self, callback: Callable[[str, Any, Any], None]):
self._all_callbacks.append(callback) | module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type list identifier identifier identifier type none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Subscribes to all keys changes |
def init(name, runtime):
runtime = click.unstyle(runtime)
stdout.write(
style.format_command(
'Initializing',
'%s %s %s' % (name, style.gray('@'), style.green(runtime))
)
)
config = Config(os.getcwd())
config.set('runtime', runtime)
config.save()
generate.main(['init', name], standalone_mode=False)
run.main(['python', 'manage.py', 'migrate']) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end tuple identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end | Create a new Django app. |
def public(self, *args, **kwargs):
kwargs['public'] = True
return self.filter(*args, **kwargs) | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment subscript identifier string string_start string_content string_end true return_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier | Only return public actions |
def image_mapped(name):
try:
out = check_output(['rbd', 'showmapped'])
if six.PY3:
out = out.decode('UTF-8')
except CalledProcessError:
return False
return name in out | module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list list string string_start string_content string_end string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block return_statement false return_statement comparison_operator identifier identifier | Determine whether a RADOS block device is mapped locally. |
def click_a_point(self, x=0, y=0, duration=100):
self._info("Clicking on a point (%s,%s)." % (x,y))
driver = self._current_application()
action = TouchAction(driver)
try:
action.press(x=float(x), y=float(y)).wait(float(duration)).release().perform()
except:
assert False, "Can't click on a point at (%s,%s)" % (x,y) | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier try_statement block expression_statement call attribute call attribute call attribute call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier identifier argument_list call identifier argument_list identifier identifier argument_list identifier argument_list except_clause block assert_statement false binary_operator string string_start string_content string_end tuple identifier identifier | Click on a point |
def getRloc16(self):
print '%s call getRloc16' % self.port
rloc16 = self.__sendCommand('rloc16')[0]
return int(rloc16, 16) | module function_definition identifier parameters identifier block print_statement binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer return_statement call identifier argument_list identifier integer | get rloc16 short address |
def copy_files(src, ext, dst):
src_path = os.path.join(os.path.dirname(__file__), src)
dst_path = os.path.join(os.path.dirname(__file__), dst)
file_list = os.listdir(src_path)
for f in file_list:
if f == '__init__.py':
continue
f_path = os.path.join(src_path, f)
if os.path.isfile(f_path) and f.endswith(ext):
shutil.copy(f_path, dst_path) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block continue_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement boolean_operator call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier | Copies files with extensions "ext" from "src" to "dst" directory. |
def line(self, text=''):
self.out.write(text)
self.out.write('\n') | module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end | A simple helper to write line with `\n` |
def update(self,record,**kw):
vals = self._make_sql_params(kw)
sql = "UPDATE %s SET %s WHERE rowid=?" %(self.name,
",".join(vals))
self.cursor.execute(sql,kw.values()+[record['__id__']]) | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier binary_operator call attribute identifier identifier argument_list list subscript identifier string string_start string_content string_end | Update the record with new keys and values |
def bookmarks_changed(self):
bookmarks = self.editor.get_bookmarks()
if self.editor.bookmarks != bookmarks:
self.editor.bookmarks = bookmarks
self.sig_save_bookmarks.emit(self.filename, repr(bookmarks)) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute attribute identifier identifier identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier | Bookmarks list has changed. |
def out_filename(template, n_val, mode):
return '{0}_{1}_{2}.cpp'.format(template.name, n_val, mode.identifier) | module function_definition identifier parameters identifier identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier attribute identifier identifier | Determine the output filename |
def add_reference(self, source, target, **kwargs):
addRef_kw = kwargs.copy()
addRef_kw.setdefault("referenceClass", self.referenceClass)
if "schema" in addRef_kw:
del addRef_kw["schema"]
uid = api.get_uid(target)
rc = api.get_tool("reference_catalog")
rc.addReference(source, uid, self.relationship, **addRef_kw)
self.link_version(source, target) | module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block delete_statement subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier attribute identifier identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier identifier | Add a new reference |
def draw_image(
self, img_filename:str, x:float, y:float, w:float, h:float
) -> None:
pass | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type none block pass_statement | Draws the given image. |
def split_on_condition(seq, condition):
l1, l2 = tee((condition(item), item) for item in seq)
return (i for p, i in l1 if p), (i for p, i in l2 if not p) | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier generator_expression tuple call identifier argument_list identifier identifier for_in_clause identifier identifier return_statement expression_list generator_expression identifier for_in_clause pattern_list identifier identifier identifier if_clause identifier generator_expression identifier for_in_clause pattern_list identifier identifier identifier if_clause not_operator identifier | Split a sequence into two iterables without looping twice |
def to_wire(self, file, compress=None, origin=None, **kw):
return super(RRset, self).to_wire(self.name, file, compress, origin,
self.deleting, **kw) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block return_statement call attribute call identifier argument_list identifier identifier identifier argument_list attribute identifier identifier identifier identifier identifier attribute identifier identifier dictionary_splat identifier | Convert the RRset to wire format. |
def validate_with_schema(self, collection=None, context=None):
if self._schema is None or not collection:
return
result = []
try:
for index, item in enumerate(collection):
item_result = self._schema.validate(
model=item,
context=context if self.use_context else None
)
result.append(item_result)
except TypeError:
pass
return result | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement boolean_operator comparison_operator attribute identifier identifier none not_operator identifier block return_statement expression_statement assignment identifier list try_statement block for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier conditional_expression identifier attribute identifier identifier none expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement return_statement identifier | Validate each item in collection with our schema |
def create_role(name):
role = role_manager.create(name=name)
if click.confirm(f'Are you sure you want to create {role!r}?'):
role_manager.save(role, commit=True)
click.echo(f'Successfully created {role!r}')
else:
click.echo('Cancelled.') | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier if_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier type_conversion string_content string_end block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier type_conversion string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Create a new role. |
def address_inline(request, prefix="", country_code=None, template_name="postal/form.html"):
country_prefix = "country"
prefix = request.POST.get('prefix', prefix)
if prefix:
country_prefix = prefix + '-country'
country_code = request.POST.get(country_prefix, country_code)
form_class = form_factory(country_code=country_code)
if request.method == "POST":
data = {}
for (key, val) in request.POST.items():
if val is not None and len(val) > 0:
data[key] = val
data.update({country_prefix: country_code})
form = form_class(prefix=prefix, initial=data)
else:
form = form_class(prefix=prefix)
return render_to_string(template_name, RequestContext(request, {
"form": form,
"prefix": prefix,
})) | module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier none default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier dictionary for_statement tuple_pattern identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier none comparison_operator call identifier argument_list identifier integer block expression_statement assignment subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list dictionary pair identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier return_statement call identifier argument_list identifier call identifier argument_list identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier | Displays postal address with localized fields |
def remove_file(file_path):
if path.exists(file_path):
try:
rmtree(file_path)
except Exception:
print('Unable to remove temporary workdir {}'.format(file_path)) | module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list identifier block try_statement block expression_statement call identifier argument_list identifier except_clause identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier | Remove a file from the filesystem. |
def async_step(self):
assert len(self._agents_to_act) == 0
self._init_step()
t = time.time()
aiomas.run(until=self.env.trigger_all())
self._agents_to_act = []
self._step_processing_time = time.time() - t
self._finalize_step() | module function_definition identifier parameters identifier block assert_statement comparison_operator call identifier argument_list attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier binary_operator call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list | Progress simulation by running all agents once asynchronously. |
def render_check_and_set_platforms(self):
phase = 'prebuild_plugins'
plugin = 'check_and_set_platforms'
if not self.pt.has_plugin_conf(phase, plugin):
return
if self.user_params.koji_target.value:
self.pt.set_plugin_arg(phase, plugin, "koji_target",
self.user_params.koji_target.value) | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier identifier block return_statement if_statement attribute attribute attribute identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier | If the check_and_set_platforms plugin is present, configure it |
def normalize_urls(urls):
_urls = []
if isinstance(urls, list):
if urls:
if isinstance(urls[0], list):
_urls = urls
elif isinstance(urls[0], str):
_urls = [urls]
else:
raise RuntimeError("No target host url provided.")
elif isinstance(urls, str):
_urls = [[urls]]
return _urls | module function_definition identifier parameters identifier block expression_statement assignment identifier list if_statement call identifier argument_list identifier identifier block if_statement identifier block if_statement call identifier argument_list subscript identifier integer identifier block expression_statement assignment identifier identifier elif_clause call identifier argument_list subscript identifier integer identifier block expression_statement assignment identifier list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier list list identifier return_statement identifier | Overload urls and make list of lists of urls. |
def adjust(self, ln):
adj_ln = ln
need_unskipped = 0
for i in self.skips:
if i <= ln:
need_unskipped += 1
elif adj_ln + need_unskipped < i:
break
else:
need_unskipped -= i - adj_ln - 1
adj_ln = i
return adj_ln + need_unskipped | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement augmented_assignment identifier integer elif_clause comparison_operator binary_operator identifier identifier identifier block break_statement else_clause block expression_statement augmented_assignment identifier binary_operator binary_operator identifier identifier integer expression_statement assignment identifier identifier return_statement binary_operator identifier identifier | Converts a parsing line number into an original line number. |
def load_data(self):
options=self.options
command = open(self.options.data_script).read()
self.result["data_script"]=command
t0=time.time()
data=None
exec(command)
t1=time.time()
print(("Elapsed time for data reading is %.2f seconds" % (t1-t0)))
self.data=data
return self.data | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute call identifier argument_list attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier none expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list parenthesized_expression binary_operator string string_start string_content string_end parenthesized_expression binary_operator identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier | Run the job specified in data_script |
def stars_list(self, **kwargs) -> SlackResponse:
self._validate_xoxp_token()
return self.api_call("stars.list", http_verb="GET", params=kwargs) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier type identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier | Lists stars for a user. |
def copy_figure(self):
if self.figviewer and self.figviewer.figcanvas.fig:
self.figviewer.figcanvas.copy_figure() | module function_definition identifier parameters identifier block if_statement boolean_operator attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list | Copy figure from figviewer to clipboard. |
def convert(outputfile, inputfile, to_format, from_format):
emb = word_embedding.WordEmbedding.load(
inputfile, format=_input_choices[from_format][1],
binary=_input_choices[from_format][2])
emb.save(outputfile, format=_output_choices[to_format][1],
binary=_output_choices[to_format][2]) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier subscript subscript identifier identifier integer keyword_argument identifier subscript subscript identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier subscript subscript identifier identifier integer keyword_argument identifier subscript subscript identifier identifier integer | Convert pretrained word embedding file in one format to another. |
def decorate_callable(self, target):
def absorb_mocks(test_case, *args):
return target(test_case)
should_absorb = not (self.pass_mocks or isinstance(target, type))
result = absorb_mocks if should_absorb else target
for patcher in self.patchers:
result = patcher(result)
return result | module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier list_splat_pattern identifier block return_statement call identifier argument_list identifier expression_statement assignment identifier not_operator parenthesized_expression boolean_operator attribute identifier identifier call identifier argument_list identifier identifier expression_statement assignment identifier conditional_expression identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier | Called as a decorator. |
def vport_meta(self, vip):
vport_meta = self.meta(vip, 'vport', None)
if vport_meta is None:
vport_meta = self.meta(vip, 'port', {})
return vport_meta | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end none if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end dictionary return_statement identifier | Get the vport meta, no matter which name was used |
def _check_repos(self, repos):
self._checking_repos = []
self._valid_repos = []
for repo in repos:
worker = self.download_is_valid_url(repo)
worker.sig_finished.connect(self._repos_checked)
worker.repo = repo
self._checking_repos.append(repo) | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Check if repodata urls are valid. |
def str_fmthdr(self, goid, goobj):
go_txt = goid.replace("GO:", "G")
if 'mark_alt_id' in self.present and goid != goobj.id:
go_txt += 'a'
return go_txt | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier comparison_operator identifier attribute identifier identifier block expression_statement augmented_assignment identifier string string_start string_content string_end return_statement identifier | Return hdr line seen inside a GO Term box. |
def insert(self, crc, toc):
if self._rw_cache:
try:
filename = '%s/%08X.json' % (self._rw_cache, crc)
cache = open(filename, 'w')
cache.write(json.dumps(toc, indent=2,
default=self._encoder))
cache.close()
logger.info('Saved cache to [%s]', filename)
self._cache_files += [filename]
except Exception as exp:
logger.warning('Could not save cache to file [%s]: %s',
filename, str(exp))
else:
logger.warning('Could not save cache, no writable directory') | module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block try_statement block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier integer keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement augmented_assignment attribute identifier identifier list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Save a new cache to file |
def rssi_bars(self) -> int:
rssi_db = self.rssi_db
if rssi_db < 45:
return 0
elif rssi_db < 60:
return 1
elif rssi_db < 75:
return 2
elif rssi_db < 90:
return 3
return 4 | module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier integer block return_statement integer elif_clause comparison_operator identifier integer block return_statement integer elif_clause comparison_operator identifier integer block return_statement integer elif_clause comparison_operator identifier integer block return_statement integer return_statement integer | Received Signal Strength Indication, from 0 to 4 bars. |
def user_get_websudo(self):
url = 'secure/admin/WebSudoAuthenticate.jspa'
headers = self.form_token_headers
data = {
'webSudoPassword': self.password,
}
return self.post(path=url, data=data, headers=headers) | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Get web sudo cookies using normal http request |
def load_interfaces(self, interfaces_dict):
if interfaces_dict.get('apilist', {}).get('interfaces', None) is None:
raise ValueError("Invalid response for GetSupportedAPIList")
interfaces = interfaces_dict['apilist']['interfaces']
if len(interfaces) == 0:
raise ValueError("API returned not interfaces; probably using invalid key")
for interface in self.interfaces:
delattr(self, interface.name)
self.interfaces = []
for interface in interfaces:
obj = WebAPIInterface(interface, parent=self)
self.interfaces.append(obj)
setattr(self, obj.name, obj) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end none none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier attribute identifier identifier expression_statement assignment attribute identifier identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call identifier argument_list identifier attribute identifier identifier identifier | Populates the namespace under the instance |
def random_sample(self, num_samples, df=None, replace=False, weights=None, random_state=100, axis='row'):
if df is None:
df = self.dat_to_df()
if axis == 'row':
axis = 0
if axis == 'col':
axis = 1
df = self.export_df()
df = df.sample(n=num_samples, replace=replace, weights=weights, random_state=random_state, axis=axis)
self.load_df(df) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false default_parameter identifier none default_parameter identifier integer default_parameter identifier string string_start string_content string_end block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier integer if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Return random sample of matrix. |
def UpdateClientsFromFleetspeak(clients):
if not fleetspeak_connector.CONN or not fleetspeak_connector.CONN.outgoing:
return
id_map = {}
for client in clients:
if client.fleetspeak_enabled:
id_map[fleetspeak_utils.GRRIDToFleetspeakID(client.client_id)] = client
if not id_map:
return
res = fleetspeak_connector.CONN.outgoing.ListClients(
admin_pb2.ListClientsRequest(client_ids=list(iterkeys(id_map))))
for read in res.clients:
api_client = id_map[read.client_id]
api_client.last_seen_at = fleetspeak_utils.TSToRDFDatetime(
read.last_contact_time)
api_client.last_clock = fleetspeak_utils.TSToRDFDatetime(read.last_clock) | module function_definition identifier parameters identifier block if_statement boolean_operator not_operator attribute identifier identifier not_operator attribute attribute identifier identifier identifier block return_statement expression_statement assignment identifier dictionary for_statement identifier identifier block if_statement attribute identifier identifier block expression_statement assignment subscript identifier call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement not_operator identifier block return_statement expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list call identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier | Updates ApiClient records to include info from Fleetspeak. |
def _flattenPortsSide(side: List[LNode]) -> List[LNode]:
new_side = []
for i in side:
for new_p in flattenPort(i):
new_side.append(new_p)
return new_side | module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier list for_statement identifier identifier block for_statement identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Flatten hierarchical ports on node side |
def switch_state(context, ain):
context.obj.login()
actor = context.obj.get_actor_by_ain(ain)
if actor:
click.echo("State for {} is: {}".format(ain,'ON' if actor.get_state() else 'OFF'))
else:
click.echo("Actor not found: {}".format(ain)) | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier conditional_expression string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier | Get an actor's power state |
def canonical_names(self):
cns = []
for r_id in relation_ids('identity-service'):
for unit in related_units(r_id):
rdata = relation_get(rid=r_id, unit=unit)
for k in rdata:
if k.startswith('ssl_key_'):
cns.append(k.lstrip('ssl_key_'))
return sorted(list(set(cns))) | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list string string_start string_content string_end block for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier for_statement identifier 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 call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list call identifier argument_list identifier | Figure out which canonical names clients will access this service. |
def example_splits(url_file, all_files):
def generate_hash(inp):
h = hashlib.sha1()
h.update(inp)
return h.hexdigest()
all_files_map = {f.split("/")[-1]: f for f in all_files}
urls = [line.strip().encode("utf-8") for line in tf.gfile.Open(url_file)]
filelist = []
for url in urls:
url_hash = generate_hash(url)
filename = url_hash + ".story"
if filename not in all_files_map:
tf.logging.info("Missing file: %s" % url)
continue
filelist.append(all_files_map[filename])
tf.logging.info("Found %d examples" % len(filelist))
return filelist | module function_definition identifier parameters identifier identifier block 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 return_statement call attribute identifier identifier argument_list expression_statement assignment identifier dictionary_comprehension pair subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer identifier for_in_clause identifier identifier expression_statement assignment identifier list_comprehension call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end for_in_clause identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier continue_statement expression_statement call attribute identifier identifier argument_list subscript identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier return_statement identifier | Generate splits of the data. |
def iterkeys(self):
def _iterkeys(bin):
for item in bin:
yield item.key
for bin in self.bins:
yield _iterkeys(bin) | module function_definition identifier parameters identifier block function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement yield attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement yield call identifier argument_list identifier | An iterator over the keys of each bin. |
def getCorner(index,top,left,expand=0,y=206):
x = str(-(expand+old_div(ARENA_WIDTH,2))) if left else str(expand+old_div(ARENA_WIDTH,2))
z = str(-(expand+old_div(ARENA_BREADTH,2))) if top else str(expand+old_div(ARENA_BREADTH,2))
return 'x'+index+'="'+x+'" y'+index+'="' +str(y)+'" z'+index+'="'+z+'"' | module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer default_parameter identifier integer block expression_statement assignment identifier conditional_expression call identifier argument_list unary_operator parenthesized_expression binary_operator identifier call identifier argument_list identifier integer identifier call identifier argument_list binary_operator identifier call identifier argument_list identifier integer expression_statement assignment identifier conditional_expression call identifier argument_list unary_operator parenthesized_expression binary_operator identifier call identifier argument_list identifier integer identifier call identifier argument_list binary_operator identifier call identifier argument_list identifier integer return_statement binary_operator binary_operator 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 string_end identifier string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end | Return part of the XML string that defines the requested corner |
def _is_socket(cls, stream):
try:
fd = stream.fileno()
except ValueError:
return False
sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_RAW)
try:
sock.getsockopt(socket.SOL_SOCKET, socket.SO_TYPE)
except socket.error as ex:
if ex.args[0] != errno.ENOTSOCK:
return True
else:
return True | module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause identifier block return_statement false expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block if_statement comparison_operator subscript attribute identifier identifier integer attribute identifier identifier block return_statement true else_clause block return_statement true | Check if the given stream is a socket. |
def _linearInterpolationTransformMatrix(matrix1, matrix2, value):
return tuple(_interpolateValue(matrix1[i], matrix2[i], value) for i in range(len(matrix1))) | module function_definition identifier parameters identifier identifier identifier block return_statement call identifier generator_expression call identifier argument_list subscript identifier identifier subscript identifier identifier identifier for_in_clause identifier call identifier argument_list call identifier argument_list identifier | Linear, 'oldstyle' interpolation of the transform matrix. |
def _term_str(term: TermAtom) -> str:
if is_operation(term):
return term.name + '('
elif is_symbol_wildcard(term):
return '*{!s}'.format(term.__name__)
elif isinstance(term, Wildcard):
return '*{!s}{!s}'.format(term.min_count, (not term.fixed_size) and '+' or '')
elif term == Wildcard:
return '*'
else:
return str(term) | module function_definition identifier parameters typed_parameter identifier type identifier type identifier block if_statement call identifier argument_list identifier block return_statement binary_operator attribute identifier identifier string string_start string_content string_end elif_clause call identifier argument_list identifier block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier elif_clause call identifier argument_list identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier boolean_operator boolean_operator parenthesized_expression not_operator attribute identifier identifier string string_start string_content string_end string string_start string_end elif_clause comparison_operator identifier identifier block return_statement string string_start string_content string_end else_clause block return_statement call identifier argument_list identifier | Return a string representation of a term atom. |
def getPlaintextLen(self, ciphertext):
completeCiphertextHeader = (len(ciphertext) >= 16)
if completeCiphertextHeader is False:
raise RecoverableDecryptionError('Incomplete ciphertext header.')
ciphertext_header = ciphertext[:16]
L = self._ecb_enc_K1.decrypt(ciphertext_header)
padding_expected = '\x00\x00\x00\x00'
padding_actual = L[-8:-4]
validPadding = (padding_actual == padding_expected)
if validPadding is False:
raise UnrecoverableDecryptionError(
'Invalid padding: ' + padding_actual)
message_length = fte.bit_ops.bytes_to_long(L[-8:])
msgLenNonNegative = (message_length >= 0)
if msgLenNonNegative is False:
raise UnrecoverableDecryptionError('Negative message length.')
return message_length | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier parenthesized_expression comparison_operator call identifier argument_list identifier integer if_statement comparison_operator identifier false block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end expression_statement assignment identifier subscript identifier slice unary_operator integer unary_operator integer expression_statement assignment identifier parenthesized_expression comparison_operator identifier identifier if_statement comparison_operator identifier false block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier slice unary_operator integer expression_statement assignment identifier parenthesized_expression comparison_operator identifier integer if_statement comparison_operator identifier false block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier | Given a ``ciphertext`` with a valid header, returns the length of the plaintext payload. |
def query(self, query, inplace=True):
result = self.data.query(query, inplace=inplace)
return result | module function_definition identifier parameters identifier identifier default_parameter identifier true block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier return_statement identifier | State what you want to keep |
def default_values_of(func):
signature = inspect.signature(func)
return [k
for k, v in signature.parameters.items()
if v.default is not inspect.Parameter.empty or
v.kind != inspect.Parameter.POSITIONAL_OR_KEYWORD] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement list_comprehension identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause boolean_operator comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier | Return the defaults of the function `func`. |
def prune_clusters(clusters, index, n=3):
torem = set(c for c in clusters if c.size < n)
pruned_clusters = [c for c in clusters if c.size >= n]
terms_torem = []
for term, clusters in index.items():
index[term] = clusters - torem
if len(index[term]) == 0:
terms_torem.append(term)
for t in terms_torem:
del index[t]
return pruned_clusters, index | module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier call identifier generator_expression identifier for_in_clause identifier identifier if_clause comparison_operator attribute identifier identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator attribute identifier identifier identifier expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier binary_operator identifier identifier if_statement comparison_operator call identifier argument_list subscript identifier identifier integer block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block delete_statement subscript identifier identifier return_statement expression_list identifier identifier | Delete clusters with fewer than n elements. |
def _verify_config_dict(self, valid, config, dev_os, key_path=None):
if not key_path:
key_path = []
for key, value in valid.items():
self._verify_config_key(key, value, valid, config, dev_os, key_path) | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier | Verify if the config dict is valid. |
def _str_elem(config, key):
_value = config.pop(key, '')
if _valid_str(_value):
config[key] = _value | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_end if_statement call identifier argument_list identifier block expression_statement assignment subscript identifier identifier identifier | Re-adds the value of a specific key in the dict, only in case of valid str value. |
def bind_to_provider(self, cls, provider):
self._check_class(cls)
if provider is None:
raise InjectorException('Provider cannot be None, key=%s' % cls)
self._bindings[cls] = provider
logger.debug('Bound %s to a provider %s', cls, provider)
return self | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement identifier | Bind a class to a callable instance provider executed for each injection. |
def inject_pid(self, data):
pid_value = data.pop('pid', None)
if pid_value:
pid_field = current_app.config['PIDSTORE_RECID_FIELD']
data.setdefault(pid_field, pid_value)
return data | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier | Inject context PID in the RECID field. |
def make_file_system_tree(root_folder, _parent=None):
root_node = Node(os.path.basename(root_folder), _parent)
root_node.path = root_folder
for item in os.listdir(root_folder):
item_path = os.path.join(root_folder, item)
if os.path.isfile(item_path):
file_node = Node(os.path.basename(item), root_node)
file_node.path = item_path
elif os.path.isdir(item_path):
make_file_system_tree(item_path, _parent=root_node)
return root_node | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier identifier elif_clause call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call identifier argument_list identifier keyword_argument identifier identifier return_statement identifier | This function makes a tree from folders and files. |
def datedif(ctx, start_date, end_date, unit):
start_date = conversions.to_date(start_date, ctx)
end_date = conversions.to_date(end_date, ctx)
unit = conversions.to_string(unit, ctx).lower()
if start_date > end_date:
raise ValueError("Start date cannot be after end date")
if unit == 'y':
return relativedelta(end_date, start_date).years
elif unit == 'm':
delta = relativedelta(end_date, start_date)
return 12 * delta.years + delta.months
elif unit == 'd':
return (end_date - start_date).days
elif unit == 'md':
return relativedelta(end_date, start_date).days
elif unit == 'ym':
return relativedelta(end_date, start_date).months
elif unit == 'yd':
return (end_date - start_date.replace(year=end_date.year)).days
raise ValueError("Invalid unit value: %s" % unit) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier identifier argument_list if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block return_statement attribute call identifier argument_list identifier identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement binary_operator binary_operator integer attribute identifier identifier attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement attribute parenthesized_expression binary_operator identifier identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement attribute call identifier argument_list identifier identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement attribute call identifier argument_list identifier identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement attribute parenthesized_expression binary_operator identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier | Calculates the number of days, months, or years between two dates. |
def items(self):
if hasattr(self, '_items'):
return self.filter_items(self._items)
self._items = self.get_items()
return self.filter_items(self._items) | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list attribute identifier identifier | access for filtered items |
def _get_headers(self, resource):
if type(resource) == file:
resource.seek(0)
reader = csv.reader(resource)
elif isinstance(resource, basestring):
result = six.moves.urllib.parse.urlparse(resource)
if result.scheme in ['http', 'https']:
with closing(requests.get(resource, stream=True)) as response:
header_row = response.iter_lines().next()
else:
with open(resource) as resource_file:
reader = csv.reader(resource_file)
header_row = reader.next()
reader = csv.reader(cStringIO.StringIO(header_row))
else:
raise IOError('Resource type not supported')
return reader.next() | module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end block with_statement with_clause with_item as_pattern call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier true as_pattern_target identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list else_clause block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list | Get CSV file headers from the provided resource. |
def register_workflow(self, name, workflow):
assert name not in self.workflows
self.workflows[name] = workflow | module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier | Register an workflow to be showed in the workflows list. |
def _update_conda_devel():
conda_bin = _get_conda_bin()
channels = _get_conda_channels(conda_bin)
assert conda_bin, "Could not find anaconda distribution for upgrading bcbio"
subprocess.check_call([conda_bin, "install", "--quiet", "--yes"] + channels +
["bcbio-nextgen>=%s" % version.__version__.replace("a0", "a")])
return os.path.dirname(os.path.dirname(conda_bin)) | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier assert_statement identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator binary_operator list identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier list binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier | Update to the latest development conda package. |
def id_to_symbol(self, entrez_id):
entrez_id = str(entrez_id)
if entrez_id not in self.ids_to_symbols:
m = 'Could not look up symbol for Entrez ID ' + entrez_id
raise Exception(m)
return self.ids_to_symbols[entrez_id] | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier raise_statement call identifier argument_list identifier return_statement subscript attribute identifier identifier identifier | Gives the symbol for a given entrez id) |
def p2pardict(self, p):
d = {}
N = self.Nstars
i = 0
for s in self.systems:
age, feh, dist, AV = p[i+N[s]:i+N[s]+4]
for j in xrange(N[s]):
l = '{}_{}'.format(s,j)
mass = p[i+j]
d[l] = [mass, age, feh, dist, AV]
i += N[s] + 4
return d | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier subscript identifier slice binary_operator identifier subscript identifier identifier binary_operator binary_operator identifier subscript identifier identifier integer for_statement identifier call identifier argument_list subscript identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier subscript identifier binary_operator identifier identifier expression_statement assignment subscript identifier identifier list identifier identifier identifier identifier identifier expression_statement augmented_assignment identifier binary_operator subscript identifier identifier integer return_statement identifier | Given leaf labels, turns parameter vector into pardict |
def write_bubble(self, filename:str):
from bubbletools import converter
converter.tree_to_bubble(self, filename) | module function_definition identifier parameters identifier typed_parameter identifier type identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement call attribute identifier identifier argument_list identifier identifier | Write in given filename the lines of bubble describing this instance |
def _log(self, fname, txt, prg=''):
if os.sep not in fname:
fname = self.log_folder + os.sep + fname
delim = ','
q = '"'
dte = TodayAsString()
usr = GetUserName()
hst = GetHostName()
i = self.session_id
if prg == '':
prg = 'cls_log.log'
logEntry = q + dte + q + delim + q + i + q + delim + q + usr + q + delim + q + hst + q + delim + q + prg + q + delim + q + txt + q + delim + '\n'
with open(fname, "a", encoding='utf-8', errors='replace') as myfile:
myfile.write(logEntry) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_end block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier attribute identifier identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier string string_start string_content escape_sequence string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier | logs an entry to fname along with standard date and user details |
def load_modules(self, data=None, proxy=None):
self.functions = self.wrapper
self.utils = salt.loader.utils(self.opts)
self.serializers = salt.loader.serializers(self.opts)
locals_ = salt.loader.minion_mods(self.opts, utils=self.utils)
self.states = salt.loader.states(self.opts, locals_, self.utils, self.serializers)
self.rend = salt.loader.render(self.opts, self.functions) | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier | Load up the modules for remote compilation via ssh |
def _thread_listen(self):
while self._running:
try:
rest = requests.get(URL_LISTEN.format(self._url),
timeout=self._timeout)
if rest.status_code == 200:
self._queue.put(rest.json())
else:
_LOGGER.error('QSUSB response code %s', rest.status_code)
sleep(30)
except requests.exceptions.ConnectionError as err:
if str(err).find('timed') > 0:
self._queue.put({QS_CMD: CMD_UPDATE})
else:
_LOGGER.error(str(err))
sleep(60)
except Exception as err:
_LOGGER.error("%s - %s", str(type(err)), str(err))
sleep(5)
self._queue.put({}) | module function_definition identifier parameters identifier block while_statement attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list integer except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block if_statement comparison_operator call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end integer block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call identifier argument_list integer except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier expression_statement call identifier argument_list integer expression_statement call attribute attribute identifier identifier identifier argument_list dictionary | The main &listen loop. |
def _POUpdateBuilder(env, **kw):
import SCons.Action
from SCons.Tool.GettextCommon import _POFileBuilder
action = SCons.Action.Action(_update_or_init_po_files, None)
return _POFileBuilder(env, action=action, target_alias='$POUPDATE_ALIAS') | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block import_statement dotted_name identifier identifier import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier none return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end | Create an object of `POUpdate` builder |
def fit(self, data):
_raise_error_if_not_sframe(data, "data")
fitted_state = {}
feature_columns = _internal_utils.get_column_names(data, self._exclude, self._features)
if not feature_columns:
raise RuntimeError("No valid feature columns specified in transformation.")
fitted_state['features'] = feature_columns
fitted_state['fitted'] = True
self.__proxy__.update(fitted_state)
return self | module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end true expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier | Fits the transformer using the given data. |
def _add_referrer(cls, request: Request, url_record: URLRecord):
if url_record.parent_url.startswith('https://') and \
url_record.url_info.scheme == 'http':
return
request.fields['Referer'] = url_record.parent_url | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block if_statement boolean_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end line_continuation comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block return_statement expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier | Add referrer URL to request. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.