code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def pointSampler(actor, distance=None):
poly = actor.polydata(True)
pointSampler = vtk.vtkPolyDataPointSampler()
if not distance:
distance = actor.diagonalSize() / 100.0
pointSampler.SetDistance(distance)
pointSampler.SetInputData(poly)
pointSampler.Update()
uactor = Actor(pointSampler.GetOutput())
prop = vtk.vtkProperty()
prop.DeepCopy(actor.GetProperty())
uactor.SetProperty(prop)
return uactor | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list true expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list float expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Algorithm to generate points the specified distance apart. |
def response_hook(self, r, **kwargs):
if r.status_code == 401:
www_authenticate = r.headers.get('www-authenticate', '').lower()
auth_type = _auth_type_from_header(www_authenticate)
if auth_type is not None:
return self.retry_using_http_NTLM_auth(
'www-authenticate',
'Authorization',
r,
auth_type,
kwargs
)
elif r.status_code == 407:
proxy_authenticate = r.headers.get(
'proxy-authenticate', ''
).lower()
auth_type = _auth_type_from_header(proxy_authenticate)
if auth_type is not None:
return self.retry_using_http_NTLM_auth(
'proxy-authenticate',
'Proxy-authorization',
r,
auth_type,
kwargs
)
return r | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier identifier elif_clause comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier identifier return_statement identifier | The actual hook handler. |
def com_google_fonts_check_name_version_format(ttFont):
from fontbakery.utils import get_name_entry_strings
import re
def is_valid_version_format(value):
return re.match(r'Version\s0*[1-9]+\.\d+', value)
failed = False
version_entries = get_name_entry_strings(ttFont, NameID.VERSION_STRING)
if len(version_entries) == 0:
failed = True
yield FAIL, Message("no-version-string",
("Font lacks a NameID.VERSION_STRING (nameID={})"
" entry").format(NameID.VERSION_STRING))
for ventry in version_entries:
if not is_valid_version_format(ventry):
failed = True
yield FAIL, Message("bad-version-strings",
("The NameID.VERSION_STRING (nameID={}) value must"
" follow the pattern \"Version X.Y\" with X.Y"
" between 1.000 and 9.999."
" Current version string is:"
" \"{}\"").format(NameID.VERSION_STRING,
ventry))
if not failed:
yield PASS, "Version format in NAME table entries is correct." | module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier import_statement dotted_name identifier function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier false expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier true expression_statement yield expression_list identifier call identifier argument_list string string_start string_content string_end call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier block expression_statement assignment identifier true expression_statement yield expression_list identifier call identifier argument_list string string_start string_content string_end call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end identifier argument_list attribute identifier identifier identifier if_statement not_operator identifier block expression_statement yield expression_list identifier string string_start string_content string_end | Version format is correct in 'name' table? |
def req_cycle(req):
cls = req.__class__
seen = {req.name}
while isinstance(req.comes_from, cls):
req = req.comes_from
if req.name in seen:
return True
else:
seen.add(req.name)
return False | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier set attribute identifier identifier while_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier identifier block return_statement true else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement false | is this requirement cyclic? |
def roughsize(size, above=20, mod=10):
if size < above:
return str(size)
return "{:d}+".format(size - size % mod) | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer block if_statement comparison_operator identifier identifier block return_statement call identifier argument_list identifier return_statement call attribute string string_start string_content string_end identifier argument_list binary_operator identifier binary_operator identifier identifier | 6 -> '6' 15 -> '15' 134 -> '130+'. |
def _is_free_link_end(self, this, next):
after, ctx = self._read(2), self._context
equal_sign_contexts = contexts.TEMPLATE_PARAM_KEY | contexts.HEADING
return (this in (self.END, "\n", "[", "]", "<", ">") or
this == next == "'" or
(this == "|" and ctx & contexts.TEMPLATE) or
(this == "=" and ctx & equal_sign_contexts) or
(this == next == "}" and ctx & contexts.TEMPLATE) or
(this == next == after == "}" and ctx & contexts.ARGUMENT)) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list integer attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement parenthesized_expression boolean_operator boolean_operator boolean_operator boolean_operator boolean_operator comparison_operator identifier tuple attribute identifier identifier string string_start string_content escape_sequence 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 comparison_operator identifier identifier string string_start string_content string_end parenthesized_expression boolean_operator comparison_operator identifier string string_start string_content string_end binary_operator identifier attribute identifier identifier parenthesized_expression boolean_operator comparison_operator identifier string string_start string_content string_end binary_operator identifier identifier parenthesized_expression boolean_operator comparison_operator identifier identifier string string_start string_content string_end binary_operator identifier attribute identifier identifier parenthesized_expression boolean_operator comparison_operator identifier identifier identifier string string_start string_content string_end binary_operator identifier attribute identifier identifier | Return whether the current head is the end of a free link. |
def first(self):
if self.total and self.limit < self.total:
return {'page[offset]': 0, 'page[limit]': self.limit}
else:
return None | module function_definition identifier parameters identifier block if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block return_statement dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end attribute identifier identifier else_clause block return_statement none | Generate query parameters for the first page |
def _flush(self):
t1, t2 = str(time.time()).split(".")
state_path = os.path.join(self.ep_directory, "state_{}_{}.npz".format(t1, t2))
if hasattr(self.env, "unwrapped"):
env_name = self.env.unwrapped.__class__.__name__
else:
env_name = self.env.__class__.__name__
np.savez(
state_path,
states=np.array(self.states),
action_infos=self.action_infos,
env=env_name,
)
self.states = []
self.action_infos = [] | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute call identifier argument_list call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier attribute attribute attribute attribute identifier identifier identifier identifier identifier else_clause block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list | Method to flush internal state to disk. |
def format_close(code: int, reason: str) -> str:
if 3000 <= code < 4000:
explanation = "registered"
elif 4000 <= code < 5000:
explanation = "private use"
else:
explanation = CLOSE_CODES.get(code, "unknown")
result = f"code = {code} ({explanation}), "
if reason:
result += f"reason = {reason}"
else:
result += "no reason"
return result | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block if_statement comparison_operator integer identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator integer identifier integer block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content interpolation identifier string_content interpolation identifier string_content string_end if_statement identifier block expression_statement augmented_assignment identifier string string_start string_content interpolation identifier string_end else_clause block expression_statement augmented_assignment identifier string string_start string_content string_end return_statement identifier | Display a human-readable version of the close code and reason. |
def languages(self, key, value):
languages = self.get('languages', [])
values = force_list(value.get('a'))
for value in values:
for language in RE_LANGUAGE.split(value):
try:
name = language.strip().capitalize()
languages.append(pycountry.languages.get(name=name).alpha_2)
except KeyError:
pass
return languages | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier block try_statement block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier except_clause identifier block pass_statement return_statement identifier | Populate the ``languages`` key. |
def legend_title_header_element(feature, parent):
_ = feature, parent
header = legend_title_header['string_format']
return header.capitalize() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier expression_list identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list | Retrieve legend title header string from definitions. |
def _createConnectivity(self, linkList, connectList):
for idx, link in enumerate(linkList):
connectivity = connectList[idx]
for upLink in connectivity['upLinks']:
upstreamLink = UpstreamLink(upstreamLinkID=int(upLink))
upstreamLink.streamLink = link
link.downstreamLinkID = int(connectivity['downLink'])
link.numUpstreamLinks = int(connectivity['numUpLinks']) | module function_definition identifier parameters identifier identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier for_statement identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list keyword_argument identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end | Create GSSHAPY Connect Object Method |
def distance(vec1, vec2):
if isinstance(vec1, Vector2) \
and isinstance(vec2, Vector2):
dist_vec = vec2 - vec1
return dist_vec.length()
else:
raise TypeError("vec1 and vec2 must be Vector2's") | module function_definition identifier parameters identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier line_continuation call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator identifier identifier return_statement call attribute identifier identifier argument_list else_clause block raise_statement call identifier argument_list string string_start string_content string_end | Calculate the distance between two Vectors |
def sendResult(self, future):
future.greenlet = None
assert future._ended(), "The results are not valid"
self.socket.sendResult(future) | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier none assert_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Send back results to broker for distribution to parent task. |
def mav_param(self):
compid = self.settings.target_component
if compid == 0:
compid = 1
sysid = (self.settings.target_system, compid)
if not sysid in self.mav_param_by_sysid:
self.mav_param_by_sysid[sysid] = mavparm.MAVParmDict()
return self.mav_param_by_sysid[sysid] | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier integer expression_statement assignment identifier tuple attribute attribute identifier identifier identifier identifier if_statement not_operator comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list return_statement subscript attribute identifier identifier identifier | map mav_param onto the current target system parameters |
def _designspace_locations(self, designspace):
maps = []
for elements in (designspace.sources, designspace.instances):
location_map = {}
for element in elements:
path = _normpath(element.path)
location_map[path] = element.location
maps.append(location_map)
return maps | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier tuple attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Map font filenames to their locations in a designspace. |
def instance_contains(container, item):
return item in (member for _, member in inspect.getmembers(container)) | module function_definition identifier parameters identifier identifier block return_statement comparison_operator identifier generator_expression identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list identifier | Search into instance attributes, properties and return values of no-args methods. |
def rpm_info(rpm_path):
ts = rpm.TransactionSet()
ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
rpm_info = {}
rpm_fd = open(rpm_path, 'rb')
pkg = ts.hdrFromFdno(rpm_fd)
rpm_info['name'] = pkg['name']
rpm_info['version'] = pkg['version']
rpm_info['release'] = pkg['release']
rpm_info['epoch'] = 0
rpm_info['arch'] = pkg['arch']
rpm_info['nvrea'] = tuple((rpm_info['name'], rpm_info['version'], rpm_info['release'], rpm_info['epoch'], rpm_info['arch']))
rpm_info['cksum'] = hashlib.md5(rpm_path).hexdigest()
rpm_info['size'] = os.path.getsize(rpm_path)
rpm_info['package_basename'] = os.path.basename(rpm_path)
rpm_fd.close()
return rpm_info | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier dictionary expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end integer expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list tuple subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute call attribute identifier identifier argument_list identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement identifier | Query information about the RPM at `rpm_path`. |
def discover(self, details = False):
'Discover API definitions. Set details=true to show details'
if details and not (isinstance(details, str) and details.lower() == 'false'):
return copy.deepcopy(self.discoverinfo)
else:
return dict((k,v.get('description', '')) for k,v in self.discoverinfo.items()) | module function_definition identifier parameters identifier default_parameter identifier false block expression_statement string string_start string_content string_end if_statement boolean_operator identifier not_operator parenthesized_expression boolean_operator call identifier argument_list identifier identifier comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call attribute identifier identifier argument_list attribute identifier identifier else_clause block return_statement call identifier generator_expression tuple identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list | Discover API definitions. Set details=true to show details |
def EncodeMessageList(cls, message_list, packed_message_list):
uncompressed_data = message_list.SerializeToString()
packed_message_list.message_list = uncompressed_data
compressed_data = zlib.compress(uncompressed_data)
if len(compressed_data) < len(uncompressed_data):
packed_message_list.compression = (
rdf_flows.PackedMessageList.CompressionType.ZCOMPRESSION)
packed_message_list.message_list = compressed_data | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block expression_statement assignment attribute identifier identifier parenthesized_expression attribute attribute attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier identifier | Encode the MessageList into the packed_message_list rdfvalue. |
def insert_file(self, f, namespace, timestamp):
doc = f.get_metadata()
doc["content"] = f.read()
self.doc_dict[f._id] = Entry(doc=doc, ns=namespace, ts=timestamp) | module function_definition identifier parameters identifier identifier 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 call attribute identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier attribute identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Inserts a file to the doc dict. |
def complete(self):
if self.scan_limit is not None and self.scan_limit == 0:
return True
if self.item_limit is not None and self.item_limit == 0:
return True
return False | module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier integer block return_statement true if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier integer block return_statement true return_statement false | Return True if the limit has been reached |
def upload_rabbitmq_conf(template_name=None, context=None, restart=True):
template_name = template_name or u'rabbitmq/rabbitmq.config'
destination = u'/etc/rabbitmq/rabbitmq.config'
upload_template(template_name, destination, context=context, use_sudo=True)
if restart:
restart_service(u'rabbitmq') | module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier boolean_operator identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier true if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end | Upload RabbitMQ configuration from a template. |
def serve(self, host='', port=8000, no_documentation=False, display_intro=True):
if no_documentation:
api = self.server(None)
else:
api = self.server()
if display_intro:
print(INTRO)
httpd = make_server(host, port, api)
print("Serving on {0}:{1}...".format(host, port))
httpd.serve_forever() | module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier integer default_parameter identifier false default_parameter identifier true block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list none else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list | Runs the basic hug development server against this API |
def make_country_nationality_list(cts, ct_file):
countries = pd.read_csv(ct_file)
nationality = dict(zip(countries.nationality,countries.alpha_3_code))
both_codes = {**nationality, **cts}
return both_codes | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier dictionary dictionary_splat identifier dictionary_splat identifier return_statement identifier | Combine list of countries and list of nationalities |
def _get_timezone(self, tz):
if tz == "Local":
try:
return tzlocal.get_localzone()
except pytz.UnknownTimeZoneError:
return "?"
if len(tz) == 2:
try:
zones = pytz.country_timezones(tz)
except KeyError:
return "?"
tz = zones[0]
try:
zone = pytz.timezone(tz)
except pytz.UnknownTimeZoneError:
return "?"
return zone | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block try_statement block return_statement call attribute identifier identifier argument_list except_clause attribute identifier identifier block return_statement string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block return_statement string string_start string_content string_end expression_statement assignment identifier subscript identifier integer try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause attribute identifier identifier block return_statement string string_start string_content string_end return_statement identifier | Find and return the time zone if possible |
def hourly_relative_humidity(self):
dpt_data = self._humidity_condition.hourly_dew_point_values(
self._dry_bulb_condition)
rh_data = [rel_humid_from_db_dpt(x, y) for x, y in zip(
self._dry_bulb_condition.hourly_values, dpt_data)]
return self._get_daily_data_collections(
fraction.RelativeHumidity(), '%', rh_data) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list attribute attribute identifier identifier identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier | A data collection containing hourly relative humidity over they day. |
def _get_mainchain(df, invert):
if invert:
mc = df[(df['atom_name'] != 'C') &
(df['atom_name'] != 'O') &
(df['atom_name'] != 'N') &
(df['atom_name'] != 'CA')]
else:
mc = df[(df['atom_name'] == 'C') |
(df['atom_name'] == 'O') |
(df['atom_name'] == 'N') |
(df['atom_name'] == 'CA')]
return mc | module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement assignment identifier subscript identifier binary_operator binary_operator binary_operator parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment identifier subscript identifier binary_operator binary_operator binary_operator parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier | Return only main chain atom entries from a DataFrame |
def check_password(password: str, encrypted: str) -> bool:
if encrypted.startswith("{crypt}"):
encrypted = "{CRYPT}" + encrypted[7:]
return pwd_context.verify(password, encrypted) | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript identifier slice integer return_statement call attribute identifier identifier argument_list identifier identifier | Check a plaintext password against a hashed password. |
def _validate_platforms_in_image(self, image):
expected_platforms = get_platforms(self.workflow)
if not expected_platforms:
self.log.info('Skipping validation of available platforms '
'because expected platforms are unknown')
return
if len(expected_platforms) == 1:
self.log.info('Skipping validation of available platforms for base image '
'because this is a single platform build')
return
if not image.registry:
self.log.info('Cannot validate available platforms for base image '
'because base image registry is not defined')
return
try:
platform_to_arch = get_platform_to_goarch_mapping(self.workflow)
except KeyError:
self.log.info('Cannot validate available platforms for base image '
'because platform descriptors are not defined')
return
manifest_list = self._get_manifest_list(image)
if not manifest_list:
raise RuntimeError('Unable to fetch manifest list for base image')
all_manifests = manifest_list.json()['manifests']
manifest_list_arches = set(
manifest['platform']['architecture'] for manifest in all_manifests)
expected_arches = set(
platform_to_arch[platform] for platform in expected_platforms)
self.log.info('Manifest list arches: %s, expected arches: %s',
manifest_list_arches, expected_arches)
assert manifest_list_arches >= expected_arches, \
'Missing arches in manifest list for base image'
self.log.info('Base image is a manifest list for all required platforms') | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement try_statement block expression_statement assignment identifier call identifier argument_list attribute identifier identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier generator_expression subscript subscript identifier string string_start string_content string_end string string_start string_content string_end for_in_clause identifier identifier expression_statement assignment identifier call identifier generator_expression subscript identifier identifier for_in_clause identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier assert_statement comparison_operator identifier identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end | Ensure that the image provides all platforms expected for the build. |
def write_yara(self, output_file):
fout = open(output_file, 'wb')
fout.write('\n')
for iocid in self.yara_signatures:
signature = self.yara_signatures[iocid]
fout.write(signature)
fout.write('\n')
fout.close()
return True | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list return_statement true | Write out yara signatures to a file. |
def from_str(string):
match = re.match(r'^ADD (\w+)$', string)
if match:
return AddEvent(match.group(1))
else:
raise EventParseError | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list integer else_clause block raise_statement identifier | Generate a `AddEvent` object from a string |
def __clean_rouge_args(self, rouge_args):
if not rouge_args:
return
quot_mark_pattern = re.compile('"(.+)"')
match = quot_mark_pattern.match(rouge_args)
if match:
cleaned_args = match.group(1)
return cleaned_args
else:
return rouge_args | module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer return_statement identifier else_clause block return_statement identifier | Remove enclosing quotation marks, if any. |
def localDirPath(self):
rootDirPath = os.environ[self.rootDirPathEnvName]
return os.path.join(rootDirPath, self.contentHash) | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier | The path to the directory containing the resource on the worker. |
def rq_job(self):
if not self.rq_id or not self.rq_origin:
return
try:
return RQJob.fetch(self.rq_id, connection=get_connection(self.rq_origin))
except NoSuchJobError:
return | module function_definition identifier parameters identifier block if_statement boolean_operator not_operator attribute identifier identifier not_operator attribute identifier identifier block return_statement try_statement block return_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier call identifier argument_list attribute identifier identifier except_clause identifier block return_statement | The last RQ Job this ran on |
def _sync(timeout=None):
evt = WeakEvent(auto_reset=False)
Callback(evt.Signal)
evt.Wait(timeout=timeout)
evt.Reset()
wait4 = set(_handlers)
_handlers.clear()
_handlers.add(evt)
try:
WaitForAll(wait4, timeout=timeout)
except Exception as e:
evt.SignalException(e)
else:
evt.Signal() | module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier call identifier argument_list keyword_argument identifier false expression_statement call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier try_statement block expression_statement call identifier argument_list identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list | I will wait until all pending handlers cothreads have completed |
def tqdm(self):
with utils.async_tqdm(
total=0, desc='Extraction completed...', unit=' file') as pbar_path:
self._pbar_path = pbar_path
yield | module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment attribute identifier identifier identifier expression_statement yield | Add a progression bar for the current extraction. |
def createDashboardOverlay(self, pchOverlayKey, pchOverlayFriendlyName):
fn = self.function_table.createDashboardOverlay
pMainHandle = VROverlayHandle_t()
pThumbnailHandle = VROverlayHandle_t()
result = fn(pchOverlayKey, pchOverlayFriendlyName, byref(pMainHandle), byref(pThumbnailHandle))
return result, pMainHandle, pThumbnailHandle | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier call identifier argument_list identifier call identifier argument_list identifier return_statement expression_list identifier identifier identifier | Creates a dashboard overlay and returns its handle |
def connect(self, **settings):
if not settings:
settings = self.connection_settings
connection_key = ':'.join([str(settings[k]) for k in sorted(settings)])
if connection_key not in self._connections:
self._connections[connection_key] = redis.StrictRedis(
decode_responses=True, **settings)
return self._connections[connection_key] | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension call identifier argument_list subscript identifier identifier for_in_clause identifier call identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list keyword_argument identifier true dictionary_splat identifier return_statement subscript attribute identifier identifier identifier | Connect to redis and cache the new connection |
def getPhotos(self, tags='', per_page='', page=''):
method = 'flickr.groups.pools.getPhotos'
data = _doget(method, group_id=self.id, tags=tags,\
per_page=per_page, page=page)
photos = []
for photo in data.rsp.photos.photo:
photos.append(_parse_photo(photo))
return photos | module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier line_continuation keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier list for_statement identifier attribute attribute attribute identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier | Get a list of photo objects for this group |
def push(self, instance, action, success, idxs=_marker):
uid = api.get_uid(instance)
info = self.objects.get(uid, {})
idx = [] if idxs is _marker else idxs
info[action] = {'success': success, 'idxs': idx}
self.objects[uid] = info | module function_definition identifier parameters identifier identifier identifier identifier default_parameter 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 identifier dictionary expression_statement assignment identifier conditional_expression list comparison_operator identifier identifier identifier expression_statement assignment subscript identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier identifier identifier | Adds an instance into the pool, to be reindexed on resume |
def _backup_pb_gui(self, dirs):
import PySimpleGUI as sg
with ZipFile(self.zip_filename, 'w') as backup_zip:
for count, path in enumerate(dirs):
backup_zip.write(path, path[len(self.source):len(path)])
if not sg.OneLineProgressMeter('Writing Zip Files', count + 1, len(dirs) - 1, 'Files'):
break | module function_definition identifier parameters identifier identifier block import_statement aliased_import dotted_name identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier subscript identifier slice call identifier argument_list attribute identifier identifier call identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end binary_operator identifier integer binary_operator call identifier argument_list identifier integer string string_start string_content string_end block break_statement | Create a zip backup with a GUI progress bar. |
def enable_scanners_by_group(self, group):
if group == 'all':
self.logger.debug('Enabling all scanners')
return self.zap.ascan.enable_all_scanners()
try:
scanner_list = self.scanner_group_map[group]
except KeyError:
raise ZAPError(
'Invalid group "{0}" provided. Valid groups are: {1}'.format(
group, ', '.join(self.scanner_groups)
)
)
self.logger.debug('Enabling scanner group {0}'.format(group))
return self.enable_scanners_by_ids(scanner_list) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list try_statement block expression_statement assignment identifier subscript attribute identifier identifier identifier except_clause identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier 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 | Enables the scanners in the group if it matches one in the scanner_group_map. |
def fixpath(path):
return os.path.normpath(os.path.realpath(os.path.expanduser(path))) | module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier | Uniformly format a path. |
def make(self, apps):
for subreport in self.subreports:
logger.debug('Make subreport "{0}"'.format(subreport.name))
subreport.make(apps)
for subreport in self.subreports:
subreport.compact_tables() | module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list | Create the report from application results |
def image_to_texture(image):
vtex = vtk.vtkTexture()
vtex.SetInputDataObject(image)
vtex.Update()
return vtex | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement identifier | Converts ``vtkImageData`` to a ``vtkTexture`` |
def certs(self):
certstack = libcrypto.CMS_get1_certs(self.ptr)
if certstack is None:
raise CMSError("getting certs")
return StackOfX509(ptr=certstack, disposable=True) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier true | List of the certificates contained in the structure |
def use_comparative_assessment_view(self):
self._object_views['assessment'] = COMPARATIVE
for session in self._get_provider_sessions():
try:
session.use_comparative_assessment_view()
except AttributeError:
pass | module function_definition identifier parameters identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement | Pass through to provider AssessmentLookupSession.use_comparative_assessment_view |
def render_template(template_name, **context):
tmpl = jinja_env.get_template(template_name)
context["url_for"] = url_for
return Response(tmpl.render(context), mimetype="text/html") | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end | Render a template into a response. |
def edit_history(self):
ret = self._db.session\
.query(Config)\
.filter(Config.type == 'buildstate')\
.filter(Config.group == 'access')\
.filter(Config.key == 'last')\
.order_by(Config.modified.desc())\
.all()
return ret | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute call attribute call attribute call attribute call attribute attribute attribute identifier identifier identifier line_continuation identifier argument_list identifier line_continuation identifier argument_list comparison_operator attribute identifier identifier string string_start string_content string_end line_continuation identifier argument_list comparison_operator attribute identifier identifier string string_start string_content string_end line_continuation identifier argument_list comparison_operator attribute identifier identifier string string_start string_content string_end line_continuation identifier argument_list call attribute attribute identifier identifier identifier argument_list line_continuation identifier argument_list return_statement identifier | Return config record information about the most recent bundle accesses and operations |
def clear_last_lines(self, n):
self.term.stream.write(
self.term.move_up * n + self.term.clear_eos)
self.term.stream.flush() | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list binary_operator binary_operator attribute attribute identifier identifier identifier identifier attribute attribute identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list | Clear last N lines of terminal output. |
def as_sql(self, compiler, connection):
sql, params = super().as_sql(compiler, connection)
params.append(self.path)
return sql, params | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute call identifier argument_list identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement expression_list identifier identifier | Compile SQL for this function. |
def write_file_to_manifest(file_name, width, manifest_fh):
manifest_fh.write("%s,%s\n" % (file_name, str(width)))
logging.debug("Wrote file %s to manifest", file_name) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier | Write the given file in manifest. |
def validate_authentication(self, username, password, handler):
user = authenticate(
**{self.username_field: username, 'password': password}
)
account = self.get_account(username)
if not (user and account):
raise AuthenticationFailed("Authentication failed.") | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list dictionary_splat dictionary pair attribute identifier identifier identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator parenthesized_expression boolean_operator identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end | authenticate user with password |
def receive_promise(self, msg):
self.observe_proposal(msg.proposal_id)
if not self.leader and msg.proposal_id == self.proposal_id and msg.from_uid not in self.promises_received:
self.promises_received.add(msg.from_uid)
if self.highest_accepted_id is None or msg.last_accepted_id > self.highest_accepted_id:
self.highest_accepted_id = msg.last_accepted_id
if msg.last_accepted_value is not None:
self.proposed_value = msg.last_accepted_value
if len(self.promises_received) == self.quorum_size:
self.leader = True
if self.proposed_value is not None:
self.current_accept_msg = Accept(self.network_uid, self.proposal_id, self.proposed_value)
return self.current_accept_msg | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement boolean_operator boolean_operator not_operator attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier true if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement attribute identifier identifier | Returns an Accept messages if a quorum of Promise messages is achieved |
def _openapi_json(self):
from pprint import pprint
pprint(self.to_dict())
return current_app.response_class(json.dumps(self.to_dict(), indent=4),
mimetype='application/json') | module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end | Serve JSON spec file |
def featurize(*features):
from functools import cmp_to_key
def compare_subclass(left, right):
if issubclass(left, right):
return -1
elif issubclass(right, left):
return 1
return 0
sorted_features = sorted(features, key=cmp_to_key(compare_subclass))
name = 'FeaturizedClient[{features}]'.format(
features=', '.join(feature.__name__ for feature in sorted_features))
return type(name, tuple(sorted_features), {}) | module function_definition identifier parameters list_splat_pattern identifier block import_from_statement dotted_name identifier dotted_name identifier function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement unary_operator integer elif_clause call identifier argument_list identifier identifier block return_statement integer return_statement integer expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call attribute string string_start string_content string_end identifier generator_expression attribute identifier identifier for_in_clause identifier identifier return_statement call identifier argument_list identifier call identifier argument_list identifier dictionary | Put features into proper MRO order. |
def split_interface(intf_name):
head = intf_name.rstrip(r"/\0123456789. ")
tail = intf_name[len(head) :].lstrip()
return (head, tail) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute subscript identifier slice call identifier argument_list identifier identifier argument_list return_statement tuple identifier identifier | Split an interface name based on first digit, slash, or space match. |
def update_control_board_calibration(control_board, fitted_params):
control_board.a0_series_resistance = fitted_params['fitted R'].values
control_board.a0_series_capacitance = fitted_params['fitted C'].values | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier attribute subscript identifier string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier attribute subscript identifier string string_start string_content string_end identifier | Update the control board with the specified fitted parameters. |
def _update_header_size(self):
column_count = self.table_header.model().columnCount()
for index in range(0, column_count):
if index < column_count:
column_width = self.dataTable.columnWidth(index)
self.table_header.setColumnWidth(index, column_width)
else:
break | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list for_statement identifier call identifier argument_list integer identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier else_clause block break_statement | Update the column width of the header. |
def read_flash(self, addr=0xFF, page=0x00):
buff = bytearray()
page_size = self.targets[addr].page_size
for i in range(0, int(math.ceil(page_size / 25.0))):
pk = None
retry_counter = 5
while ((not pk or pk.header != 0xFF or
struct.unpack('<BB', pk.data[0:2]) != (addr, 0x1C)) and
retry_counter >= 0):
pk = CRTPPacket()
pk.set_header(0xFF, 0xFF)
pk.data = struct.pack('<BBHH', addr, 0x1C, page, (i * 25))
self.link.send_packet(pk)
pk = self.link.receive_packet(1)
retry_counter -= 1
if (retry_counter < 0):
return None
else:
buff += pk.data[6:]
return buff[0:page_size] | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier attribute subscript attribute identifier identifier identifier identifier for_statement identifier call identifier argument_list integer call identifier argument_list call attribute identifier identifier argument_list binary_operator identifier float block expression_statement assignment identifier none expression_statement assignment identifier integer while_statement parenthesized_expression boolean_operator parenthesized_expression boolean_operator boolean_operator not_operator identifier comparison_operator attribute identifier identifier integer comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end subscript attribute identifier identifier slice integer integer tuple identifier integer comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list integer integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier integer identifier parenthesized_expression binary_operator identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer expression_statement augmented_assignment identifier integer if_statement parenthesized_expression comparison_operator identifier integer block return_statement none else_clause block expression_statement augmented_assignment identifier subscript attribute identifier identifier slice integer return_statement subscript identifier slice integer identifier | Read back a flash page from the Crazyflie and return it |
def _force_force_on_start(self):
if self.force_on_start in self.available_combinations:
self.displayed = self.force_on_start
self._choose_what_to_display(force_refresh=True)
self._apply(force=True)
self.py3.update()
self.force_on_start = None | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier true expression_statement call attribute identifier identifier argument_list keyword_argument identifier true expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none | Force the user configured mode on start. |
def print(self):
print("TOTALS -------------------------------------------")
print(json.dumps(self.counts, indent=4, sort_keys=True))
if self.sub_total:
print("\nSUB TOTALS --- based on '%s' ---------" % self.sub_total)
print(json.dumps(self.sub_counts, indent=4, sort_keys=True))
if self.list_blank:
print("\nMISSING nodes for '%s':" % self.list_blank,
len(self.blank)) | module function_definition identifier parameters identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier integer keyword_argument identifier true if_statement attribute identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier integer keyword_argument identifier true if_statement attribute identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier call identifier argument_list attribute identifier identifier | prints to terminal the summray statistics |
def exists_course_list(curriculum_abbr, course_number, section_id,
quarter, year, joint=False):
return exists(get_course_list_name(curriculum_abbr, course_number,
section_id, quarter, year, joint)) | module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier false block return_statement call identifier argument_list call identifier argument_list identifier identifier identifier identifier identifier identifier | Return True if the corresponding mailman list exists for the course |
def parametric_mean_function(max_iters=100, optimize=True, plot=True):
mf = GPy.core.Mapping(1,1)
mf.f = np.sin
X = np.linspace(0,10,50).reshape(-1,1)
Y = np.sin(X) + 0.5*np.cos(3*X) + 0.1*np.random.randn(*X.shape) + 3*X
mf = GPy.mappings.Linear(1,1)
k =GPy.kern.RBF(1)
lik = GPy.likelihoods.Gaussian()
m = GPy.core.GP(X, Y, kernel=k, likelihood=lik, mean_function=mf)
if optimize:
m.optimize(max_iters=max_iters)
if plot:
m.plot()
return m | module function_definition identifier parameters default_parameter identifier integer default_parameter identifier true default_parameter identifier true block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer integer expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list integer integer integer identifier argument_list unary_operator integer integer expression_statement assignment identifier binary_operator binary_operator binary_operator call attribute identifier identifier argument_list identifier binary_operator float call attribute identifier identifier argument_list binary_operator integer identifier binary_operator float call attribute attribute identifier identifier identifier argument_list list_splat attribute identifier identifier binary_operator integer identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list return_statement identifier | A linear mean function with parameters that we'll learn alongside the kernel |
def client_status(self, config_path):
c = self.client_for(config_path)
status = "stopped"
if not c or not c.ensime:
status = 'unloaded'
elif c.ensime.is_ready():
status = 'ready'
elif c.ensime.is_running():
status = 'startup'
elif c.ensime.aborted():
status = 'aborted'
return status | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end if_statement boolean_operator not_operator identifier not_operator attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end elif_clause call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end elif_clause call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end elif_clause call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end return_statement identifier | Get status of client for a project, given path to its config. |
def update(self, vts):
for vt in vts.versioned_targets:
vt.ensure_legal()
if not vt.valid:
self._invalidator.update(vt.cache_key)
vt.valid = True
self._artifact_write_callback(vt)
if not vts.valid:
vts.ensure_legal()
self._invalidator.update(vts.cache_key)
vts.valid = True
self._artifact_write_callback(vts) | module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list identifier | Mark a changed or invalidated VersionedTargetSet as successfully processed. |
def handler(self):
if hasNTLM:
if self._handler is None:
passman = request.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, self._parsed_org_url, self._login_username, self._password)
self._handler = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)
return self._handler
else:
raise Exception("Missing Ntlm python package.") | module function_definition identifier parameters identifier block if_statement identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list none attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end | gets the security handler for the class |
def google(self):
tms_x, tms_y = self.tms
return tms_x, (2 ** self.zoom - 1) - tms_y | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier return_statement expression_list identifier binary_operator parenthesized_expression binary_operator binary_operator integer attribute identifier identifier integer identifier | Gets the tile in the Google format, converted from TMS |
def load_conf(cfg_path):
global config
try:
cfg = open(cfg_path, 'r')
except Exception as ex:
if verbose:
print("Unable to open {0}".format(cfg_path))
print(str(ex))
return False
cfg_json = cfg.read()
cfg.close()
try:
config = json.loads(cfg_json)
except Exception as ex:
print("Unable to parse configuration file as JSON")
print(str(ex))
return False
return True | module function_definition identifier parameters identifier block global_statement identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block if_statement identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list call identifier argument_list identifier return_statement false expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list call identifier argument_list identifier return_statement false return_statement true | Try to load the given conf file. |
def _setup_message(self):
if self.content == 'html':
self._message = MIMEMultipart('alternative')
part = MIMEText(self.body, 'html', 'UTF-8')
else:
self._message = MIMEMultipart()
part = MIMEText(self.body, 'plain', 'UTF-8')
self._message.preamble = 'Multipart massage.\n'
self._message.attach(part)
self._message['From'] = self.sender
self._message['To'] = COMMASPACE.join(self.to)
if self.cc:
self._message['Cc'] = COMMASPACE.join(self.cc)
self._message['Date'] = formatdate(localtime=True)
self._message['Subject'] = self.subject
for part in self._parts:
self._message.attach(part) | 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 call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list keyword_argument identifier true expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Constructs the actual underlying message with provided values |
def _remove_add_key(self, key):
if not hasattr(self, '_queue'):
return
if key in self._queue:
self._queue.remove(key)
self._queue.append(key)
if self.maxsize == 0:
return
while len(self._queue) > self.maxsize:
del self[self._queue[0]] | module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block return_statement if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block return_statement while_statement comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block delete_statement subscript identifier subscript attribute identifier identifier integer | Move a key to the end of the linked list and discard old entries. |
def related_lua_args(self):
related = self.queryelem.select_related
if related:
meta = self.meta
for rel in related:
field = meta.dfields[rel]
relmodel = field.relmodel
bk = self.backend.basekey(relmodel._meta) if relmodel else ''
fields = list(related[rel])
if meta.pkname() in fields:
fields.remove(meta.pkname())
if not fields:
fields.append('')
ftype = field.type if field in meta.multifields else ''
data = {'field': field.attname, 'type': ftype,
'bk': bk, 'fields': fields}
yield field.name, data | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier conditional_expression call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier string string_start string_end expression_statement assignment identifier call identifier argument_list subscript identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement assignment identifier conditional_expression attribute identifier identifier comparison_operator identifier attribute identifier identifier string string_start string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier 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 identifier expression_statement yield expression_list attribute identifier identifier identifier | Generator of load_related arguments |
def apply_attributes(self, nc, table, prefix=''):
for name, value in sorted(table.items()):
if name in nc.ncattrs():
LOG.debug('already have a value for %s' % name)
continue
if value is not None:
setattr(nc, name, value)
else:
funcname = prefix+name
func = getattr(self, funcname, None)
if func is not None:
value = func()
if value is not None:
setattr(nc, name, value)
else:
LOG.info('no routine matching %s' % funcname) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_end block for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement comparison_operator identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier continue_statement if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier identifier identifier else_clause block expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier none if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier | apply fixed attributes, or look up attributes needed and apply them |
def code(self, text, lang=None):
with self.paragraph(stylename='code'):
lines = text.splitlines()
for line in lines[:-1]:
self._code_line(line)
self.linebreak()
self._code_line(lines[-1]) | module function_definition identifier parameters identifier identifier default_parameter identifier none block 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 call attribute identifier identifier argument_list for_statement identifier subscript identifier slice unary_operator integer block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list subscript identifier unary_operator integer | Add a code block. |
def dispatch_hook(cls, _pkt=None, *args, **kargs):
if _pkt:
attr_type = orb(_pkt[0])
return cls.registered_attributes.get(attr_type, cls)
return cls | module function_definition identifier parameters identifier default_parameter identifier none list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement identifier block expression_statement assignment identifier call identifier argument_list subscript identifier integer return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier | Returns the right RadiusAttribute class for the given data. |
def temporary_directory():
dir_name = tempfile.mkdtemp()
yield dir_name
if os.path.exists(dir_name):
shutil.rmtree(dir_name) | module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement yield identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier | make a temporary directory, yeild its name, cleanup on exit |
def loop(self):
if not self._loop:
self._loop = IOLoop.current()
return self._loop
return self._loop | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement attribute identifier identifier return_statement attribute identifier identifier | Lazy event loop initialization |
def func(self):
fn = self.engine.query.sense_func_get(
self.observer.name,
self.sensename,
*self.engine._btt()
)
if fn is not None:
return SenseFuncWrap(self.observer, fn) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier list_splat call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier none block return_statement call identifier argument_list attribute identifier identifier identifier | Return the function most recently associated with this sense. |
def peer_address(self):
if not self._peer_address:
self._peer_address = self.proto.reader._transport.get_extra_info('peername')
if len(self._peer_address) == 4:
self._peer_address = self._peer_address[:2]
return self._peer_address | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice integer return_statement attribute identifier identifier | Peer endpoint address as a tuple |
async def on_open(self):
self.__ensure_barrier()
while self.connected:
try:
if self.__lastping > self.__lastpong:
raise IOError("Last ping remained unanswered")
self.send_message("2")
self.send_ack()
self.__lastping = time.time()
await asyncio.sleep(self.ping_interval)
except Exception as ex:
LOGGER.exception("Failed to ping")
try:
self.reraise(ex)
except Exception:
LOGGER.exception(
"failed to force close connection after ping error"
)
break | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list while_statement attribute identifier identifier block try_statement block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement await call attribute identifier identifier argument_list attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end break_statement | DingDongmaster the connection is open |
def motion_sensor(self, enabled):
if enabled is True:
value = CONST.SETTINGS_MOTION_POLICY_ON
elif enabled is False:
value = CONST.SETTINGS_MOTION_POLICY_OFF
else:
raise SkybellException(ERROR.INVALID_SETTING_VALUE,
(CONST.SETTINGS_MOTION_POLICY, enabled))
self._set_setting({CONST.SETTINGS_MOTION_POLICY: value}) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier true block expression_statement assignment identifier attribute identifier identifier elif_clause comparison_operator identifier false block expression_statement assignment identifier attribute identifier identifier else_clause block raise_statement call identifier argument_list attribute identifier identifier tuple attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list dictionary pair attribute identifier identifier identifier | Set the motion sensor state. |
def _get_stripped_marker(marker, strip_func):
if not marker:
return None
marker = _ensure_marker(marker)
elements = marker._markers
strip_func(elements)
if elements:
return marker
return None | module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement none expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement call identifier argument_list identifier if_statement identifier block return_statement identifier return_statement none | Build a new marker which is cleaned according to `strip_func` |
def _run(method, cmd, cwd=None, shell=True, universal_newlines=True,
stderr=STDOUT):
if not cmd:
error_msg = 'Passed empty text or list'
raise AttributeError(error_msg)
if isinstance(cmd, six.string_types):
cmd = str(cmd)
if shell:
if isinstance(cmd, list):
cmd = ' '.join(cmd)
else:
if isinstance(cmd, str):
cmd = cmd.strip().split()
out = method(cmd, shell=shell, cwd=cwd, stderr=stderr,
universal_newlines=universal_newlines)
if isinstance(out, bytes):
out = out.decode('utf-8')
return str(out).strip() | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier true default_parameter identifier true default_parameter identifier identifier block if_statement not_operator identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier else_clause block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute call identifier argument_list identifier identifier argument_list | Internal wrapper for `call` amd `check_output` |
def visit_call(self, node):
expr_str = self._precedence_parens(node, node.func)
args = [arg.accept(self) for arg in node.args]
if node.keywords:
keywords = [kwarg.accept(self) for kwarg in node.keywords]
else:
keywords = []
args.extend(keywords)
return "%s(%s)" % (expr_str, ", ".join(args)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier else_clause block expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list identifier return_statement binary_operator string string_start string_content string_end tuple identifier call attribute string string_start string_content string_end identifier argument_list identifier | return an astroid.Call node as string |
def to_unit_cell(self, in_place=False):
frac_coords = np.mod(self.frac_coords, 1)
if in_place:
self.frac_coords = frac_coords
else:
return PeriodicSite(self.species, frac_coords, self.lattice,
properties=self.properties) | module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier integer if_statement identifier block expression_statement assignment attribute identifier identifier identifier else_clause block return_statement call identifier argument_list attribute identifier identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier | Move frac coords to within the unit cell cell. |
def parse_keyring(self, namespace=None):
results = {}
if not keyring:
return results
if not namespace:
namespace = self.prog
for option in self._options:
secret = keyring.get_password(namespace, option.name)
if secret:
results[option.dest] = option.type(secret)
return results | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier dictionary if_statement not_operator identifier block return_statement identifier if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement identifier block expression_statement assignment subscript identifier attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier | Find settings from keyring. |
def csrf_protect_all_post_and_cross_origin_requests():
success = None
if is_cross_origin(request):
logger.warning("Received cross origin request. Aborting")
abort(403)
if request.method in ["POST", "PUT"]:
token = session.get("csrf_token")
if token == request.form.get("csrf_token"):
return success
elif token == request.environ.get("HTTP_X_CSRFTOKEN"):
return success
else:
logger.warning("Received invalid csrf token. Aborting")
abort(403) | module function_definition identifier parameters block expression_statement assignment identifier none if_statement call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list integer if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block return_statement identifier elif_clause comparison_operator identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block return_statement identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list integer | returns None upon success |
def replace_keys(record: Mapping, key_map: Mapping) -> dict:
return {key_map[k]: v for k, v in record.items() if k in key_map} | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block return_statement dictionary_comprehension pair subscript identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier identifier | New record with renamed keys including keys only found in key_map. |
async def _register(self):
if self.registered:
return
self._registration_attempts += 1
self.connection.throttle = False
if self.password:
await self.rawmsg('PASS', self.password)
await self.set_nickname(self._attempt_nicknames.pop(0))
await self.rawmsg('USER', self.username, '0', '*', self.realname) | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment attribute attribute identifier identifier identifier false if_statement attribute identifier identifier block expression_statement await call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement await call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list integer expression_statement await call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier string string_start string_content string_end string string_start string_content string_end attribute identifier identifier | Perform IRC connection registration. |
def copy_plus(orig, new):
for ext in ["", ".idx", ".gbi", ".tbi", ".bai"]:
if os.path.exists(orig + ext) and (not os.path.lexists(new + ext) or not os.path.exists(new + ext)):
shutil.copyfile(orig + ext, new + ext) | module function_definition identifier parameters identifier identifier block for_statement identifier list string string_start 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 block if_statement boolean_operator call attribute attribute identifier identifier identifier argument_list binary_operator identifier identifier parenthesized_expression boolean_operator not_operator call attribute attribute identifier identifier identifier argument_list binary_operator identifier identifier not_operator call attribute attribute identifier identifier identifier argument_list binary_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier binary_operator identifier identifier | Copy a fils, including biological index files. |
def _simplify_shape(self, alist, rec=0):
if rec != 0:
if len(alist) == 1:
return alist[-1]
return alist
if len(alist) == 1:
return self._simplify_shape(alist[-1], 1)
return [self._simplify_shape(al, 1) for al in alist] | module function_definition identifier parameters identifier identifier default_parameter identifier integer block if_statement comparison_operator identifier integer block if_statement comparison_operator call identifier argument_list identifier integer block return_statement subscript identifier unary_operator integer return_statement identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement call attribute identifier identifier argument_list subscript identifier unary_operator integer integer return_statement list_comprehension call attribute identifier identifier argument_list identifier integer for_in_clause identifier identifier | Reduce the alist dimension if needed |
def add_param(self, param_key, param_val):
self.params.append([param_key, param_val])
if param_key == '__success_test':
self.success = param_val | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list list identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier identifier | adds parameters as key value pairs |
def find(self,cell_designation,cell_filter=lambda x,c: 'c' in x and x['c'] == c):
if 'parent' in self.meta:
return (self.meta['parent'],self.meta['parent'].find(cell_designation,cell_filter=cell_filter)) | module function_definition identifier parameters identifier identifier default_parameter identifier lambda lambda_parameters identifier identifier boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement tuple subscript attribute identifier identifier string string_start string_content string_end call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier keyword_argument identifier identifier | finds spike containers in multi spike containers collection offspring |
def getDbNames(self):
request = []
request.append(uu({'-dbnames': '' }))
result = self._doRequest(request)
result = FMResultset.FMResultset(result)
dbNames = []
for dbName in result.resultset:
dbNames.append(string.lower(dbName['DATABASE_NAME']))
return dbNames | module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list call identifier argument_list dictionary pair string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier 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 subscript identifier string string_start string_content string_end return_statement identifier | This function returns the list of open databases |
async def set_heating_level(self, level, duration=0):
url = '{}/devices/{}'.format(API_URL, self.device.deviceid)
level = 10 if level < 10 else level
level = 100 if level > 100 else level
if self.side == 'left':
data = {
'leftHeatingDuration': duration,
'leftTargetHeatingLevel': level
}
elif self.side == 'right':
data = {
'rightHeatingDuration': duration,
'rightTargetHeatingLevel': level
}
set_heat = await self.device.api_put(url, data)
if set_heat is None:
_LOGGER.error('Unable to set eight heating level.')
else:
self.device.handle_device_json(set_heat['device']) | module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier attribute attribute identifier identifier identifier expression_statement assignment identifier conditional_expression integer comparison_operator identifier integer identifier expression_statement assignment identifier conditional_expression integer comparison_operator identifier integer identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier await call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end | Update heating data json. |
def included_length(self):
return sum([shot.length for shot in self.shots if shot.is_included]) | module function_definition identifier parameters identifier block return_statement call identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier if_clause attribute identifier identifier | Surveyed length, not including "excluded" shots |
def run(self):
self._finished.clear()
for line in iter(self.pipeReader.readline, ''):
logging.log(self.level, line.strip('\n'))
self.pipeReader.close()
self._finished.set() | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list for_statement identifier call identifier argument_list attribute attribute identifier identifier identifier string string_start string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list | Run the thread, logging everything. |
async def cancel_watchdog(self):
if self._watchdog_task is not None:
_LOGGER.debug("Canceling Watchdog task.")
self._watchdog_task.cancel()
try:
await self._watchdog_task
except asyncio.CancelledError:
self._watchdog_task = None | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement await attribute identifier identifier except_clause attribute identifier identifier block expression_statement assignment attribute identifier identifier none | Cancel the watchdog task and related variables. |
def factory_object(self, index, doc_type, data=None, id=None):
data = data or {}
obj = self.model()
obj._meta.index = index
obj._meta.type = doc_type
obj._meta.connection = self
if id:
obj._meta.id = id
if data:
obj.update(data)
return obj | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier if_statement identifier block expression_statement assignment attribute attribute identifier identifier identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Create a stub object to be manipulated |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.