code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def Filter(self, filename_spec):
if "@" in filename_spec:
file_path, package_name = filename_spec.split("@")
else:
file_path, package_name = filename_spec, Resource.default_package
resource_path = package.ResourcePath(package_name, file_path)
if resource_path is not None:
return resource_path
raise FilterError(
"Unable to find resource %s while interpolating: " % filename_spec)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment pattern_list identifier identifier expression_list identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block return_statement identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
|
Use pkg_resources to find the path to the required resource.
|
def getfiles(qfiles, dirname, names):
for name in names:
fullname = os.path.join(dirname, name)
if os.path.isfile(fullname) and \
fullname.endswith('.cf') or \
fullname.endswith('.post'):
qfiles.put(fullname)
|
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement boolean_operator boolean_operator call attribute attribute identifier identifier identifier argument_list identifier line_continuation 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 block expression_statement call attribute identifier identifier argument_list identifier
|
Get rule files in a directory
|
def search_genius_web(self, search_term, per_page=5):
endpoint = "search/multi?"
params = {'per_page': per_page, 'q': search_term}
url = "https://genius.com/api/" + endpoint + urlencode(params)
response = requests.get(url, timeout=self.timeout)
time.sleep(max(self._SLEEP_MIN, self.sleep_time))
return response.json()['response'] if response else None
|
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier return_statement conditional_expression subscript call attribute identifier identifier argument_list string string_start string_content string_end identifier none
|
Use the web-version of Genius search
|
def _handle_iorder(self, state):
if self.opts['state_auto_order']:
for name in state:
for s_dec in state[name]:
if not isinstance(s_dec, six.string_types):
continue
if not isinstance(state[name], dict):
continue
if not isinstance(state[name][s_dec], list):
continue
found = False
if s_dec.startswith('_'):
continue
for arg in state[name][s_dec]:
if isinstance(arg, dict):
if arg:
if next(six.iterkeys(arg)) == 'order':
found = True
if not found:
if not isinstance(state[name][s_dec], list):
continue
state[name][s_dec].append(
{'order': self.iorder}
)
self.iorder += 1
return state
|
module function_definition identifier parameters identifier identifier block if_statement subscript attribute identifier identifier string string_start string_content string_end block for_statement identifier identifier block for_statement identifier subscript identifier identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block continue_statement if_statement not_operator call identifier argument_list subscript identifier identifier identifier block continue_statement if_statement not_operator call identifier argument_list subscript subscript identifier identifier identifier identifier block continue_statement expression_statement assignment identifier false if_statement call attribute identifier identifier argument_list string string_start string_content string_end block continue_statement for_statement identifier subscript subscript identifier identifier identifier block if_statement call identifier argument_list identifier identifier block if_statement identifier block if_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier true if_statement not_operator identifier block if_statement not_operator call identifier argument_list subscript subscript identifier identifier identifier identifier block continue_statement expression_statement call attribute subscript subscript identifier identifier identifier identifier argument_list dictionary pair string string_start string_content string_end attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer return_statement identifier
|
Take a state and apply the iorder system
|
def main():
parser = argparse.ArgumentParser(description='Run SSOIS and return the available images in a particular filter.')
parser.add_argument("--filter",
action="store",
default='r',
dest="filter",
choices=['r', 'u'],
help="Passband: default is r.")
parser.add_argument("--family", '-f',
action="store",
default=None,
help='List of objects to query.')
parser.add_argument("--member", '-m',
action="store",
default=None,
help='Member object of family to query.')
args = parser.parse_args()
if args.family != None and args.member == None:
get_family_info(str(args.family), args.filter)
elif args.family == None and args.member != None:
get_member_info(str(args.member), args.filter)
else:
print "Please input either a family or single member name"
|
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier none keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier none keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none block expression_statement call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier elif_clause boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none block expression_statement call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier else_clause block print_statement string string_start string_content string_end
|
Input asteroid family, filter type, and image type to query SSOIS
|
def v_unique_name_leaf_list(ctx, stmt):
if not stmt.i_config:
return
seen = []
for defval in stmt.i_default:
if defval in seen:
err_add(ctx.errors, stmt.pos, 'DUPLICATE_DEFAULT', (defval))
else:
seen.append(defval)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier string string_start string_content string_end parenthesized_expression identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier
|
Make sure config true leaf-lists do nothave duplicate defaults
|
def gen_cmd_and_param_completions(self):
if self.complete_command:
for param in self.command_param_info.get(self.current_command, []):
if self.validate_param_completion(param, self.leftover_args):
yield self.yield_param_completion(param, self.unfinished_word)
elif not self.leftover_args:
for child_command in self.subtree.children:
if self.validate_completion(child_command):
yield Completion(child_command, -len(self.unfinished_word))
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier list block if_statement call attribute identifier identifier argument_list identifier attribute identifier identifier block expression_statement yield call attribute identifier identifier argument_list identifier attribute identifier identifier elif_clause not_operator attribute identifier identifier block for_statement identifier attribute attribute identifier identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement yield call identifier argument_list identifier unary_operator call identifier argument_list attribute identifier identifier
|
generates command and parameter completions
|
def _len_table_cache(self):
length = 0
for table in self._table_cache:
length += len(self._table_cache[table])
return length
|
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block expression_statement augmented_assignment identifier call identifier argument_list subscript attribute identifier identifier identifier return_statement identifier
|
Returns the length of the table cache
|
def eidos_process_jsonld():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
eidos_json = body.get('jsonld')
ep = eidos.process_json_str(eidos_json)
return _stmts_from_proc(ep)
|
module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement dictionary expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
|
Process an EIDOS JSON-LD and return INDRA Statements.
|
def _normalize_path(self, path):
norm_path = os.path.normpath(path)
return os.path.relpath(norm_path, start=self._get_working_dir())
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list
|
Normalizes a file path so that it returns a path relative to the root repo directory.
|
def html_attributes(self):
extra_attributes = ''
if self.element_id is not None:
extra_attributes = ' id="%s"' % self.element_id
if self.style_class is not None:
extra_attributes = '%s class="%s"' % (
extra_attributes, self.style_class)
if self.attributes is not None:
extra_attributes = '%s %s' % (extra_attributes, self.attributes)
return extra_attributes
|
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier return_statement identifier
|
Get extra html attributes such as id and class.
|
def creator(entry, config):
template_file = os.path.join(os.path.dirname(__file__), 'templates/docker-container.sh.j2')
with open(template_file) as handle:
template = handle.read()
wrapped_script = render(template, container={
'image': 'centos:7' if 'image' not in entry else entry['image'],
'remove': True if 'remove' not in entry else str(entry['remove']).lower(),
'background': False if 'background' not in entry else str(entry['background']).lower(),
'mount': False if 'mount' not in entry else str(entry['mount']).lower(),
'network': '' if 'network' not in entry else entry['network'],
'labels': {} if 'labels' not in entry else entry['labels'],
'script': config.script
})
config.script = wrapped_script
return Container(config)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier dictionary pair string string_start string_content string_end conditional_expression string string_start string_content string_end comparison_operator string string_start string_content string_end identifier subscript identifier string string_start string_content string_end pair string string_start string_content string_end conditional_expression true comparison_operator string string_start string_content string_end identifier call attribute call identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list pair string string_start string_content string_end conditional_expression false comparison_operator string string_start string_content string_end identifier call attribute call identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list pair string string_start string_content string_end conditional_expression false comparison_operator string string_start string_content string_end identifier call attribute call identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list pair string string_start string_content string_end conditional_expression string string_start string_end comparison_operator string string_start string_content string_end identifier subscript identifier string string_start string_content string_end pair string string_start string_content string_end conditional_expression dictionary comparison_operator string string_start string_content string_end identifier subscript identifier string string_start string_content string_end pair string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement call identifier argument_list identifier
|
Creator function for creating an instance of a Bash.
|
def getV0(self, v_mag_guess, buses, generators, type=CASE_GUESS):
if type == CASE_GUESS:
Va = array([b.v_angle * (pi / 180.0) for b in buses])
Vm = array([b.v_magnitude for b in buses])
V0 = Vm * exp(1j * Va)
elif type == FLAT_START:
V0 = ones(len(buses))
elif type == FROM_INPUT:
V0 = v_mag_guess
else:
raise ValueError
gbus = [g.bus._i for g in generators]
Vg = array([g.v_magnitude for g in generators])
V0[gbus] = Vg * abs(V0[gbus]) / V0[gbus]
return V0
|
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list list_comprehension binary_operator attribute identifier identifier parenthesized_expression binary_operator identifier float for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier binary_operator identifier call identifier argument_list binary_operator integer identifier elif_clause comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier elif_clause comparison_operator identifier identifier block expression_statement assignment identifier identifier else_clause block raise_statement identifier expression_statement assignment identifier list_comprehension attribute attribute identifier identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier identifier expression_statement assignment subscript identifier identifier binary_operator binary_operator identifier call identifier argument_list subscript identifier identifier subscript identifier identifier return_statement identifier
|
Returns the initial voltage profile.
|
def add(name, connection_uri, id_file="", o=[], config=None):
storm_ = get_storm_instance(config)
try:
if '@' in name:
raise ValueError('invalid value: "@" cannot be used in name.')
user, host, port = parse(
connection_uri,
user=get_default("user", storm_.defaults),
port=get_default("port", storm_.defaults)
)
storm_.add_entry(name, host, user, port, id_file, o)
print(
get_formatted_message(
'{0} added to your ssh config. you can connect '
'it by typing "ssh {0}".'.format(name),
'success')
)
except ValueError as error:
print(get_formatted_message(error, 'error'), file=sys.stderr)
sys.exit(1)
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end default_parameter identifier list default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier try_statement block if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list string string_start string_content string_end attribute identifier identifier keyword_argument identifier call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier expression_statement call identifier argument_list 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 string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer
|
Adds a new entry to sshconfig.
|
def iterargs(self):
iterargs = OrderedDict()
for name in self._iterargs:
plural = self._profile.iterargs[name]
iterargs[name] = tuple(self._values[plural])
return iterargs
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier expression_statement assignment subscript identifier identifier call identifier argument_list subscript attribute identifier identifier identifier return_statement identifier
|
uses the singular name as key
|
def sin(x, context=None):
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_sin,
(BigFloat._implicit_convert(x),),
context,
)
|
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call identifier argument_list identifier attribute identifier identifier tuple call attribute identifier identifier argument_list identifier identifier
|
Return the sine of ``x``.
|
def encode_query_kwargs(dynamizer, kwargs):
ret = {}
for k, v in six.iteritems(kwargs):
if '__' not in k:
raise TypeError("Invalid query argument '%s'" % k)
name, condition_key = k.split('__')
if condition_key == 'eq' and is_null(v):
condition_key = 'null'
v = True
if condition_key == 'null':
ret[name] = {
'ComparisonOperator': 'NULL' if v else 'NOT_NULL'
}
continue
elif condition_key not in ('in', 'between'):
v = (v,)
ret[name] = {
'AttributeValueList': [dynamizer.encode(value) for value in v],
'ComparisonOperator': CONDITIONS[condition_key],
}
return ret
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator identifier string string_start string_content string_end call identifier argument_list identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier true if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier dictionary pair string string_start string_content string_end conditional_expression string string_start string_content string_end identifier string string_start string_content string_end continue_statement elif_clause comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier tuple identifier expression_statement assignment subscript identifier identifier dictionary pair string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier pair string string_start string_content string_end subscript identifier identifier return_statement identifier
|
Encode query constraints in Dynamo format
|
def levenshteinDistance(self, tree):
s1 = ' '.join(map(View.__microStr__, self.views))
s2 = ' '.join(map(View.__microStr__, tree))
return ViewClient.__levenshteinDistance(s1, s2)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier
|
Finds the Levenshtein distance between this tree and the one passed as argument.
|
def require_user(wa, email):
cache_key = 'user-list'
try:
data = userCache[cache_key]
except KeyError:
data = wa.users.loadUsers()
userCache[cache_key] = data
return AssertUser([x for x in data if x.username == email])
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end try_statement block expression_statement assignment identifier subscript identifier identifier except_clause identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier identifier identifier return_statement call identifier argument_list list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator attribute identifier identifier identifier
|
Require that the user has an account
|
def _group_directional(self, clusters, adj_list, counts):
observed = set()
groups = []
for cluster in clusters:
if len(cluster) == 1:
groups.append(list(cluster))
observed.update(cluster)
else:
cluster = sorted(cluster, key=lambda x: counts[x],
reverse=True)
temp_cluster = []
for node in cluster:
if node not in observed:
temp_cluster.append(node)
observed.add(node)
groups.append(temp_cluster)
return groups
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier subscript identifier identifier keyword_argument identifier true expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
return groups for directional method
|
def parse_tfjob_config():
if os.getenv("TF_CONFIG"):
try:
return json.loads(os.environ["TF_CONFIG"])
except ValueError:
return False
else:
return False
|
module function_definition identifier parameters block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block try_statement block return_statement call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end except_clause identifier block return_statement false else_clause block return_statement false
|
Attempts to parse TFJob config, returning False if it can't find it
|
def _str(obj):
values = []
for name in obj._attribs:
val = getattr(obj, name)
if isinstance(val, str):
val = repr(val)
val = str(val) if len(str(val)) < 10 else "(...)"
values.append((name, val))
values = ", ".join("{}={}".format(k, v) for k, v in values)
return "{}({})".format(obj.__class__.__name__, values)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier conditional_expression call identifier argument_list identifier comparison_operator call identifier argument_list call identifier argument_list identifier integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list tuple identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier generator_expression call attribute string string_start string_content string_end identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier identifier
|
Show nicely the generic object received.
|
def go_to_parent_directory(self):
self.chdir(osp.abspath(osp.join(getcwd_or_home(), os.pardir)))
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier
|
Go to parent directory
|
def deploy(project_name):
request_log = requestlog.RequestLog
header_addon = HeaderControl
fault_wrapper = FaultWrapper
application = handler.SdkHandler()
for middleware in (header_addon,
fault_wrapper,
request_log,
):
if middleware:
application = middleware(application)
return application
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier tuple identifier identifier identifier block if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
|
Assemble the middleware pipeline
|
async def receive(self, pkt):
self.server.logger.info('%s: Received packet %s data %s',
self.sid, packet.packet_names[pkt.packet_type],
pkt.data if not isinstance(pkt.data, bytes)
else '<binary>')
if pkt.packet_type == packet.PING:
self.last_ping = time.time()
await self.send(packet.Packet(packet.PONG, pkt.data))
elif pkt.packet_type == packet.MESSAGE:
await self.server._trigger_event(
'message', self.sid, pkt.data,
run_async=self.server.async_handlers)
elif pkt.packet_type == packet.UPGRADE:
await self.send(packet.Packet(packet.NOOP))
elif pkt.packet_type == packet.CLOSE:
await self.close(wait=False, abort=True)
else:
raise exceptions.UnknownPacketError()
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier subscript attribute identifier identifier attribute identifier identifier conditional_expression attribute identifier identifier not_operator call identifier argument_list attribute identifier identifier identifier string string_start string_content string_end if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement await call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement await call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement await call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement await call attribute identifier identifier argument_list keyword_argument identifier false keyword_argument identifier true else_clause block raise_statement call attribute identifier identifier argument_list
|
Receive packet from the client.
|
def _init():
if ApplicationLayer._isinit:
return
ApplicationLayer._isinit = True
ApplicationLayer._to_app = {}
ApplicationLayer._from_app = Queue()
|
module function_definition identifier parameters block if_statement attribute identifier identifier block return_statement expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier call identifier argument_list
|
Internal switchyard static initialization method.
|
def error(self, text):
self.logger.error("{}{}".format(self.message_prefix, text))
|
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 attribute identifier identifier identifier
|
Ajout d'un message de log de type ERROR
|
def mean(attrs, inputs, proto_obj):
concat_input = [symbol.expand_dims(op_input, axis=0) for op_input in inputs]
concat_sym = symbol.concat(*concat_input, dim=0)
mean_sym = symbol.mean(concat_sym, axis=0)
return mean_sym, attrs, inputs
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier keyword_argument identifier integer for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier keyword_argument identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer return_statement expression_list identifier identifier identifier
|
Mean of all the input tensors.
|
def ok(self):
rgb, hsv, hexa = self.square.get()
if self.alpha_channel:
hexa = self.hexa.get()
rgb += (self.alpha.get(),)
self.color = rgb, hsv, hexa
self.destroy()
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement augmented_assignment identifier tuple call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier expression_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list
|
Validate color selection and destroy dialog.
|
def _print_divide(self):
for space in self.AttributesLength:
self.StrTable += "+ " + "- " * space
self.StrTable += "+" + "\n"
|
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier binary_operator string string_start string_content string_end binary_operator string string_start string_content string_end identifier expression_statement augmented_assignment attribute identifier identifier binary_operator string string_start string_content string_end string string_start string_content escape_sequence string_end
|
Prints all those table line dividers.
|
def configure_stdout_logger(log_level=logging.DEBUG):
root = logging.getLogger()
root.setLevel(log_level)
handler = logging.StreamHandler()
handler.setLevel(log_level)
handler.setFormatter(logging.Formatter(LOG_FORMAT_ESCAPED))
root.addHandler(handler)
|
module function_definition identifier parameters default_parameter identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
|
Configures logging to use STDOUT
|
def parse_address(self, address_line):
params = {"term": address_line}
json = self._make_request('/address/getParsedAddress', params)
if json is None:
return None
return Address.from_json(json)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier none block return_statement none return_statement call attribute identifier identifier argument_list identifier
|
Parses the given address into it's individual address fields.
|
def deinit(self):
for i in range(len(self.buf)):
self.buf[i] = 0
neopixel_write(self.pin, self.buf)
self.pin.deinit()
|
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list call identifier argument_list attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier integer expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
|
Blank out the NeoPixels and release the pin.
|
def tweets_files(string, path):
for filename in os.listdir(path):
if re.match(string, filename) and ".jsonl" in filename:
f = gzip.open if ".gz" in filename else open
yield path + filename, f
Ellipsis
|
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier block if_statement boolean_operator call attribute identifier identifier argument_list identifier identifier comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier conditional_expression attribute identifier identifier comparison_operator string string_start string_content string_end identifier identifier expression_statement yield expression_list binary_operator identifier identifier identifier expression_statement identifier
|
Iterates over json files in path.
|
def _nelec(self):
pd = self.particle_distribution(self._gam * mec2)
return pd.to(1 / mec2_unit).value
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator attribute identifier identifier identifier return_statement attribute call attribute identifier identifier argument_list binary_operator integer identifier identifier
|
Particles per unit lorentz factor
|
def FromStream(cls, stream, auto_transfer=True, total_size=None, **kwds):
return cls(stream, auto_transfer=auto_transfer, total_size=total_size,
**kwds)
|
module function_definition identifier parameters identifier identifier default_parameter identifier true default_parameter identifier none dictionary_splat_pattern identifier block return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier
|
Create a new Download object from a stream.
|
def order_error(subtag, got, expected):
options = SUBTAG_TYPES[expected:]
if len(options) == 1:
expect_str = options[0]
elif len(options) == 2:
expect_str = '%s or %s' % (options[0], options[1])
else:
expect_str = '%s, or %s' % (', '.join(options[:-1]), options[-1])
got_str = SUBTAG_TYPES[got]
raise LanguageTagError("This %s subtag, %r, is out of place. "
"Expected %s." % (got_str, subtag, expect_str))
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript identifier slice identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier subscript identifier integer elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple subscript identifier integer subscript identifier integer else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple call attribute string string_start string_content string_end identifier argument_list subscript identifier slice unary_operator integer subscript identifier unary_operator integer expression_statement assignment identifier subscript identifier identifier raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier identifier identifier
|
Output an error indicating that tags were out of order.
|
def _ReadAndLockNextRequestsToProcess(self, flow_keys, cursor):
query =
condition_template = "(client_id = %s AND flow_id = %s)"
conditions = [condition_template] * len(flow_keys)
query = query.format(conditions=" OR ".join(conditions))
args = []
for client_id, flow_id in flow_keys:
args.append(db_utils.ClientIDToInt(client_id))
args.append(db_utils.FlowIDToInt(flow_id))
cursor.execute(query, args)
next_requests = {}
for client_id_int, flow_id_int, next_request in cursor.fetchall():
flow_key = (db_utils.IntToClientID(client_id_int),
db_utils.IntToFlowID(flow_id_int))
next_requests[flow_key] = next_request
return next_requests
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator list identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier tuple call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
|
Reads and locks the next_request_to_process for a number of flows.
|
def _set_annotation_to_str(annotation_data: Mapping[str, Mapping[str, bool]], key: str) -> str:
value = annotation_data[key]
if len(value) == 1:
return 'SET {} = "{}"'.format(key, list(value)[0])
x = ('"{}"'.format(v) for v in sorted(value))
return 'SET {} = {{{}}}'.format(key, ', '.join(x))
|
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier type identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement call attribute string string_start string_content string_end identifier argument_list identifier subscript call identifier argument_list identifier integer expression_statement assignment identifier generator_expression call attribute string string_start string_content string_end identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier
|
Return a set annotation string.
|
def weighted_mean(data):
W, N, mean, d = 0, len(data), 0, 0
if N < 1:
return "", ""
if N == 1:
return data[0][0], 0
for x in data:
W += x[1]
for x in data:
mean += old_div((float(x[1]) * float(x[0])), float(W))
for x in data:
d += (old_div(float(x[1]), float(W))) * (float(x[0]) - mean)**2
stdev = np.sqrt(d * (old_div(1., (float(N - 1)))))
return mean, stdev
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier expression_list integer call identifier argument_list identifier integer integer if_statement comparison_operator identifier integer block return_statement expression_list string string_start string_end string string_start string_end if_statement comparison_operator identifier integer block return_statement expression_list subscript subscript identifier integer integer integer for_statement identifier identifier block expression_statement augmented_assignment identifier subscript identifier integer for_statement identifier identifier block expression_statement augmented_assignment identifier call identifier argument_list parenthesized_expression binary_operator call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer call identifier argument_list identifier for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator parenthesized_expression call identifier argument_list call identifier argument_list subscript identifier integer call identifier argument_list identifier binary_operator parenthesized_expression binary_operator call identifier argument_list subscript identifier integer identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier parenthesized_expression call identifier argument_list float parenthesized_expression call identifier argument_list binary_operator identifier integer return_statement expression_list identifier identifier
|
calculates weighted mean of data
|
def apply_statusbar_settings(self):
show_status_bar = CONF.get('main', 'show_status_bar')
self.statusBar().setVisible(show_status_bar)
if show_status_bar:
for widget, name in ((self.mem_status, 'memory_usage'),
(self.cpu_status, 'cpu_usage')):
if widget is not None:
widget.setVisible(CONF.get('main', '%s/enable' % name))
widget.set_interval(CONF.get('main', '%s/timeout' % name))
else:
return
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list identifier if_statement identifier block for_statement pattern_list identifier identifier tuple tuple attribute identifier identifier string string_start string_content string_end tuple attribute identifier identifier string string_start string_content string_end block if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end identifier else_clause block return_statement
|
Update status bar widgets settings
|
def undecorated(o):
if type(o) is type:
return o
try:
closure = o.func_closure
except AttributeError:
pass
try:
closure = o.__closure__
except AttributeError:
return
if closure:
for cell in closure:
if cell.cell_contents is o:
continue
if looks_like_a_decorator(cell.cell_contents):
undecd = undecorated(cell.cell_contents)
if undecd:
return undecd
else:
return o
else:
return o
|
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier identifier block return_statement identifier try_statement block expression_statement assignment identifier attribute identifier identifier except_clause identifier block pass_statement try_statement block expression_statement assignment identifier attribute identifier identifier except_clause identifier block return_statement if_statement identifier block for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block continue_statement if_statement call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement identifier block return_statement identifier else_clause block return_statement identifier else_clause block return_statement identifier
|
Remove all decorators from a function, method or class
|
def _run_event_methods(self, tag, stage=None):
import inspect
from ambry.bundle.events import _runable_for_event
funcs = []
for func_name, f in inspect.getmembers(self, predicate=inspect.ismethod):
if _runable_for_event(f, tag, stage):
funcs.append(f)
for func in funcs:
func()
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block import_statement dotted_name identifier import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier block if_statement call identifier argument_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call identifier argument_list
|
Run code in the bundle that is marked with events.
|
def listPrimaryDSTypes(self, primary_ds_type="", dataset=""):
conn = self.dbi.connection()
try:
result = self.primdstypeList.execute(conn, primary_ds_type, dataset)
if conn: conn.close()
return result
finally:
if conn:
conn.close()
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list return_statement identifier finally_clause block if_statement identifier block expression_statement call attribute identifier identifier argument_list
|
Returns all primary dataset types if dataset or primary_ds_type are not passed.
|
def _writen(fd, data):
while data:
n = os.write(fd, data)
data = data[n:]
|
module function_definition identifier parameters identifier identifier block while_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier subscript identifier slice identifier
|
Write all the data to a descriptor.
|
def getServiceLevel(self):
command = '$GE'
settings = self.sendCommand(command)
flags = int(settings[2], 16)
return (flags & 0x0001) + 1
|
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list subscript identifier integer integer return_statement binary_operator parenthesized_expression binary_operator identifier integer integer
|
Returns the service level
|
def fan_triangulate(indices):
if len(indices[0]) != 4:
raise ValueError("Assumes working with a sequence of quad indices")
new_indices = []
for face in indices:
new_indices.extend([face[:-1], face[1:]])
return np.array(new_indices)
|
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list subscript identifier integer integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list list subscript identifier slice unary_operator integer subscript identifier slice integer return_statement call attribute identifier identifier argument_list identifier
|
Return an array of vertices in triangular order using a fan triangulation algorithm.
|
def deactivate(profile='default'):
with jconfig(profile) as config:
deact = True;
if not getattr(config.NotebookApp.contents_manager_class, 'startswith',lambda x:False)('jupyterdrive'):
deact=False
if 'gdrive' not in getattr(config.NotebookApp.tornado_settings,'get', lambda _,__:'')('contents_js_source',''):
deact=False
if deact:
del config['NotebookApp']['tornado_settings']['contents_js_source']
del config['NotebookApp']['contents_manager_class']
|
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier true if_statement not_operator call call identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end lambda lambda_parameters identifier false argument_list string string_start string_content string_end block expression_statement assignment identifier false if_statement comparison_operator string string_start string_content string_end call call identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end lambda lambda_parameters identifier identifier string string_start string_end argument_list string string_start string_content string_end string string_start string_end block expression_statement assignment identifier false if_statement identifier block delete_statement subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end delete_statement subscript subscript identifier string string_start string_content string_end string string_start string_content string_end
|
should be a matter of just unsetting the above keys
|
def processEnded(self, reason):
log_debug("{name} process exited", name=self.name)
if self.deferred:
if reason.type == ProcessDone:
self.deferred.callback(reason.value.exitCode)
elif reason.type == ProcessTerminated:
self.deferred.errback(reason)
return self.deferred
|
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier if_statement attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier elif_clause comparison_operator attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement attribute identifier identifier
|
Connected process shut down
|
def remove_resource_file(issue, filepath, ignore_layouts):
if os.path.exists(filepath) and (ignore_layouts is False or issue.elements[0][0] != 'layout'):
print('removing resource: {0}'.format(filepath))
os.remove(os.path.abspath(filepath))
|
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator call attribute attribute identifier identifier identifier argument_list identifier parenthesized_expression boolean_operator comparison_operator identifier false comparison_operator subscript subscript attribute identifier identifier integer integer 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 expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier
|
Delete a file from the filesystem
|
def usages(self):
row, col = self.editor.cursor()
self.log.debug('usages: in')
self.call_options[self.call_id] = {
"word_under_cursor": self.editor.current_word(),
"false_resp_msg": "Not a valid symbol under the cursor"}
self.send_at_point("UsesOfSymbol", row, col)
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier attribute identifier identifier dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier
|
Request usages of whatever at cursor.
|
def open(self, fn):
"Open image in `fn`, subclass and overwrite for custom behavior."
return open_image(fn, convert_mode=self.convert_mode, after_open=self.after_open)
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end return_statement call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Open image in `fn`, subclass and overwrite for custom behavior.
|
def put(self, event):
self.log("Configuration put request ",
event.user)
try:
component = model_factory(Schema).find_one({
'uuid': event.data['uuid']
})
component.update(event.data)
component.save()
response = {
'component': 'hfos.ui.configurator',
'action': 'put',
'data': True
}
self.log('Updated component configuration:',
component.name)
self.fireEvent(reload_configuration(component.name))
except (KeyError, ValueError, ValidationError, PermissionError) as e:
response = {
'component': 'hfos.ui.configurator',
'action': 'put',
'data': False
}
self.log('Storing component configuration failed: ',
type(e), e, exc=True, lvl=error)
self.fireEvent(send(event.client.uuid, response))
return
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier try_statement block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list dictionary pair string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier except_clause as_pattern tuple identifier identifier identifier identifier as_pattern_target identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier identifier keyword_argument identifier true keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier identifier return_statement
|
Store a given configuration
|
async def set_as_default_gateway(self):
interface = self._data['interface']
await interface._handler.set_default_gateway(
system_id=interface.node.system_id, id=interface.id,
link_id=self.id)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement await call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Set this link as the default gateway for the node.
|
def _formatOntologyTerm(self, element, element_type):
elementClause = None
if isinstance(element, dict) and element.get('terms'):
elements = []
for _term in element['terms']:
if _term.get('id'):
elements.append('?{} = <{}> '.format(
element_type, _term['id']))
else:
elements.append('?{} = <{}> '.format(
element_type, self._toNamespaceURL(_term['term'])))
elementClause = "({})".format(" || ".join(elements))
return elementClause
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier none if_statement boolean_operator call identifier argument_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier list for_statement identifier subscript identifier string string_start string_content string_end block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier subscript identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
|
Formats the ontology terms for query
|
def add_callback(self, callback, *callback_args, **callback_kwargs):
return self.add_callbacks(callback, callback_args=callback_args,
callback_kwargs=callback_kwargs)
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Add a callback without an associated errback.
|
def _one(self, query):
try:
result = query.one()
if result.has_expired(self._expirations):
raise NotFoundError
return result
except (NoResultFound, MultipleResultsFound):
raise NotFoundError
|
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list attribute identifier identifier block raise_statement identifier return_statement identifier except_clause tuple identifier identifier block raise_statement identifier
|
Gets one row from the query. Raises NotFoundError if there isn't a row or if there are multiple rows
|
def find_console_handler(logger):
for handler in logger.handlers:
if (isinstance(handler, logging.StreamHandler) and
handler.stream == sys.stderr):
return handler
|
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block if_statement parenthesized_expression boolean_operator call identifier argument_list identifier attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block return_statement identifier
|
Return a stream handler, if it exists.
|
def format_from_extension(self, extension):
formats = [name
for name, format in self._formats.items()
if format.get('file_extension', None) == extension]
if len(formats) == 0:
return None
elif len(formats) == 2:
raise RuntimeError("Several extensions are registered with "
"that extension; please specify the format "
"explicitly.")
else:
return formats[0]
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement none elif_clause comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end else_clause block return_statement subscript identifier integer
|
Find a format from its extension.
|
def to_bytes(s):
if isinstance(s, bytes):
return s
if isinstance(s, str) or is_unicode(s):
return s.encode("utf-8")
try:
return unicode(s).encode("utf-8")
except NameError:
return str(s).encode("utf-8")
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement identifier if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block return_statement call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end except_clause identifier block return_statement call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end
|
Convert an item into bytes.
|
def _enable_cleanup(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
result = func(*args, **kwargs)
self.cleanup(self)
return result
return wrapper
|
module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier return_statement identifier
|
Execute cleanup operation when the decorated function completed.
|
def parse(cls, parser, text, pos):
match = cls.regex.match(text)
if match:
if match.group(0).lower() not in cls.grammar:
result = text, SyntaxError(repr(match.group(0)) + " is not a member of " + repr(cls.grammar))
else:
result = text[len(match.group(0)):], cls(match.group(0))
else:
result = text, SyntaxError("expecting " + repr(cls.__name__))
return result
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block if_statement comparison_operator call attribute call attribute identifier identifier argument_list integer identifier argument_list attribute identifier identifier block expression_statement assignment identifier expression_list identifier call identifier argument_list binary_operator binary_operator call identifier argument_list call attribute identifier identifier argument_list integer string string_start string_content string_end call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier expression_list subscript identifier slice call identifier argument_list call attribute identifier identifier argument_list integer call identifier argument_list call attribute identifier identifier argument_list integer else_clause block expression_statement assignment identifier expression_list identifier call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list attribute identifier identifier return_statement identifier
|
Checks if terminal token is a keyword after lower-casing it.
|
def rate(self, currency):
if not self._backend:
raise ExchangeBackendNotInstalled()
return self._backend.rate(currency)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Return quotation between the base and another currency
|
def py_bisect(f, a, b, args=(), xtol=_xtol, rtol=_rtol, maxiter=_iter,
ytol=None, full_output=False, disp=True):
fa = f(a, *args)
fb = f(b, *args)
if fa*fb > 0.0:
raise ValueError("f(a) and f(b) must have different signs")
elif fa == 0.0:
return a
elif fb == 0.0:
return b
dm = b - a
iterations = 0.0
for i in range(maxiter):
dm *= 0.5
xm = a + dm
fm = f(xm, *args)
if fm*fa >= 0.0:
a = xm
abs_dm = fabs(dm)
if fm == 0.0:
return xm
elif ytol is not None:
if (abs_dm < xtol + rtol*abs_dm) and abs(fm) < ytol:
return xm
elif (abs_dm < xtol + rtol*abs_dm):
return xm
raise UnconvergedError("Failed to converge after %d iterations" %maxiter)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier tuple default_parameter identifier identifier default_parameter identifier identifier default_parameter identifier identifier default_parameter identifier none default_parameter identifier false default_parameter identifier true block expression_statement assignment identifier call identifier argument_list identifier list_splat identifier expression_statement assignment identifier call identifier argument_list identifier list_splat identifier if_statement comparison_operator binary_operator identifier identifier float block raise_statement call identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier float block return_statement identifier elif_clause comparison_operator identifier float block return_statement identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier float for_statement identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier float expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list identifier list_splat identifier if_statement comparison_operator binary_operator identifier identifier float block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier float block return_statement identifier elif_clause comparison_operator identifier none block if_statement boolean_operator parenthesized_expression comparison_operator identifier binary_operator identifier binary_operator identifier identifier comparison_operator call identifier argument_list identifier identifier block return_statement identifier elif_clause parenthesized_expression comparison_operator identifier binary_operator identifier binary_operator identifier identifier block return_statement identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
|
Port of SciPy's C bisect routine.
|
def delete(self, params, args, data):
ctx = self._create_context(params, args, data)
row_id = ctx.get_row_id()
if row_id:
deleted = self._delete_one(row_id, ctx)
if deleted:
return ResourceResult(body={})
else:
return NOT_FOUND
else:
return NOT_FOUND
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block return_statement call identifier argument_list keyword_argument identifier dictionary else_clause block return_statement identifier else_clause block return_statement identifier
|
Supports only singular delete and adds proper http status.
|
def analysis_info(self, webid):
response = self._post(self.apiurl + "/v2/analysis/info", data={'apikey': self.apikey, 'webid': webid})
return self._raise_or_extract(response)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier
|
Show the status and most important attributes of an analysis.
|
def license2marc(self, key, value):
return {
'a': value.get('license'),
'b': value.get('imposing'),
'u': value.get('url'),
'3': value.get('material'),
}
|
module function_definition identifier parameters identifier identifier identifier block return_statement dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end
|
Populate the ``540`` MARC field.
|
def GetClientStates(self, client_list, client_chunk=50):
for client_group in collection.Batch(client_list, client_chunk):
for fd in aff4.FACTORY.MultiOpen(
client_group,
mode="r",
aff4_type=aff4_grr.VFSGRRClient,
token=self.token):
result = {}
result["age"] = fd.Get(fd.Schema.PING)
result["hostname"] = fd.Get(fd.Schema.HOSTNAME)
yield (fd.urn, result)
|
module function_definition identifier parameters identifier identifier default_parameter identifier integer block for_statement identifier call attribute identifier identifier argument_list identifier identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement yield tuple attribute identifier identifier identifier
|
Take in a client list and return dicts with their age and hostname.
|
def targets_for_class(self, target, classname):
targets_with_class = set()
for target in target.closure():
for one_class in self._target_classes(target):
if classname in one_class:
targets_with_class.add(target)
break
return targets_with_class
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier break_statement return_statement identifier
|
Search which targets from `target`'s transitive dependencies contain `classname`.
|
def createCatalog(config,roi=None,lon=None,lat=None):
import ugali.observation.catalog
if roi is None: roi = createROI(config,lon,lat)
catalog = ugali.observation.catalog.Catalog(config,roi=roi)
return catalog
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block import_statement dotted_name identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier keyword_argument identifier identifier return_statement identifier
|
Create a catalog object
|
def write_question(self, question):
self.write_name(question.name)
self.write_short(question.type)
self.write_short(question.clazz)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Writes a question to the packet
|
def _run_formula(self, variable, population, period):
formula = variable.get_formula(period)
if formula is None:
return None
if self.trace:
parameters_at = self.trace_parameters_at_instant
else:
parameters_at = self.tax_benefit_system.get_parameters_at_instant
if formula.__code__.co_argcount == 2:
array = formula(population, period)
else:
array = formula(population, period, parameters_at)
self._check_formula_result(array, variable, population, period)
return array
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement none if_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier integer block expression_statement assignment identifier call identifier argument_list identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier return_statement identifier
|
Find the ``variable`` formula for the given ``period`` if it exists, and apply it to ``population``.
|
def send(self, event):
event_str = json.dumps(event, cls=DateTimeJSONEncoder)
if self.max_event_size is None or len(event_str) <= self.max_event_size:
self.log(event_str)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Send the event to the standard python logger
|
def build_json(self, guid):
upserts = []
for value in self.upserts:
upserts.append({"value": value, "criteria": self.upserts[value]})
return json.dumps({'replace_all': self.replace_all, 'guid': guid,
'complete': self.complete, 'upserts': upserts, 'deletes': self.deletes})
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block 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 subscript attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier
|
Build JSON with the input guid
|
def rename(self, from_, to):
blueprint = self._create_blueprint(from_)
blueprint.rename(to)
self._build(blueprint)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
|
Rename a table on the schema.
|
def to_torrent(magnet_link):
infoHash = parse_magnet(magnet_link)['infoHash']
torcache = 'http://torcache.net/torrent/' + infoHash + '.torrent'
torrage = 'https://torrage.com/torrent/' + infoHash + '.torrent'
reflektor = 'http://reflektor.karmorra.info/torrent/' + \
infoHash + '.torrent'
thetorrent = 'http://TheTorrent.org/'+infoHash
btcache = 'http://www.btcache.me/torrent/'+infoHash
for link in [torcache, torrage, reflektor, btcache, thetorrent]:
try:
print "Checking "+link
response = requests.head(link, headers=HEADERS)
if response.headers['content-type'] in ['application/x-bittorrent',
'application/octet-stream']:
return link
except requests.exceptions.ConnectionError:
pass
return
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end line_continuation identifier string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier binary_operator string string_start string_content string_end identifier for_statement identifier list identifier identifier identifier identifier identifier block try_statement block print_statement binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end block return_statement identifier except_clause attribute attribute identifier identifier identifier block pass_statement return_statement
|
turn a magnet link to a link to a torrent file
|
def visit_GeneratorExp(self, node: ast.GeneratorExp) -> Any:
result = self._execute_comprehension(node=node)
for generator in node.generators:
self.visit(generator.iter)
return result
|
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
|
Compile the generator expression as a function and call it.
|
def _get_id_from_name(self, name):
_filter = {
'placementGroups': {
'name': {'operation': name}
}
}
mask = "mask[id, name]"
results = self.client.call('Account', 'getPlacementGroups', filter=_filter, mask=mask)
return [result['id'] for result in results]
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier return_statement list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier
|
List placement group ids which match the given name.
|
def find_rak():
if hasattr(current_app, 'rak'):
return getattr(current_app, 'rak')
else:
if hasattr(current_app, 'blueprints'):
blueprints = getattr(current_app, 'blueprints')
for blueprint_name in blueprints:
if hasattr(blueprints[blueprint_name], 'rak'):
return getattr(blueprints[blueprint_name], 'rak')
|
module function_definition identifier parameters block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement call identifier argument_list identifier string string_start string_content string_end else_clause block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end for_statement identifier identifier block if_statement call identifier argument_list subscript identifier identifier string string_start string_content string_end block return_statement call identifier argument_list subscript identifier identifier string string_start string_content string_end
|
Find our instance of Rak, navigating Local's and possible blueprints.
|
def append(self, content, encoding='utf8'):
if not self.parent.exists:
self.parent.create()
with open(self._filename, "ab") as output_file:
if not is_text(content):
Log.error(u"expecting to write unicode only")
output_file.write(content.encode(encoding))
output_file.write(b"\n")
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block if_statement not_operator attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block if_statement not_operator call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end
|
add a line to file
|
def untokenize_without_newlines(tokens):
text = ''
last_row = 0
last_column = -1
for t in tokens:
token_string = t[1]
(start_row, start_column) = t[2]
(end_row, end_column) = t[3]
if start_row > last_row:
last_column = 0
if (
(start_column > last_column or token_string == '\n') and
not text.endswith(' ')
):
text += ' '
if token_string != '\n':
text += token_string
last_row = end_row
last_column = end_column
return text.rstrip()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier integer expression_statement assignment identifier unary_operator integer for_statement identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment tuple_pattern identifier identifier subscript identifier integer expression_statement assignment tuple_pattern identifier identifier subscript identifier integer if_statement comparison_operator identifier identifier block expression_statement assignment identifier integer if_statement parenthesized_expression boolean_operator parenthesized_expression boolean_operator comparison_operator identifier identifier comparison_operator identifier string string_start string_content escape_sequence string_end not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content escape_sequence string_end block expression_statement augmented_assignment identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier identifier return_statement call attribute identifier identifier argument_list
|
Return source code based on tokens.
|
def setCursorSize(self, p):
'sets width based on diagonal corner p'
self.cursorBox = BoundingBox(self.cursorBox.xmin, self.cursorBox.ymin, p.x, p.y)
self.cursorBox.w = max(self.cursorBox.w, self.canvasCharWidth)
self.cursorBox.h = max(self.cursorBox.h, self.canvasCharHeight)
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier
|
sets width based on diagonal corner p
|
def _listdir(self, path):
if self._user is None:
return os.listdir(path)
else:
args = self._build_cmdline(['/bin/ls', '-1A', path])
return subprocess.check_output(args, stderr=DEVNULL).decode('utf-8', errors='ignore').split('\n')
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block return_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end identifier return_statement call attribute call attribute call attribute identifier identifier argument_list identifier keyword_argument identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end identifier argument_list string string_start string_content escape_sequence string_end
|
Return the list of files in a directory, assuming that our user can read it.
|
def _AssertDataIsList(key, lst):
if not isinstance(lst, list) and not isinstance(lst, tuple):
raise NotAListError('%s must be a list' % key)
for element in lst:
if not isinstance(element, str):
raise ElementNotAStringError('Unsupported list element %s found in %s',
(element, lst))
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator not_operator call identifier argument_list identifier identifier not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end tuple identifier identifier
|
Assert that lst contains list data and is not structured.
|
def send(self, endpoint, json_message):
_send_event_task.spool(endpoint=endpoint, json_message=json_message)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
|
Queues the message to be sent.
|
def clean(self, elements):
cleanelements = []
for i in xrange(len(elements)):
if isempty(elements[i]):
return []
next = elements[i]
if isinstance(elements[i], (list, tuple)):
next = self.clean(elements[i])
if next:
cleanelements.append(elements[i])
return cleanelements
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list call identifier argument_list identifier block if_statement call identifier argument_list subscript identifier identifier block return_statement list expression_statement assignment identifier subscript identifier identifier if_statement call identifier argument_list subscript identifier identifier tuple identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list subscript identifier identifier return_statement identifier
|
Removes empty or incomplete answers.
|
def help_text(self):
help_text = '\n'.join(sorted(get_commands().keys()))
help_text = "\nCommands:\n" + help_text
return help_text
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list call identifier argument_list call attribute call identifier argument_list identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end identifier return_statement identifier
|
Formats and prints the help text from the command list
|
def config(self, steps_per_epoch, starting_epoch, max_epoch):
self.starting_epoch = int(starting_epoch)
self.max_epoch = int(max_epoch)
self.steps_per_epoch = int(steps_per_epoch)
assert self.steps_per_epoch >= 0 and self.max_epoch >= 0
self._epoch_num = starting_epoch - 1
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier assert_statement boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer expression_statement assignment attribute identifier identifier binary_operator identifier integer
|
Configure the loop given the settings.
|
def compare_balance(self, operator, or_equals, amount):
amount = int(amount)
if operator == 'less':
if or_equals:
self.assertLessEqual(self.balance, amount)
else:
self.assertLess(self.balance, amount)
elif or_equals:
self.assertGreaterEqual(self.balance, amount)
else:
self.assertGreater(self.balance, amount)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier elif_clause identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
|
Additional step using regex matcher to compare the current balance with some number
|
def encode (self):
delay_s = int( math.floor(self.delay) )
delay_ms = int( (self.delay - delay_s) * 255.0 )
return struct.pack('>H', delay_s) + struct.pack('B', delay_ms)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator parenthesized_expression binary_operator attribute identifier identifier identifier float return_statement binary_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier
|
Encodes this SeqDelay to a binary bytearray.
|
def unique_lorem(anon, obj, field, val):
return anon.faker.unique_lorem(field=field)
|
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier
|
Generates a unique paragraph of lorem ipsum text
|
def handle_raw_output(ctx, data):
if ctx.obj['format'] == 'json':
print(json_dump(data))
exit(0)
if ctx.obj['format'] == 'yaml':
print(yaml_dump(data), end='')
exit(0)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call identifier argument_list call identifier argument_list identifier expression_statement call identifier argument_list integer if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call identifier argument_list call identifier argument_list identifier keyword_argument identifier string string_start string_end expression_statement call identifier argument_list integer
|
If a raw output format is set, dump data and exit
|
def strip_byte_order_mark(cls, data):
encoding = None
if (len(data) >= 4) and (data[:2] == b'\xfe\xff') \
and (data[2:4] != '\x00\x00'):
encoding = 'utf-16be'
data = data[2:]
elif (len(data) >= 4) and (data[:2] == b'\xff\xfe') \
and (data[2:4] != '\x00\x00'):
encoding = 'utf-16le'
data = data[2:]
elif data[:3] == b'\xef\xbb\xbf':
encoding = 'utf-8'
data = data[3:]
elif data[:4] == b'\x00\x00\xfe\xff':
encoding = 'utf-32be'
data = data[4:]
elif data[:4] == b'\xff\xfe\x00\x00':
encoding = 'utf-32le'
data = data[4:]
return data, encoding
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none if_statement boolean_operator boolean_operator parenthesized_expression comparison_operator call identifier argument_list identifier integer parenthesized_expression comparison_operator subscript identifier slice integer string string_start string_content escape_sequence escape_sequence string_end line_continuation parenthesized_expression comparison_operator subscript identifier slice integer integer string string_start string_content escape_sequence escape_sequence string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer elif_clause boolean_operator boolean_operator parenthesized_expression comparison_operator call identifier argument_list identifier integer parenthesized_expression comparison_operator subscript identifier slice integer string string_start string_content escape_sequence escape_sequence string_end line_continuation parenthesized_expression comparison_operator subscript identifier slice integer integer string string_start string_content escape_sequence escape_sequence string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer elif_clause comparison_operator subscript identifier slice integer string string_start string_content escape_sequence escape_sequence escape_sequence string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer elif_clause comparison_operator subscript identifier slice integer string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer elif_clause comparison_operator subscript identifier slice integer string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer return_statement expression_list identifier identifier
|
If a byte-order mark is present, strip it and return the encoding it implies.
|
def get(self):
config = self.get_block('^router bgp .*')
if not config:
return None
response = dict()
response.update(self._parse_bgp_as(config))
response.update(self._parse_router_id(config))
response.update(self._parse_max_paths(config))
response.update(self._parse_shutdown(config))
response.update(self._parse_networks(config))
response['neighbors'] = self.neighbors.getall()
return response
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block return_statement none expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list return_statement identifier
|
Returns the bgp routing configuration as a dict object
|
def filter_zone(self, data):
if self.private_zone is not None:
if data['Config']['PrivateZone'] != self.str2bool(self.private_zone):
return False
if data['Name'] != '{0}.'.format(self.domain):
return False
return True
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block if_statement comparison_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier block return_statement false if_statement comparison_operator subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier block return_statement false return_statement true
|
Check if a zone is private
|
def process_response(self, request, response):
if not self.should_cache(request, response):
return response
response = self.patch_headers(response)
self.set_cache(request, response)
return response
|
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
|
Sets the cache and deals with caching headers if needed
|
def visit(self, node: AST, dfltChaining: bool = True) -> str:
if node is None:
return ''
if isinstance(node, ast.Expression):
return self.visit(node.body)
method = 'visit_' + node.__class__.__name__
visitor = getattr(self, method, self.generic_visit)
return visitor(node, dfltChaining)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier true type identifier block if_statement comparison_operator identifier none block return_statement string string_start string_end if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier attribute identifier identifier return_statement call identifier argument_list identifier identifier
|
Process `node` by dispatching to a handler.
|
def column_types(self):
column_types = {}
for c in self.sqla_columns:
column_types[c.name] = c.type
return column_types
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier attribute identifier identifier return_statement identifier
|
Return a dict mapping column name to type for all columns in table
|
def setupCentral(self):
self.central = TabsWindow(self.bin_windows, self)
self.setCentralWidget(self.central)
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Setup empty window supporting tabs at startup.
|
def parse(binary, **params):
binary = io.BytesIO(binary)
collection = list()
with tarfile.TarFile(fileobj=binary, mode='r') as tar:
for tar_info in tar.getmembers():
content_type, encoding = mimetypes.guess_type(tar_info.name)
content = tar.extractfile(tar_info)
content = content_encodings.get(encoding).decode(content)
content = content_types.get(content_type).parse(content, **params)
collection.apppend((tar_info.name, content))
return collection
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list tuple attribute identifier identifier identifier return_statement identifier
|
Turns a TAR file into a frozen sample.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.