code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def process_file(self,filename=None, format=None):
rdfgraph = rdflib.Graph()
if format is None:
if filename.endswith(".ttl"):
format='turtle'
elif filename.endswith(".rdf"):
format='xml'
rdfgraph.parse(filename, format=format)
return self.process_rdfgraph(rdfgraph)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier
|
Parse a file into an ontology object, using rdflib
|
def prune_feed_map(meta_graph, feed_map):
node_names = [x.name + ":0" for x in meta_graph.graph_def.node]
keys_to_delete = []
for k, _ in feed_map.items():
if k not in node_names:
keys_to_delete.append(k)
for k in keys_to_delete:
del feed_map[k]
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension binary_operator attribute identifier identifier string string_start string_content string_end for_in_clause identifier attribute attribute identifier identifier identifier expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block delete_statement subscript identifier identifier
|
Function to prune the feedmap of nodes which no longer exist.
|
def to_polygon(self):
x,y = self.corners.T
vertices = PixCoord(x=x, y=y)
return PolygonPixelRegion(vertices=vertices, meta=self.meta,
visual=self.visual)
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Return a 4-cornered polygon equivalent to this rectangle
|
def status():
for plugin, package, filename in available_migrations():
migration = get_migration(plugin, filename)
if migration:
status = green(migration['date'].strftime(DATE_FORMAT))
else:
status = yellow('Not applied')
log_status(plugin, filename, status)
|
module function_definition identifier parameters block for_statement pattern_list identifier identifier identifier call identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier identifier identifier
|
Display the database migrations status
|
def _default_objc(self):
objc = ctypes.cdll.LoadLibrary(find_library('objc'))
objc.objc_getClass.restype = ctypes.c_void_p
objc.sel_registerName.restype = ctypes.c_void_p
objc.objc_msgSend.restype = ctypes.c_void_p
objc.objc_msgSend.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
return objc
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier list attribute identifier identifier attribute identifier identifier return_statement identifier
|
Load the objc library using ctypes.
|
def dynamips_auto_idlepc(self):
return (yield from self._compute.get("/projects/{}/{}/nodes/{}/auto_idlepc".format(self._project.id, self._node_type, self._id), timeout=240)).json
|
module function_definition identifier parameters identifier block return_statement attribute parenthesized_expression yield call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier integer identifier
|
Compute the idle PC for a dynamips node
|
def combine_focus_with_prev(self):
above, ignore = self.get_prev(self.focus)
if above is None:
return
focus = self.lines[self.focus]
above.set_edit_pos(len(above.edit_text))
above.set_edit_text(above.edit_text + focus.edit_text)
del self.lines[self.focus]
self.focus -= 1
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block return_statement expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier attribute identifier identifier delete_statement subscript attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer
|
Combine the focus edit widget with the one above.
|
def reset(self):
import tqdm
self.iter = 0
self.pbar = tqdm.tqdm(total=self.niter, **self.kwargs)
|
module function_definition identifier parameters identifier block import_statement dotted_name identifier expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier dictionary_splat attribute identifier identifier
|
Set `iter` to 0.
|
def _filter_attributes(self, keyset):
filtered = self._filter_keys(self.to_dict(), keyset)
return Language.make(**filtered)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list dictionary_splat identifier
|
Return a copy of this object with a subset of its attributes set.
|
def serialize(self):
return {
'word': self.word,
'pos': self.pos,
'label': self.label,
'dependency': self.dependency,
'has_cjk': self.has_cjk(),
}
|
module function_definition identifier parameters identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list
|
Returns serialized chunk data in dictionary.
|
def runGlob(self, path, **kwargs):
def commandComplete(cmd):
return cmd.updates['files'][-1]
return self.runRemoteCommand('glob', {'path': path,
'logEnviron': self.logEnviron, },
evaluateCommand=commandComplete, **kwargs)
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block function_definition identifier parameters identifier block return_statement subscript subscript attribute identifier identifier string string_start string_content string_end unary_operator integer return_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier keyword_argument identifier identifier dictionary_splat identifier
|
find files matching a shell-style pattern
|
def send(self, url, data, headers):
req = urllib2.Request(url, headers=headers)
try:
response = urlopen(
url=req,
data=data,
timeout=self.timeout,
verify_ssl=self.verify_ssl,
ca_certs=self.ca_certs,
)
except urllib2.HTTPError as exc:
msg = exc.headers.get('x-sentry-error')
code = exc.getcode()
if code == 429:
try:
retry_after = int(exc.headers.get('retry-after'))
except (ValueError, TypeError):
retry_after = 0
raise RateLimited(msg, retry_after)
elif msg:
raise APIError(msg, code)
else:
raise
return response
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier integer block try_statement block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end except_clause tuple identifier identifier block expression_statement assignment identifier integer raise_statement call identifier argument_list identifier identifier elif_clause identifier block raise_statement call identifier argument_list identifier identifier else_clause block raise_statement return_statement identifier
|
Sends a request to a remote webserver using HTTP POST.
|
def find_available_vc_vers(self):
ms = self.ri.microsoft
vckeys = (self.ri.vc, self.ri.vc_for_python, self.ri.vs)
vc_vers = []
for hkey in self.ri.HKEYS:
for key in vckeys:
try:
bkey = winreg.OpenKey(hkey, ms(key), 0, winreg.KEY_READ)
except (OSError, IOError):
continue
subkeys, values, _ = winreg.QueryInfoKey(bkey)
for i in range(values):
try:
ver = float(winreg.EnumValue(bkey, i)[0])
if ver not in vc_vers:
vc_vers.append(ver)
except ValueError:
pass
for i in range(subkeys):
try:
ver = float(winreg.EnumKey(bkey, i))
if ver not in vc_vers:
vc_vers.append(ver)
except ValueError:
pass
return sorted(vc_vers)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier tuple attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier list for_statement identifier attribute attribute identifier identifier identifier block for_statement identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier call identifier argument_list identifier integer attribute identifier identifier except_clause tuple identifier identifier block continue_statement expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier for_statement identifier call identifier argument_list identifier block try_statement block expression_statement assignment identifier call identifier argument_list subscript call attribute identifier identifier argument_list identifier identifier integer if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement for_statement identifier call identifier argument_list identifier block try_statement block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement return_statement call identifier argument_list identifier
|
Find all available Microsoft Visual C++ versions.
|
def find_signature_inputs_from_multivalued_ops(inputs):
dense_inputs = []
for name, tensor in sorted(inputs.items()):
if isinstance(tensor, tf.SparseTensor):
dense_inputs.extend(("%s.%s" % (name, attr), getattr(tensor, attr))
for attr in ("indices", "values", "dense_shape"))
else:
dense_inputs.append((name, tensor))
warnings = [(name, tensor.name) for name, tensor in dense_inputs
if len(tensor.op.outputs) != 1]
if warnings:
return (
"WARNING: The inputs declared in hub.add_signature() should be tensors "
"from ops with a single output, or else uses of tf.colocate_with() on "
"that op can trigger fatal errors when the module is applied and "
"colocation constraints have to be rewritten.\nAffected inputs: %s" %
", ".join("%s='%s'" % pair for pair in warnings))
return None
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier generator_expression tuple binary_operator string string_start string_content string_end tuple identifier identifier call identifier argument_list identifier identifier for_in_clause identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list tuple identifier identifier expression_statement assignment identifier list_comprehension tuple identifier attribute identifier identifier for_in_clause pattern_list identifier identifier identifier if_clause comparison_operator call identifier argument_list attribute attribute identifier identifier identifier integer if_statement identifier block return_statement parenthesized_expression binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content escape_sequence string_end call attribute string string_start string_content string_end identifier generator_expression binary_operator string string_start string_content string_end identifier for_in_clause identifier identifier return_statement none
|
Returns error message for module inputs from ops with multiple outputs.
|
def _get_vector_tile(self, x_tile, y_tile, z_tile):
cache_file = "mapscache/{}.{}.{}.json".format(z_tile, x_tile, y_tile)
if cache_file not in self._tiles:
if os.path.isfile(cache_file):
with open(cache_file, 'rb') as f:
tile = json.loads(f.read().decode('utf-8'))
else:
url = _VECTOR_URL.format(z_tile, x_tile, y_tile, _KEY)
data = requests.get(url).content
try:
tile = mapbox_vector_tile.decode(data)
with open(cache_file, mode='w') as f:
json.dump(literal_eval(repr(tile)), f)
except DecodeError:
tile = None
if tile:
self._tiles[cache_file] = [x_tile, y_tile, z_tile, tile, False]
if len(self._tiles) > _CACHE_SIZE:
self._tiles.popitem(False)
self._screen.force_update()
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier if_statement comparison_operator identifier attribute identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier identifier except_clause identifier block expression_statement assignment identifier none if_statement identifier block expression_statement assignment subscript attribute identifier identifier identifier list identifier identifier identifier identifier false if_statement comparison_operator call identifier argument_list attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list false expression_statement call attribute attribute identifier identifier identifier argument_list
|
Load up a single vector tile.
|
def _write_min_gradient(self)->None:
"Writes the minimum of the gradients to Tensorboard."
min_gradient = min(x.data.min() for x in self.gradients)
self._add_gradient_scalar('min_gradient', scalar_value=min_gradient)
|
module function_definition identifier parameters identifier type none block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier generator_expression call attribute attribute identifier identifier identifier argument_list for_in_clause identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier
|
Writes the minimum of the gradients to Tensorboard.
|
def get(self, uri, params={}):
logging.debug("Requesting URL: "+str(urlparse.urljoin(self.BASE_URL, uri)))
return requests.get(urlparse.urljoin(self.BASE_URL, uri),
params=params, verify=False,
auth=self.auth)
|
module function_definition identifier parameters identifier identifier default_parameter identifier dictionary block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier false keyword_argument identifier attribute identifier identifier
|
A generic method to make GET requests
|
def new_preload():
testrunner_image = get_testrunner_image()
local_image = testrunner_image.rsplit(':')[-2].rsplit('/')[-1]
version_file = 'testrunner_version.txt'
template = yaml.safe_load(f
)
return 'preload', template
|
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier subscript call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer identifier argument_list string string_start string_content string_end unary_operator integer expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement expression_list string string_start string_content string_end identifier
|
Job running prior to builds - fetches TestRunner image
|
def y1(x, context=None):
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_y1,
(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 value of the second kind Bessel function of order 1 at x.
|
async def handle_request(self, request):
service_name = request.rel_url.query['servicename']
received_code = request.rel_url.query['pairingcode'].lower()
_LOGGER.info('Got pairing request from %s with code %s',
service_name, received_code)
if self._verify_pin(received_code):
cmpg = tags.uint64_tag('cmpg', int(self._pairing_guid, 16))
cmnm = tags.string_tag('cmnm', self._name)
cmty = tags.string_tag('cmty', 'iPhone')
response = tags.container_tag('cmpa', cmpg + cmnm + cmty)
self._has_paired = True
return web.Response(body=response)
return web.Response(status=500)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute subscript attribute attribute identifier identifier identifier string string_start string_content string_end identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier 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 assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end binary_operator binary_operator identifier identifier identifier expression_statement assignment attribute identifier identifier true return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier integer
|
Respond to request if PIN is correct.
|
def stream(self):
stream = self._p4dict.get('stream')
if stream:
return Stream(stream, self._connection)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement identifier block return_statement call identifier argument_list identifier attribute identifier identifier
|
Which stream, if any, the client is under
|
def close_state_machine(self, widget, page_number, event=None):
page = widget.get_nth_page(page_number)
for tab_info in self.tabs.values():
if tab_info['page'] is page:
state_machine_m = tab_info['state_machine_m']
self.on_close_clicked(event, state_machine_m, None, force=False)
return
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier none keyword_argument identifier false return_statement
|
Triggered when the close button in the tab is clicked
|
def write_to(self, group, append=False):
data = self.data
if append is True:
try:
original = read_properties(group)
data = original + data
except EOFError:
pass
data = pickle.dumps(data).replace(b'\x00', b'__NULL__')
group['properties'][...] = np.void(data)
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier true block try_statement block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier identifier except_clause identifier block pass_statement expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end expression_statement assignment subscript subscript identifier string string_start string_content string_end ellipsis call attribute identifier identifier argument_list identifier
|
Writes the properties to a `group`, or append it
|
def addfield(self, pkt, s, val):
v = pkt.tls_session.tls_version
if v and v < 0x0300:
return s
return super(SigLenField, self).addfield(pkt, s, val)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement boolean_operator identifier comparison_operator identifier integer block return_statement identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier
|
With SSLv2 you will never be able to add a sig_len.
|
def smart_crop(crop_w, crop_h, image_path):
cropping = face_and_energy_detector(image_path)
img = Image.open(image_path)
w, h = img.size
scaled_size = get_crop_size(crop_w, crop_h, *img.size)
gravity_x = int(round(scaled_size[0] * cropping.gravity[0]))
gravity_y = int(round(scaled_size[1] * cropping.gravity[1]))
if scaled_size[0] == crop_w:
crop_top, crop_bot = calc_subrange(scaled_size[1], crop_h, gravity_y)
return scaled_size, Rect(left=0, top=crop_top, right=crop_w, bottom=crop_bot)
else:
crop_left, crop_right = calc_subrange(scaled_size[0], crop_w, gravity_x)
return scaled_size, Rect(left=crop_left, top=0, right=crop_right, bottom=crop_h)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier list_splat attribute identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list binary_operator subscript identifier integer subscript attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list call identifier argument_list binary_operator subscript identifier integer subscript attribute identifier identifier integer if_statement comparison_operator subscript identifier integer identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list subscript identifier integer identifier identifier return_statement expression_list identifier call identifier argument_list keyword_argument identifier integer keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment pattern_list identifier identifier call identifier argument_list subscript identifier integer identifier identifier return_statement expression_list identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier identifier keyword_argument identifier identifier
|
Return the scaled image size and crop rectangle
|
def prompt_for_install(self):
print(self.key_info)
repo_key_url = "{0}/{1}".format(self.url, self.repo_signing_key)
print(("warning: Repository key untrusted \n"
"Importing GPG key 0x{0}:\n"
" Userid: \"{1}\"\n"
" From : {2}".format(self.key_info['fingerprint'],
self.key_info['uids'][0],
repo_key_url)))
response = prompt(u'Is this ok: [y/N] ')
if response == 'y':
self.install_key(self.raw_key)
return True
else:
return False
|
module function_definition identifier parameters identifier block expression_statement call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list parenthesized_expression call attribute concatenated_string string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content escape_sequence escape_sequence escape_sequence string_end string string_start string_content string_end identifier argument_list subscript attribute identifier identifier string string_start string_content string_end subscript subscript attribute identifier identifier string string_start string_content string_end integer identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement true else_clause block return_statement false
|
Prompt user to install untrusted repo signing key
|
def register(linter):
linter.register_checker(NewDbFieldWithDefaultChecker(linter))
if not compat.LOAD_CONFIGURATION_SUPPORTED:
load_configuration(linter)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier if_statement not_operator attribute identifier identifier block expression_statement call identifier argument_list identifier
|
Required method to auto register this checker.
|
def full_path(path):
return os.path.realpath(os.path.expanduser(os.path.expandvars(path)))
|
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier
|
Get the real path, expanding links and bashisms
|
def socket_reader(connection: socket, buffer_size: int = 1024):
while connection is not None:
try:
buffer = connection.recv(buffer_size)
if not len(buffer):
raise ConnectionAbortedError
except ConnectionAbortedError:
print('connection aborted')
connection.close()
yield None
except OSError:
print('socket closed')
connection.close()
yield None
else:
yield buffer
|
module function_definition identifier parameters typed_parameter identifier type identifier typed_default_parameter identifier type identifier integer block while_statement comparison_operator identifier none block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator call identifier argument_list identifier block raise_statement identifier except_clause identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement yield none except_clause identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement yield none else_clause block expression_statement yield identifier
|
read data from adb socket
|
def write_template_to_file(conf, template_body):
template_file_name = _get_stack_name(conf) + '-generated-cf-template.json'
with open(template_file_name, 'w') as opened_file:
opened_file.write(template_body)
print('wrote cf-template for %s to disk: %s' % (
get_env(), template_file_name))
return template_file_name
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list identifier return_statement identifier
|
Writes the template to disk
|
def selectionComponents(self):
comps = []
model = self.model()
for comp in self._selectedComponents:
index = model.indexByComponent(comp)
if index is not None:
comps.append(comp)
return comps
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Returns the names of the component types in this selection
|
def add_errors(self, *errors: Union[BaseSchemaError, SchemaErrorCollection]) -> None:
for error in errors:
self._error_cache.add(error)
|
module function_definition identifier parameters identifier typed_parameter list_splat_pattern identifier type generic_type identifier type_parameter type identifier type identifier type none block for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Adds errors to the error store for the schema
|
def _write_marker(self, indent_string, depth, entry, comment):
return '%s%s%s%s%s' % (indent_string,
self._a_to_u('[' * depth),
self._quote(self._decode_element(entry), multiline=False),
self._a_to_u(']' * depth),
self._decode_element(comment))
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block return_statement binary_operator string string_start string_content string_end tuple identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier false call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier call attribute identifier identifier argument_list identifier
|
Write a section marker line
|
def rescale_image(image):
s2_min_value, s2_max_value = 0, 1
out_min_value, out_max_value = 0, 255
image[image > s2_max_value] = s2_max_value
image[image < s2_min_value] = s2_min_value
out_image = out_max_value + (image-s2_min_value)*(out_max_value-out_min_value)/(s2_max_value-s2_min_value)
return out_image.astype(np.uint8)
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier expression_list integer integer expression_statement assignment pattern_list identifier identifier expression_list integer integer expression_statement assignment subscript identifier comparison_operator identifier identifier identifier expression_statement assignment subscript identifier comparison_operator identifier identifier identifier expression_statement assignment identifier binary_operator identifier binary_operator binary_operator parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Normalise and scale image in 0-255 range
|
def match(self, path_info: str) -> MatchResult:
matched = self.regex.match(path_info)
if matched is None:
return None
matchlength = len(matched.group(0))
matchdict = matched.groupdict()
try:
matchdict = self.convert_values(matchdict)
except ValueError:
return None
return MatchResult(matchdict,
matchlength)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block return_statement none return_statement call identifier argument_list identifier identifier
|
parse path_info and detect urlvars of url pattern
|
def blit(self, image, x, y):
x += self.font_bbox[2] - self.bbox[2]
y += self.font_bbox[3] - self.bbox[3]
x += self.font_bbox[0] - self.bbox[0]
y += self.font_bbox[1] - self.bbox[1]
image[y:y+self.height, x:x+self.width] = self.bitmap * 255
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement augmented_assignment identifier binary_operator subscript attribute identifier identifier integer subscript attribute identifier identifier integer expression_statement augmented_assignment identifier binary_operator subscript attribute identifier identifier integer subscript attribute identifier identifier integer expression_statement augmented_assignment identifier binary_operator subscript attribute identifier identifier integer subscript attribute identifier identifier integer expression_statement augmented_assignment identifier binary_operator subscript attribute identifier identifier integer subscript attribute identifier identifier integer expression_statement assignment subscript identifier slice identifier binary_operator identifier attribute identifier identifier slice identifier binary_operator identifier attribute identifier identifier binary_operator attribute identifier identifier integer
|
blit to the image array
|
def render(self, h, w):
'resets plotter, cancels previous render threads, spawns a new render'
self.needsRefresh = False
cancelThread(*(t for t in self.currentThreads if t.name == 'plotAll_async'))
self.labels.clear()
self.resetCanvasDimensions(h, w)
self.render_async()
|
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment attribute identifier identifier false expression_statement call identifier argument_list list_splat generator_expression identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator attribute identifier identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list
|
resets plotter, cancels previous render threads, spawns a new render
|
def _get_network_vswitch_map_by_port_id(self, port_id):
for network_id, vswitch in six.iteritems(self._network_vswitch_map):
if port_id in vswitch['ports']:
return (network_id, vswitch)
return (None, None)
|
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block return_statement tuple identifier identifier return_statement tuple none none
|
Get the vswitch name for the received port id.
|
def delete(self, model):
signals.pre_delete.send(model.__class__, model=model)
param = {'rid_value': self.to_pg(model)[model.rid_field]}
query =
query = query.format(
cols=self.field_cols(model),
rid_field=model.rid_field,
table=model.rtype,
)
result = self.query(query, param=param)
signals.post_delete.send(model.__class__, model=model)
return result
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier return_statement identifier
|
Given a model object instance delete it
|
def _ping(self) -> bool:
assert self.socket is not None
resp = None
try:
self.socket.sendall(b"PINGPING")
resp = self.socket.recv(8)
except Exception:
pass
return resp == b"PONGPONG"
|
module function_definition identifier parameters identifier type identifier block assert_statement comparison_operator attribute identifier identifier none expression_statement assignment identifier none try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer except_clause identifier block pass_statement return_statement comparison_operator identifier string string_start string_content string_end
|
Test if the device is listening.
|
def parse_out_ips(message):
ips = []
for entry in message.answer:
for rdata in entry.items:
ips.append(rdata.to_text())
return ips
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement identifier
|
Given a message, parse out the ips in the answer
|
def _recv_sf(self, data):
self.rx_timer.cancel()
if self.rx_state != ISOTP_IDLE:
warning("RX state was reset because single frame was received")
self.rx_state = ISOTP_IDLE
length = six.indexbytes(data, 0) & 0xf
if len(data) - 1 < length:
return 1
msg = data[1:1 + length]
self.rx_queue.put(msg)
for cb in self.rx_callbacks:
cb(msg)
self.call_release()
return 0
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier integer integer if_statement comparison_operator binary_operator call identifier argument_list identifier integer identifier block return_statement integer expression_statement assignment identifier subscript identifier slice integer binary_operator integer identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement integer
|
Process a received 'Single Frame' frame
|
def execute_from_command_line(argv=None):
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "colab.settings")
from django.conf import settings
if not hasattr(settings, 'SECRET_KEY') and 'initconfig' in sys.argv:
command = initconfig.Command()
command.handle()
else:
utility = ManagementUtility(argv)
utility.execute()
|
module function_definition identifier parameters default_parameter identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end import_from_statement dotted_name identifier identifier dotted_name identifier if_statement boolean_operator not_operator call identifier argument_list identifier string string_start string_content string_end comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
A simple method that runs a ManagementUtility.
|
def fetch(weeks, force):
weeks = get_last_weeks(weeks)
print(weeks)
recommender = RecordRecommender(config)
recommender.fetch_weeks(weeks, overwrite=force)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
|
Fetch newest PageViews and Downloads.
|
def install_hook(ctx):
try:
lint_config = ctx.obj[0]
hooks.GitHookInstaller.install_commit_msg_hook(lint_config)
hook_path = hooks.GitHookInstaller.commit_msg_hook_path(lint_config)
click.echo(u"Successfully installed gitlint commit-msg hook in {0}".format(hook_path))
ctx.exit(0)
except hooks.GitHookInstallerError as e:
click.echo(ustr(e), err=True)
ctx.exit(GIT_CONTEXT_ERROR_CODE)
|
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list identifier
|
Install gitlint as a git commit-msg hook.
|
def _unfold_map(self, display_text_map):
from ..type.primitives import Type
lt_identifier = Id(display_text_map['languageTypeId']).get_identifier()
st_identifier = Id(display_text_map['scriptTypeId']).get_identifier()
ft_identifier = Id(display_text_map['formatTypeId']).get_identifier()
try:
self._language_type = Type(**language_types.get_type_data(lt_identifier))
except AttributeError:
raise NotFound('Language Type: ' + lt_identifier)
try:
self._script_type = Type(**script_types.get_type_data(st_identifier))
except AttributeError:
raise NotFound('Script Type: ' + st_identifier)
try:
self._format_type = Type(**format_types.get_type_data(ft_identifier))
except AttributeError:
raise NotFound('Format Type: ' + ft_identifier)
self._text = display_text_map['text']
|
module function_definition identifier parameters identifier identifier block import_from_statement relative_import import_prefix dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call attribute call identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list dictionary_splat call attribute identifier identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list dictionary_splat call attribute identifier identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list dictionary_splat call attribute identifier identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end
|
Parses a display text dictionary map.
|
def comp_overlap_table(data):
headers = OrderedDict()
headers['comp_rate'] = {
'title': 'Compare rate',
'description': 'Ratio of known variants found in the reference set.',
'namespace': 'GATK',
'min': 0,
'max': 100,
'suffix': '%',
'format': '{:,.2f}',
'scale': 'Blues',
}
headers['concordant_rate'] = {
'title': 'Concordant rate',
'description': 'Ratio of variants matching alleles in the reference set.',
'namespace': 'GATK',
'min': 0,
'max': 100,
'suffix': '%',
'format': '{:,.2f}',
'scale': 'Blues',
}
headers['eval_variants'] = {
'title': 'M Evaluated variants',
'description': 'Number of called variants (millions)',
'namespace': 'GATK',
'min': 0,
'modify': lambda x: float(x) / 1000000.0
}
headers['known_sites'] = {
'title': 'M Known sites',
'description': 'Number of known variants (millions)',
'namespace': 'GATK',
'min': 0,
'modify': lambda x: float(x) / 1000000.0
}
headers['novel_sites'] = {
'title': 'M Novel sites',
'description': 'Number of novel variants (millions)',
'namespace': 'GATK',
'min': 0,
'modify': lambda x: float(x) / 1000000.0
}
table_html = table.plot(data, headers, {'id': 'gatk_compare_overlap', 'table_title': 'GATK - Compare Overlap'})
return table_html
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end lambda lambda_parameters identifier binary_operator call identifier argument_list identifier float expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end lambda lambda_parameters identifier binary_operator call identifier argument_list identifier float expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end lambda lambda_parameters identifier binary_operator call identifier argument_list identifier float expression_statement assignment identifier call attribute identifier identifier argument_list identifier 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 return_statement identifier
|
Build a table from the comp overlaps output.
|
def cufflinks_conversion():
for size, md5, fn in cufflinks_tables:
fn = os.path.join(args.data_dir, fn)
table = fn.replace('.gtf.gz', '.table')
if not _up_to_date(md5, table):
logger.info("Converting Cufflinks GTF %s to table" % fn)
fout = open(table, 'w')
fout.write('id\tscore\tfpkm\n')
x = pybedtools.BedTool(fn)
seen = set()
for i in x:
accession = i['transcript_id'].split('.')[0]
if accession not in seen:
seen.update([accession])
fout.write(
'\t'.join([accession, i.score, i['FPKM']]) + '\n')
fout.close()
|
module function_definition identifier parameters block for_statement pattern_list identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement not_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment identifier subscript call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end integer if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier expression_statement call attribute identifier identifier argument_list binary_operator call attribute string string_start string_content escape_sequence string_end identifier argument_list list identifier attribute identifier identifier subscript identifier string string_start string_content string_end string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list
|
convert Cufflinks output GTF files into tables of score and FPKM.
|
def re_rect(FlowRate, Width, DistCenter, Nu, openchannel):
ut.check_range([FlowRate, ">0", "Flow rate"], [Nu, ">0", "Nu"])
return (4 * FlowRate
* radius_hydraulic(Width, DistCenter, openchannel).magnitude
/ (Width * DistCenter * Nu))
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier string string_start string_content string_end string string_start string_content string_end list identifier string string_start string_content string_end string string_start string_content string_end return_statement parenthesized_expression binary_operator binary_operator binary_operator integer identifier attribute call identifier argument_list identifier identifier identifier identifier parenthesized_expression binary_operator binary_operator identifier identifier identifier
|
Return the Reynolds Number for a rectangular channel.
|
def start_recv(sockfile=None):
if sockfile is not None:
SOCKFILE = sockfile
else:
SOCKFILE = "/tmp/snort_alert"
if os.path.exists(SOCKFILE):
os.unlink(SOCKFILE)
unsock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
unsock.bind(SOCKFILE)
logging.warning('Unix socket start listening...')
while True:
data = unsock.recv(BUFSIZE)
parsed_msg = alert.AlertPkt.parser(data)
if parsed_msg:
yield parsed_msg
|
module function_definition identifier parameters default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement yield identifier
|
Open a server on Unix Domain Socket
|
def _increment(self, what, host):
self.processed[host] = 1
prev = (getattr(self, what)).get(host, 0)
getattr(self, what)[host] = prev+1
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier integer expression_statement assignment identifier call attribute parenthesized_expression call identifier argument_list identifier identifier identifier argument_list identifier integer expression_statement assignment subscript call identifier argument_list identifier identifier identifier binary_operator identifier integer
|
helper function to bump a statistic
|
def _match_replace_binary(cls, ops: list) -> list:
n = len(ops)
if n <= 1:
return ops
ops_left = ops[:n // 2]
ops_right = ops[n // 2:]
return _match_replace_binary_combine(
cls,
_match_replace_binary(cls, ops_left),
_match_replace_binary(cls, ops_right))
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block return_statement identifier expression_statement assignment identifier subscript identifier slice binary_operator identifier integer expression_statement assignment identifier subscript identifier slice binary_operator identifier integer return_statement call identifier argument_list identifier call identifier argument_list identifier identifier call identifier argument_list identifier identifier
|
Reduce list of `ops`
|
def _get_file_index_str(self):
file_index = str(self.file_index)
if self.n_digits is not None:
file_index = file_index.zfill(self.n_digits)
return file_index
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
|
Create a string out of the current file_index
|
def list_devices():
output = {}
for device_id, device in devices.items():
output[device_id] = {
'host': device.host,
'state': device.state
}
return jsonify(devices=output)
|
module function_definition identifier parameters block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier
|
List devices via HTTP GET.
|
def decode_file(fname):
if _debug: decode_file._debug("decode_file %r", fname)
if not pcap:
raise RuntimeError("failed to import pcap")
p = pcap.pcap(fname)
for i, (timestamp, data) in enumerate(p):
try:
pkt = decode_packet(data)
if not pkt:
continue
except Exception as err:
if _debug: decode_file._debug(" - exception decoding packet %d: %r", i+1, err)
continue
pkt._number = i + 1
pkt._timestamp = timestamp
yield pkt
|
module function_definition identifier parameters identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block continue_statement except_clause as_pattern identifier as_pattern_target identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end binary_operator identifier integer identifier continue_statement expression_statement assignment attribute identifier identifier binary_operator identifier integer expression_statement assignment attribute identifier identifier identifier expression_statement yield identifier
|
Given the name of a pcap file, open it, decode the contents and yield each packet.
|
def write(self, buf):
return self.transport_sock.sendto(
buf,
(self.transport_host, self.transport_port)
)
|
module function_definition identifier parameters identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier
|
Raw write to the UDP socket.
|
def VCStoreRefs(self):
if self.vc_ver < 14.0:
return []
return [os.path.join(self.si.VCInstallDir, r'Lib\store\references')]
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier float block return_statement list return_statement list call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end
|
Microsoft Visual C++ store references Libraries
|
def fold_path(path, width=30):
assert isinstance(path, six.string_types)
if len(path) > width:
path.replace(".", ".\n ")
return path
|
module function_definition identifier parameters identifier default_parameter identifier integer block assert_statement call identifier argument_list identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end return_statement identifier
|
Fold a string form of a path so that each element is on separate line
|
def update_configs(self, release):
git_repo = release['git_repo']
git_cache = release['git_cache']
if not os.path.isdir(git_cache):
self.call(['git', 'clone', '--mirror', git_repo, git_cache])
else:
self.call(['git', 'fetch', '--all', '--prune'], cwd=git_cache)
git_dir = release['git_dir'] = os.path.join(release['tmp_dir'],
os.path.basename(git_repo))
self.call(['git', 'clone', '-b', release['git_branch'],
git_cache, git_dir])
if release['delete_repo_files']:
for repo_file in glob.glob(os.path.join(git_dir, '*.repo')):
self.log.info('Deleting %s' % repo_file)
os.unlink(repo_file)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end identifier identifier if_statement subscript identifier string string_start string_content string_end block for_statement identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier
|
Update the fedora-atomic.git repositories for a given release
|
def to_path_globs(self, relpath, conjunction):
return PathGlobs(
include=tuple(os.path.join(relpath, glob) for glob in self._file_globs),
exclude=tuple(os.path.join(relpath, exclude) for exclude in self._excluded_file_globs),
conjunction=conjunction)
|
module function_definition identifier parameters identifier identifier identifier block return_statement call identifier argument_list keyword_argument identifier call identifier generator_expression call attribute attribute identifier identifier identifier argument_list identifier identifier for_in_clause identifier attribute identifier identifier keyword_argument identifier call identifier generator_expression call attribute attribute identifier identifier identifier argument_list identifier identifier for_in_clause identifier attribute identifier identifier keyword_argument identifier identifier
|
Return a PathGlobs representing the included and excluded Files for these patterns.
|
def workers_status(self):
return [self._workers_status[identifier]
for identifier in sorted(self._workers_status.keys())]
|
module function_definition identifier parameters identifier block return_statement list_comprehension subscript attribute identifier identifier identifier for_in_clause identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list
|
The worker status objects sorted by identifier.
|
def main():
neutron_config.register_agent_state_opts_helper(CONF)
common_config.init(sys.argv[1:])
neutron_config.setup_logging()
hnv_agent = HNVAgent()
LOG.info("Agent initialized successfully, now running... ")
hnv_agent.daemon_loop()
|
module function_definition identifier parameters block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier slice integer expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
|
The entry point for the HNV Agent.
|
def transform(row, table):
'Transform row "link" into full URL and add "state" based on "name"'
data = row._asdict()
data["link"] = urljoin("https://pt.wikipedia.org", data["link"])
data["name"], data["state"] = regexp_city_state.findall(data["name"])[0]
return data
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment pattern_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end integer return_statement identifier
|
Transform row "link" into full URL and add "state" based on "name"
|
def rollback(self):
with self.native(writeAccess=True) as conn:
return self._rollback(conn)
|
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list keyword_argument identifier true as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier
|
Rolls back changes to this database.
|
def stash(self, storage, url):
result = {}
if self.is_valid():
upload = self.cleaned_data['upload']
name = storage.save(upload.name, upload)
result['filename'] = os.path.basename(name)
try:
result['url'] = storage.url(name)
except NotImplementedError:
result['url'] = None
result['stored'] = serialize_upload(name, storage, url)
return result
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier try_statement block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment subscript identifier string string_start string_content string_end none expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier identifier identifier return_statement identifier
|
Stores the uploaded file in a temporary storage location.
|
def download_decode(URL, encoding='utf-8', verbose=True):
if verbose:
print("Downloading data from " + URL)
req = Request(URL)
try:
with urlopen(req) as u:
decoded_file = u.read().decode(encoding)
except URLError as e:
if hasattr(e, 'reason'):
print('Server could not be reached.')
print('Reason: ', e.reason)
elif hasattr(e, 'code'):
print('The server couldn\'t fulfill the request.')
print('Error code: ', e.code)
return None
return decoded_file
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier true block if_statement identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier elif_clause call identifier argument_list identifier string string_start string_content string_end block expression_statement call identifier argument_list string string_start string_content escape_sequence string_end expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement none return_statement identifier
|
Downloads data from URL and returns decoded contents.
|
def plot_ac(calc_id):
dstore = util.read(calc_id)
agg_curve = dstore['agg_curve-rlzs']
plt = make_figure(agg_curve)
plt.show()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Aggregate loss curves plotter.
|
def table_metadata(self, database, table):
"Fetch table-specific metadata."
return (self.metadata("databases") or {}).get(database, {}).get(
"tables", {}
).get(
table, {}
)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end return_statement call attribute call attribute call attribute parenthesized_expression boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list identifier dictionary identifier argument_list string string_start string_content string_end dictionary identifier argument_list identifier dictionary
|
Fetch table-specific metadata.
|
def handle_PoisonPillFrame(self, frame):
if self.connection.closed.done():
return
self._close_all(frame.exception)
|
module function_definition identifier parameters identifier identifier block if_statement call attribute attribute attribute identifier identifier identifier identifier argument_list block return_statement expression_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Is sent in case protocol lost connection to server.
|
def location_filter(files_with_tags, location, radius):
on_location = dict()
for f, tags in files_with_tags.items():
if 'GPS GPSLatitude' in tags:
try:
lat = convert_to_decimal(str(tags['GPS GPSLatitude']))
long = convert_to_decimal(str(tags['GPS GPSLongitude']))
except ValueError:
print('{0} has invalid gps info'.format(f))
try:
if haversine(lat, long, location['lat'], location['long']) < radius:
on_location[f] = tags
except InvalidCoordinate:
print('{0} has invalid gps info'.format(f))
return on_location
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator string string_start string_content string_end identifier block try_statement block expression_statement assignment identifier call identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end except_clause identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier try_statement block if_statement comparison_operator call identifier argument_list identifier identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier block expression_statement assignment subscript identifier identifier identifier except_clause identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
|
Get photos taken within the specified radius from a given point.
|
def _simulated_EOT(self, state):
is_manadrain = True
for swap_pair in state.board.potential_swaps():
result_board, destroyed_groups = \
state.board.execute_once(swap=swap_pair,
random_fill=self.random_fill)
if destroyed_groups:
is_manadrain = False
break
if is_manadrain:
end = self._simulated_mana_drain(state)
else:
end = EOT(False)
state.graft_child(end)
return end
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier true for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment pattern_list identifier identifier line_continuation call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier false break_statement if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list false expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Simulate a normal or mana drain EOT and return it.
|
def normalize_features(features):
return (features - N.min(features)) / (N.max(features) - N.min(features))
|
module function_definition identifier parameters identifier block return_statement binary_operator parenthesized_expression binary_operator identifier call attribute identifier identifier argument_list identifier parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier
|
Standardizes features array to fall between 0 and 1
|
def _asdict_anything(val, filter, dict_factory, retain_collection_types):
if getattr(val.__class__, "__attrs_attrs__", None) is not None:
rv = asdict(val, True, filter, dict_factory, retain_collection_types)
elif isinstance(val, (tuple, list, set)):
cf = val.__class__ if retain_collection_types is True else list
rv = cf(
[
_asdict_anything(
i, filter, dict_factory, retain_collection_types
)
for i in val
]
)
elif isinstance(val, dict):
df = dict_factory
rv = df(
(
_asdict_anything(kk, filter, df, retain_collection_types),
_asdict_anything(vv, filter, df, retain_collection_types),
)
for kk, vv in iteritems(val)
)
else:
rv = val
return rv
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end none none block expression_statement assignment identifier call identifier argument_list identifier true identifier identifier identifier elif_clause call identifier argument_list identifier tuple identifier identifier identifier block expression_statement assignment identifier conditional_expression attribute identifier identifier comparison_operator identifier true identifier expression_statement assignment identifier call identifier argument_list list_comprehension call identifier argument_list identifier identifier identifier identifier for_in_clause identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier generator_expression tuple call identifier argument_list identifier identifier identifier identifier call identifier argument_list identifier identifier identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier identifier return_statement identifier
|
``asdict`` only works on attrs instances, this works on anything.
|
def apply_completion(self, completion):
assert isinstance(completion, Completion)
if self.complete_state:
self.go_to_completion(None)
self.complete_state = None
self.delete_before_cursor(-completion.start_position)
self.insert_text(completion.text)
|
module function_definition identifier parameters identifier identifier block assert_statement call identifier argument_list identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list none expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list unary_operator attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Insert a given completion.
|
def generate_data_for_problem(problem):
training_gen, dev_gen, test_gen = _SUPPORTED_PROBLEM_GENERATORS[problem]
num_train_shards = FLAGS.num_shards or 10
tf.logging.info("Generating training data for %s.", problem)
train_output_files = generator_utils.train_data_filenames(
problem + generator_utils.UNSHUFFLED_SUFFIX, FLAGS.data_dir,
num_train_shards)
generator_utils.generate_files(training_gen(), train_output_files,
FLAGS.max_cases)
num_dev_shards = int(num_train_shards * 0.1)
tf.logging.info("Generating development data for %s.", problem)
dev_output_files = generator_utils.dev_data_filenames(
problem + generator_utils.UNSHUFFLED_SUFFIX, FLAGS.data_dir,
num_dev_shards)
generator_utils.generate_files(dev_gen(), dev_output_files)
num_test_shards = int(num_train_shards * 0.1)
test_output_files = []
test_gen_data = test_gen()
if test_gen_data is not None:
tf.logging.info("Generating test data for %s.", problem)
test_output_files = generator_utils.test_data_filenames(
problem + generator_utils.UNSHUFFLED_SUFFIX, FLAGS.data_dir,
num_test_shards)
generator_utils.generate_files(test_gen_data, test_output_files)
all_output_files = train_output_files + dev_output_files + test_output_files
generator_utils.shuffle_dataset(all_output_files)
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier subscript identifier identifier expression_statement assignment identifier boolean_operator attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier float expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier float expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier binary_operator binary_operator identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
Generate data for a problem in _SUPPORTED_PROBLEM_GENERATORS.
|
def _pool_event_lifecycle_cb(conn, pool, event, detail, opaque):
_salt_send_event(opaque, conn, {
'pool': {
'name': pool.name(),
'uuid': pool.UUIDString()
},
'event': _get_libvirt_enum_string('VIR_STORAGE_POOL_EVENT_', event),
'detail': 'unknown'
})
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call identifier argument_list identifier identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call identifier argument_list string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end
|
Storage pool lifecycle events handler
|
def second_derivative_5(var, key):
global derivative_data
import mavutil
tnow = mavutil.mavfile_global.timestamp
if not key in derivative_data:
derivative_data[key] = (tnow, [var]*5)
return 0
(last_time, data) = derivative_data[key]
data.pop(0)
data.append(var)
derivative_data[key] = (tnow, data)
h = (tnow - last_time)
ret = ((data[4] + data[0]) - 2*data[2]) / (4*h**2)
return ret
|
module function_definition identifier parameters identifier identifier block global_statement identifier import_statement dotted_name identifier expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement not_operator comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier tuple identifier binary_operator list identifier integer return_statement integer expression_statement assignment tuple_pattern identifier identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier tuple identifier identifier expression_statement assignment identifier parenthesized_expression binary_operator identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator parenthesized_expression binary_operator subscript identifier integer subscript identifier integer binary_operator integer subscript identifier integer parenthesized_expression binary_operator integer binary_operator identifier integer return_statement identifier
|
5 point 2nd derivative
|
def _set_fields(self):
self.fields = []
self.required_input = []
for member_name, member_object in inspect.getmembers(self.__class__):
if inspect.isdatadescriptor(member_object) and not member_name.startswith("__"):
self.fields.append(member_name)
if member_object.required_input:
self.required_input.append(member_name)
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement boolean_operator call attribute identifier identifier argument_list identifier not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Initialize the fields for data caching.
|
def _get_contigs_to_keep(self, filename):
if filename is None:
return set()
with open(filename) as f:
return {line.rstrip() for line in f}
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement call identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block return_statement set_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier
|
Returns a set of names from file called filename. If filename is None, returns an empty set
|
def lat_to_deg(lat):
if isinstance(lat, str) and (':' in lat):
lat_deg = dmsStrToDeg(lat)
else:
lat_deg = float(lat)
return lat_deg
|
module function_definition identifier parameters identifier block if_statement boolean_operator call identifier argument_list identifier identifier parenthesized_expression comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
|
Convert latitude to degrees.
|
def main(argv=None):
arguments = cli_common(__doc__, argv=argv)
plugin = 'benchmark' if arguments['benchmark'] else None
if arguments['-g']:
template.generate_config(plugin, arguments['<FILE>'])
else:
with open(arguments['<FILE>']) as istr:
context = json.load(istr)
kwargs = dict(no_input=True, extra_context=context)
if arguments['--output-dir']:
kwargs.update(output_dir=arguments['--output-dir'])
if arguments['--interactive']:
kwargs.update(no_input=False)
logging.info(
'generating template in directory ' + kwargs.get('output_dir', os.getcwd())
)
template.generate_template(plugin, **kwargs)
|
module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier conditional_expression string string_start string_content string_end subscript identifier string string_start string_content string_end none if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end else_clause block with_statement with_clause with_item as_pattern call identifier argument_list subscript identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier true keyword_argument identifier identifier if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list keyword_argument identifier false expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier dictionary_splat identifier
|
ben-tpl entry point
|
def _cursorRight(self):
if self.cursorPos < len(self.inputBuffer):
self.cursorPos += 1
sys.stdout.write(console.CURSOR_RIGHT)
sys.stdout.flush()
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier call identifier argument_list attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
|
Handles "cursor right" events
|
def start_server_background(port):
if sys.version_info[0] == 2:
lines = ('import pydoc\n'
'pydoc.serve({port})')
cell = lines.format(port=port)
else:
path = repr(os.path.dirname(os.path.realpath(__file__)))
lines = ('import sys\n'
'sys.path.append({path})\n'
'import newtabmagic\n'
'newtabmagic.pydoc_cli_monkey_patched({port})')
cell = lines.format(path=path, port=port)
line = "python --proc proc --bg --err error --out output"
ip = get_ipython()
ip.run_cell_magic("script", line, cell)
return ip.user_ns['proc']
|
module function_definition identifier parameters identifier block if_statement comparison_operator subscript attribute identifier identifier integer integer block expression_statement assignment identifier parenthesized_expression concatenated_string string string_start string_content escape_sequence string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier parenthesized_expression concatenated_string string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement subscript attribute identifier identifier string string_start string_content string_end
|
Start the newtab server as a background process.
|
def _resume_with_session_id(
self,
server_info: ServerConnectivityInfo,
ssl_version_to_use: OpenSslVersionEnum
) -> bool:
session1 = self._resume_ssl_session(server_info, ssl_version_to_use)
try:
session1_id = self._extract_session_id(session1)
except IndexError:
return False
if session1_id == '':
return False
session2 = self._resume_ssl_session(server_info, ssl_version_to_use, session1)
try:
session2_id = self._extract_session_id(session2)
except IndexError:
return False
if session1_id != session2_id:
return False
return True
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block return_statement false if_statement comparison_operator identifier string string_start string_end block return_statement false expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block return_statement false if_statement comparison_operator identifier identifier block return_statement false return_statement true
|
Perform one session resumption using Session IDs.
|
def formatMessage(self, record: logging.LogRecord) -> str:
level_color = "0"
text_color = "0"
fmt = ""
if record.levelno <= logging.DEBUG:
fmt = "\033[0;37m" + logging.BASIC_FORMAT + "\033[0m"
elif record.levelno <= logging.INFO:
level_color = "1;36"
lmsg = record.message.lower()
if self.GREEN_RE.search(lmsg):
text_color = "1;32"
elif record.levelno <= logging.WARNING:
level_color = "1;33"
elif record.levelno <= logging.CRITICAL:
level_color = "1;31"
if not fmt:
fmt = "\033[" + level_color + \
"m%(levelname)s\033[0m:%(rthread)s:%(name)s:\033[" + text_color + \
"m%(message)s\033[0m"
fmt = _fest + fmt
record.rthread = reduce_thread_id(record.thread)
return fmt % record.__dict__
|
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_end if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier binary_operator binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier string string_start string_content escape_sequence string_end elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator string string_start string_content escape_sequence string_end identifier string string_start string_content escape_sequence escape_sequence string_end identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier return_statement binary_operator identifier attribute identifier identifier
|
Convert the already filled log record to a string.
|
def revoke_member(context, request):
mapping = request.json['mapping']
for entry in mapping:
user = entry['user']
roles = entry['roles']
username = user.get('username', None)
userid = user.get('userid', None)
if userid:
u = context.get_user_by_userid(userid)
elif username:
u = context.get_user_by_username(username)
else:
u = None
if u is None:
raise UnprocessableError(
'User %s does not exists' % (userid or username))
for rolename in roles:
context.revoke_member_role(u.userid, rolename)
return {'status': 'success'}
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier elif_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier none if_statement comparison_operator identifier none block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression boolean_operator identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement dictionary pair string string_start string_content string_end string string_start string_content string_end
|
Revoke member roles in the group.
|
def write(self, data):
if self._ignore_write_operations:
return
assert self.is_connected()
try:
self._connection.send(data.encode('ascii'))
except socket.error:
self.close()
self._ignore_write_operations = True
|
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block return_statement assert_statement call attribute identifier identifier argument_list try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true
|
Sends some data to the client.
|
def __get_lookup(in_fn, selected_type=None):
lookup_func = None
if selected_type is not None:
lookup_func = get_lookup_by_filetype(selected_type)
else:
extension = os.path.splitext(in_fn)[1]
lookup_func = get_lookup_by_file_extension(extension)
assert(lookup_func is not None)
return lookup_func
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier none if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list identifier assert_statement parenthesized_expression comparison_operator identifier none return_statement identifier
|
Determine which lookup func to use based on inpt files and type option.
|
def _add_node(self, node, depth):
self._topmost_node.add_child(node, bool(depth[1]))
self._stack.append((depth, node))
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier call identifier argument_list subscript identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier
|
Add a node to the graph, and the stack.
|
def _transform_fast(self, result, obj, func_nm):
cast = self._transform_should_cast(func_nm)
ids, _, ngroup = self.grouper.group_info
output = []
for i, _ in enumerate(result.columns):
res = algorithms.take_1d(result.iloc[:, i].values, ids)
if cast:
res = self._try_cast(res, obj.iloc[:, i])
output.append(res)
return DataFrame._from_arrays(output, columns=result.columns,
index=obj.index)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute subscript attribute identifier identifier slice identifier identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript attribute identifier identifier slice identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Fast transform path for aggregations
|
def target_sdp_state(self, state):
LOG.info('Setting SDP target state to %s', state)
if self._sdp_state.current_state == state:
LOG.info('Target state ignored, SDP is already "%s"!', state)
if state == 'on':
self.set_state(DevState.ON)
if state == 'off':
self.set_state(DevState.OFF)
if state == 'standby':
self.set_state(DevState.STANDBY)
if state == 'disable':
self.set_state(DevState.DISABLE)
self._sdp_state.update_target_state(state)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator attribute attribute identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Update the target state of SDP.
|
def read_unsigned_byte(self, cmd):
result = self.bus.read_byte_data(self.address, cmd)
self.log.debug(
"read_unsigned_byte: Read 0x%02X from command register 0x%02X" % (
result, cmd
)
)
return result
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement identifier
|
Read an unsigned byte from the specified command register
|
def session_hook(exception):
safeprint(
"The resource you are trying to access requires you to "
"re-authenticate with specific identities."
)
params = exception.raw_json["authorization_parameters"]
message = params.get("session_message")
if message:
safeprint("message: {}".format(message))
identities = params.get("session_required_identities")
if identities:
id_str = " ".join(identities)
safeprint(
"Please run\n\n"
" globus session update {}\n\n"
"to re-authenticate with the required identities".format(id_str)
)
else:
safeprint(
'Please use "globus session update" to re-authenticate '
"with specific identities".format(id_str)
)
exit_with_mapped_status(exception.http_status)
|
module function_definition identifier parameters identifier block expression_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list call attribute concatenated_string string string_start string_content escape_sequence escape_sequence string_end string string_start string_content escape_sequence escape_sequence string_end string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list attribute identifier identifier
|
Expects an exception with an authorization_paramaters field in its raw_json
|
def consume_changes(self, start, end):
left, right = self._get_changed(start, end)
if left < right:
del self.lines[left:right]
return left < right
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block delete_statement subscript attribute identifier identifier slice identifier identifier return_statement comparison_operator identifier identifier
|
Clear the changed status of lines from start till end
|
def clone(self, fp):
return self.__class__(fp,
self._mangle_from_,
None,
policy=self.policy)
|
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier none keyword_argument identifier attribute identifier identifier
|
Clone this generator with the exact same options.
|
def write_keyring(path, key, uid=-1, gid=-1):
tmp_file = tempfile.NamedTemporaryFile('wb', delete=False)
tmp_file.write(key)
tmp_file.close()
keyring_dir = os.path.dirname(path)
if not path_exists(keyring_dir):
makedir(keyring_dir, uid, gid)
shutil.move(tmp_file.name, path)
|
module function_definition identifier parameters identifier identifier default_parameter identifier unary_operator integer default_parameter identifier unary_operator integer block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier false expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
|
create a keyring file
|
def join(self, timeout=None):
return super(_StoppableDaemonThread, self).join(timeout or self.JOIN_TIMEOUT)
|
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call attribute call identifier argument_list identifier identifier identifier argument_list boolean_operator identifier attribute identifier identifier
|
Joins with a default timeout exposed on the class.
|
def rebuild(self):
movi = self.riff.find('LIST', 'movi')
movi.chunks = self.combine_streams()
self.rebuild_index()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
|
Rebuild RIFF tree and index from streams.
|
def samtools(items):
samtools = config_utils.get_program("samtools", items[0]["config"])
p = subprocess.Popen([samtools, "sort", "-h"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output, stderr = p.communicate()
p.stdout.close()
p.stderr.close()
if str(output).find("-@") == -1 and str(stderr).find("-@") == -1:
return ("Installed version of samtools sort does not have support for "
"multithreading (-@ option) "
"required to support bwa piped alignment and BAM merging. "
"Please upgrade to the latest version "
"from http://samtools.sourceforge.net/")
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end subscript subscript identifier integer string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list list identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list if_statement boolean_operator comparison_operator call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end unary_operator integer comparison_operator call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end unary_operator integer block return_statement parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end
|
Ensure samtools has parallel processing required for piped analysis.
|
def dumpfree(self):
fmt = "L" if self.version > 15 else "H"
hdrsize = 8 if self.version > 15 else 4
pn = self.firstfree
if pn == 0:
print("no free pages")
return
while pn:
self.fh.seek(pn * self.pagesize)
data = self.fh.read(self.pagesize)
if len(data) == 0:
print("could not read FREE data at page %06x" % pn)
break
count, nextfree = struct.unpack_from("<" + (fmt * 2), data)
freepages = list(struct.unpack_from("<" + (fmt * count), data, hdrsize))
freepages.insert(0, pn)
for pn in freepages:
self.fh.seek(pn * self.pagesize)
data = self.fh.read(self.pagesize)
print("%06x: free: %s" % (pn, hexdump(data[:64])))
pn = nextfree
|
module function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression string string_start string_content string_end comparison_operator attribute identifier identifier integer string string_start string_content string_end expression_statement assignment identifier conditional_expression integer comparison_operator attribute identifier identifier integer integer expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier integer block expression_statement call identifier argument_list string string_start string_content string_end return_statement while_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier break_statement expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression binary_operator identifier integer identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression binary_operator identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list integer identifier for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier call identifier argument_list subscript identifier slice integer expression_statement assignment identifier identifier
|
list all free pages
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.