code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def generate_rsa_key_pair():
key = rsa.generate_private_key(
backend=default_backend(), public_exponent=65537, key_size=2048)
public_key = key.public_key().public_bytes(
serialization.Encoding.OpenSSH,
serialization.PublicFormat.OpenSSH).decode("utf-8")
pem = key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.NoEncryption()).decode("utf-8")
return public_key, pem
|
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier integer keyword_argument identifier integer expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end return_statement expression_list identifier identifier
|
Create public and private ssh-keys.
|
def generate_events_list(generator):
if not localized_events:
generator.context['events_list'] = sorted(events, reverse = True,
key=lambda ev: (ev.dtstart, ev.dtend))
else:
generator.context['events_list'] = {k: sorted(v, reverse = True,
key=lambda ev: (ev.dtstart, ev.dtend))
for k, v in localized_events.items()}
|
module function_definition identifier parameters identifier block if_statement not_operator identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list identifier keyword_argument identifier true keyword_argument identifier lambda lambda_parameters identifier tuple attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end dictionary_comprehension pair identifier call identifier argument_list identifier keyword_argument identifier true keyword_argument identifier lambda lambda_parameters identifier tuple attribute identifier identifier attribute identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list
|
Populate the event_list variable to be used in jinja templates
|
def mavlink_packet(self, m):
if m.get_type() == 'GLOBAL_POSITION_INT':
if abs(m.lat) < 1000 and abs(m.lon) < 1000:
return
self.vehicle_pos = VehiclePos(m)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block if_statement boolean_operator comparison_operator call identifier argument_list attribute identifier identifier integer comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement expression_statement assignment attribute identifier identifier call identifier argument_list identifier
|
get time from mavlink ATTITUDE
|
def read_dataset_metadata(self):
if self.dataset_meta:
return
shell_call(['gsutil', 'cp',
'gs://' + self.storage_client.bucket_name + '/'
+ 'dataset/' + self.dataset_name + '_dataset.csv',
LOCAL_DATASET_METADATA_FILE])
with open(LOCAL_DATASET_METADATA_FILE, 'r') as f:
self.dataset_meta = eval_lib.DatasetMetadata(f)
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement expression_statement call identifier argument_list list string string_start string_content string_end string string_start string_content string_end binary_operator binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier
|
Read `dataset_meta` field from bucket
|
def dumps(obj, **kwargs) -> str:
return json.dumps(obj, cls=BioCJSONEncoder, **kwargs)
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier type identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier dictionary_splat identifier
|
Serialize a BioC ``obj`` to a JSON formatted ``str``.
|
def findRoleID(self, name):
for r in self:
if r['name'].lower() == name.lower():
return r['id']
del r
return None
|
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement comparison_operator call attribute subscript identifier string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list block return_statement subscript identifier string string_start string_content string_end delete_statement identifier return_statement none
|
searches the roles by name and returns the role's ID
|
def _setStyle(node, styleMap):
u
fixedStyle = ';'.join([prop + ':' + styleMap[prop] for prop in styleMap])
if fixedStyle != '':
node.setAttribute('style', fixedStyle)
elif node.getAttribute('style'):
node.removeAttribute('style')
return node
|
module function_definition identifier parameters identifier identifier block expression_statement identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension binary_operator binary_operator identifier string string_start string_content string_end subscript identifier identifier for_in_clause identifier identifier if_statement comparison_operator identifier string string_start string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
|
u"""Sets the style attribute of a node to the dictionary ``styleMap``.
|
def domain(self):
remove_pac = self.cleanup.replace(
"https://", "").replace("http://", "").replace("www.", "")
try:
return remove_pac.split('/')[0]
except:
return None
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute 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 string string_start string_content string_end string string_start string_end identifier argument_list string string_start string_content string_end string string_start string_end try_statement block return_statement subscript call attribute identifier identifier argument_list string string_start string_content string_end integer except_clause block return_statement none
|
Return domain from the url
|
def addNode(self, node):
self.mybldgbuids[node.buid] = node
self.allbldgbuids[node.buid] = (node, self.doneevent)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier attribute identifier identifier tuple identifier attribute identifier identifier
|
Update the shared map with my in-construction node
|
def _construct_timeseries(self, timeseries, constraints={}):
self.response_from(timeseries, constraints)
if self.response == None:
return None
return {'data':self.response['data'],
'period':self.response['period'],
'start time':datetime.datetime.fromtimestamp(self.response['start_time']),
'end time':datetime.datetime.fromtimestamp(self.response['end_time'])}
|
module function_definition identifier parameters identifier identifier default_parameter identifier dictionary block expression_statement call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator attribute identifier identifier none block return_statement none return_statement dictionary pair string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end pair string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end
|
wraps response_from for timeseries calls, returns the resulting dict
|
def between(y, z):
return _combinable(lambda x: (y <= x < z) or _equal_or_float_equal(x, y))
|
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list lambda lambda_parameters identifier boolean_operator parenthesized_expression comparison_operator identifier identifier identifier call identifier argument_list identifier identifier
|
Greater than or equal to y and less than z.
|
def _zeep_to_dict(cls, obj):
res = serialize_object(obj)
res = cls._get_non_empty_dict(res)
return res
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
|
Convert a zeep object to a dictionary.
|
def _check_apt_get():
check = False
if 'TESTING' not in os.environ:
result = exec_command(['dpkg', '-l', 'apio'])
if result and result.get('returncode') == 0:
match = re.findall('rc\s+apio', result.get('out')) + \
re.findall('ii\s+apio', result.get('out'))
check = len(match) > 0
return check
|
module function_definition identifier parameters block expression_statement assignment identifier false if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement boolean_operator identifier comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end integer block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end line_continuation call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier comparison_operator call identifier argument_list identifier integer return_statement identifier
|
Check if apio can be installed through apt-get
|
def run_ajax_spider(self, target_url):
self.logger.debug('AJAX Spidering target {0}...'.format(target_url))
self.zap.ajaxSpider.scan(target_url)
while self.zap.ajaxSpider.status == 'running':
self.logger.debug('AJAX Spider: {0}'.format(self.zap.ajaxSpider.status))
time.sleep(self._status_check_sleep)
self.logger.debug('AJAX Spider completed')
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier while_statement comparison_operator attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
|
Run AJAX Spider against a URL.
|
def migrate(dest_datastore, source_datastore):
for uid in source_datastore.list():
try:
paste = source_datastore._retrieve(uid)
except Exception as exc:
print(
"{exc.__class__.__name__} occurred retrieving {uid}: {exc}"
.format(exc=exc, uid=uid),
file=sys.stderr)
continue
data = paste.pop('data', None)
try:
dest_datastore._store(uid, paste, data)
except Exception as exc:
print(
"{exc.__class__.__name__} occurred storing {uid}: {exc}"
.format(exc=exc, uid=uid),
file=sys.stderr)
continue
|
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute identifier identifier argument_list block 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 call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier continue_statement
|
Copy all records from source_datastore to dest_datastore
|
def show_port(self, port, **_params):
return self.get(self.port_path % (port), params=_params)
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier parenthesized_expression identifier keyword_argument identifier identifier
|
Fetches information of a certain port.
|
def query(transport, query):
with CommandLineClient(transport) as client:
echo_event(client.query(query))
|
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier
|
Query the Riemann server
|
def add(self, dist):
new_path = (
dist.location not in self.paths and (
dist.location not in self.sitedirs or
dist.location == os.getcwd()
)
)
if new_path:
self.paths.append(dist.location)
self.dirty = True
Environment.add(self, dist)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier parenthesized_expression boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier parenthesized_expression boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier call attribute identifier identifier argument_list if_statement 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 identifier
|
Add `dist` to the distribution map
|
def height_water_critical(FlowRate, Width):
ut.check_range([FlowRate, ">0", "Flow rate"], [Width, ">0", "Width"])
return (FlowRate / (Width * np.sqrt(gravity.magnitude))) ** (2/3)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier string string_start string_content string_end string string_start string_content string_end list identifier string string_start string_content string_end string string_start string_content string_end return_statement binary_operator parenthesized_expression binary_operator identifier parenthesized_expression binary_operator identifier call attribute identifier identifier argument_list attribute identifier identifier parenthesized_expression binary_operator integer integer
|
Return the critical local water depth.
|
def getVolInfo(*paths):
path = os.path.join(*paths)
path = os.path.expanduser(path)
st = os.statvfs(path)
free = st.f_bavail * st.f_frsize
total = st.f_blocks * st.f_frsize
return {
'free': free,
'used': total - free,
'total': total,
}
|
module function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list list_splat identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end binary_operator identifier identifier pair string string_start string_content string_end identifier
|
Retrieve volume usage info for the given path.
|
def _get_users(self, user_base):
results = self._search(
getattr(self, '_%s_user_base' % user_base),
'(objectClass=*)',
['*'],
scope=ldap.SCOPE_ONELEVEL
)
for dn, attrs in results:
uid = attrs.get('uid')[0].decode('utf-8', 'ignore')
getattr(self, '_%s_users' % user_base)[uid] = FreeIPAUser(dn, attrs)
log.debug('%s users: %s' % (user_base.capitalize(), len(getattr(self, '_%s_users' % user_base))))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier binary_operator string string_start string_content string_end identifier string string_start string_content string_end list string string_start string_content string_end keyword_argument identifier attribute identifier identifier for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript call identifier argument_list identifier binary_operator string string_start string_content string_end identifier identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier binary_operator string string_start string_content string_end identifier
|
Get users from LDAP
|
def map_helper(data):
as_list = []
length = 2
for field, value in data.items():
as_list.append(Container(field=bytes(field, ENCODING),
value=bytes(value, ENCODING)))
length += len(field) + len(value) + 4
return (Container(
num=len(as_list),
map=as_list
), length)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier integer for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier call identifier argument_list identifier identifier keyword_argument identifier call identifier argument_list identifier identifier expression_statement augmented_assignment identifier binary_operator binary_operator call identifier argument_list identifier call identifier argument_list identifier integer return_statement tuple call identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier identifier
|
Build a map message.
|
def flush(self):
if self._num_outstanding_events == 0 or self._recordio_writer is None:
return
self._recordio_writer.flush()
if self._logger is not None:
self._logger.info('wrote %d %s to disk', self._num_outstanding_events,
'event' if self._num_outstanding_events == 1 else 'events')
self._num_outstanding_events = 0
|
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier none block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier conditional_expression string string_start string_content string_end comparison_operator attribute identifier identifier integer string string_start string_content string_end expression_statement assignment attribute identifier identifier integer
|
Flushes the event file to disk.
|
def _byte_buffer_md5(buffer_):
md5 = hashlib.md5(buffer_)
byte_digest = md5.digest()
return base64.b64encode(byte_digest).decode()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list
|
Computes the md5 digest of a byte buffer in base64 encoding.
|
def load(fp, cls=BinaryQuadraticModel, vartype=None):
pattern = re.compile(_LINE_REGEX)
vartype_pattern = re.compile(_VARTYPE_HEADER_REGEX)
triplets = []
for line in fp:
triplets.extend(pattern.findall(line))
vt = vartype_pattern.findall(line)
if vt:
if vartype is None:
vartype = vt[0]
else:
if isinstance(vartype, str):
vartype = Vartype[vartype]
else:
vartype = Vartype(vartype)
if Vartype[vt[0]] != vartype:
raise ValueError("vartypes from headers and/or inputs do not match")
if vartype is None:
raise ValueError("vartype must be provided either as a header or as an argument")
bqm = cls.empty(vartype)
for u, v, bias in triplets:
if u == v:
bqm.add_variable(int(u), float(bias))
else:
bqm.add_interaction(int(u), int(v), float(bias))
return bqm
|
module function_definition identifier parameters identifier default_parameter identifier identifier default_parameter identifier none block 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 identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier subscript identifier integer else_clause block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier subscript identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator subscript identifier subscript identifier integer identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier return_statement identifier
|
Load a COOrdinate formatted binary quadratic model from a file.
|
def close(self):
if (self.__ser is not None):
self.__ser.close()
if (self.__tcpClientSocket is not None):
self.__stoplistening = True
self.__tcpClientSocket.shutdown(socket.SHUT_RDWR)
self.__tcpClientSocket.close()
self.__connected = False
|
module function_definition identifier parameters identifier block if_statement parenthesized_expression comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement parenthesized_expression comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier false
|
Closes Serial port, or TCP-Socket connection
|
def _to_query_json(self):
return {
'quote': self._quote,
'fieldDelimiter': self._delimiter,
'encoding': self._encoding.upper(),
'skipLeadingRows': self._skip_leading_rows,
'allowQuotedNewlines': self._allow_quoted_newlines,
'allowJaggedRows': self._allow_jagged_rows
}
|
module function_definition identifier parameters identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier
|
Return the options as a dictionary to be used as JSON in a query job.
|
def execPath(self):
vers = self.version.label if self.version else None
return self.installedApp.exec_path(vers)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression attribute attribute identifier identifier identifier attribute identifier identifier none return_statement call attribute attribute identifier identifier identifier argument_list identifier
|
the executable application's path
|
def resize(self, width, height):
'Set the canvas size in pixels'
self.canvas.SetInitialSize(wx.Size(width, height))
self.window.GetSizer().Fit(self.window)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list attribute identifier identifier
|
Set the canvas size in pixels
|
def data_to_sys_base(self):
if not self.n or self._flags['sysbase'] is True:
return
self.copy_data_ext(model='Synchronous', field='Sn', dest='Sn', idx=self.gen)
super(GovernorBase, self).data_to_sys_base()
self._store['R'] = self.R
self.R = self.system.mva * div(self.R, self.Sn)
|
module function_definition identifier parameters identifier block if_statement boolean_operator not_operator attribute identifier identifier comparison_operator subscript attribute identifier identifier string string_start string_content string_end true block return_statement expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier
|
Custom system base conversion function
|
def tutor_courses(self):
tutoring = self.user.courses_tutoring.all().filter(active__exact=True)
owning = self.user.courses.all().filter(active__exact=True)
result = (tutoring | owning).distinct()
return result
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list identifier argument_list keyword_argument identifier true expression_statement assignment identifier call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list identifier argument_list keyword_argument identifier true expression_statement assignment identifier call attribute parenthesized_expression binary_operator identifier identifier identifier argument_list return_statement identifier
|
Returns the list of courses this user is tutor or owner for.
|
def _IsUnparsedFlagAccessAllowed(self, name):
if _UNPARSED_FLAG_ACCESS_ENV_NAME in os.environ:
allow_unparsed_flag_access = (
os.getenv(_UNPARSED_FLAG_ACCESS_ENV_NAME) == '1')
elif self.__dict__['__reset_called']:
allow_unparsed_flag_access = False
elif _helpers.IsRunningTest():
name_bytes = name.encode('utf8') if not isinstance(name, bytes) else name
flag_percentile = (
struct.unpack('<I', hashlib.md5(name_bytes).digest()[:4])[0] % 100)
allow_unparsed_flag_access = (
_UNPARSED_ACCESS_DISABLED_PERCENT <= flag_percentile)
else:
allow_unparsed_flag_access = True
return allow_unparsed_flag_access
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier parenthesized_expression comparison_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end elif_clause subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier false elif_clause call attribute identifier identifier argument_list block expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list string string_start string_content string_end not_operator call identifier argument_list identifier identifier identifier expression_statement assignment identifier parenthesized_expression binary_operator subscript call attribute identifier identifier argument_list string string_start string_content string_end subscript call attribute call attribute identifier identifier argument_list identifier identifier argument_list slice integer integer integer expression_statement assignment identifier parenthesized_expression comparison_operator identifier identifier else_clause block expression_statement assignment identifier true return_statement identifier
|
Determine whether to allow unparsed flag access or not.
|
def all(*validators):
def validate_all(fields):
for validator in validators:
errors = validator(fields)
if errors:
return errors
validate_all.__doc__ = " and ".join(validator.__doc__ for validator in validators)
return validate_all
|
module function_definition identifier parameters list_splat_pattern identifier block function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block return_statement identifier expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier generator_expression attribute identifier identifier for_in_clause identifier identifier return_statement identifier
|
Validation only succeeds if all passed in validators return no errors
|
def _submit(primitive, port_index, tuple_):
args = (_get_opc(primitive), port_index, tuple_)
_ec._submit(args)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier tuple call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
Internal method to submit a tuple
|
def show_attrs(directory):
"print out the tempo for each audio file in the given directory"
for f in os.listdir(directory):
if _is_audio(f):
path = os.path.join(directory, f)
_show_one(path)
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list identifier block if_statement call identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call identifier argument_list identifier
|
print out the tempo for each audio file in the given directory
|
def author_line(soup):
author_line = None
authors_json_data = authors_json(soup)
author_names = extract_author_line_names(authors_json_data)
if len(author_names) > 0:
author_line = format_author_line(author_names)
return author_line
|
module function_definition identifier parameters identifier block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
|
take preferred names from authors json and format them into an author line
|
def send(self, data):
assert isinstance(data, text_type)
self.stdout.write(data.replace('\n', '\r\n'))
self.stdout.flush()
|
module function_definition identifier parameters identifier identifier block assert_statement call identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content escape_sequence escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list
|
Send text to the client.
|
def foreignkey(element, exceptions):
label = element.field.__dict__['label']
try:
label = unicode(label)
except NameError:
pass
if (not label) or (label in exceptions):
return False
else:
return "_queryset" in element.field.__dict__
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block pass_statement if_statement boolean_operator parenthesized_expression not_operator identifier parenthesized_expression comparison_operator identifier identifier block return_statement false else_clause block return_statement comparison_operator string string_start string_content string_end attribute attribute identifier identifier identifier
|
function to determine if each select field needs a create button or not
|
def getEditorBinary(self, cmdVersion=False):
return os.path.join(self.getEngineRoot(), 'Engine', 'Binaries', self.getPlatformIdentifier(), 'UE4Editor' + self._editorPathSuffix(cmdVersion))
|
module function_definition identifier parameters identifier default_parameter identifier false block return_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier
|
Determines the location of the UE4Editor binary
|
def encode_basic_auth(username, password):
return "Basic {}".format(
b64encode(
"{}:{}".format(
username,
password,
).encode("utf-8")
).decode("utf-8")
)
|
module function_definition identifier parameters identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list call attribute call identifier argument_list call attribute call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end
|
Encode basic auth credentials.
|
def SaveResourceUsage(self, client_id, status):
self.hunt_obj.ProcessClientResourcesStats(client_id, status)
self.UpdateProtoResources(status)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
Update the resource usage of the hunt.
|
def _persist_result(self):
self._prepare_persistence_engine()
return self._persistence_engine.store_async_result(
self.id, self.result)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier
|
Store this Async's result in persistent storage.
|
def _remove_observation_from_means(self, xj, yj):
self._mean_x_in_window = ((self.window_size * self._mean_x_in_window - xj) /
(self.window_size - 1.0))
self._mean_y_in_window = ((self.window_size * self._mean_y_in_window - yj) /
(self.window_size - 1.0))
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier parenthesized_expression binary_operator parenthesized_expression binary_operator binary_operator attribute identifier identifier attribute identifier identifier identifier parenthesized_expression binary_operator attribute identifier identifier float expression_statement assignment attribute identifier identifier parenthesized_expression binary_operator parenthesized_expression binary_operator binary_operator attribute identifier identifier attribute identifier identifier identifier parenthesized_expression binary_operator attribute identifier identifier float
|
Update the means without recalculating for the deletion of one observation.
|
def create_dir_unless_exists(*args):
path = os.path.join(*args)
if not os.path.isdir(path):
os.makedirs(path)
|
module function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list list_splat identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Creates a directory unless it exists already.
|
def flo(string):
callers_locals = {}
frame = inspect.currentframe()
try:
outerframe = frame.f_back
callers_locals = outerframe.f_locals
finally:
del frame
return string.format(**callers_locals)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier finally_clause block delete_statement identifier return_statement call attribute identifier identifier argument_list dictionary_splat identifier
|
Return the string given by param formatted with the callers locals.
|
def load_replacement_patterns(self):
filename = self.dictionary + '.py'
models = self.language + '_models_cltk'
rel_path = os.path.join('~/cltk_data',
self.language,
'model',
models,
'semantics',
filename)
path = os.path.expanduser(rel_path)
logger.info('Loading lemmata or synonyms. This may take a minute.')
loader = importlib.machinery.SourceFileLoader(filename, path)
module = types.ModuleType(loader.name)
loader.exec_module(module)
return module.DICTIONARY
|
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
|
Check for availability of the specified dictionary.
|
def _create_child(self, tag):
return etree.SubElement(self._root, self._get_namespace_tag(tag))
|
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier
|
Create a new child element with the given tag.
|
def build_rpm(ctx, target):
if target not in ('centos6', 'centos7'):
print('Error: unknown target "{0}"!'.format(target), file=sys.stderr)
sys.exit(1)
os.chdir(PROJECT_DIR)
rpmbuild_dir = os.path.join(DIST_DIR, 'rpmbuild')
ctx.run('mkdir -p {0}'.format(' '.join(os.path.join(rpmbuild_dir, d)
for d in ('BUILD', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS'))))
build_src(ctx, dest=os.path.join(rpmbuild_dir, 'SOURCES'))
ctx.run('cp -f {0} {1}'.format(os.path.join(PROJECT_DIR, 'rpm/centos/mssh-copy-id.spec'),
os.path.join(rpmbuild_dir, 'SPECS')))
ctx.run('docker run -e LOCAL_USER_ID={local_user_id} -v {local}:{cont} {img}'
.format(local_user_id=os.getuid(),
local=rpmbuild_dir,
cont='/rpmbuild',
img=DOCKER_IMGS[target]['name']))
ctx.run('mv -f {0} {1}'.format(os.path.join(rpmbuild_dir, 'RPMS/noarch/mssh-copy-id-*.rpm'), DIST_DIR))
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier generator_expression call attribute attribute identifier identifier identifier argument_list identifier identifier for_in_clause identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier subscript subscript identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end identifier
|
build an RPM package
|
def _neighbour_pixels(hp, ipix):
neigh_ipix = np.unique(hp.neighbours(ipix).ravel())
return neigh_ipix[np.where(neigh_ipix >= 0)]
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier identifier argument_list return_statement subscript identifier call attribute identifier identifier argument_list comparison_operator identifier integer
|
Returns all the pixels neighbours of ``ipix``
|
def unset_env(self, key):
os.environ.pop(make_env_key(self.appname, key), None)
self._registered_env_keys.discard(key)
self._clear_memoization()
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier identifier none expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Removes an environment variable using the prepended app_name convention with `key`.
|
def nextStation(ID, date):
jd = eph.nextStation(ID, date.jd)
return Datetime.fromJD(jd, date.utcoffset)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
|
Returns the aproximate date of the next station.
|
def extern_eval(self, context_handle, python_code_str_ptr, python_code_str_len):
c = self._ffi.from_handle(context_handle)
return self.call(c, eval, [self.to_py_str(python_code_str_ptr, python_code_str_len)])
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier list call attribute identifier identifier argument_list identifier identifier
|
Given an evalable string, eval it and return a Handle for its result.
|
def add_dependency(self, name, obj):
if name in self._deps:
if self._deps[name] is obj:
return
raise ValueError(
"There exists a different dep with the same name : %r" % name)
self._deps[name] = obj
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block if_statement comparison_operator subscript attribute identifier identifier identifier identifier block return_statement raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier identifier identifier
|
Add a code dependency so it gets inserted into globals
|
def _map_player_request_to_func(self, player_request_type):
view_func = self._intent_view_funcs.get(player_request_type, lambda: None)
argspec = inspect.getargspec(view_func)
arg_names = argspec.args
arg_values = self._map_params_to_view_args(player_request_type, arg_names)
return partial(view_func, *arg_values)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier lambda none expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list identifier list_splat identifier
|
Provides appropriate parameters to the on_playback functions.
|
def _get_json(self, url):
"Get JSON-type content"
content = self._get_content('jsonds/' + url)
try:
json_content = json.loads(content.decode())
except AttributeError:
json_content = json.loads(content)
if json_content['Comment']:
log.warning(json_content['Comment'])
if json_content['Result'] != 'OK':
raise ValueError('Error while retrieving the parameter list.')
return json_content['Data']
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end return_statement subscript identifier string string_start string_content string_end
|
Get JSON-type content
|
def clear_sessions(venv=None):
if "VIRTUAL_ENV" in os.environ:
ve = os.path.basename(os.environ["VIRTUAL_ENV"])
else:
ve = ""
if venv is not None:
ve = venv
else:
ve = prompt("Enter the name of the "
"sandbox whose sessions you would like to delete, or "
"\"ion\" to clear production sessions:", default=ve)
c = "redis-cli -n {0} KEYS {1}:session:* | sed 's/\"^.*\")//g'"
keys_command = c.format(REDIS_SESSION_DB, ve)
keys = local(keys_command, capture=True)
count = 0 if keys.strip() == "" else keys.count("\n") + 1
if count == 0:
puts("No sessions to destroy.")
return 0
plural = "s" if count != 1 else ""
if not confirm("Are you sure you want to destroy {} {}" "session{}?".format(count, "production " if ve == "ion" else "", plural)):
return 0
if count > 0:
local("{0}| xargs redis-cli -n " "{1} DEL".format(keys_command, REDIS_SESSION_DB))
puts("Destroyed {} session{}.".format(count, plural))
|
module function_definition identifier parameters default_parameter identifier none block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_end if_statement comparison_operator identifier none block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end keyword_argument identifier identifier expression_statement assignment identifier string string_start string_content escape_sequence escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier conditional_expression integer comparison_operator call attribute identifier identifier argument_list string string_start string_end binary_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end integer if_statement comparison_operator identifier integer block expression_statement call identifier argument_list string string_start string_content string_end return_statement integer expression_statement assignment identifier conditional_expression string string_start string_content string_end comparison_operator identifier integer string string_start string_end if_statement not_operator call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier conditional_expression string string_start string_content string_end comparison_operator identifier string string_start string_content string_end string string_start string_end identifier block return_statement integer if_statement comparison_operator identifier integer block expression_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier
|
Clear all sessions for all sandboxes or for production.
|
def unit_type(scale=None):
palette_size = scale or max(static_data.UNIT_TYPES) + 1
palette = shuffled_hue(palette_size)
assert len(static_data.UNIT_TYPES) <= len(distinct_colors)
for i, v in enumerate(static_data.UNIT_TYPES):
palette[v] = distinct_colors[i]
return palette
|
module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier binary_operator call identifier argument_list attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list identifier assert_statement comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript identifier identifier subscript identifier identifier return_statement identifier
|
Returns a palette that maps unit types to rgb colors.
|
def dispatch(self, category, func, *args):
self.factory.loader.runPlugins(category, func, self, *args)
|
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier identifier list_splat identifier
|
Dispatch an event to all listening plugins.
|
def on(self):
msg = X10Send.unit_code_msg(self.address.x10_housecode,
self.address.x10_unitcode)
self._send_method(msg)
msg = X10Send.command_msg(self.address.x10_housecode,
X10_COMMAND_ON)
self._send_method(msg, False)
self._update_subscribers(0xff)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier false expression_statement call attribute identifier identifier argument_list integer
|
Send the On command to an X10 device.
|
def _track_from_response(result, timeout):
response = result['response']
status = response['track']['status'].lower()
if status == 'pending':
result = _wait_for_pending_track(response['track']['id'], timeout)
response = result['response']
status = response['track']['status'].lower()
if not status == 'complete':
track_id = response['track']['id']
if status == 'pending':
raise Exception('%s: the operation didn\'t complete before the timeout (%d secs)' %
(track_id, timeout))
else:
raise Exception('%s: there was an error analyzing the track, status: %s' % (track_id, status))
else:
track_properties = response['track']
identifier = track_properties.pop('id')
md5 = track_properties.pop('md5', None)
track_properties.update(track_properties.pop('audio_summary'))
return Track(identifier, md5, track_properties)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list if_statement not_operator comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier else_clause block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier identifier identifier
|
This is the function that actually creates the track object
|
def _print_breakdown(cls, savedir, fname, data):
if not os.path.exists(savedir):
os.makedirs(savedir)
with open(os.path.join(savedir, fname), 'w') as fout:
fout.write(data)
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Function to print model fixtures into generated file
|
def from_python_file(
cls, python_file, lambdas_path, json_filename: str, stem: str
):
with open(python_file, "r") as f:
pySrc = f.read()
return cls.from_python_src(pySrc, lambdas_path, json_filename, stem)
|
module function_definition identifier parameters identifier identifier identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier
|
Builds GrFN object from Python file.
|
def new_nodes_allowed_for_layer(self):
if not self.pk and self.layer and not self.layer.new_nodes_allowed:
raise ValidationError(_('New nodes are not allowed for this layer'))
|
module function_definition identifier parameters identifier block if_statement boolean_operator boolean_operator not_operator attribute identifier identifier attribute identifier identifier not_operator attribute attribute identifier identifier identifier block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end
|
ensure new nodes are allowed for this layer
|
def _get_os_price_id(items, os, location):
for item in items:
if any([utils.lookup(item,
'itemCategory',
'categoryCode') != 'os',
utils.lookup(item,
'softwareDescription',
'referenceCode') != os]):
continue
for price in item['prices']:
if not _matches_location(price, location):
continue
return price['id']
raise SoftLayer.SoftLayerError("Could not find valid price for os: '%s'" %
os)
|
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block if_statement call identifier argument_list list comparison_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end comparison_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end identifier block continue_statement for_statement identifier subscript identifier string string_start string_content string_end block if_statement not_operator call identifier argument_list identifier identifier block continue_statement return_statement subscript identifier string string_start string_content string_end raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
|
Returns the price id matching.
|
def chao_shen(q):
yx = q[q > 0]
n = np.sum(yx)
p = yx.astype(float)/n
f1 = np.sum(yx == 1)
if f1 == n:
f1 -= 1
C = 1 - (f1/n)
pa = C * p
la = (1 - (1 - pa) ** n)
H = -np.sum((pa * np.log2(pa)) / la)
return (H, pa, la)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier comparison_operator identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list comparison_operator identifier integer if_statement comparison_operator identifier identifier block expression_statement augmented_assignment identifier integer expression_statement assignment identifier binary_operator integer parenthesized_expression binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier parenthesized_expression binary_operator integer binary_operator parenthesized_expression binary_operator integer identifier identifier expression_statement assignment identifier unary_operator call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator identifier call attribute identifier identifier argument_list identifier identifier return_statement tuple identifier identifier identifier
|
Computes some terms needed for the Chao-Shen KL correction.
|
def interrupt(self, interrupt):
self._interrupt = True
self.stop()
self._interrupt = interrupt
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier
|
Perform the shutdown of this server and save the exception.
|
def flatten_dict(self, obj):
return OrderedDict(zip(self.fieldnames, self.flatten(obj)))
|
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier
|
Return an OrderedDict dict preserving order of keys in fieldnames
|
def overlap(self, other):
if self._start < other.end and self._end > other.start:
return True
return False
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block return_statement true return_statement false
|
Determine whether this range overlaps with another.
|
def list(self, where):
if where == 'pillar':
schedule = self._get_schedule(include_opts=False)
elif where == 'opts':
schedule = self._get_schedule(include_pillar=False)
else:
schedule = self._get_schedule()
evt = salt.utils.event.get_event('minion', opts=self.opts, listen=False)
evt.fire_event({'complete': True, 'schedule': schedule},
tag='/salt/minion/minion_schedule_list_complete')
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier false elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier false else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end true pair string string_start string_content string_end identifier keyword_argument identifier string string_start string_content string_end
|
List the current schedule items
|
def count(cls, user_id):
return cls.query.with_entities(
cls.user_id).filter_by(user_id=user_id).count()
|
module function_definition identifier parameters identifier identifier block return_statement call attribute call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list
|
Count sessions with user_id
|
def _bottom(self):
_, top, _, height = self._extents
return top + height
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier attribute identifier identifier return_statement binary_operator identifier identifier
|
Index of row following last row of range
|
def sqrt(self, val, flag):
if val.iszero():
return val
sw = self.p % 8
if sw == 3 or sw == 7:
res = val ** ((self.p + 1) / 4)
elif sw == 5:
x = val ** ((self.p + 1) / 4)
if x == 1:
res = val ** ((self.p + 3) / 8)
else:
res = (4 * val) ** ((self.p - 5) / 8) * 2 * val
else:
raise Exception("modsqrt non supported for (p%8)==1")
if res.value % 2 == flag:
return res
else:
return -res
|
module function_definition identifier parameters identifier identifier identifier block if_statement call attribute identifier identifier argument_list block return_statement identifier expression_statement assignment identifier binary_operator attribute identifier identifier integer if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer elif_clause comparison_operator identifier integer block expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer else_clause block expression_statement assignment identifier binary_operator binary_operator binary_operator parenthesized_expression binary_operator integer identifier parenthesized_expression binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer integer identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator binary_operator attribute identifier identifier integer identifier block return_statement identifier else_clause block return_statement unary_operator identifier
|
calculate the square root modulus p
|
def addRectAnnot(self, rect):
CheckParent(self)
val = _fitz.Page_addRectAnnot(self, rect)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
return val
|
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement not_operator identifier block return_statement expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier call identifier argument_list identifier identifier return_statement identifier
|
Add a 'Rectangle' annotation.
|
def deserialize_instance(model, data={}):
"Translate raw data into a model instance."
ret = model()
for k, v in data.items():
if v is not None:
try:
f = model._meta.get_field(k)
if isinstance(f, DateTimeField):
v = dateparse.parse_datetime(v)
elif isinstance(f, TimeField):
v = dateparse.parse_time(v)
elif isinstance(f, DateField):
v = dateparse.parse_date(v)
except FieldDoesNotExist:
pass
setattr(ret, k, v)
return ret
|
module function_definition identifier parameters identifier default_parameter identifier dictionary block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier none block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement expression_statement call identifier argument_list identifier identifier identifier return_statement identifier
|
Translate raw data into a model instance.
|
def run_cell_magic(self, magic_name, line, cell):
if magic_name == 'bash':
self.shebang("bash", cell)
elif magic_name == 'metatab':
self.mm.metatab(line, cell)
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
|
Run a limited number of magics from scripts, without IPython
|
def provider_factory(provider, **options):
try:
return {"tmdb": TMDb, "tvdb": TVDb}[provider.lower()](**options)
except KeyError:
msg = "Attempted to initialize non-existing DB Provider"
log.error(msg)
raise MapiException(msg)
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block try_statement block return_statement call subscript dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier call attribute identifier identifier argument_list argument_list dictionary_splat identifier except_clause identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list identifier
|
Factory function for DB Provider Concrete Classes
|
def update_type(self, request, *args, **kwargs):
self.object = self.get_object()
success_url = self.get_success_url()
self.object.type = self.target_type
self.object.save()
messages.success(self.request, self.success_message)
return HttpResponseRedirect(success_url)
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement call identifier argument_list identifier
|
Updates the type of the considered topic and retirects the user to the success URL.
|
def GetMostRecentClient(client_list, token=None):
last = rdfvalue.RDFDatetime(0)
client_urn = None
for client in aff4.FACTORY.MultiOpen(client_list, token=token):
client_last = client.Get(client.Schema.LAST)
if client_last > last:
last = client_last
client_urn = client.urn
return client_urn
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier none for_statement identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier attribute identifier identifier return_statement identifier
|
Return most recent client from list of clients.
|
def compare(self, path, prefixed_path, source_storage):
comparitor = getattr(self, 'compare_%s' % self.comparison_method, None)
if not comparitor:
comparitor = self._create_comparitor(self.comparison_method)
return comparitor(path, prefixed_path, source_storage)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier binary_operator string string_start string_content string_end attribute identifier identifier none if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list identifier identifier identifier
|
Returns True if the file should be copied.
|
def _Reg2Py(data, size, data_type):
if data_type == winreg.REG_DWORD:
if size == 0:
return 0
return ctypes.cast(data, ctypes.POINTER(ctypes.c_uint32)).contents.value
elif data_type == winreg.REG_SZ or data_type == winreg.REG_EXPAND_SZ:
return ctypes.wstring_at(data, size // 2).rstrip(u"\x00")
elif data_type == winreg.REG_MULTI_SZ:
return ctypes.wstring_at(data, size // 2).rstrip(u"\x00").split(u"\x00")
else:
if size == 0:
return None
return ctypes.string_at(data, size)
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block if_statement comparison_operator identifier integer block return_statement integer return_statement attribute attribute call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list attribute identifier identifier identifier identifier elif_clause boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator identifier attribute identifier identifier block return_statement call attribute call attribute identifier identifier argument_list identifier binary_operator identifier integer identifier argument_list string string_start string_content escape_sequence string_end elif_clause comparison_operator identifier attribute identifier identifier block return_statement call attribute call attribute call attribute identifier identifier argument_list identifier binary_operator identifier integer identifier argument_list string string_start string_content escape_sequence string_end identifier argument_list string string_start string_content escape_sequence string_end else_clause block if_statement comparison_operator identifier integer block return_statement none return_statement call attribute identifier identifier argument_list identifier identifier
|
Converts a Windows Registry value to the corresponding Python data type.
|
def disconnect(self, sid, namespace):
if namespace not in self.rooms:
return
rooms = []
for room_name, room in six.iteritems(self.rooms[namespace].copy()):
if sid in room:
rooms.append(room_name)
for room in rooms:
self.leave_room(sid, namespace, room)
if sid in self.callbacks and namespace in self.callbacks[sid]:
del self.callbacks[sid][namespace]
if len(self.callbacks[sid]) == 0:
del self.callbacks[sid]
if namespace in self.pending_disconnect and \
sid in self.pending_disconnect[namespace]:
self.pending_disconnect[namespace].remove(sid)
if len(self.pending_disconnect[namespace]) == 0:
del self.pending_disconnect[namespace]
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list call attribute subscript attribute identifier identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier if_statement boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator identifier subscript attribute identifier identifier identifier block delete_statement subscript subscript attribute identifier identifier identifier identifier if_statement comparison_operator call identifier argument_list subscript attribute identifier identifier identifier integer block delete_statement subscript attribute identifier identifier identifier if_statement boolean_operator comparison_operator identifier attribute identifier identifier line_continuation comparison_operator identifier subscript attribute identifier identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list subscript attribute identifier identifier identifier integer block delete_statement subscript attribute identifier identifier identifier
|
Register a client disconnect from a namespace.
|
def from_file(cls, filepath):
with open(filepath, "rt") as fh:
return cls(**yaml.safe_load(fh))
|
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call identifier argument_list dictionary_splat call attribute identifier identifier argument_list identifier
|
Read the configuration parameters from a Yaml file.
|
def managepy(cmd, extra=None):
extra = extra.split() if extra else []
run_django_cli(['invoke', cmd] + extra)
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list identifier list expression_statement call identifier argument_list binary_operator list string string_start string_content string_end identifier identifier
|
Run manage.py using this component's specific Django settings
|
def _bucket_exists(self):
try:
self.s3client.get_bucket_location(Bucket=self.bucket)
return True
except ClientError as error:
LOG.error(error)
return False
|
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier return_statement true except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement false
|
Check if the bucket exists.
|
def mda_count(self):
self.open()
mda = lvm_pv_get_mda_count(self.handle)
self.close()
return mda
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
|
Returns the physical volume mda count.
|
def _open_connection(self):
if self._scheme == 'unix':
self._connection = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
self._connection.connect(self._path)
elif self._scheme == 'tcp':
self._connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.SOL_TCP)
self._connection.connect((self._host, self._port))
elif self._scheme == 'http':
self._connection = httplib.HTTPConnection(self._host, self._port, strict=False)
else:
raise ConnectionError("Connection scheme not recognized!")
|
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 attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier false else_clause block raise_statement call identifier argument_list string string_start string_content string_end
|
Open a new connection socket to the CPS.
|
def pages_admin_menu(context, page):
request = context.get('request', None)
expanded = False
if request and "tree_expanded" in request.COOKIES:
cookie_string = urllib.unquote(request.COOKIES['tree_expanded'])
if cookie_string:
ids = [int(id) for id in
urllib.unquote(request.COOKIES['tree_expanded']).split(',')]
if page.id in ids:
expanded = True
context.update({'expanded': expanded, 'page': page})
return context
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier false if_statement boolean_operator identifier comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier true expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement identifier
|
Render the admin table of pages.
|
def _finalize(self):
if self.status in ['running', 'halt']:
if self.verbose > 0:
print_('\nSampling finished normally.')
self.status = 'ready'
self.save_state()
self.db._finalize()
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator attribute identifier identifier integer block expression_statement call identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
|
Reset the status and tell the database to finalize the traces.
|
def print_square(row_queue, t):
occupied_rows = {y: row for _, y, row in row_queue}
empty_row = ', '.join('...' for _ in range(t))
for y in range(t):
print('|', end=' ')
if y not in occupied_rows:
print(empty_row, end=' ')
else:
row = dict(occupied_rows[y])
all_cols = ('%3d' % row[x] if x in row else '...'
for x in range(t))
print(', '.join(all_cols), end=' ')
print("|")
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier generator_expression string string_start string_content string_end for_in_clause identifier call identifier argument_list identifier for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call identifier argument_list subscript identifier identifier expression_statement assignment identifier generator_expression conditional_expression binary_operator string string_start string_content string_end subscript identifier identifier comparison_operator identifier identifier string string_start string_content string_end for_in_clause identifier call identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end
|
Prints a row queue as its conceptual square array.
|
def move_to(x, y):
for b in _button_state:
if _button_state[b]:
e = Quartz.CGEventCreateMouseEvent(
None,
_button_mapping[b][3],
(x, y),
_button_mapping[b][0])
break
else:
e = Quartz.CGEventCreateMouseEvent(
None,
Quartz.kCGEventMouseMoved,
(x, y),
Quartz.kCGMouseButtonLeft)
Quartz.CGEventPost(Quartz.kCGHIDEventTap, e)
|
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement subscript identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list none subscript subscript identifier identifier integer tuple identifier identifier subscript subscript identifier identifier integer break_statement else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list none attribute identifier identifier tuple identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
|
Sets the mouse's location to the specified coordinates.
|
def check_presence_download(filename, backup_url):
import os
filename = str(filename)
if not os.path.exists(filename):
from .readwrite import download_progress
dr = os.path.dirname(filename)
try:
os.makedirs(dr)
except FileExistsError:
pass
from urllib.request import urlretrieve
urlretrieve(backup_url, filename, reporthook=download_progress)
|
module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement call identifier argument_list identifier identifier keyword_argument identifier identifier
|
Check if file is present otherwise download.
|
def build_FAILED(self, prgnam):
self.template(78)
print("| Some error on the package {0} [ {1}FAILED{2} ]".format(
prgnam, self.meta.color["RED"], self.meta.color["ENDC"]))
self.template(78)
print("| See the log file in '{0}/var/log/slpkg/sbo/build_logs{1}' "
"directory or read the README file".format(
self.meta.color["CYAN"], self.meta.color["ENDC"]))
self.template(78)
print("")
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list integer expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer expression_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list subscript attribute attribute identifier identifier identifier string string_start string_content string_end subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer expression_statement call identifier argument_list string string_start string_end
|
Print error message if build failed
|
def filter_data(df, filter_name, verbose=False):
"Filter certain entries with given name."
df = df[df.stop_name.apply(
lambda cell: filter_name.encode('utf-8') in cell)]
if verbose:
msg = '- Filtered down to %d entries containing "%s".'
print(msg % (len(df), filter_name))
return df
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement string string_start string_content string_end expression_statement assignment identifier subscript identifier call attribute attribute identifier identifier identifier argument_list lambda lambda_parameters identifier comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call identifier argument_list binary_operator identifier tuple call identifier argument_list identifier identifier return_statement identifier
|
Filter certain entries with given name.
|
def predict(self, inputs: np.ndarray) -> np.ndarray:
return self.sess.run(self.out_var, {self.inp_var: inputs})
|
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier dictionary pair attribute identifier identifier identifier
|
Run on multiple inputs
|
def delLadder(name):
ladders = getKnownLadders()
try:
ladder = ladders[name]
os.remove(ladder.filename)
del ladders[name]
return ladder
except KeyError:
raise ValueError("given ladder name '%s' is not a known ladder definition"%(name))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list try_statement block expression_statement assignment identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier delete_statement subscript identifier identifier return_statement identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier
|
forget about a previously defined Ladder setting by deleting its disk file
|
def from_data(data):
header, length = struct.unpack('4s<I', data[:8])
data = data[8:]
return RiffDataChunk(header, data)
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier slice integer expression_statement assignment identifier subscript identifier slice integer return_statement call identifier argument_list identifier identifier
|
Create a chunk from data including header and length bytes.
|
def worker(data):
creator = get_creator_by_name(data['creator'])
shell = creator(data['entry'],
ShellConfig(script=data['entry']['script'],
title=data['entry']['title'] if 'title' in data['entry'] else '',
model=data['model'], env=data['env'], item=data['item'],
dry_run=data['dry_run'], debug=data['debug'], strict=data['strict'],
variables=data['variables'],
temporary_scripts_path=data['temporary_scripts_path']))
output = []
for line in shell.process():
output.append(line)
Logger.get_logger(__name__ + '.worker').info(" | %s", line)
return {'id': data['id'], 'success': shell.success, 'output': output}
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end call identifier argument_list keyword_argument identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier conditional_expression subscript subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end string string_start string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end identifier return_statement dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier
|
Running on shell via multiprocessing.
|
def tmpfile(prefix, direc):
return tempfile.mktemp(prefix=prefix, suffix='.pdb', dir=direc)
|
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier
|
Returns the path to a newly created temporary file.
|
def decrease_weight(self, proxy):
new_weight = proxy.weight * self.dec_ratio
if new_weight < self.weight_thr:
self.remove_proxy(proxy)
else:
proxy.weight = new_weight
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment attribute identifier identifier identifier
|
Decreasing the weight of a proxy by multiplying dec_ratio
|
def randomArray(size, bound):
if type(size) == type(1):
size = (size,)
temp = Numeric.array( ndim(*size) ) * (2.0 * bound)
return temp - bound
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier call identifier argument_list integer block expression_statement assignment identifier tuple identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list call identifier argument_list list_splat identifier parenthesized_expression binary_operator float identifier return_statement binary_operator identifier identifier
|
Returns an array initialized to random values between -max and max.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.