code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def checker_from_dict(self, dct):
checker_identifier = list(dct.keys())[0]
checker_class = self.get_checker(checker_identifier)
if checker_class:
return checker_class(**dct[checker_identifier])
return None | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript call identifier argument_list call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement call identifier argument_list dictionary_splat subscript identifier identifier return_statement none | Return a checker instance from a dict object. |
def green_callback(fn, obj=None, green_mode=None):
executor = get_object_executor(obj, green_mode)
@wraps(fn)
def greener(*args, **kwargs):
return executor.submit(fn, *args, **kwargs)
return greener | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier | Return a green verion of the given callback. |
def RenderValue(value, limit_lists=-1):
if value is None:
return None
renderer = ApiValueRenderer.GetRendererForValueOrClass(
value, limit_lists=limit_lists)
return renderer.RenderValue(value) | module function_definition identifier parameters identifier default_parameter identifier unary_operator integer block if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier | Render given RDFValue as plain old python objects. |
def _last_stack_str():
stack = extract_stack()
for s in stack[::-1]:
if op.join('vispy', 'gloo', 'buffer.py') not in __file__:
break
return format_list([s])[0] | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list for_statement identifier subscript identifier slice unary_operator integer block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier block break_statement return_statement subscript call identifier argument_list list identifier integer | Print stack trace from call that didn't originate from here |
def coerce(self, value):
return {
'lat': float(value.get('lat', value.get('latitude'))),
'lon': float(value.get('lon', value.get('longitude')))
} | module function_definition identifier parameters identifier identifier block return_statement dictionary pair string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end | Coerces value to location hash. |
def _update_index(self):
d = self.declaration
self.index = self.view.model.index(d.row, d.column)
if self.delegate:
self._refresh_count += 1
timed_call(self._loading_interval, self._update_delegate) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier | Update the reference to the index within the table |
def to_text(self, filename=None, overwrite=True):
table = self.standardized
if filename == None:
filename = '{}.txt'.format(self.name)
self.speak('saving to {}'.format(filename))
table.write(filename, format='ascii.ecsv', overwrite=overwrite) | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier | Write this catalog out to a text file. |
async def got_who_reply(self, nick=None, real_name=None, **kws):
nick = nick[2:] if nick[0:2] == 'E_' else nick
host, ports = real_name.split(' ', 1)
self.servers.remove(nick)
logger.debug("Found: '%s' at %s with port list: %s",nick, host, ports)
self.results[host.lower()] = ServerInfo(nick, host, ports)
if not self.servers:
self.all_done.set() | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier conditional_expression subscript identifier slice integer comparison_operator subscript identifier slice integer integer string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier expression_statement assignment subscript attribute identifier identifier call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list | Server replied to one of our WHO requests, with details. |
def config(self):
config = {}
if self.config_file.exists():
with open(self.config_file.as_posix(), 'rt') as f:
config = {k:self._override[k] if
k in self._override else
v for k, v in yaml.safe_load(f).items()}
return config | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary if_statement call attribute attribute identifier identifier identifier argument_list block with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier dictionary_comprehension pair identifier conditional_expression subscript attribute identifier identifier identifier comparison_operator identifier attribute identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list return_statement identifier | Allows changing the config on the fly |
def load_manifest_file(client, bucket, schema, versioned, ifilters, key_info):
yield None
with tempfile.NamedTemporaryFile() as fh:
client.download_fileobj(Bucket=bucket, Key=key_info['key'], Fileobj=fh)
fh.seek(0)
reader = csv.reader(gzip.GzipFile(fileobj=fh, mode='r'))
for key_set in chunks(reader, 1000):
keys = []
for kr in key_set:
k = kr[1]
if inventory_filter(ifilters, schema, kr):
continue
k = unquote_plus(k)
if versioned:
if kr[3] == 'true':
keys.append((k, kr[2], True))
else:
keys.append((k, kr[2]))
else:
keys.append(k)
yield keys | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement yield none with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end for_statement identifier call identifier argument_list identifier integer block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier subscript identifier integer if_statement call identifier argument_list identifier identifier identifier block continue_statement expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list tuple identifier subscript identifier integer true else_clause block expression_statement call attribute identifier identifier argument_list tuple identifier subscript identifier integer else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement yield identifier | Given an inventory csv file, return an iterator over keys |
def unsubscribe(self, request, *args, **kwargs):
self.object = self.get_object()
self.object.subscribers.remove(request.user)
messages.success(self.request, self.success_message)
return HttpResponseRedirect(self.get_success_url()) | module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list | Performs the unsubscribe action. |
def load_settings(self):
mname = 'loaded_module'
if six.PY2:
import imp
return imp.load_source(mname, self.settings_filename)
else:
import importlib.machinery
loader = importlib.machinery.SourceFileLoader(mname, self.settings_filename)
return loader.load_module(mname) | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end if_statement attribute identifier identifier block import_statement dotted_name identifier return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier else_clause block import_statement dotted_name identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier | Load settings module from the model_dir directory. |
def destinations(self, cluster='main'):
if not self.config.has_section(cluster):
raise SystemExit("Cluster '%s' not defined in %s"
% (cluster, self.config_file))
destinations = self.config.get(cluster, 'destinations')
return destinations.replace(' ', '').split(',') | module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end return_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list string string_start string_content string_end | Return a list of destinations for a cluster. |
def _bubbleP(cls, T):
c = cls._blend["bubble"]
Tj = cls._blend["Tj"]
Pj = cls._blend["Pj"]
Tita = 1-T/Tj
suma = 0
for i, n in zip(c["i"], c["n"]):
suma += n*Tita**(i/2.)
P = Pj*exp(Tj/T*suma)
return P | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator integer binary_operator identifier identifier expression_statement assignment identifier integer for_statement pattern_list identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator identifier binary_operator identifier parenthesized_expression binary_operator identifier float expression_statement assignment identifier binary_operator identifier call identifier argument_list binary_operator binary_operator identifier identifier identifier return_statement identifier | Using ancillary equation return the pressure of bubble point |
def my_workspaces(context):
pc = api.portal.get_tool('portal_catalog')
brains = pc(
portal_type="ploneintranet.workspace.workspacefolder",
sort_on="modified",
sort_order="reversed",
)
workspaces = [
{
'id': brain.getId,
'title': brain.Title,
'description': brain.Description,
'url': brain.getURL(),
'activities': get_workspace_activities(brain),
'class': escape_id_to_class(brain.getId),
} for brain in brains
]
return workspaces | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument 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 expression_statement assignment identifier list_comprehension dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end call identifier argument_list attribute identifier identifier for_in_clause identifier identifier return_statement identifier | The list of my workspaces |
def policy_list(request, **kwargs):
policies = neutronclient(request).list_qos_policies(
**kwargs).get('policies')
return [QoSPolicy(p) for p in policies] | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute call attribute call identifier argument_list identifier identifier argument_list dictionary_splat identifier identifier argument_list string string_start string_content string_end return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier | List of QoS Policies. |
def file_exists(original_file):
s3 = boto3.resource('s3')
bucket_name, object_key = _parse_s3_file(original_file)
bucket = s3.Bucket(bucket_name)
bucket_iterator = bucket.objects.filter(Prefix=object_key)
bucket_list = [x for x in bucket_iterator]
logger.debug("Bucket List: {0}".format(", ".join([x.key for x in bucket_list])))
logger.debug("bucket_list length: {0}".format(len(bucket_list)))
return len(bucket_list) == 1 | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier return_statement comparison_operator call identifier argument_list identifier integer | Validate the original file is in the S3 bucket |
def _wrap_in_place(func):
@wraps(func)
def wrapper(graph, *args, **kwargs):
func(graph, *args, **kwargs)
return graph
return wrapper | module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier return_statement identifier | Take a function that doesn't return the graph and returns the graph. |
def _update_sub_file_dict(self, sub_files):
sub_files.file_dict.clear()
for job_details in self.jobs.values():
if job_details.file_dict is not None:
sub_files.update(job_details.file_dict)
if job_details.sub_file_dict is not None:
sub_files.update(job_details.sub_file_dict) | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier | Update a file dict with information from self |
def _make_ndarray_function(handle, name, func_name):
code, doc_str = _generate_ndarray_function_code(handle, name, func_name)
local = {}
exec(code, None, local)
ndarray_function = local[func_name]
ndarray_function.__name__ = func_name
ndarray_function.__doc__ = doc_str
ndarray_function.__module__ = 'mxnet.ndarray'
return ndarray_function | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier dictionary expression_statement call identifier argument_list identifier none identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier string string_start string_content string_end return_statement identifier | Create a NDArray function from the FunctionHandle. |
def _construct_where_to_match(where_block):
if where_block.predicate == TrueLiteral:
raise AssertionError(u'Received WHERE block with TrueLiteral predicate: {}'
.format(where_block))
return u'WHERE ' + where_block.predicate.to_match() | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list | Transform a Filter block into a MATCH query string. |
def submissions(self):
r = fapi.get_submissions(self.namespace, self.name, self.api_url)
fapi._check_response_code(r, 200)
return r.json() | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier integer return_statement call attribute identifier identifier argument_list | List job submissions in workspace. |
def quote_by_instruments(cls, client, ids):
base_url = "https://api.robinhood.com/instruments"
id_urls = ["{}/{}/".format(base_url, _id) for _id in ids]
return cls.quotes_by_instrument_urls(client, id_urls) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier list_comprehension call attribute string string_start string_content string_end identifier argument_list identifier identifier for_in_clause identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier | create instrument urls, fetch, return results |
def _remove_keycache(self, entity_branch, turn, tick):
keycache = self.keycache
if entity_branch in keycache:
kc = keycache[entity_branch]
if turn in kc:
kcturn = kc[turn]
if tick in kcturn:
del kcturn[tick]
kcturn.truncate(tick)
if not kcturn:
del kc[turn]
kc.truncate(turn)
if not kc:
del keycache[entity_branch] | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier identifier block delete_statement subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator identifier block delete_statement subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator identifier block delete_statement subscript identifier identifier | Remove the future of a given entity from a branch in the keycache |
def _local_upload(self, filepath, remove=False):
if os.path.isfile(filepath):
filename = os.path.basename(os.path.abspath(filepath))
if filename and self.__isValidFilename(filename):
suffix = self.__getFilenameSuffix(filename)
try:
self.__unpack_tgz(os.path.abspath(filepath)) if self.__isValidTGZ(suffix) else self.__unpack_zip(os.path.abspath(filepath))
finally:
if remove is True:
os.remove(filepath)
else:
raise InstallError("Invalid Filename")
else:
raise InstallError("Invalid Filepath") | module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier if_statement boolean_operator identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement conditional_expression call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier finally_clause block if_statement comparison_operator identifier true block expression_statement call attribute identifier identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content string_end | Local plugin package processing |
def removeFeatureSet(self, featureSet):
q = models.Featureset.delete().where(
models.Featureset.id == featureSet.getId())
q.execute() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list comparison_operator attribute attribute identifier identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Removes the specified featureSet from this repository. |
def from_env(cls):
token = getenv(cls.TOKEN_ENV_VAR)
if token is None:
msg = 'missing environment variable: {!r}'.format(cls.TOKEN_ENV_VAR)
raise ValueError(msg)
return cls(api_token=token) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier raise_statement call identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier | Create a service instance from an environment variable. |
def trail(self):
inner = (self.get_query()
.select(PageView.ip, PageView.url)
.order_by(PageView.timestamp))
return (PageView
.select(
PageView.ip,
fn.array_agg(PageView.url).alias('urls'))
.from_(inner.alias('t1'))
.group_by(PageView.ip)) | module function_definition identifier parameters identifier block expression_statement assignment identifier parenthesized_expression call attribute call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier attribute identifier identifier identifier argument_list attribute identifier identifier return_statement parenthesized_expression call attribute call attribute call attribute identifier identifier argument_list attribute identifier identifier call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list attribute identifier identifier | Get all visitors by IP and then list the pages they visited in order. |
def append_rules(self, an_iterable):
self.rules.extend(
TransformRule(*x, config=self.config) for x in an_iterable
) | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier generator_expression call identifier argument_list list_splat identifier keyword_argument identifier attribute identifier identifier for_in_clause identifier identifier | add rules to the TransformRuleSystem |
def reset(self):
self._components = OrderedDict()
self.clear_selections()
self._logger.info("<block: %s> reset component list" % (self.name)) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression attribute identifier identifier | Removes all the components of the block |
def start(self):
if not self._thread:
_LOGGER.info("Starting SocketIO thread...")
self._thread = threading.Thread(target=self._run_socketio_thread,
name='SocketIOThread')
self._thread.deamon = True
self._thread.start() | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list | Start a thread to handle SocketIO notifications. |
def create_fa(self):
if self._seqs is None:
os.symlink(self._fa0_fn, self._fa_fn)
else:
in_seqs = pyfaidx.Fasta(self._fa0_fn)
with open(self._fa_fn, "w+") as g:
for seq_desc in self._seqs:
x = in_seqs[seq_desc]
name, seq = x.name, str(x)
g.write(">" + name + "\n")
n = 80
seq_split = "\n".join([seq[i:i + n] for i in range(0, len(seq), n)])
g.write(seq_split + "\n") | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier integer expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list list_comprehension subscript identifier slice identifier binary_operator identifier identifier for_in_clause identifier call identifier argument_list integer call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content escape_sequence string_end | Create a FASTA file with extracted sequences. |
def remove_sort(self, field_name):
self.sorts = [dict(field=value) for field, value in self.sorts if field
is not field_name] | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier list_comprehension call identifier argument_list keyword_argument identifier identifier for_in_clause pattern_list identifier identifier attribute identifier identifier if_clause comparison_operator identifier identifier | Clears sorting criteria affecting ``field_name``. |
def _write(self, to_write):
self._file.write(to_write.encode(self._encoding or
self._default_encoding)) | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list boolean_operator attribute identifier identifier attribute identifier identifier | Helper to call encode before writing to file for Python 3 compat. |
def connect(sock, addr):
try:
sock.connect(addr)
except ssl.SSLError as e:
return (ssl.SSLError, e.strerror if e.strerror else e.message)
except socket.herror as (_, msg):
return (socket.herror, msg)
except socket.gaierror as (_, msg):
return (socket.gaierror, msg)
except socket.timeout:
return (socket.timeout, "timeout")
except socket.error as e:
return (socket.error, e.strerror if e.strerror else e.message)
return None | module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block return_statement tuple attribute identifier identifier conditional_expression attribute identifier identifier attribute identifier identifier attribute identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target tuple identifier identifier block return_statement tuple attribute identifier identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target tuple identifier identifier block return_statement tuple attribute identifier identifier identifier except_clause attribute identifier identifier block return_statement tuple attribute identifier identifier string string_start string_content string_end except_clause as_pattern attribute identifier identifier as_pattern_target identifier block return_statement tuple attribute identifier identifier conditional_expression attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement none | Connect to some addr. |
def update_config(cls, config_file, config):
need_save = False
if 'api' in config and 'env' in config['api']:
del config['api']['env']
need_save = True
ssh_key = config.get('ssh_key')
sshkeys = config.get('sshkey')
if ssh_key and not sshkeys:
config.update({'sshkey': [ssh_key]})
need_save = True
elif ssh_key and sshkeys:
config.update({'sshkey': sshkeys.append(ssh_key)})
need_save = True
if ssh_key:
del config['ssh_key']
need_save = True
if need_save:
cls.save(config_file, config) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier false if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end block delete_statement subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier true 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 string string_start string_content string_end if_statement boolean_operator identifier not_operator identifier block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end list identifier expression_statement assignment identifier true elif_clause boolean_operator identifier identifier block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment identifier true if_statement identifier block delete_statement subscript identifier string string_start string_content string_end expression_statement assignment identifier true if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier | Update configuration if needed. |
def _validate_applications(self, apps):
for application_id, application_config in apps.items():
self._validate_config(application_id, application_config)
application_config["APPLICATION_ID"] = application_id | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier | Validate the application collection |
def last_modified(self):
last_modified = time.strftime(
"%a, %d %b %Y %H:%M:%S GMT",
time.gmtime(time.time()))
return last_modified | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement identifier | Get the HTTP-datetime of when the collection was modified. |
def clean(self):
if not util.is_blank(self.catalog.catname) and os.path.exists(self.catalog.catname):
os.remove(self.catalog.catname) | module function_definition identifier parameters identifier block if_statement boolean_operator not_operator call attribute identifier identifier argument_list attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier | Remove intermediate files created |
def _clear_temp_dir():
tempdir = get_tempdir()
for fname in os.listdir(tempdir):
try:
os.remove( os.path.join(tempdir, fname) )
except Exception:
pass | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute identifier identifier argument_list identifier block try_statement block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier except_clause identifier block pass_statement | Clear the temporary directory. |
def _load_manifest_from_file(manifest, path):
path = os.path.abspath(os.path.expanduser(path))
if not os.path.exists(path):
raise ManifestException("Manifest does not exist at {0}!".format(path))
manifest.read(path)
if not manifest.has_option('config', 'source'):
manifest.set('config', 'source', str(path)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_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 identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end call identifier argument_list identifier | load manifest from file |
def analyze_overs(self):
self.dif1 = [self.overs[i][0]-self.overs[i-1][0] for i in range(1,len(self.overs))]
self.dif2 = [self.overs[i][1]-self.overs[i-1][1] for i in range(1,len(self.overs))]
self.start1 = self.overs[0][0] == 0
self.start2 = self.overs[0][1] == 0
self.end1 = self.overs[-1][0] == len(self.j1)-1
self.end2 = self.overs[-1][1] == len(self.j2)-1
return | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier list_comprehension binary_operator subscript subscript attribute identifier identifier identifier integer subscript subscript attribute identifier identifier binary_operator identifier integer integer for_in_clause identifier call identifier argument_list integer call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier list_comprehension binary_operator subscript subscript attribute identifier identifier identifier integer subscript subscript attribute identifier identifier binary_operator identifier integer integer for_in_clause identifier call identifier argument_list integer call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier comparison_operator subscript subscript attribute identifier identifier integer integer integer expression_statement assignment attribute identifier identifier comparison_operator subscript subscript attribute identifier identifier integer integer integer expression_statement assignment attribute identifier identifier comparison_operator subscript subscript attribute identifier identifier unary_operator integer integer binary_operator call identifier argument_list attribute identifier identifier integer expression_statement assignment attribute identifier identifier comparison_operator subscript subscript attribute identifier identifier unary_operator integer integer binary_operator call identifier argument_list attribute identifier identifier integer return_statement | A helper function to prepare values describing overlaps |
def show_intro(self):
from IPython.core.usage import interactive_usage
self.main.help.show_rich_text(interactive_usage) | module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier | Show intro to IPython help |
def error_lineno(self):
if isinstance(self.docstring, Docstring):
return self.docstring.start
return self.start | module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier identifier block return_statement attribute attribute identifier identifier identifier return_statement attribute identifier identifier | Get the line number with which to report violations. |
def check_uri_security(uri):
if urlparse(uri).scheme != 'https':
warning_message = (
'WARNING: this client is sending a request to an insecure'
' API endpoint. Any API request you make may expose your API key and'
' secret to third parties. Consider using the default endpoint:\n\n'
' %s\n') % uri
warnings.warn(warning_message, UserWarning)
return uri | module function_definition identifier parameters identifier block if_statement comparison_operator attribute call identifier argument_list identifier identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end string string_start string_content escape_sequence string_end identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier | Warns if the URL is insecure. |
def _submit_and_wait(cmd, cores, config, output_dir):
batch_script = "submit_bcl2fastq.sh"
if not os.path.exists(batch_script + ".finished"):
if os.path.exists(batch_script + ".failed"):
os.remove(batch_script + ".failed")
with open(batch_script, "w") as out_handle:
out_handle.write(config["process"]["bcl2fastq_batch"].format(
cores=cores, bcl2fastq_cmd=" ".join(cmd), batch_script=batch_script))
submit_cmd = utils.get_in(config, ("process", "submit_cmd"))
subprocess.check_call(submit_cmd.format(batch_script=batch_script), shell=True)
while 1:
if os.path.exists(batch_script + ".finished"):
break
if os.path.exists(batch_script + ".failed"):
raise ValueError("bcl2fastq batch script failed: %s" %
os.path.join(output_dir, batch_script))
time.sleep(5) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list binary_operator identifier string string_start string_content string_end block if_statement call attribute attribute identifier identifier identifier argument_list binary_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier tuple string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier true while_statement integer block if_statement call attribute attribute identifier identifier identifier argument_list binary_operator identifier string string_start string_content string_end block break_statement if_statement call attribute attribute identifier identifier identifier argument_list binary_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list integer | Submit command with batch script specified in configuration, wait until finished |
def delete_edge_by_id(self, edge_id):
edge = self.get_edge(edge_id)
from_node_id = edge['vertices'][0]
from_node = self.get_node(from_node_id)
from_node['edges'].remove(edge_id)
to_node_id = edge['vertices'][1]
to_node = self.get_node(to_node_id)
to_node['edges'].remove(edge_id)
del self.edges[edge_id]
self._num_edges -= 1 | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier delete_statement subscript attribute identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier integer | Removes the edge identified by "edge_id" from the graph. |
def _make_resource(self):
with self._lock:
for i in self._unavailable_range():
if self._reference_queue[i] is None:
rtracker = _ResourceTracker(
self._factory(**self._factory_arguments))
self._reference_queue[i] = rtracker
self._size += 1
return rtracker
raise PoolFullError | module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator subscript attribute identifier identifier identifier none block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list dictionary_splat attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier integer return_statement identifier raise_statement identifier | Returns a resource instance. |
def construct_docstring(options):
s = "\nParameters\n"
s += "----------\n\n"
for key, opt in options.items():
s += "%s : %s\n %s [%s]\n" % (key, str(opt[2]),
str(opt[1]), str(opt[0]))
return s | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content escape_sequence escape_sequence string_end expression_statement augmented_assignment identifier string string_start string_content escape_sequence escape_sequence string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end tuple identifier call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer return_statement identifier | Construct a docstring for a set of options |
def check_url_warnings(self):
effectiveurl = urlutil.urlunsplit(self.urlparts)
if self.url != effectiveurl:
self.add_warning(_("Effective URL %(url)r.") %
{"url": effectiveurl},
tag=WARN_URL_EFFECTIVE_URL)
self.url = effectiveurl
if len(self.url) > URL_MAX_LENGTH and self.scheme != u"data":
args = dict(len=len(self.url), max=URL_MAX_LENGTH)
self.add_warning(_("URL length %(len)d is longer than %(max)d.") % args, tag=WARN_URL_TOO_LONG) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement boolean_operator comparison_operator call identifier argument_list attribute identifier identifier identifier comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier | Check URL name and length. |
def check_state(self, pair, state):
self.__log_info('Check %s %s -> %s', pair, pair.state, state)
pair.state = state | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier | Updates the state of a check. |
def print_info(ds, ds_path=None):
"Prints basic summary of a given dataset."
if ds_path is None:
bname = ''
else:
bname = basename(ds_path)
dashes = '-' * len(bname)
print('\n{}\n{}\n{:full}'.format(dashes, bname, ds))
return | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_end else_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence escape_sequence string_end identifier argument_list identifier identifier identifier return_statement | Prints basic summary of a given dataset. |
def _parse_raw_data(self):
if self.uuid == _XMP_UUID:
txt = self.raw_data.decode('utf-8')
elt = ET.fromstring(txt)
self.data = ET.ElementTree(elt)
elif self.uuid == _GEOTIFF_UUID:
self.data = tiff_header(self.raw_data)
elif self.uuid == _EXIF_UUID:
self.data = tiff_header(self.raw_data[6:])
else:
self.data = self.raw_data | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier elif_clause comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier elif_clause comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list subscript attribute identifier identifier slice integer else_clause block expression_statement assignment attribute identifier identifier attribute identifier identifier | Private function for parsing UUID payloads if possible. |
def map_entity(self, entity: dal.AssetClass):
obj = model.AssetClass()
obj.id = entity.id
obj.parent_id = entity.parentid
obj.name = entity.name
obj.allocation = entity.allocation
obj.sort_order = entity.sortorder
if entity.parentid == None:
obj.depth = 0
return obj | module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier integer return_statement identifier | maps data from entity -> object |
def deleteOverlapping(self, targetList):
start = self.pointList[0][0]
stop = self.pointList[-1][0]
if self.netLeftShift < 0:
start += self.netLeftShift
if self.netRightShift > 0:
stop += self.netRightShift
targetList = _deletePoints(targetList, start, stop)
return targetList | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript subscript attribute identifier identifier integer integer expression_statement assignment identifier subscript subscript attribute identifier identifier unary_operator integer integer if_statement comparison_operator attribute identifier identifier integer block expression_statement augmented_assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement augmented_assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement identifier | Erase points from another list that overlap with points in this list |
def _query_compressed(options, collection_name, num_to_skip,
num_to_return, query, field_selector,
opts, check_keys=False, ctx=None):
op_query, max_bson_size = _query(
options,
collection_name,
num_to_skip,
num_to_return,
query,
field_selector,
opts,
check_keys)
rid, msg = _compress(2004, op_query, ctx)
return rid, msg, max_bson_size | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier default_parameter identifier false default_parameter identifier none block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list integer identifier identifier return_statement expression_list identifier identifier identifier | Internal compressed query message helper. |
def format_exc(*exc_info):
typ, exc, tb = exc_info or sys.exc_info()
error = traceback.format_exception(typ, exc, tb)
return "".join(error) | module function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier identifier boolean_operator identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement call attribute string string_start string_end identifier argument_list identifier | Show exception with traceback. |
def obtain_all_devices(my_devices):
new_devices = {}
for device_name, device_or_group in my_devices.items():
if not isinstance(device_or_group, list):
new_devices[device_name] = device_or_group
return new_devices | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier identifier return_statement identifier | Dynamically create 'all' group. |
async def _set_greeting_text(self):
page = self.settings()
if 'greeting' in page:
await self._send_to_messenger_profile(page, {
'greeting': page['greeting'],
})
logger.info('Greeting text set for page %s', page['page_id']) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block expression_statement await call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end | Set the greeting text of the page |
def name(self):
basename = self.basename
if basename is None:
return None
parent = self.Naming_parent
if parent is None:
return basename
else:
return parent.generate_unique_name(basename) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block return_statement identifier else_clause block return_statement call attribute identifier identifier argument_list identifier | The unique name of this object, relative to the parent. |
def nice_report(self):
if not self.json:
return '[no CSP report data]'
try:
data = json.loads(self.json)
except ValueError:
return "Invalid CSP report: '{}'".format(self.json)
if 'csp-report' not in data:
return 'Invalid CSP report: ' + json.dumps(data, indent=4, sort_keys=True, separators=(',', ': '))
return json.dumps(data['csp-report'], indent=4, sort_keys=True, separators=(',', ': ')) | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier except_clause identifier block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block return_statement binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier keyword_argument identifier integer keyword_argument identifier true keyword_argument identifier tuple string string_start string_content string_end string string_start string_content string_end return_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier true keyword_argument identifier tuple string string_start string_content string_end string string_start string_content string_end | Return a nicely formatted original report. |
def all_contributors(soup, detail="brief"):
"find all contributors not contrained to only the ones in article meta"
contrib_tags = raw_parser.contributors(soup)
contributors = format_authors(soup, contrib_tags, detail)
return contributors | module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement identifier | find all contributors not contrained to only the ones in article meta |
def save_file(client, bucket, data_file, items, dry_run=None):
logger.debug('Writing {number_items} items to s3. Bucket: {bucket} Key: {key}'.format(
number_items=len(items),
bucket=bucket,
key=data_file
))
if not dry_run:
return _put_to_s3(client, bucket, data_file, json.dumps(items)) | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement not_operator identifier block return_statement call identifier argument_list identifier identifier identifier call attribute identifier identifier argument_list identifier | Tries to write JSON data to data file in S3. |
def _fetch(url, ssl_verify = True):
req = Request(url)
if ssl_verify:
page = urlopen(req)
else:
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
page = urlopen(req, context=ctx)
content = page.read().decode('utf-8')
page.close()
return content | module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list return_statement identifier | Helper funcation to fetch content from a given url. |
def album_primary_image_url(self):
path = '/Items/{}/Images/Primary'.format(self.album_id)
return self.connector.get_url(path, attach_api_key=False) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier false | The image of the album |
def _add_onchain_locksroot_to_snapshot(
raiden: RaidenService,
storage: SQLiteStorage,
snapshot_record: StateChangeRecord,
) -> str:
snapshot = json.loads(snapshot_record.data)
for payment_network in snapshot.get('identifiers_to_paymentnetworks', dict()).values():
for token_network in payment_network.get('tokennetworks', list()):
channelidentifiers_to_channels = token_network.get(
'channelidentifiers_to_channels',
dict(),
)
for channel in channelidentifiers_to_channels.values():
our_locksroot, partner_locksroot = _get_onchain_locksroots(
raiden=raiden,
storage=storage,
token_network=token_network,
channel=channel,
)
channel['our_state']['onchain_locksroot'] = serialize_bytes(our_locksroot)
channel['partner_state']['onchain_locksroot'] = serialize_bytes(partner_locksroot)
return json.dumps(snapshot, indent=4), snapshot_record.identifier | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier argument_list block for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment pattern_list identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end call identifier argument_list identifier expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end call identifier argument_list identifier return_statement expression_list call attribute identifier identifier argument_list identifier keyword_argument identifier integer attribute identifier identifier | Add `onchain_locksroot` to each NettingChannelEndState |
def format_version(epoch, version, release):
full_version = '{0}:{1}'.format(epoch, version) if epoch else version
if release:
full_version += '-{0}'.format(release)
return full_version | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier conditional_expression call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier | Formats a version string for list_pkgs. |
def step(self) -> None:
event = heappop(self._events)
self._ts_now = event.timestamp or self._ts_now
event.execute(self) | module function_definition identifier parameters identifier type none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier boolean_operator attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Runs a single event of the simulation. |
def radius_of_gyration(neurite):
centre_mass = neurite_centre_of_mass(neurite)
sum_sqr_distance = 0
N = 0
dist_sqr = [distance_sqr(centre_mass, s) for s in nm.iter_segments(neurite)]
sum_sqr_distance = np.sum(dist_sqr)
N = len(dist_sqr)
return np.sqrt(sum_sqr_distance / N) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier integer expression_statement assignment identifier integer expression_statement assignment identifier list_comprehension call identifier argument_list identifier identifier for_in_clause identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list binary_operator identifier identifier | Calculate and return radius of gyration of a given neurite. |
def log_internal(args, filetype):
file_name = get_config_filename(args)
if filetype == 'stdout':
file_full_path = os.path.join(NNICTL_HOME_DIR, file_name, 'stdout')
else:
file_full_path = os.path.join(NNICTL_HOME_DIR, file_name, 'stderr')
print(check_output_command(file_full_path, head=args.head, tail=args.tail)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end expression_statement call identifier argument_list call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier | internal function to call get_log_content |
def clean_csvs(dialogpath=None):
dialogdir = os.dirname(dialogpath) if os.path.isfile(dialogpath) else dialogpath
filenames = [dialogpath.split(os.path.sep)[-1]] if os.path.isfile(dialogpath) else os.listdir(dialogpath)
for filename in filenames:
filepath = os.path.join(dialogdir, filename)
df = clean_df(filepath)
df.to_csv(filepath, header=None)
return filenames | module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier conditional_expression list subscript call attribute identifier identifier argument_list attribute attribute identifier identifier identifier unary_operator integer call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier none return_statement identifier | Translate non-ASCII characters to spaces or equivalent ASCII characters |
def stop(self):
self.my_server.stop()
self.http_thread.join()
logging.info("HTTP server: Stopped") | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Stop the HTTP server thread. |
def _active_case(self, value: ObjectValue) -> Optional["CaseNode"]:
for c in self.children:
for cc in c.data_children():
if cc.iname() in value:
return c | module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type string string_start string_content string_end block for_statement identifier attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator call attribute identifier identifier argument_list identifier block return_statement identifier | Return receiver's case that's active in an instance node value. |
def _property_create_dict(header, data):
prop = dict(zip(header, _merge_last(data, len(header))))
prop['name'] = _property_normalize_name(prop['property'])
prop['type'] = _property_detect_type(prop['name'], prop['values'])
prop['edit'] = from_bool(prop['edit'])
if 'inherit' in prop:
prop['inherit'] = from_bool(prop['inherit'])
del prop['property']
return prop | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end delete_statement subscript identifier string string_start string_content string_end return_statement identifier | Create a property dict |
def json(self, json_string=None):
if json_string is not None:
return self.__init__(loads(json_string))
dump = self
if isinstance(self, HAR.log):
dump = {"log": dump}
return dumps(dump, default=lambda x: dict(x)) | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier return_statement call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list identifier | Convenience method allowing easy dumping to and loading from json. |
def address(self):
port = ""
if self._port:
port = ":{}".format(self._port)
return Address(
"{}/{}{}".format(
self.interface.ip.compressed,
self.interface.exploded.split("/")[-1],
port,
)
) | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end if_statement attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute attribute identifier identifier identifier identifier subscript call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end unary_operator integer identifier | IP Address using bacpypes Address format |
def apply_filters(query, args):
pre_joins = []
for querystring_key, filter_value in args.items(multi=True):
if querystring_key in filter_registry:
cls_inst = filter_registry[querystring_key]
query = cls_inst.apply_filter(query, args, pre_joins)
elif querystring_key in PaginationKeys._value_list:
pass
else:
raise InvalidQueryString(querystring_key, filter_value)
return query | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier true block if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier elif_clause comparison_operator identifier attribute identifier identifier block pass_statement else_clause block raise_statement call identifier argument_list identifier identifier return_statement identifier | Apply all QueryFilters, validating the querystring in the process. |
def update_system_path():
cwd = os.getcwd()
lib_dir = os.path.join(os.getcwd(), 'lib_')
lib_latest = os.path.join(os.getcwd(), 'lib_latest')
if not [p for p in sys.path if lib_dir in p]:
sys.path.insert(0, lib_latest)
try:
sys.path.remove(cwd)
except ValueError:
pass
sys.path.insert(0, cwd) | module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list 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 call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list integer identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block pass_statement expression_statement call attribute attribute identifier identifier identifier argument_list integer identifier | Update the system path to ensure project modules and dependencies can be found. |
def proxy(request):
uri = "http://" + HOST + request.META['PATH_INFO']
if request.META['QUERY_STRING']:
uri += '?' + request.META['QUERY_STRING']
headers = {}
for name, val in six.iteritems(request.environ):
if name.startswith('HTTP_'):
name = header_name(name)
headers[name] = val
http = Http()
http.follow_redirects = False
logger.debug("GET for: %s" % uri)
info, content = http.request(uri, 'GET', headers=headers)
response = HttpResponse(content, status=info.pop('status'))
for name, val in info.items():
if not is_hop_by_hop(name):
response[name] = val
logger.info("PROXY to: %s" % uri)
return response | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end identifier subscript attribute identifier identifier string string_start string_content string_end if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier false expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier block expression_statement assignment subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier | Pass an HTTP request on to another server. |
def should_store_best_checkpoint(self, epoch_idx, metrics) -> bool:
if not self.store_best:
return False
metric = metrics[self.metric]
if better(self._current_best_metric_value, metric, self.metric_mode):
self._current_best_metric_value = metric
return True
return False | module function_definition identifier parameters identifier identifier identifier type identifier block if_statement not_operator attribute identifier identifier block return_statement false expression_statement assignment identifier subscript identifier attribute identifier identifier if_statement call identifier argument_list attribute identifier identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier return_statement true return_statement false | Should we store current checkpoint as the best |
def iterall(cls, target, branch, build, flags, platform=None):
flags = BuildFlags(*flags)
for task in BuildTask.iterall(build, branch, flags, platform):
yield cls(target, branch, task, flags, platform) | module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list list_splat identifier for_statement identifier call attribute identifier identifier argument_list identifier identifier identifier identifier block expression_statement yield call identifier argument_list identifier identifier identifier identifier identifier | Return an iterable for all available builds matching a particular build type |
def restore_grid(func):
@wraps(func)
def wrapped_func(self, *args, **kwargs):
grid = (self.xaxis._gridOnMinor, self.xaxis._gridOnMajor,
self.yaxis._gridOnMinor, self.yaxis._gridOnMajor)
try:
return func(self, *args, **kwargs)
finally:
self.xaxis.grid(grid[0], which="minor")
self.xaxis.grid(grid[1], which="major")
self.yaxis.grid(grid[2], which="minor")
self.yaxis.grid(grid[3], which="major")
return wrapped_func | module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier tuple attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier try_statement block return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier finally_clause block expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier integer keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier integer keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier integer keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier integer keyword_argument identifier string string_start string_content string_end return_statement identifier | Wrap ``func`` to preserve the Axes current grid settings. |
def bifurcation_partitions(neurites, neurite_type=NeuriteType.all):
return map(_bifurcationfunc.bifurcation_partition,
iter_sections(neurites,
iterator_type=Tree.ibifurcation_point,
neurite_filter=is_type(neurite_type))) | module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block return_statement call identifier argument_list attribute identifier identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call identifier argument_list identifier | Partition at bifurcation points of a collection of neurites |
def local_id(personal):
if personal:
try:
ep_id = LocalGlobusConnectPersonal().endpoint_id
except IOError as e:
safeprint(e, write_to_stderr=True)
click.get_current_context().exit(1)
if ep_id is not None:
safeprint(ep_id)
else:
safeprint("No Globus Connect Personal installation found.")
click.get_current_context().exit(1) | module function_definition identifier parameters identifier block if_statement identifier block try_statement block expression_statement assignment identifier attribute call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier keyword_argument identifier true expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list integer if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier else_clause block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list integer | Executor for `globus endpoint local-id` |
def safe_send(self, connection, target, message, *args, **kwargs):
prefix = "PRIVMSG {0} :".format(target)
max_len = 510 - len(prefix)
for chunk in chunks(message.format(*args, **kwargs), max_len):
connection.send_raw("{0}{1}".format(prefix, chunk)) | module function_definition identifier parameters identifier identifier identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier binary_operator integer call identifier argument_list identifier for_statement identifier call identifier argument_list call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier | Safely sends a message to the given target |
def url(self, service):
if service not in TILE_SERVICES:
raise TileException('unknown tile service %s' % service)
url = string.Template(TILE_SERVICES[service])
(x,y) = self.tile
tile_info = TileServiceInfo(x, y, self.zoom)
return url.substitute(tile_info) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier identifier expression_statement assignment tuple_pattern identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier | return URL for a tile |
def readline(self, size=None):
if self._pos >= self.limit:
return self.on_exhausted()
if size is None:
size = self.limit - self._pos
else:
size = min(size, self.limit - self._pos)
try:
line = self._readline(size)
except (ValueError, IOError):
return self.on_disconnect()
if size and not line:
return self.on_disconnect()
self._pos += len(line)
return line | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier binary_operator attribute identifier identifier attribute identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier block return_statement call attribute identifier identifier argument_list if_statement boolean_operator identifier not_operator identifier block return_statement call attribute identifier identifier argument_list expression_statement augmented_assignment attribute identifier identifier call identifier argument_list identifier return_statement identifier | Reads one line from the stream. |
def _get_handler(self, handler_class):
element = None
for handler in self.handlers:
if isinstance(handler, handler_class):
element = handler
break
return element | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none for_statement identifier attribute identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier identifier break_statement return_statement identifier | Return an existing class of handler. |
def add_list_members(self, screen_name=None, user_id=None, slug=None,
list_id=None, owner_id=None, owner_screen_name=None):
return self._add_list_members(list_to_csv(screen_name),
list_to_csv(user_id),
slug, list_id, owner_id,
owner_screen_name) | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier call identifier argument_list identifier identifier identifier identifier identifier | Perform bulk add of list members from user ID or screenname |
def fetch(self, is_dl_forced=False):
cxn = {}
cxn['host'] = 'nif-db.crbs.ucsd.edu'
cxn['database'] = 'disco_crawler'
cxn['port'] = '5432'
cxn['user'] = config.get_config()['user']['disco']
cxn['password'] = config.get_config()['keys'][cxn['user']]
self.dataset.setFileAccessUrl(
'jdbc:postgresql://'+cxn['host']+':'+cxn['port']+'/'+cxn['database'],
is_object_literal=True)
self.fetch_from_pgdb(self.tables, cxn)
self.get_files(is_dl_forced)
fstat = os.stat('/'.join((self.rawdir, 'dvp.pr_nlx_157874_1')))
filedate = datetime.utcfromtimestamp(fstat[ST_CTIME]).strftime("%Y-%m-%d")
self.dataset.setVersion(filedate)
return | module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript subscript call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end keyword_argument identifier true expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list tuple attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list subscript identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement | connection details for DISCO |
def StopHunt(hunt_id, reason=None):
hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id)
if hunt_obj.hunt_state not in [
hunt_obj.HuntState.STARTED, hunt_obj.HuntState.PAUSED
]:
raise OnlyStartedOrPausedHuntCanBeStoppedError(hunt_obj)
data_store.REL_DB.UpdateHuntObject(
hunt_id, hunt_state=hunt_obj.HuntState.STOPPED, hunt_state_comment=reason)
data_store.REL_DB.RemoveForemanRule(hunt_id=hunt_obj.hunt_id)
if (reason is not None and
hunt_obj.creator not in aff4_users.GRRUser.SYSTEM_USERS):
notification.Notify(
hunt_obj.creator, rdf_objects.UserNotification.Type.TYPE_HUNT_STOPPED,
reason,
rdf_objects.ObjectReference(
reference_type=rdf_objects.ObjectReference.Type.HUNT,
hunt=rdf_objects.HuntReference(hunt_id=hunt_obj.hunt_id)))
return data_store.REL_DB.ReadHuntObject(hunt_id) | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier block raise_statement call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier if_statement parenthesized_expression boolean_operator comparison_operator identifier none comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier | Stops a hunt with a given id. |
def version(*args, **attrs):
if hasattr(sys, "_getframe"):
package = attrs.pop("package", sys._getframe(1).f_globals.get("__package__"))
if package:
attrs.setdefault("version", get_version(package))
return click.version_option(*args, **attrs) | module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute attribute call attribute identifier identifier argument_list integer identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier return_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier | Show the version and exit. |
def _line_to_entry(self,line):
f = line.rstrip().split("\t")
return Bed12Fields(
f[0],
int(f[1]),
int(f[2]),
f[3],
int(f[4]),
f[5],
int(f[6]),
int(f[7]),
[int(x) for x in f[8].rstrip(',').split(',')],
int(f[9]),
[int(x) for x in f[10].rstrip(',').split(',')],
[int(x) for x in f[11].rstrip(',').split(',')]) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content escape_sequence string_end return_statement call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer subscript identifier integer call identifier argument_list subscript identifier integer subscript identifier integer call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute call attribute subscript identifier integer identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end call identifier argument_list subscript identifier integer list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute call attribute subscript identifier integer identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute call attribute subscript identifier integer identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end | parse the line into entries and keys |
def update_component(name, comp, component_dict):
for dia in component_dict.get('dialogues', ()):
try:
comp.add_dialogue(*_get_pair(dia))
except Exception as e:
msg = 'In device %s, malformed dialogue %s\n%r'
raise Exception(msg % (name, dia, e))
for prop_name, prop_dict in component_dict.get('properties', {}).items():
try:
getter = (_get_pair(prop_dict['getter'])
if 'getter' in prop_dict else None)
setter = (_get_triplet(prop_dict['setter'])
if 'setter' in prop_dict else None)
comp.add_property(prop_name, prop_dict.get('default', ''),
getter, setter, prop_dict.get('specs', {}))
except Exception as e:
msg = 'In device %s, malformed property %s\n%r'
raise type(e)(msg % (name, prop_name, format_exc())) | module function_definition identifier parameters identifier identifier identifier block for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end tuple block try_statement block expression_statement call attribute identifier identifier argument_list list_splat call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier string string_start string_content escape_sequence string_end raise_statement call identifier argument_list binary_operator identifier tuple identifier identifier identifier for_statement pattern_list identifier identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list block try_statement block expression_statement assignment identifier parenthesized_expression conditional_expression call identifier argument_list subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end identifier none expression_statement assignment identifier parenthesized_expression conditional_expression call identifier argument_list subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end identifier none expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier string string_start string_content escape_sequence string_end raise_statement call call identifier argument_list identifier argument_list binary_operator identifier tuple identifier identifier call identifier argument_list | Get a component from a component dict. |
def open(self):
if self._state != 'open':
if self._line is not None:
self._state = 'open'
self._nodes = self.grid.graph.nodes_from_line(self._line)
self.grid.graph.remove_edge(
self._nodes[0], self._nodes[1])
else:
raise ValueError('``line`` is not set') | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list subscript attribute identifier identifier integer subscript attribute identifier identifier integer else_clause block raise_statement call identifier argument_list string string_start string_content string_end | Toggle state to open switch disconnector |
def import_wiki_json(path='wikipedia_crawler_data.json', model=WikiItem, batch_len=100, db_alias='default', verbosity=2):
return djdb.import_json(path=path, model=model, batch_len=batch_len, db_alias=db_alias, verbosity=verbosity) | module function_definition identifier parameters default_parameter identifier string string_start string_content string_end default_parameter identifier identifier default_parameter identifier integer default_parameter identifier string string_start string_content string_end default_parameter identifier integer block return_statement 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 | Read json file and create the appropriate records according to the given database model. |
def offset(self, offset):
query = self._copy()
query._offset = offset
return query | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier return_statement identifier | Apply an OFFSET to the query and return the newly resulting Query. |
def _start_timeout():
global _timeout
LOGGER.debug('Adding a new timeout in %i ms', _timeout_interval)
_maybe_stop_timeout()
_timeout = ioloop.IOLoop.current().add_timeout(
ioloop.IOLoop.current().time() + _timeout_interval / 1000.0,
_on_timeout) | module function_definition identifier parameters block global_statement identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list binary_operator call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list binary_operator identifier float identifier | Stop a running timeout if it's there, then create a new one. |
def delete_term(set_id, term_id, access_token):
api_call('delete', 'sets/{}/terms/{}'.format(set_id, term_id), access_token=access_token) | module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier identifier | Delete the given term. |
def plot_bcr(fignum, Bcr1, Bcr2):
plt.figure(num=fignum)
plt.plot(Bcr1, Bcr2, 'ro')
plt.xlabel('Bcr1')
plt.ylabel('Bcr2')
plt.title('Compare coercivity of remanence') | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | function to plot two estimates of Bcr against each other |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.