code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def _checkMetadata(self, variantFile):
metadata = self._getMetadataFromVcf(variantFile)
if self._metadata is not None and self._metadata != metadata:
raise exceptions.InconsistentMetaDataException(
variantFile.filename) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier identifier block raise_statement call attribute identifier identifier argument_list attribute identifier identifier | Checks that metadata is consistent |
def delete(self, id):
id = self.as_id(id)
response = self.http.delete(
'%s/%s' % (self.api_url, id),
auth=self.auth)
response.raise_for_status() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list | Delete a component by id |
def delete(self):
return self.bucket.delete_key(self.name, version_id=self.version_id) | module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier | Delete this key from S3 |
def from_timestamp(timestamp, tz_offset):
utc_dt = datetime.fromtimestamp(timestamp, utc)
try:
local_dt = utc_dt.astimezone(tzoffset(tz_offset))
return local_dt
except ValueError:
return utc_dt | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier except_clause identifier block return_statement identifier | Converts a timestamp + tz_offset into an aware datetime instance. |
def module_is_imported(modname, scope=None):
if not module_is_in_cache(modname):
return False
if scope is None:
scope = inspect.stack()[1][0].f_globals
for m in scope.values():
if isinstance(m, type(sys)) and m.__name__ == modname:
return True
return False | module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator call identifier argument_list identifier block return_statement false if_statement comparison_operator identifier none block expression_statement assignment identifier attribute subscript subscript call attribute identifier identifier argument_list integer integer identifier for_statement identifier call attribute identifier identifier argument_list block if_statement boolean_operator call identifier argument_list identifier call identifier argument_list identifier comparison_operator attribute identifier identifier identifier block return_statement true return_statement false | Checks if a module is imported within the current namespace. |
def _open_dataset(self, urlpath):
import dask.dataframe
if self.pattern is None:
self._dataframe = dask.dataframe.read_csv(
urlpath, storage_options=self._storage_options,
**self._csv_kwargs)
return
if not (DASK_VERSION >= '0.19.0'):
raise ValueError("Your version of dask is '{}'. "
"The ability to include filenames in read_csv output "
"(``include_path_column``) was added in 0.19.0, so "
"pattern urlpaths are not supported.".format(DASK_VERSION))
drop_path_column = 'include_path_column' not in self._csv_kwargs
path_column = self._path_column()
self._dataframe = dask.dataframe.read_csv(
urlpath, storage_options=self._storage_options, **self._csv_kwargs)
self._set_pattern_columns(path_column)
if drop_path_column:
self._dataframe = self._dataframe.drop([path_column], axis=1) | module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier dictionary_splat attribute identifier identifier return_statement if_statement not_operator parenthesized_expression comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier comparison_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier dictionary_splat attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list list identifier keyword_argument identifier integer | Open dataset using dask and use pattern fields to set new columns |
def _link_to(self, linked_picker):
yformat = self.config['options']['format'].replace('-01-01', '-12-31')
self.config['options']['format'] = yformat | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier | Customize the options when linked with other date-time input |
def _add_auth_headers(self, base):
if 'access_token' in self.creds:
return _extend(base, {
'authorization': 'Bearer ' + self.creds['access_token']
})
return base | module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement call identifier argument_list identifier dictionary pair string string_start string_content string_end binary_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end return_statement identifier | Attach the acces_token to a request. |
def savecache(apicache, json_file):
if apicache is None or apicache is {}:
return ""
apicachestr = json.dumps(apicache, indent=2)
with open(json_file, 'w') as cache_file:
cache_file.write(apicachestr)
return apicachestr | module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier dictionary block return_statement string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Saves apicache dictionary as json_file, returns dictionary as indented str |
def package_remove(name):
cmd = 'pkg_remove ' + name
out, err = DETAILS['server'].sendline(cmd)
return parse(out) | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier return_statement call identifier argument_list identifier | Remove a "package" on the ssh server |
def nbins(self, axis=0, overflow=False):
if axis == 0:
nbins = self.GetNbinsX()
elif axis == 1:
nbins = self.GetNbinsY()
elif axis == 2:
nbins = self.GetNbinsZ()
else:
raise ValueError("axis must be 0, 1, or 2")
if overflow:
nbins += 2
return nbins | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier false block if_statement comparison_operator identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list elif_clause comparison_operator identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list elif_clause comparison_operator identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block raise_statement call identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement augmented_assignment identifier integer return_statement identifier | Get the number of bins along an axis |
def _get_section(self, event):
sentence_id = event.get('sentence')
section = None
if sentence_id:
qstr = "$.sentences.frames[(@.frame_id is \'%s\')]" % sentence_id
res = self.tree.execute(qstr)
if res:
sentence_frame = list(res)[0]
passage_id = sentence_frame.get('passage')
if passage_id:
qstr = "$.sentences.frames[(@.frame_id is \'%s\')]" % \
passage_id
res = self.tree.execute(qstr)
if res:
passage_frame = list(res)[0]
section = passage_frame.get('section-id')
if section in self._section_list:
return section
elif section.startswith('fig'):
return 'figure'
elif section.startswith('supm'):
return 'supplementary'
elif section == 'article-title':
return 'title'
elif section in ['subjects|methods', 'methods|subjects']:
return 'methods'
elif section == 'conclusions':
return 'conclusion'
elif section == 'intro':
return 'introduction'
else:
return None | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier none if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier subscript call identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end line_continuation identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier subscript call identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block return_statement identifier elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end else_clause block return_statement none | Get the section of the paper that the event is from. |
def _directory_prefix(self):
if self.downder == "wget":
self.dir_prefix = "--directory-prefix="
elif self.downder == "aria2c":
self.dir_prefix = "--dir=" | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier string string_start string_content string_end | Downloader options for specific directory |
def prepare(cls, options, round_manager):
super(NodeResolve, cls).prepare(options, round_manager)
for resolver in cls._resolver_by_type.values():
resolver.prepare(options, round_manager) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier identifier | Allow each resolver to declare additional product requirements. |
def report_missing_dependencies(self):
missing_deps = dependencies.missing_dependencies()
if missing_deps:
QMessageBox.critical(self, _('Error'),
_("<b>You have missing dependencies!</b>"
"<br><br><tt>%s</tt><br><br>"
"<b>Please install them to avoid this message.</b>"
"<br><br>"
"<i>Note</i>: Spyder could work without some of these "
"dependencies, however to have a smooth experience when "
"using Spyder we <i>strongly</i> recommend you to install "
"all the listed missing dependencies.<br><br>"
"Failing to install these dependencies might result in bugs. "
"Please be sure that any found bugs are not the direct "
"result of missing dependencies, prior to reporting a new "
"issue."
) % missing_deps, QMessageBox.Ok) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end binary_operator call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier attribute identifier identifier | Show a QMessageBox with a list of missing hard dependencies |
def ordered(self):
active, inactive = self.active_inactive
order = active + inactive
return UnitCell(self.matrix[:,order], self.active[order]) | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator identifier identifier return_statement call identifier argument_list subscript attribute identifier identifier slice identifier subscript attribute identifier identifier identifier | An equivalent unit cell with the active cell vectors coming first |
def stop_listening(self):
self._halt_threads = True
for name, queue_waker in self.recieved_signals.items():
q, wake_event = queue_waker
wake_event.set() | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier true for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment pattern_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list | Stop listener threads for acquistion queues |
def write_hier(self, GO_id, out=sys.stdout,
len_dash=1, max_depth=None, num_child=None, short_prt=False,
include_only=None, go_marks=None):
gos_printed = set()
self[GO_id].write_hier_rec(gos_printed, out, len_dash, max_depth, num_child,
short_prt, include_only, go_marks) | module function_definition identifier parameters identifier identifier default_parameter identifier attribute identifier identifier default_parameter identifier integer default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list expression_statement call attribute subscript identifier identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier | Write hierarchy for a GO Term. |
def distance(self, other):
return distance((self.separation, self.pa), (other.separation, other.pa)) | module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list tuple attribute identifier identifier attribute identifier identifier tuple attribute identifier identifier attribute identifier identifier | Coordinate distance from another ObsNode |
def create_new_csv(samples, args):
out_fn = os.path.splitext(args.csv)[0] + "-merged.csv"
logger.info("Preparing new csv: %s" % out_fn)
with file_transaction(out_fn) as tx_out:
with open(tx_out, 'w') as handle:
handle.write(_header(args.csv))
for s in samples:
sample_name = s['name'] if isinstance(s['out_file'], list) else os.path.basename(s['out_file'])
handle.write("%s,%s,%s\n" % (sample_name, s['name'], ",".join(s['anno']))) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator subscript call attribute attribute identifier identifier identifier argument_list attribute identifier identifier integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple identifier subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end | create csv file that can be use with bcbio -w template |
def check_can_approve(self, request, application, roles):
try:
authorised_persons = self.get_authorised_persons(application)
authorised_persons.get(pk=request.user.pk)
return True
except Person.DoesNotExist:
return False | module function_definition identifier parameters identifier identifier identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier return_statement true except_clause attribute identifier identifier block return_statement false | Check the person's authorization. |
def add_to_path(p):
if p not in os.environ["PATH"]:
os.environ["PATH"] = "{0}{1}{2}".format(p, os.pathsep, os.environ["PATH"]) | module function_definition identifier parameters identifier block if_statement comparison_operator identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end | Adds a given path to the PATH. |
def insert_empty_rows(self, y: int, amount: int = 1) -> None:
def transform_rows(
column: Union[int, float],
row: Union[int, float]
) -> Tuple[Union[int, float], Union[int, float]]:
return column, row + (amount if row >= y else 0)
self._transform_coordinates(transform_rows) | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier integer type none block function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type identifier type generic_type identifier type_parameter type identifier type identifier block return_statement expression_list identifier binary_operator identifier parenthesized_expression conditional_expression identifier comparison_operator identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier | Insert a number of rows after the given row. |
def x_build_timestamp( self, node ):
self.timestamps.append(self.get_data(node).strip())
return None | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier identifier argument_list return_statement none | The time-stamp goes to the corresponding attribute in the result. |
def strict_defaults(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
defaults = _get_default_args(fn)
needed_types={
key:type(defaults[key]) for key in defaults
}
arg_names=_get_arg_names(fn)
assert not len(arg_names) - len(fn.__defaults__), '{} needs default variables on all arguments'.format(fn.__name__)
for i in range(len(args)):
if args[i] not in kwargs.keys():
kwargs[arg_names[i]]=args[i]
for name in needed_types:
assert isinstance(kwargs[name],needed_types[name]), 'got {} and expected a {}'.format(kwargs[name],needed_types[name])
return fn(**kwargs)
return wrapper | module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier dictionary_comprehension pair identifier call identifier argument_list subscript identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list identifier assert_statement not_operator binary_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier for_statement identifier call identifier argument_list call identifier argument_list identifier block if_statement comparison_operator subscript identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier subscript identifier identifier subscript identifier identifier for_statement identifier identifier block assert_statement call identifier argument_list subscript identifier identifier subscript identifier identifier call attribute string string_start string_content string_end identifier argument_list subscript identifier identifier subscript identifier identifier return_statement call identifier argument_list dictionary_splat identifier return_statement identifier | use this decorator to enforce type checking on functions based on the function's defaults |
def show_all(self, as_string=True):
result = []
for item in self.container:
pattern = str(item[0])[10:] if PY3 else item[0].pattern
instances = item[2] or []
value = (
'%s "%s"' % (item[1].__name__, (item[1].__doc__ or ""))
if callable(item[1])
else str(item[1])
)
value = "%s %s" % (type(item[1]), value)
result.append(" => ".join((pattern, ",".join(instances), value)))
return "\n".join(result) if as_string else result | module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier conditional_expression subscript call identifier argument_list subscript identifier integer slice integer identifier attribute subscript identifier integer identifier expression_statement assignment identifier boolean_operator subscript identifier integer list expression_statement assignment identifier parenthesized_expression conditional_expression binary_operator string string_start string_content string_end tuple attribute subscript identifier integer identifier parenthesized_expression boolean_operator attribute subscript identifier integer identifier string string_start string_end call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer expression_statement assignment identifier binary_operator string string_start string_content string_end tuple call identifier argument_list subscript identifier integer identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list tuple identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement conditional_expression call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier identifier identifier | , python2 will not show flags |
def create_html(api_key, attrs):
gif = get_gif(api_key, attrs['gif_id'])
if 'alt' not in attrs.keys():
attrs['alt'] = 'source: {}'.format(gif['data']['source'])
html_out = '<a href="{}">'.format(gif['data']['url'])
html_out += '<img src="{}" alt="{}">'.format(
gif['data']['images']['original']['url'],
attrs['alt'])
html_out += '</a>'
return html_out | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list block expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement augmented_assignment identifier string string_start string_content string_end return_statement identifier | Returns complete html tag string. |
def to_aws_format(tags):
if TAG_RAY_NODE_NAME in tags:
tags["Name"] = tags[TAG_RAY_NODE_NAME]
del tags[TAG_RAY_NODE_NAME]
return tags | module function_definition identifier parameters identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier identifier delete_statement subscript identifier identifier return_statement identifier | Convert the Ray node name tag to the AWS-specific 'Name' tag. |
def dump_yaml(data, Dumper=_Dumper, default_flow_style=False):
content = yaml.dump(data,
default_flow_style=default_flow_style,
Dumper=Dumper)
return content.strip() | module function_definition identifier parameters identifier default_parameter identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list | Returns data as yaml-formatted string. |
def _edits1(word: str) -> Set[str]:
splits = [(word[:i], word[i:]) for i in range(len(word) + 1)]
deletes = [L + R[1:] for L, R in splits if R]
transposes = [L + R[1] + R[0] + R[2:] for L, R in splits if len(R) > 1]
replaces = [L + c + R[1:] for L, R in splits if R for c in thai_letters]
inserts = [L + c + R for L, R in splits for c in thai_letters]
return set(deletes + transposes + replaces + inserts) | module function_definition identifier parameters typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier list_comprehension tuple subscript identifier slice identifier subscript identifier slice identifier for_in_clause identifier call identifier argument_list binary_operator call identifier argument_list identifier integer expression_statement assignment identifier list_comprehension binary_operator identifier subscript identifier slice integer for_in_clause pattern_list identifier identifier identifier if_clause identifier expression_statement assignment identifier list_comprehension binary_operator binary_operator binary_operator identifier subscript identifier integer subscript identifier integer subscript identifier slice integer for_in_clause pattern_list identifier identifier identifier if_clause comparison_operator call identifier argument_list identifier integer expression_statement assignment identifier list_comprehension binary_operator binary_operator identifier identifier subscript identifier slice integer for_in_clause pattern_list identifier identifier identifier if_clause identifier for_in_clause identifier identifier expression_statement assignment identifier list_comprehension binary_operator binary_operator identifier identifier identifier for_in_clause pattern_list identifier identifier identifier for_in_clause identifier identifier return_statement call identifier argument_list binary_operator binary_operator binary_operator identifier identifier identifier identifier | Return a set of words with edit distance of 1 from the input word |
def commit_update():
unused = _find_unused_partition()
new = _switch_partition()
if new != unused:
msg = f"Bad switch: switched to {new} when {unused} was unused"
LOG.error(msg)
raise RuntimeError(msg)
else:
LOG.info(f'commit_update: committed to booting {new}') | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier identifier block expression_statement assignment identifier string string_start string_content interpolation identifier string_content interpolation identifier string_content string_end expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_end | Switch the target boot partition. |
def _hmac_auth(self):
return TcExHmacAuth(self.args.api_access_id, self.args.api_secret_key, self.tcex.log) | module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier | Add ThreatConnect HMAC Auth to Session. |
def connect(self, (host, port)):
super(GeventTransport, self).connect((host, port), klass=socket.socket) | module function_definition identifier parameters identifier tuple_pattern identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list tuple identifier identifier keyword_argument identifier attribute identifier identifier | Connect using a host,port tuple |
def make(collector, image, **kwargs):
tag = kwargs.get("artifact", NotSpecified)
if tag is NotSpecified:
tag = collector.configuration["harpoon"].tag
if tag is not NotSpecified:
image.tag = tag
Builder().make_image(image, collector.configuration["images"])
print("Created image {0}".format(image.image_name)) | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier attribute subscript attribute identifier identifier string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute call identifier argument_list identifier argument_list identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier | Just create an image |
def isInstalledBuild(self):
sentinelFile = os.path.join(self.getEngineRoot(), 'Engine', 'Build', 'InstalledBuild.txt')
return os.path.exists(sentinelFile) | module function_definition identifier parameters identifier block 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 string string_start string_content string_end string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list identifier | Determines if the Engine is an Installed Build |
def _unpack_v1(h5file):
points = np.array(h5file['points'])
groups = np.array(h5file['structure'])
return points, groups | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement expression_list identifier identifier | Unpack groups from HDF5 v1 file |
def ensure_dtype(core, dtype, dtype_):
core = core.copy()
if dtype is None:
dtype = dtype_
if dtype_ == dtype:
return core, dtype
for key, val in {
int: chaospy.poly.typing.asint,
float: chaospy.poly.typing.asfloat,
np.float32: chaospy.poly.typing.asfloat,
np.float64: chaospy.poly.typing.asfloat,
}.items():
if dtype == key:
converter = val
break
else:
raise ValueError("dtype not recognised (%s)" % str(dtype))
for key, val in core.items():
core[key] = converter(val)
return core, dtype | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier identifier if_statement comparison_operator identifier identifier block return_statement expression_list identifier identifier for_statement pattern_list identifier identifier call attribute dictionary pair identifier attribute attribute attribute identifier identifier identifier identifier pair identifier attribute attribute attribute identifier identifier identifier identifier pair attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier pair attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier break_statement else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier call identifier argument_list identifier return_statement expression_list identifier identifier | Ensure dtype is correct. |
def __track_job(self):
while not self.__verify_job_has_started():
time.sleep(self.__POLL_TIME)
self.__logger.debug("Waiting for Kubernetes job " + self.uu_name + " to start")
self.__print_kubectl_hints()
status = self.__get_job_status()
while status == "RUNNING":
self.__logger.debug("Kubernetes job " + self.uu_name + " is running")
time.sleep(self.__POLL_TIME)
status = self.__get_job_status()
assert status != "FAILED", "Kubernetes job " + self.uu_name + " failed"
self.__logger.info("Kubernetes job " + self.uu_name + " succeeded")
self.signal_complete() | module function_definition identifier parameters identifier block while_statement not_operator call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list while_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list assert_statement comparison_operator identifier string string_start string_content string_end binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list | Poll job status while active |
def _get_description(self, args: Tuple, kwargs: Dict[str, Any]) -> Dict[str, Any]:
return {
'id': uuid1().hex,
'args': args,
'kwargs': kwargs,
'module': self._module_name,
'function': self.f.__name__,
'sender_hostname': socket.gethostname(),
'sender_pid': os.getpid(),
'sender_cmd': ' '.join(sys.argv),
'sender_timestamp': datetime.utcnow().isoformat()[:19],
} | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier type generic_type identifier type_parameter type identifier type identifier block return_statement dictionary pair string string_start string_content string_end attribute call identifier argument_list identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute attribute identifier 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 attribute identifier identifier argument_list pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier pair string string_start string_content string_end subscript call attribute call attribute identifier identifier argument_list identifier argument_list slice integer | Return the dictionary to be sent to the queue. |
def _linux_iqn():
ret = []
initiator = '/etc/iscsi/initiatorname.iscsi'
try:
with salt.utils.files.fopen(initiator, 'r') as _iscsi:
for line in _iscsi:
line = line.strip()
if line.startswith('InitiatorName='):
ret.append(line.split('=', 1)[1])
except IOError as ex:
if ex.errno != errno.ENOENT:
log.debug("Error while accessing '%s': %s", initiator, ex)
return ret | module function_definition identifier parameters block expression_statement assignment identifier list expression_statement assignment identifier string string_start string_content string_end try_statement block with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end integer integer except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement identifier | Return iSCSI IQN from a Linux host. |
def _GetRunFlowFlags(args=None):
import argparse
parser = argparse.ArgumentParser(parents=[tools.argparser])
flags, _ = parser.parse_known_args(args=args)
if hasattr(FLAGS, 'auth_host_name'):
flags.auth_host_name = FLAGS.auth_host_name
if hasattr(FLAGS, 'auth_host_port'):
flags.auth_host_port = FLAGS.auth_host_port
if hasattr(FLAGS, 'auth_local_webserver'):
flags.noauth_local_webserver = (not FLAGS.auth_local_webserver)
return flags | module function_definition identifier parameters default_parameter identifier none block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier list attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier parenthesized_expression not_operator attribute identifier identifier return_statement identifier | Retrieves command line flags based on gflags module. |
def _color(self, color, msg):
if self.useColor:
return '{0}{1}{2}'.format(color, msg, self.RESET_SEQ)
else:
return msg | module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier attribute identifier identifier else_clause block return_statement identifier | Converts a message to be printed to the user's terminal in red |
def slots(self):
if self.implied:
return ()
data = clips.data.DataObject(self._env)
lib.EnvDeftemplateSlotNames(self._env, self._tpl, data.byref)
return tuple(
TemplateSlot(self._env, self._tpl, n.encode()) for n in data.value) | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement tuple expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement call identifier generator_expression call identifier argument_list attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list for_in_clause identifier attribute identifier identifier | Iterate over the Slots of the Template. |
def load_data(self, filename):
with zopen(filename, "rt") as f:
self._data = json.load(f, cls=MontyDecoder) | module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier | Load assimilated data from a file |
def _deprecation_notice(cls):
_deprecation_msg = (
'{name} {type} is deprecated. '
'It will be removed in the next version. '
'Use saml2.cryptography.symmetric instead.'
).format(name=cls.__name__, type=type(cls).__name__)
_warnings.warn(_deprecation_msg, DeprecationWarning) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier | Warn about deprecation of this class. |
def namedb_get_all_importing_namespace_hashes( self, current_block ):
query = "SELECT preorder_hash FROM namespaces WHERE (op = ? AND reveal_block < ?) OR (op = ? AND block_number < ?);"
args = (NAMESPACE_REVEAL, current_block + NAMESPACE_REVEAL_EXPIRE, NAMESPACE_PREORDER, current_block + NAMESPACE_PREORDER_EXPIRE )
namespace_rows = namedb_query_execute( cur, query, args )
ret = []
for namespace_row in namespace_rows:
ret.append( namespace_row['preorder_hash'] )
return ret | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier tuple identifier binary_operator identifier identifier identifier binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier | Get the list of all non-expired preordered and revealed namespace hashes. |
def canonical_clamav_conf ():
if os.name == 'posix':
clamavconf = "/etc/clamav/clamd.conf"
elif os.name == 'nt':
clamavconf = r"c:\clamav-devel\etc\clamd.conf"
else:
clamavconf = "clamd.conf"
return clamavconf | module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end return_statement identifier | Default clamav configs for various platforms. |
def today(year=None):
return datetime.date(int(year), _date.month, _date.day) if year else _date | module function_definition identifier parameters default_parameter identifier none block return_statement conditional_expression call attribute identifier identifier argument_list call identifier argument_list identifier attribute identifier identifier attribute identifier identifier identifier identifier | this day, last year |
def main(options):
client = Client(server=options.server, username=options.username, password=options.password)
print('Successfully connected to %s' % client.server)
print(client.si.CurrentTime())
client.logout() | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | A simple connection test to login and print the server time. |
def __parse_precipfc_data(data, timeframe):
result = {AVERAGE: None, TOTAL: None, TIMEFRAME: None}
log.debug("Precipitation data: %s", data)
lines = data.splitlines()
index = 1
totalrain = 0
numberoflines = 0
nrlines = min(len(lines), round(float(timeframe) / 5) + 1)
while index < nrlines:
line = lines[index]
log.debug("__parse_precipfc_data: line: %s", line)
(val, key) = line.split("|")
mmu = 10**(float((int(val) - 109)) / 32)
totalrain = totalrain + float(mmu)
numberoflines = numberoflines + 1
index += 1
if numberoflines > 0:
result[AVERAGE] = round((totalrain / numberoflines), 2)
else:
result[AVERAGE] = 0
result[TOTAL] = round(totalrain / 12, 2)
result[TIMEFRAME] = timeframe
return result | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair identifier none pair identifier none pair identifier none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier integer expression_statement assignment identifier integer expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier binary_operator call identifier argument_list binary_operator call identifier argument_list identifier integer integer while_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator integer parenthesized_expression binary_operator call identifier argument_list parenthesized_expression binary_operator call identifier argument_list identifier integer integer expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier integer expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier integer block expression_statement assignment subscript identifier identifier call identifier argument_list parenthesized_expression binary_operator identifier identifier integer else_clause block expression_statement assignment subscript identifier identifier integer expression_statement assignment subscript identifier identifier call identifier argument_list binary_operator identifier integer integer expression_statement assignment subscript identifier identifier identifier return_statement identifier | Parse the forecasted precipitation data. |
def types(self):
res = []
for column in self.column_definitions:
tmp = column.get('type', None)
res.append(ModelCompiler.get_column_type(tmp)) if tmp else False
res = list(set(res))
return res | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement conditional_expression call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier false expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier return_statement identifier | All the unique types found in user supplied model |
def _create_base_ensemble(self, out, n_estimators, n_folds):
ensemble_scores = numpy.empty((n_estimators, n_folds))
base_ensemble = numpy.empty_like(ensemble_scores, dtype=numpy.object)
for model, fold, score, est in out:
ensemble_scores[model, fold] = score
base_ensemble[model, fold] = est
return ensemble_scores, base_ensemble | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier for_statement pattern_list identifier identifier identifier identifier identifier block expression_statement assignment subscript identifier identifier identifier identifier expression_statement assignment subscript identifier identifier identifier identifier return_statement expression_list identifier identifier | For each base estimator collect models trained on each fold |
def configure(**kwargs):
for key in kwargs:
if key == 'is_logging_enabled':
Event.is_logging_enabled = kwargs[key]
elif key == 'collector_queue':
Event.collector_queue = kwargs[key]
else:
Logger.get_logger(__name__).error("Unknown key %s in configure or bad type %s",
key, type(kwargs[key])) | module function_definition identifier parameters dictionary_splat_pattern identifier block for_statement identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier subscript identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier subscript identifier identifier else_clause block expression_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end identifier call identifier argument_list subscript identifier identifier | Global configuration for event handling. |
def make_messages(context: Context, javascript=False, fuzzy=False):
kwargs = {
'all': True,
'keep_pot': True,
'no_wrap': True,
}
if fuzzy:
kwargs['allow_fuzzy'] = True
if javascript:
kwargs.update(domain='djangojs', ignore_patterns=['*.bundle.js'])
with in_dir(context.app.django_app_name):
return context.management_command('makemessages', **kwargs) | module function_definition identifier parameters typed_parameter identifier type identifier default_parameter identifier false default_parameter identifier false block expression_statement assignment identifier dictionary pair string string_start string_content string_end true pair string string_start string_content string_end true pair string string_start string_content string_end true if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end true if_statement identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier list string string_start string_content string_end with_statement with_clause with_item call identifier argument_list attribute attribute identifier identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary_splat identifier | Collects text into translation source files |
def show_message(self, message, timeout=0):
self.main.statusBar().showMessage(message, timeout) | module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier identifier | Show message in main window's status bar |
def iter_points(self):
"returns a list of tuples of names and values"
if not self.is_discrete():
raise ValueError("Patch is not discrete")
names = sorted(self.sets.keys())
icoords = [self.sets[name].iter_members() for name in names]
for coordinates in product(*icoords):
yield tuple(zip(names,coordinates)) | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier list_comprehension call attribute subscript attribute identifier identifier identifier identifier argument_list for_in_clause identifier identifier for_statement identifier call identifier argument_list list_splat identifier block expression_statement yield call identifier argument_list call identifier argument_list identifier identifier | returns a list of tuples of names and values |
def _covar_mstep_full(gmm, X, responsibilities, weighted_X_sum, norm,
min_covar):
n_features = X.shape[1]
cv = np.empty((gmm.n_components, n_features, n_features))
for c in range(gmm.n_components):
post = responsibilities[:, c]
mu = gmm.means_[c]
diff = X - mu
with np.errstate(under='ignore'):
avg_cv = np.dot(post * diff.T, diff) / (post.sum() + 10 * EPS)
cv[c] = avg_cv + min_covar * np.eye(n_features)
return cv | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list tuple attribute identifier identifier identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript identifier slice identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier binary_operator identifier identifier with_statement with_clause with_item call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list binary_operator identifier attribute identifier identifier identifier parenthesized_expression binary_operator call attribute identifier identifier argument_list binary_operator integer identifier expression_statement assignment subscript identifier identifier binary_operator identifier binary_operator identifier call attribute identifier identifier argument_list identifier return_statement identifier | Performing the covariance M step for full cases |
def urlretrieve(url, dest, write_mode="w"):
response = urllib2.urlopen(url)
mkdir_recursive(os.path.dirname(dest))
with open(dest, write_mode) as f:
f.write(response.read())
f.close() | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | save a file to disk from a given url |
def _analyse_status_type(line):
spaces = _count_spaces_startswith(line)
if spaces is None:
return ''
switch = {
0: 'RESOURCE',
2: {' disk:': 'LOCALDISK', ' role:': 'PEERNODE', ' connection:': 'PEERNODE'},
4: {' peer-disk:': 'PEERDISK'}
}
ret = switch.get(spaces, 'UNKNOWN')
if isinstance(ret, six.text_type):
return ret
for x in ret:
if x in line:
return ret[x]
return 'UNKNOWN' | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block return_statement string string_start string_end expression_statement assignment identifier dictionary pair integer string string_start string_content string_end pair integer dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair integer dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end if_statement call identifier argument_list identifier attribute identifier identifier block return_statement identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier return_statement string string_start string_content string_end | Figure out the sections in drbdadm status |
def assert_is_substring(substring, subject, message=None, extra=None):
assert (
(subject is not None)
and (substring is not None)
and (subject.find(substring) != -1)
), _assert_fail_message(message, substring, subject, "is not in", extra) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block assert_statement parenthesized_expression boolean_operator boolean_operator parenthesized_expression comparison_operator identifier none parenthesized_expression comparison_operator identifier none parenthesized_expression comparison_operator call attribute identifier identifier argument_list identifier unary_operator integer call identifier argument_list identifier identifier identifier string string_start string_content string_end identifier | Raises an AssertionError if substring is not a substring of subject. |
def _open_ftp(self):
_ftp = FTP()
_ftp.set_debuglevel(0)
with ftp_errors(self):
_ftp.connect(self.host, self.port, self.timeout)
_ftp.login(self.user, self.passwd, self.acct)
self._features = {}
try:
feat_response = _decode(_ftp.sendcmd("FEAT"), "latin-1")
except error_perm:
self.encoding = "latin-1"
else:
self._features = self._parse_features(feat_response)
self.encoding = "utf-8" if "UTF8" in self._features else "latin-1"
if not PY2:
_ftp.file = _ftp.sock.makefile(
"r", encoding=self.encoding
)
_ftp.encoding = self.encoding
self._welcome = _ftp.welcome
return _ftp | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list integer with_statement with_clause with_item call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier dictionary try_statement block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end except_clause identifier block expression_statement assignment attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier conditional_expression string string_start string_content string_end comparison_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier | Open a new ftp object. |
def _check_field_names_unique(self, existing_item, patched_item):
existing_fields_by_name = {f.name: f for f in existing_item.fields}
for patched_field in patched_item.fields:
if patched_field.name in existing_fields_by_name.keys():
existing_field = existing_fields_by_name[patched_field.name]
raise InvalidSpec('Patched field {} overrides pre-existing field in {} ({}:{}).'
.format(quote(patched_field.name),
quote(patched_item.name),
existing_field.path,
existing_field.lineno), patched_field.lineno, patched_field.path) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary_comprehension pair attribute identifier identifier identifier for_in_clause identifier attribute identifier identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier subscript identifier attribute identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier | Enforces that patched fields don't already exist. |
def _format_extname(self, ext):
if ext is None:
outs = ext
else:
outs = '{0},{1}'.format(ext[0], ext[1])
return outs | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript identifier integer subscript identifier integer return_statement identifier | Pretty print given extension name and number tuple. |
def _represent_undefined(self, data):
raise RepresenterError(
_format("Cannot represent an object: {0!A} of type: {1}; "
"yaml_representers: {2!A}, "
"yaml_multi_representers: {3!A}",
data, type(data), self.yaml_representers.keys(),
self.yaml_multi_representers.keys())) | module function_definition identifier parameters identifier identifier block raise_statement call identifier argument_list call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier call identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list | Raises flag for objects that cannot be represented |
def add(self, post_id):
post_data = self.get_post_data()
post_data['user_name'] = self.userinfo.user_name
post_data['user_id'] = self.userinfo.uid
post_data['post_id'] = post_id
replyid = MReply.create_reply(post_data)
if replyid:
out_dic = {'pinglun': post_data['cnt_reply'],
'uid': replyid}
logger.info('add reply result dic: {0}'.format(out_dic))
return json.dump(out_dic, self) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier | Adding reply to a post. |
def copy_resource(self, resource, targetdir):
final_path = resource.final_path()
if final_path[0] == '/' or (':' in final_path) or ('?' in final_path):
return
source_path = self.get_source_path(resource)
if resource.resource_type == DIRECTORY_RESOURCE:
for file_path in glob.iglob(os.path.join(source_path, '**'), recursive=True):
if os.path.isdir(file_path):
continue
rest_target_path = file_path[len(source_path)+1:]
target_path = os.path.join(targetdir, final_path, rest_target_path)
self._copy_file(file_path, target_path)
else:
target_path = os.path.join(targetdir, final_path)
yield self._copy_file(source_path, target_path) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator boolean_operator comparison_operator subscript identifier integer string string_start string_content string_end parenthesized_expression comparison_operator string string_start string_content string_end identifier parenthesized_expression comparison_operator string string_start string_content string_end identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier identifier block for_statement identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier true block if_statement call attribute attribute identifier identifier identifier argument_list identifier block continue_statement expression_statement assignment identifier subscript identifier slice binary_operator call identifier argument_list identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement yield call attribute identifier identifier argument_list identifier identifier | Copies a resource file and returns the source path for monitoring |
def extract_terms(self, nb):
emt = ExtractMetatabTerms()
emt.preprocess(nb, {})
return emt.terms | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier dictionary return_statement attribute identifier identifier | Extract some term values, usually set with tags or metadata |
def csw_global_dispatch_by_catalog(request, catalog_slug):
catalog = get_object_or_404(Catalog, slug=catalog_slug)
if catalog:
url = settings.SITE_URL.rstrip('/') + request.path.rstrip('/')
return csw_global_dispatch(request, url=url, catalog_id=catalog.id) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier if_statement identifier block expression_statement assignment identifier binary_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier | pycsw wrapper for catalogs |
def union(self, key, *others):
if not isinstance(key, str):
raise ValueError("String expected.")
self.db.sunionstore(key, [self.key] + [o.key for o in others])
return Set(key) | module function_definition identifier parameters identifier identifier list_splat_pattern identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier binary_operator list attribute identifier identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier return_statement call identifier argument_list identifier | Return a new set with elements from the set and all others. |
def csch(x, context=None):
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_csch,
(BigFloat._implicit_convert(x),),
context,
) | module function_definition identifier parameters identifier default_parameter identifier none block return_statement call identifier argument_list identifier attribute identifier identifier tuple call attribute identifier identifier argument_list identifier identifier | Return the hyperbolic cosecant of x. |
def _get_ssh_public_key(self):
key = ipa_utils.generate_public_ssh_key(self.ssh_private_key_file)
return '{user}:{key} {user}'.format(
user=self.ssh_user,
key=key.decode()
) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list | Generate SSH public key from private key. |
def access_token(self) -> str:
if self._token_expires_at < time.time() + self._REFRESH_THRESHOLD:
self.request_token()
return self._token["access_token"] | module function_definition identifier parameters identifier type identifier block if_statement comparison_operator attribute identifier identifier binary_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list return_statement subscript attribute identifier identifier string string_start string_content string_end | The access token stored within the requested token. |
def example_reading_spec(self):
processed_reward_type = tf.float32
if self.is_processed_rewards_discrete:
processed_reward_type = tf.int64
data_fields = {
TIMESTEP_FIELD: tf.FixedLenFeature((1,), tf.int64),
RAW_REWARD_FIELD: tf.FixedLenFeature((1,), tf.float32),
PROCESSED_REWARD_FIELD: tf.FixedLenFeature((1,), processed_reward_type),
DONE_FIELD: tf.FixedLenFeature((1,), tf.int64),
OBSERVATION_FIELD: self.observation_spec,
ACTION_FIELD: self.action_spec,
}
data_items_to_decoders = {
field: tf.contrib.slim.tfexample_decoder.Tensor(field)
for field in data_fields
}
return data_fields, data_items_to_decoders | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary pair identifier call attribute identifier identifier argument_list tuple integer attribute identifier identifier pair identifier call attribute identifier identifier argument_list tuple integer attribute identifier identifier pair identifier call attribute identifier identifier argument_list tuple integer identifier pair identifier call attribute identifier identifier argument_list tuple integer attribute identifier identifier pair identifier attribute identifier identifier pair identifier attribute identifier identifier expression_statement assignment identifier dictionary_comprehension pair identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier for_in_clause identifier identifier return_statement expression_list identifier identifier | Data fields to store on disk and their decoders. |
def scalac_classpath_entries(self):
return ScalaPlatform.global_instance().compiler_classpath_entries(
self.context.products, self.context._scheduler) | module function_definition identifier parameters identifier block return_statement call attribute call attribute identifier identifier argument_list identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier | Returns classpath entries for the scalac classpath. |
def run(self):
empty = False
while not empty:
try:
s = self.series.get()
result_dict = itunes.get_rss_feed_data_from_series(s)
self.storer.store(result_dict)
self.logger.info('Retrieved and stored %s', str(s.id))
except Exception as e:
print e
finally:
self.series.task_done()
empty = self.series.empty() | module function_definition identifier parameters identifier block expression_statement assignment identifier false while_statement not_operator identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block print_statement identifier finally_clause block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list | Run the task - compose full series + add to our results |
def dump(self):
return {
'title': self.title,
'issue_id': self.issue_id,
'reporter': self.reporter,
'assignee': self.assignee,
'status': self.status,
'product': self.product,
'component': self.component,
'created_at': self.created_at,
'updated_at': self.updated_at,
'closed_at': self.closed_at,
'status_code': self.status_code
} | module function_definition identifier parameters identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier | Return the object itself. |
def path(self):
if isinstance(self.dir, Directory):
return self.dir._path
elif isinstance(self.dir, ROOT.TDirectory):
return self.dir.GetPath()
elif isinstance(self.dir, _FolderView):
return self.dir.path()
else:
return str(self.dir) | 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 elif_clause call identifier argument_list attribute identifier identifier attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list elif_clause call identifier argument_list attribute identifier identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list else_clause block return_statement call identifier argument_list attribute identifier identifier | Get the path of the wrapped folder |
def _terms(self):
res = []
for sign, terms in self.terms.items():
for ID, lon in terms.items():
res.append(self.T(ID, sign))
return res | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier return_statement identifier | Returns a list with the objects as terms. |
def __interrupt_search(self):
if self.__search_worker_thread:
self.__search_worker_thread.quit()
self.__search_worker_thread.wait()
self.__container.engine.stop_processing(warning=False) | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier false | Interrupt the current search. |
def to_dict(self):
targets = []
for cond in self._targets:
targets.append(cond.to_dict())
if targets:
return {'targets': targets}
else:
return {} | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement identifier block return_statement dictionary pair string string_start string_content string_end identifier else_clause block return_statement dictionary | Save this message sending object into a dictionary. |
def process_predelete(self, obj, pk_set=None, action=None, update_fields=None, **kwargs):
build_kwargs = self._get_build_kwargs(obj, pk_set, action, update_fields, **kwargs)
self.delete_cache.set(obj, build_kwargs) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier dictionary_splat identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier | Render the queryset of influenced objects and cache it. |
def placeOrder(self, contract, order, orderId=None, account=None):
self.requestOrderIds()
useOrderId = self.orderId if orderId == None else orderId
if account:
order.m_account = account
self.ibConn.placeOrder(useOrderId, contract, order)
account_key = order.m_account
self.orders[useOrderId] = {
"id": useOrderId,
"symbol": self.contractString(contract),
"contract": contract,
"status": "SENT",
"reason": None,
"avgFillPrice": 0.,
"parentId": 0,
"time": datetime.fromtimestamp(int(self.time)),
"account": None
}
if hasattr(order, "m_account"):
self.orders[useOrderId]["account"] = order.m_account
return useOrderId | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier conditional_expression attribute identifier identifier comparison_operator identifier none identifier if_statement identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end none pair string string_start string_content string_end float pair string string_start string_content string_end integer pair string string_start string_content string_end call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier pair string string_start string_content string_end none if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment subscript subscript attribute identifier identifier identifier string string_start string_content string_end attribute identifier identifier return_statement identifier | Place order on IB TWS |
def triggered(self) -> bool:
if self._triggered.is_set():
return True
return any(token.triggered for token in self._chain) | module function_definition identifier parameters identifier type identifier block if_statement call attribute attribute identifier identifier identifier argument_list block return_statement true return_statement call identifier generator_expression attribute identifier identifier for_in_clause identifier attribute identifier identifier | Return `True` or `False` whether this token has been triggered. |
def wraplet_signature(app, what, name, obj, options, signature, return_annotation):
try:
wrapped = obj._raw_slave
except AttributeError:
return None
else:
slave_argspec = autodoc.getargspec(wrapped)
slave_signature = autodoc.formatargspec(obj, *slave_argspec)
return (slave_signature, return_annotation) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block try_statement block expression_statement assignment identifier attribute identifier identifier except_clause identifier block return_statement none else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier list_splat identifier return_statement tuple identifier identifier | have wrapplets use the signature of the slave |
def map_boto_exceptions(key=None, exc_pass=()):
from boto.exception import BotoClientError, BotoServerError, \
StorageResponseError
try:
yield
except StorageResponseError as e:
if e.code == 'NoSuchKey':
raise KeyError(key)
raise IOError(str(e))
except (BotoClientError, BotoServerError) as e:
if e.__class__.__name__ not in exc_pass:
raise IOError(str(e)) | module function_definition identifier parameters default_parameter identifier none default_parameter identifier tuple block import_from_statement dotted_name identifier identifier dotted_name identifier dotted_name identifier line_continuation dotted_name identifier try_statement block expression_statement yield except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list identifier raise_statement call identifier argument_list call identifier argument_list identifier except_clause as_pattern tuple identifier identifier as_pattern_target identifier block if_statement comparison_operator attribute attribute identifier identifier identifier identifier block raise_statement call identifier argument_list call identifier argument_list identifier | Map boto-specific exceptions to the simplekv-API. |
def objectMD5(obj):
if hasattr(obj, 'target_name'):
return obj.target_name()
try:
return textMD5(pickle.dumps(obj))
except:
return '' | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list try_statement block return_statement call identifier argument_list call attribute identifier identifier argument_list identifier except_clause block return_statement string string_start string_end | Get md5 of an object |
def keys_create(cls, fqdn, flag):
data = {
"flags": flag,
}
meta = cls.get_fqdn_info(fqdn)
url = meta['domain_keys_href']
ret, headers = cls.json_post(url, data=json.dumps(data),
return_header=True)
return cls.json_get(headers['location']) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true return_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end | Create new key entry for a domain. |
def check_split_ratio(split_ratio):
valid_ratio = 0.
if isinstance(split_ratio, float):
assert 0. < split_ratio < 1., (
"Split ratio {} not between 0 and 1".format(split_ratio))
test_ratio = 1. - split_ratio
return (split_ratio, test_ratio, valid_ratio)
elif isinstance(split_ratio, list):
length = len(split_ratio)
assert length == 2 or length == 3, (
"Length of split ratio list should be 2 or 3, got {}".format(split_ratio))
ratio_sum = sum(split_ratio)
if not ratio_sum == 1.:
split_ratio = [float(ratio) / ratio_sum for ratio in split_ratio]
if length == 2:
return tuple(split_ratio + [valid_ratio])
return tuple(split_ratio)
else:
raise ValueError('Split ratio must be float or a list, got {}'
.format(type(split_ratio))) | module function_definition identifier parameters identifier block expression_statement assignment identifier float if_statement call identifier argument_list identifier identifier block assert_statement comparison_operator float identifier float parenthesized_expression call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier binary_operator float identifier return_statement tuple identifier identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier assert_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer parenthesized_expression call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator comparison_operator identifier float block expression_statement assignment identifier list_comprehension binary_operator call identifier argument_list identifier identifier for_in_clause identifier identifier if_statement comparison_operator identifier integer block return_statement call identifier argument_list binary_operator identifier list identifier return_statement call identifier argument_list identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier | Check that the split ratio argument is not malformed |
def power_on(env, identifier):
vsi = SoftLayer.VSManager(env.client)
vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
env.client['Virtual_Guest'].powerOn(id=vs_id) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier string string_start string_content string_end expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list keyword_argument identifier identifier | Power on a virtual server. |
def process(self, sched, coro):
super(WaitForSignal, self).process(sched, coro)
waitlist = sched.sigwait[self.name]
waitlist.append((self, coro))
if self.name in sched.signals:
sig = sched.signals[self.name]
if sig.recipients <= len(waitlist):
sig.process(sched, sig.coro)
del sig.coro
del sched.signals[self.name] | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier delete_statement attribute identifier identifier delete_statement subscript attribute identifier identifier attribute identifier identifier | Add the calling coro in a waiting for signal queue. |
def convert(self, pattern: str) -> str:
parameters = OrderedDict()
for parameter in self.signature.parameters.values():
annotation = self.convert_type_to_parse_type(parameter)
parameters[parameter.name] = "{%s:%s}" % (parameter.name, annotation)
formatter = GoatFormatter()
values = parameters.values()
parameter_list = list(values)
converted_pattern = formatter.vformat(pattern, parameter_list, parameters)
self.context_params = formatter.unused_args
return converted_pattern | module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier attribute identifier identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier | Convert the goat step string to CFParse String |
def remove_prefix(self, id):
if 'prefix' not in request.params:
abort(400, 'Missing prefix.')
prefix = Prefix.get(int(request.params['prefix']))
prefix.pool = None
prefix.save()
redirect(url(controller = 'pool', action = 'edit', id = id)) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement call identifier argument_list integer string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list 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 identifier | Remove a prefix from pool 'id'. |
def allow_unsigned(self, mav, msgId):
if self.allow is None:
self.allow = {
mavutil.mavlink.MAVLINK_MSG_ID_RADIO : True,
mavutil.mavlink.MAVLINK_MSG_ID_RADIO_STATUS : True
}
if msgId in self.allow:
return True
if self.settings.allow_unsigned:
return True
return False | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier dictionary pair attribute attribute identifier identifier identifier true pair attribute attribute identifier identifier identifier true if_statement comparison_operator identifier attribute identifier identifier block return_statement true if_statement attribute attribute identifier identifier identifier block return_statement true return_statement false | see if an unsigned packet should be allowed |
def output(self, name: str, value: Any):
self.outputs[name] = value | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier | Export a stack output with a given name and value. |
def generate(data, dimOrder, maxWindowSize, overlapPercent, transforms = []):
width = data.shape[dimOrder.index('w')]
height = data.shape[dimOrder.index('h')]
return generateForSize(width, height, dimOrder, maxWindowSize, overlapPercent, transforms) | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier list block expression_statement assignment identifier subscript attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier identifier identifier identifier identifier identifier | Generates a set of sliding windows for the specified dataset. |
def update_buttons(self):
current_scheme = self.current_scheme
names = self.get_option("names")
try:
names.pop(names.index(u'Custom'))
except ValueError:
pass
delete_enabled = current_scheme not in names
self.delete_button.setEnabled(delete_enabled)
self.reset_button.setEnabled(not delete_enabled) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block pass_statement expression_statement assignment identifier comparison_operator identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list not_operator identifier | Updates the enable status of delete and reset buttons. |
def print_docs(self):
docs = {}
for name, func in six.iteritems(self.minion.functions):
if name not in docs:
if func.__doc__:
docs[name] = func.__doc__
for name in sorted(docs):
if name.startswith(self.opts.get('fun', '')):
salt.utils.stringutils.print_cli('{0}:\n{1}\n'.format(name, docs[name])) | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier block if_statement comparison_operator identifier identifier block if_statement attribute identifier identifier block expression_statement assignment subscript identifier identifier attribute identifier identifier for_statement identifier call identifier argument_list identifier block if_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier subscript identifier identifier | Pick up the documentation for all of the modules and print it out. |
def delete(self, task_id):
if isinstance(task_id, RegisteredTask):
task_id = task_id.id
def cloud_delete(api):
api.delete(task_id)
if len(self._threads):
self.put(cloud_delete)
else:
cloud_delete(self._api)
return self | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call identifier argument_list attribute identifier identifier return_statement identifier | Deletes a task from a TaskQueue. |
def _create_scaling_policies(conn, as_name, scaling_policies):
'helper function to create scaling policies'
if scaling_policies:
for policy in scaling_policies:
policy = autoscale.policy.ScalingPolicy(
name=policy["name"],
as_name=as_name,
adjustment_type=policy["adjustment_type"],
scaling_adjustment=policy["scaling_adjustment"],
min_adjustment_step=policy.get("min_adjustment_step", None),
cooldown=policy["cooldown"])
conn.create_scaling_policy(policy) | module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end if_statement identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end none keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier | helper function to create scaling policies |
def depth(self, pos):
parent = self.parent_position(pos)
if parent is None:
return 0
else:
return self.depth(parent) + 1 | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement integer else_clause block return_statement binary_operator call attribute identifier identifier argument_list identifier integer | determine depth of node at pos |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.