code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
req = self.request(self.mist_client.uri+'/keys/'+self.id+"/private")
private = req.get().json()
return private | def private(self) | Return the private ssh-key
:returns: The private ssh-key as string | 12.948017 | 13.60682 | 0.951583 |
req = self.request(self.mist_client.uri+'/keys/'+self.id+"/public")
public = req.get().json()
return public | def public(self) | Return the public ssh-key
:returns: The public ssh-key as string | 13.231927 | 14.032383 | 0.942957 |
payload = {
'new_name': new_name
}
data = json.dumps(payload)
req = self.request(self.mist_client.uri+'/keys/'+self.id, data=data)
req.put()
self.id = new_name
self.mist_client.update_keys() | def rename(self, new_name) | Rename a key
:param new_name: New name for the key (will also serve as the key's id)
:returns: An updated list of added keys | 4.948768 | 4.890387 | 1.011938 |
req = self.request(self.mist_client.uri+'/keys/'+self.id)
req.post()
self.is_default = True
self.mist_client.update_keys() | def set_default(self) | Set this key as the default key
:returns: An updated list of added keys | 8.937005 | 9.470438 | 0.943674 |
req = self.request(self.mist_client.uri+'/keys/'+self.id)
req.delete()
self.mist_client.update_keys() | def delete(self) | Delete this key from mist.io
:returns: An updated list of added keys | 9.275776 | 7.277789 | 1.274532 |
if self._bug.get('id', None):
if value in VALID_STATUS:
self._bug['status'] = value
else:
raise BugException("Invalid status type was used")
else:
raise BugException("Can not set status unless there is a bug id."
... | def status(self, value) | Property for getting or setting the bug status
>>> bug.status = "REOPENED" | 7.51388 | 7.867447 | 0.955059 |
if 'id' in self._bug:
result = self._bugsy.request('bug/%s' % self._bug['id'])
self._bug = dict(**result['bugs'][0])
else:
raise BugException("Unable to update bug that isn't in Bugzilla") | def update(self) | Update this object with the latest changes from Bugzilla
>>> bug.status
'NEW'
#Changes happen on Bugzilla
>>> bug.update()
>>> bug.status
'FIXED' | 7.797022 | 7.415646 | 1.051429 |
bug = str(self._bug['id'])
res = self._bugsy.request('bug/%s/comment' % bug)
return [Comment(bugsy=self._bugsy, **comments) for comments
in res['bugs'][bug]['comments']] | def get_comments(self) | Obtain comments for this bug.
Returns a list of Comment instances. | 6.886423 | 5.973299 | 1.152868 |
# If we have a key post immediately otherwise hold onto it until
# put(bug) is called
if 'id' in self._bug:
self._bugsy.request('bug/{}/comment'.format(self._bug['id']),
method='POST', json={"comment": comment}
... | def add_comment(self, comment) | Adds a comment to a bug. If the bug object does not have a bug ID
(ie you are creating a bug) then you will need to also call `put`
on the :class:`Bugsy` class.
>>> bug.add_comment("I like sausages")
>>> bugzilla.put(bug)
If it does have a bug id then this w... | 9.915591 | 6.74822 | 1.469364 |
if not isinstance(tags, list):
tags = [tags]
self._bugsy.request('bug/comment/%s/tags' % self._comment['id'],
method='PUT', json={"add": tags}) | def add_tags(self, tags) | Add tags to the comments | 7.562272 | 5.876088 | 1.286957 |
buf = bytearray()
byte = f.read(1)
while byte != end:
if byte == b'':
raise ValueError('File ended unexpectedly. Expected end byte {}.'.format(end))
buf += byte
byte = f.read(1)
return buf | def _readuntil(f, end=_TYPE_END) | Helper function to read bytes until a certain end byte is hit | 2.687827 | 2.5181 | 1.067403 |
strlen = int(_readuntil(f, _TYPE_SEP))
buf = f.read(strlen)
if not len(buf) == strlen:
raise ValueError(
'string expected to be {} bytes long but the file ended after {} bytes'
.format(strlen, len(buf)))
try:
return buf.decode()
except UnicodeDecodeError:
return buf | def _decode_buffer(f) | String types are normal (byte)strings
starting with an integer followed by ':'
which designates the string’s length.
Since there’s no way to specify the byte type
in bencoded files, we have to guess | 4.163264 | 4.541649 | 0.916685 |
if isinstance(f_or_data, str):
f_or_data = f_or_data.encode()
if isinstance(f_or_data, bytes):
f_or_data = BytesIO(f_or_data)
#TODO: the following line is the only one that needs readahead.
#peek returns a arbitrary amount of bytes, so we have to slice.
if f_or_data.seekable():
first_byte = f_or_data.rea... | def bdecode(f_or_data) | bdecodes data by looking up the type byte,
and using it to look up the respective decoding function,
which in turn is used to return the decoded object
The parameter can be a file opened in bytes mode,
bytes or a string (the last of which will be decoded) | 3.284329 | 3.281472 | 1.000871 |
if isinstance(string, str):
string = string.encode()
f.write(str(len(string)).encode())
f.write(_TYPE_SEP)
f.write(string) | def _encode_buffer(string, f) | Writes the bencoded form of the input string or bytes | 2.789194 | 2.573801 | 1.083687 |
f.write(_TYPE_DICT)
for key, value in sorted(mapping.items()):
_encode_buffer(key, f)
bencode(value, f)
f.write(_TYPE_END) | def _encode_mapping(mapping, f) | Encodes the mapping items in lexical order (spec) | 4.50452 | 4.506441 | 0.999574 |
if f is None:
f = BytesIO()
_bencode_to_file(data, f)
return f.getvalue()
else:
_bencode_to_file(data, f) | def bencode(data, f=None) | Writes a serializable data piece to f
The order of tests is nonarbitrary,
as strings and mappings are iterable.
If f is None, it writes to a byte buffer
and returns a bytestring | 2.052562 | 2.47127 | 0.83057 |
import sys, pprint
from argparse import ArgumentParser, FileType
parser = ArgumentParser(description=main.__doc__)
parser.add_argument('infile', nargs='?', type=FileType('rb'), default=sys.stdin.buffer,
help='bencoded file (e.g. torrent) [Default: stdin]')
parser.add_argument('outfile', nargs='?', type=FileTy... | def main(args=None) | Decodes bencoded files to python syntax (like JSON, but with bytes support) | 2.877324 | 2.340894 | 1.229156 |
if len(args) < 2:
print(f'Usage: {args[0]} {{ID|aid:AID}} [EPISODE]')
return
aid = state.results.parse_aid(args[1], default_key='db')
anime = query.select.lookup(state.db, aid)
if len(args) < 3:
episode = anime.watched_episodes + 1
else:
episode = int(args[2])
... | def command(state, args) | Watch an anime. | 4.316083 | 4.056046 | 1.064111 |
if no_redis:
raise Exception("redis package not found, please install redis-py via 'pip install redis'")
RliteConnection.set_file(filename)
global orig_classes
# already patched
if orig_classes:
return
orig_classes = (redis.connection.Connection,
red... | def patch_connection(filename=':memory:') | ``filename``: rlite filename to store db in, or memory
Patch the redis-py Connection and the
static from_url() of Redis and StrictRedis to use RliteConnection | 8.158568 | 7.306559 | 1.116609 |
L = fdata.shape[0]
if np.mod(L, 2) == 0:
fdata[int(L / 2), :] = 0 | def fix_even_row_data_fc(fdata) | When the number of rows in fdata is even, there is a subtlety that must
be taken care of if fdata is to satisfy the symmetry required for further
processing. For an array length of 6,the data is align as [0 1 2 -3 -2 -1]
this routine simply sets the row corresponding to the -3 index equal to
zero. It ... | 3.760504 | 3.203987 | 1.173695 |
nrows = fdata.shape[0]
ncols = fdata.shape[1]
M = nrows / 2
fdata[int(M - 1), :] = 0
fdata[int(M + 1), :] = 0
work1 = np.zeros([nrows, ncols], dtype=np.complex128)
work2 = np.zeros([nrows, ncols], dtype=np.complex128)
work1[0, :] = fdata[-1, :]
work1[1:, :] = fdata[0:-1,... | def sin_fc(fdata) | Apply sine in the Fourier domain. | 2.416961 | 2.423875 | 0.997147 |
nrows = fdata.shape[0]
ncols = fdata.shape[1]
L = int(nrows / 2) # Assuming nrows is even, which it should be.
L2 = L - 2 # This is the last index in the recursion for division by sine.
g = np.zeros([nrows, ncols], dtype=np.complex128)
g[L2, :] = 2 * 1j * fdata[L - 1, :]
f... | def divsin_fc(fdata) | Apply divide by sine in the Fourier domain. | 3.53939 | 3.281652 | 1.078539 |
nrows = fdata.shape[0]
ncols = fdata.shape[1]
B = int(ncols / 2) # As always, we assume nrows and ncols are even
a = list(range(0, int(B)))
ap = list(range(-int(B), 0))
a.extend(ap)
dphi = np.zeros([nrows, ncols], np.complex128)
for k in xrange(0, nrows):
... | def dphi_fc(fdata) | Apply phi derivative in the Fourier domain. | 3.737174 | 3.752818 | 0.995831 |
dphi_fc(tfdata)
sin_fc(pfdata)
dtheta_fc(pfdata)
return 1j * (tfdata - pfdata) | def sinLdot_fc(tfdata, pfdata) | Apply sin of theta times the L operator to the data in the Fourier
domain. | 6.956013 | 8.415421 | 0.826579 |
fd = np.copy(fdata)
dphi_fc(fdata)
divsin_fc(fdata)
dtheta_fc(fd)
return (1j * fdata, -1j * fd) | def L_fc(fdata) | Apply L in the Fourier domain. | 9.195931 | 8.839581 | 1.040313 |
# Dump processor function
def process_dump(dump, path):
for page in dump:
if page.namespace != 0: continue
else:
for cite in extract_cite_history(page, extractors):
yield cite
# Map call
return mwxml.map(process_dump, dump_files) | def extract(dump_files, extractors=ALL_EXTRACTORS) | Extracts cites from a set of `dump_files`.
:Parameters:
dump_files : str | `file`
A set of files MediaWiki XML dump files
(expects: pages-meta-history)
extractors : `list`(`extractor`)
A list of extractors to apply to the text
:Returns:
`iterable` --... | 9.796432 | 7.494632 | 1.307126 |
appearances = {} # For tracking the first appearance of an ID
ids = set() # For holding onto the ids in the last revision.
for revision in page:
ids = set(extract_ids(revision.text, extractors))
# For each ID, check to see if we have seen it before
for id in ids:
if... | def extract_cite_history(page, extractors) | Extracts cites from the history of a `page` (`mwxml.Page`).
:Parameters:
page : `iterable`(`mwxml.Revision`)
The page to extract cites from
extractors : `list`(`extractor`)
A list of extractors to apply to the text
:Returns:
`iterable` -- a generator of extracte... | 5.178814 | 5.122544 | 1.010985 |
for extractor in extractors:
for id in extractor.extract(text):
yield id | def extract_ids(text, extractors) | Uses `extractors` to extract citation identifiers from a text.
:Parameters:
text : str
The text to process
extractors : `list`(`extractor`)
A list of extractors to apply to the text
:Returns:
`iterable` -- a generator of extracted identifiers | 3.527589 | 5.068483 | 0.695985 |
'''Add other RT Components to this composite component as members.
This component must be a composite component.
'''
if not self.is_composite:
raise exceptions.NotCompositeError(self.name)
for rtc in rtcs:
if self.is_member(rtc):
raise ex... | def add_members(self, rtcs) | Add other RT Components to this composite component as members.
This component must be a composite component. | 6.798214 | 4.846643 | 1.402664 |
'''Remove other RT Components from this composite component.
rtcs is a list of components to remove. Each element must be either an
rtctree.Component object or a string containing a component's instance
name. rtctree.Component objects are more reliable.
This component must be a... | def remove_members(self, rtcs) | Remove other RT Components from this composite component.
rtcs is a list of components to remove. Each element must be either an
rtctree.Component object or a string containing a component's instance
name. rtctree.Component objects are more reliable.
This component must be a composite ... | 5.222281 | 2.807297 | 1.860252 |
'''Is the given component a member of this composition?
rtc may be a Component object or a string containing a component's
instance name. Component objects are more reliable.
Returns False if the given component is not a member of this
composition.
Raises NotCompositeE... | def is_member(self, rtc) | Is the given component a member of this composition?
rtc may be a Component object or a string containing a component's
instance name. Component objects are more reliable.
Returns False if the given component is not a member of this
composition.
Raises NotCompositeError if thi... | 4.922811 | 2.499272 | 1.969698 |
'''Member components if this component is composite.'''
with self._mutex:
if not self._members:
self._members = {}
for o in self.organisations:
# TODO: Search for these in the tree
self._members[o.org_id] = o.obj.get_mem... | def members(self) | Member components if this component is composite. | 9.051503 | 6.858385 | 1.319772 |
'''The organisations of this composition.'''
class Org:
def __init__(self, sdo_id, org_id, members, obj):
self.sdo_id = sdo_id
self.org_id = org_id
self.members = members
self.obj = obj
with self._mutex:
if ... | def organisations(self) | The organisations of this composition. | 3.250603 | 3.059371 | 1.062507 |
'''The SDO IDs of the compositions this RTC belongs to.'''
return [sdo.get_owner()._narrow(SDOPackage.SDO).get_sdo_id() \
for sdo in self._obj.get_organizations() if sdo] | def parent_org_sdo_ids(self) | The SDO IDs of the compositions this RTC belongs to. | 21.022776 | 10.555356 | 1.991669 |
'''The organisations this RTC belongs to.'''
class ParentOrg:
def __init__(self, sdo_id, org_id):
self.sdo_id = sdo_id
self.org_id = org_id
with self._mutex:
if not self._parent_orgs:
for sdo in self._obj.get_organizations(... | def parent_organisations(self) | The organisations this RTC belongs to. | 3.720273 | 3.312519 | 1.123095 |
'''Activate this component in an execution context.
@param ec_index The index of the execution context to activate in.
This index is into the total array of contexts, that
is both owned and participating contexts. If the value
of e... | def activate_in_ec(self, ec_index) | Activate this component in an execution context.
@param ec_index The index of the execution context to activate in.
This index is into the total array of contexts, that
is both owned and participating contexts. If the value
of ec_index is ... | 4.370564 | 1.722568 | 2.537237 |
'''Deactivate this component in an execution context.
@param ec_index The index of the execution context to deactivate in.
This index is into the total array of contexts, that
is both owned and participating contexts. If the value
... | def deactivate_in_ec(self, ec_index) | Deactivate this component in an execution context.
@param ec_index The index of the execution context to deactivate in.
This index is into the total array of contexts, that
is both owned and participating contexts. If the value
of ec_index... | 4.349226 | 1.715973 | 2.534555 |
'''Get a reference to the execution context with the given handle.
@param ec_handle The handle of the execution context to look for.
@type ec_handle str
@return A reference to the ExecutionContext object corresponding to
the ec_handle.
@raises NoECWithHandleError
... | def get_ec(self, ec_handle) | Get a reference to the execution context with the given handle.
@param ec_handle The handle of the execution context to look for.
@type ec_handle str
@return A reference to the ExecutionContext object corresponding to
the ec_handle.
@raises NoECWithHandleError | 4.122669 | 2.127014 | 1.938243 |
'''Get the index of the execution context with the given handle.
@param ec_handle The handle of the execution context to look for.
@type ec_handle str
@return The index into the owned + participated arrays, suitable for
use in methods such as @ref activate_in_ec, or -1 if the EC... | def get_ec_index(self, ec_handle) | Get the index of the execution context with the given handle.
@param ec_handle The handle of the execution context to look for.
@type ec_handle str
@return The index into the owned + participated arrays, suitable for
use in methods such as @ref activate_in_ec, or -1 if the EC was not
... | 4.507117 | 1.785671 | 2.524047 |
'''Get the state of this component as an optionally-coloured string.
@param add_colour If True, ANSI colour codes will be added to the
string.
@return A string describing the state of this component.
'''
with self._mutex:
if self.state == s... | def get_state_string(self, add_colour=True) | Get the state of this component as an optionally-coloured string.
@param add_colour If True, ANSI colour codes will be added to the
string.
@return A string describing the state of this component. | 3.29112 | 2.49189 | 1.320732 |
'''Get the state of the component in an execution context as a string.
@param ec_index The index of the execution context to check the state
in. This index is into the total array of contexts,
that is both owned and participating contexts. If the
... | def get_state_in_ec_string(self, ec_index, add_colour=True) | Get the state of the component in an execution context as a string.
@param ec_index The index of the execution context to check the state
in. This index is into the total array of contexts,
that is both owned and participating contexts. If the
... | 3.758663 | 2.187408 | 1.718318 |
'''Reset this component in an execution context.
@param ec_index The index of the execution context to reset in. This
index is into the total array of contexts, that is both
owned and participating contexts. If the value of
ec_inde... | def reset_in_ec(self, ec_index) | Reset this component in an execution context.
@param ec_index The index of the execution context to reset in. This
index is into the total array of contexts, that is both
owned and participating contexts. If the value of
ec_index is greate... | 4.391874 | 1.753414 | 2.504756 |
'''Get the state of the component in an execution context.
@param ec_index The index of the execution context to check the state
in. This index is into the total array of contexts,
that is both owned and participating contexts. If the
... | def state_in_ec(self, ec_index) | Get the state of the component in an execution context.
@param ec_index The index of the execution context to check the state
in. This index is into the total array of contexts,
that is both owned and participating contexts. If the
value o... | 4.44741 | 1.645315 | 2.703075 |
'''Get the up-to-date state of the component in an execution context.
This function will update the state, rather than using the cached
value. This may take time, if the component is executing on a remote
node.
@param ec_index The index of the execution context to check the sta... | def refresh_state_in_ec(self, ec_index) | Get the up-to-date state of the component in an execution context.
This function will update the state, rather than using the cached
value. This may take time, if the component is executing on a remote
node.
@param ec_index The index of the execution context to check the state
... | 4.047831 | 1.493818 | 2.709721 |
'''Is this component alive?'''
with self._mutex:
if self.exec_contexts:
for ec in self.exec_contexts:
if self._obj.is_alive(ec):
return True
return False | def alive(self) | Is this component alive? | 7.330564 | 6.789757 | 1.07965 |
'''The state of each execution context this component owns.'''
with self._mutex:
if not self._owned_ec_states:
if self.owned_ecs:
states = []
for ec in self.owned_ecs:
states.append(self._get_ec_state(ec))
... | def owned_ec_states(self) | The state of each execution context this component owns. | 3.060811 | 2.372484 | 1.29013 |
'''A list of the execution contexts owned by this component.'''
with self._mutex:
if not self._owned_ecs:
self._owned_ecs = [ExecutionContext(ec,
self._obj.get_context_handle(ec)) \
for ec in self._obj.get_owned_contexts()]
retu... | def owned_ecs(self) | A list of the execution contexts owned by this component. | 5.379626 | 3.964618 | 1.356909 |
'''The state of each execution context this component is participating
in.
'''
with self._mutex:
if not self._participating_ec_states:
if self.participating_ecs:
states = []
for ec in self.participating_ecs:
... | def participating_ec_states(self) | The state of each execution context this component is participating
in. | 2.946344 | 2.28754 | 1.287996 |
'''A list of the execution contexts this component is participating in.
'''
with self._mutex:
if not self._participating_ecs:
self._participating_ecs = [ExecutionContext(ec,
self._obj.get_context_handle(ec)) \
... | def participating_ecs(self) | A list of the execution contexts this component is participating in. | 5.251562 | 3.729211 | 1.408223 |
'''The merged state of all the execution context states, which can be
used as the overall state of this component.
The order of precedence is:
Error > Active > Inactive > Created > Unknown
'''
def merge_state(current, new):
if new == self.ERROR:
... | def state(self) | The merged state of all the execution context states, which can be
used as the overall state of this component.
The order of precedence is:
Error > Active > Inactive > Created > Unknown | 2.589026 | 1.764452 | 1.467326 |
'''Get a reference to the ExtendedFsmService.
@return A reference to the ExtendedFsmService object
@raises InvalidSdoServiceError
'''
with self._mutex:
try:
return self._obj.get_sdo_service(RTC.ExtendedFsmService._NP_RepositoryId)._narrow(RTC.Extende... | def get_extended_fsm_service(self) | Get a reference to the ExtendedFsmService.
@return A reference to the ExtendedFsmService object
@raises InvalidSdoServiceError | 6.891585 | 4.445865 | 1.550111 |
'''Get a port of this component by name.'''
with self._mutex:
for p in self.ports:
if p.name == port_name:
return p
return None | def get_port_by_name(self, port_name) | Get a port of this component by name. | 4.194751 | 3.909499 | 1.072964 |
'''Get a port of this component by reference to a CORBA PortService
object.
'''
with self._mutex:
for p in self.ports:
if p.object._is_equivalent(port_ref):
return p
return None | def get_port_by_ref(self, port_ref) | Get a port of this component by reference to a CORBA PortService
object. | 8.991255 | 4.091656 | 2.197461 |
'''Check if this component has a port by the given name.'''
with self._mutex:
if self.get_port_by_name(port_name):
return True
return False | def has_port_by_name(self, port_name) | Check if this component has a port by the given name. | 4.891738 | 4.225121 | 1.157775 |
'''Check if this component has a port by the given reference to a CORBA
PortService object.
'''
with self._mutex:
if self.get_port_by_ref(self, port_ref):
return True
return False | def has_port_by_ref(self, port_ref) | Check if this component has a port by the given reference to a CORBA
PortService object. | 9.06981 | 3.681488 | 2.463626 |
'''The list of all input ports belonging to this component that are
connected to one or more other ports.
'''
return [p for p in self.ports \
if p.__class__.__name__ == 'DataInPort' and p.is_connected] | def connected_inports(self) | The list of all input ports belonging to this component that are
connected to one or more other ports. | 6.596755 | 3.805706 | 1.733385 |
'''The list of all output ports belonging to this component that are
connected to one or more other ports.
'''
return [p for p in self.ports \
if p.__class__.__name__ == 'DataOutPort' \
and p.is_connected] | def connected_outports(self) | The list of all output ports belonging to this component that are
connected to one or more other ports. | 6.147043 | 3.659651 | 1.67968 |
'''The list of all service ports belonging to this component that are
connected to one or more other ports.
'''
return [p for p in self.ports \
if p.__class__.__name__ == 'CorbaPort' and p.is_connected] | def connected_svcports(self) | The list of all service ports belonging to this component that are
connected to one or more other ports. | 7.157475 | 3.936719 | 1.818132 |
'''The list of all ports belonging to this component.'''
with self._mutex:
if not self._ports:
self._ports = [ports.parse_port(port, self) \
for port in self._obj.get_ports()]
return self._ports | def ports(self) | The list of all ports belonging to this component. | 5.506808 | 4.857274 | 1.133724 |
'''Add a callback to receive log events from this component.
@param cb The callback function to receive log events. It must have the
signature cb(name, time, source, level, message), where name is the
name of the component the log record came from, time is a
floating... | def add_logger(self, cb, level='NORMAL', filters='ALL') | Add a callback to receive log events from this component.
@param cb The callback function to receive log events. It must have the
signature cb(name, time, source, level, message), where name is the
name of the component the log record came from, time is a
floating-point time... | 6.203199 | 3.133444 | 1.979675 |
'''Remove a logger.
@param cb_id The ID of the logger to remove.
@raises NoLoggerError
'''
if cb_id not in self._loggers:
raise exceptions.NoLoggerError(cb_id, self.name)
conf = self.object.get_configuration()
res = conf.remove_service_profile(cb_id.... | def remove_logger(self, cb_id) | Remove a logger.
@param cb_id The ID of the logger to remove.
@raises NoLoggerError | 4.849283 | 4.018835 | 1.206639 |
'''Activate a configuration set by name.
@raises NoSuchConfSetError
'''
with self._mutex:
if not set_name in self.conf_sets:
raise exceptions.NoSuchConfSetError(set_name)
self._conf.activate_configuration_set(set_name) | def activate_conf_set(self, set_name) | Activate a configuration set by name.
@raises NoSuchConfSetError | 4.384293 | 3.871346 | 1.132499 |
'''Set a configuration set parameter value.
@param set_name The name of the configuration set the destination
parameter is in.
@param param The name of the parameter to set.
@param value The new value for the parameter.
@raises NoSuchConfSetError, NoSuchC... | def set_conf_set_value(self, set_name, param, value) | Set a configuration set parameter value.
@param set_name The name of the configuration set the destination
parameter is in.
@param param The name of the parameter to set.
@param value The new value for the parameter.
@raises NoSuchConfSetError, NoSuchConfParamErr... | 2.838516 | 2.119393 | 1.339306 |
'''The currently-active configuration set.'''
with self._mutex:
if not self.conf_sets:
return None
if not self._active_conf_set:
return None
return self.conf_sets[self._active_conf_set] | def active_conf_set(self) | The currently-active configuration set. | 3.532158 | 3.570406 | 0.989288 |
'''The name of the currently-active configuration set.'''
with self._mutex:
if not self.conf_sets:
return ''
if not self._active_conf_set:
return ''
return self._active_conf_set | def active_conf_set_name(self) | The name of the currently-active configuration set. | 3.930002 | 4.164777 | 0.943628 |
'''The dictionary of configuration sets in this component, if any.'''
with self._mutex:
if not self._conf_sets:
self._parse_configuration()
return self._conf_sets | def conf_sets(self) | The dictionary of configuration sets in this component, if any. | 6.853103 | 4.49573 | 1.524358 |
for table_spec in self._table_specs:
with self._conn:
table_spec.setup(self._conn) | def setup(self) | Setup cache tables. | 7.268288 | 4.902464 | 1.482579 |
for table_spec in reversed(self._table_specs):
with self._conn:
table_spec.teardown(self._conn) | def teardown(self) | Cleanup cache tables. | 7.32641 | 5.443137 | 1.34599 |
if isinstance(statement, list):
statement.append({condition: {key: value}})
if isinstance(statement, dict):
statement[condition] = {key: value} | def append_condition(statement, condition, key, value) | >>> list = []
>>> append_condition(list, 'match', 'name', 'Jack')
>>> list
[{'match': {'name': 'Jack'}}]
>>> dict = {}
>>> append_condition(dict, 'match', 'name', 'Marry')
>>> dict
{'match': {'name': 'Marry'}} | 2.690083 | 2.771849 | 0.970501 |
self.client = Elasticsearch(hosts=hosts, **kwargs)
logger.info('Initialize normal Elasticsearch Client: %s.' % self.client) | def from_normal(self, hosts=default.ELASTICSEARCH_HOSTS, **kwargs) | Initialize a Elasticsearch client by specified hosts list.
:param hosts: list of nodes we should connect to. Node should be a
dictionary ({"host": "localhost", "port": 9200}), the entire dictionary
will be passed to the :class:`~elasticsearch.Connection` class as
kwargs, or ... | 5.959928 | 7.5506 | 0.789332 |
self.client = Elasticsearch(active_nodes,
sniff_on_start=sniff_on_start,
sniff_on_connection_fail=sniff_on_connection_fail,
sniffer_timeout=sniffer_timeout, **kwargs)
logger.info('Initial... | def from_sniffing(self,
active_nodes,
sniff_on_start=True,
sniff_on_connection_fail=True,
sniffer_timeout=60, **kwargs) | Initialize a Elasticsearch client for specify to sniff on startup to
inspect the cluster and load balance across all nodes.
The client can be configured to inspect the cluster state to get
a list of nodes upon startup, periodically and/or on failure.
:param active_nodes: the list of act... | 2.510026 | 2.557504 | 0.981436 |
self.client = Elasticsearch(hosts=hosts,
use_ssl=use_ssl,
verify_certs=verify_certs,
ca_certs=ca_certs,
client_cert=client_cert,
... | def from_ssl(self,
ca_certs,
client_cert,
client_key,
hosts=default.ELASTICSEARCH_HOSTS,
use_ssl=True,
verify_certs=True, **kwargs) | Initialize a Elasticsearch client by SSL.
:param ca_certs: optional path to CA bundle. See
https://urllib3.readthedocs.io/en/latest/security.html#using-certifi-with-urllib3
:param client_cert: path to the file containing the private key and the
certificate, or cert only if using client_... | 2.286719 | 2.548664 | 0.897222 |
mongo_client = MongoClient(host=mongo_host, port=int(mongo_port))
try:
collection = mongo_client[mongo_db][mongo_collection]
if indexed_flag_field_name != '':
mongo_query_params.update({indexed_flag_field_name: False})
mongo_docs = collection.... | def transfer_data_from_mongo(self,
index,
doc_type,
use_mongo_id=False,
indexed_flag_field_name='',
mongo_query_params={},
... | Transfer data from MongoDB into the Elasticsearch, the hostname, port, database and
collection name in MongoDB default from load in default.py
:param index: The name of the index
:param doc_type: The type of the document
:param use_mongo_id: Use id of MongoDB in the Elasticsearch if is ... | 2.613974 | 2.640593 | 0.989919 |
success, failed = es_helpers.bulk(self.client, actions, stats_only, **kwargs)
logger.info('Bulk is done success %s failed %s actions: \n %s' % (success, failed, actions)) | def bulk(self, actions, stats_only=False, **kwargs) | Executes bulk api by elasticsearch.helpers.bulk.
:param actions: iterator containing the actions
:param stats_only:if `True` only report number of successful/failed
operations instead of just number of successful and a list of error responses
Any additional keyword arguments will be pas... | 5.608069 | 6.584489 | 0.851709 |
thread_id = self._generate_thread_id(thread_name)
if thread_id in ElasticsearchClient.automatic_syn_data_flag:
lock.acquire()
try:
thread_name = thread_name + '-%s' % ElasticsearchClient.automatic_thread_name_counter
ElasticsearchClient.au... | def automatic_syn_data_from_mongo(self,
index,
doc_type,
indexed_flag_field_name,
thread_name='automatic_syn_data_thread',
interva... | Automatic synchronize data that from MongoDB into the Elasticsearch by schedule task,
it will synchronize this data if the indexed_flag_field_name of the field of the document is False.
Noteworthy that the function may be no good please you caution use it.
:param indexed_flag_field_name: the na... | 2.162763 | 2.292189 | 0.943536 |
raw = self.client.cat.indices(index, params=params, **kwargs).split('\n')
list = []
for r in raw:
alter = r.split(' ')
if len(alter) < 10: continue
dict = {
'health': alter[0],
'status': alter[1],
'index... | def get_simple_info_for_index(self, index=None, params={}, **kwargs) | Return a list of simple info by specified index (default all), each elements is a dictionary
such as
{
'health' : 'green', 'status' : 'open',
'index' : 'xxxx', 'uuid' : 'xxxx',
'pri' : 1, 'rep' : 1,
`docs_count` : 4, 'docs_deleted' : 0,
'store_... | 2.995306 | 2.555981 | 1.171881 |
params['level'] = 'indices'
result = self.cluster_health(index, params, **kwargs)
return self._process_cluster_health_info(result) | def cluster_health_for_indices(self, index=None, params={}, **kwargs) | Return a list of cluster health of specified indices(default all),
the first element is a dictionary represent a global information of the cluster
such as "cluster_name", "number_of_nodes"...
the second element represent a indices information list that each element is a dictionary for one index
... | 3.87845 | 4.566085 | 0.849404 |
params['level'] = 'shards'
result = self.cluster_health(index, params, **kwargs)
return self._process_cluster_health_info(result) | def cluster_health_for_shards(self, index=None, params={}, **kwargs) | Return a list of cluster health of specified indices(default all) and
append shards information of each index
the first element is a dictionary represent a global information of the cluster
the second element represent a information of indices and its shards and each element is a dictionary
... | 3.748993 | 4.354721 | 0.860903 |
h = ['name', 'pid', 'http_address', 'version', 'jdk', 'disk.total', 'disk.used_percent', 'heap.current',
'heap.percent', 'ram.current', 'ram.percent', 'uptime', 'node.role']
result = self.client.cat.nodes(v=True, h=h, **kwargs, params=params)
result = [x.strip().split(' ') ... | def nodes_simple_info(self, params={}, **kwargs) | Return a dictionary of the nodes simple info that key is a column name,
such as [{"http_address": "192.111.111.111", "name" : "test", ...}, ...] | 4.082564 | 3.803818 | 1.073281 |
'''
Read and return sequence of lines (including newlines) that
represent a single FASTA query record. The provided file is
expected to be blocking.
Returns None if there are no more query sequences in the file.
'''
def readline():
l = f.readline()
if l == '':
r... | def __read_single_fasta_query_lines(f) | Read and return sequence of lines (including newlines) that
represent a single FASTA query record. The provided file is
expected to be blocking.
Returns None if there are no more query sequences in the file. | 3.844094 | 2.188206 | 1.756733 |
'''
Read the result of a single query from the given string,
returning a tuple of (record, remaining-string). If no complete
record could be read, the first element of the tuple is None and
the second element is the original imput string.
'''
rf = StringIO.StringIO(rs)
def readline():
... | def __read_single_query_result(rs, field_names) | Read the result of a single query from the given string,
returning a tuple of (record, remaining-string). If no complete
record could be read, the first element of the tuple is None and
the second element is the original imput string. | 2.984441 | 2.354068 | 1.26778 |
'''
Run the select(2) loop to handle blast I/O to the given set of Popen
objects.
Yields records back that have been read from blast processes.
'''
def make_nonblocking(f):
fl = fcntl.fcntl(f.fileno(), fcntl.F_GETFL)
fl |= os.O_NONBLOCK
fcntl.fcntl(f.fileno(), fcntl.F_S... | def __run_blast_select_loop(input_file, popens, fields) | Run the select(2) loop to handle blast I/O to the given set of Popen
objects.
Yields records back that have been read from blast processes. | 3.257551 | 2.871805 | 1.134322 |
'''
Run a blast variant on the given input file.
'''
# XXX: Eventually, translate results on the fly as requested? Or
# just always use our parsed object?
if 'outfmt' in kwargs:
raise Exception('Use of the -outfmt option is not supported')
num_processes = kwargs.get(
'... | def __run_blast(blast_command, input_file, *args, **kwargs) | Run a blast variant on the given input file. | 3.740944 | 3.574162 | 1.046663 |
tmp_frame = self.track.current_frame
self.track.current_frame = self.start
frames = self.track.read_frames(self.duration, channels=channels)
self.track.current_frame = tmp_frame
for effect in self.effects:
frames = effect.apply_to(frames, self.samplerate)
... | def get_frames(self, channels=2) | Get numpy array of frames corresponding to the segment.
:param integer channels: Number of channels in output array
:returns: Array of frames in the segment
:rtype: numpy array | 4.017714 | 4.400323 | 0.91305 |
return max([x.comp_location + x.duration
for x in self.segments]) | def duration(self) | Get duration of composition | 28.302742 | 18.300611 | 1.546546 |
self.tracks.add(segment.track)
self.segments.append(segment) | def add_segment(self, segment) | Add a segment to the composition
:param segment: Segment to add to composition
:type segment: :py:class:`radiotool.composer.Segment` | 5.36747 | 5.30453 | 1.011865 |
self.tracks.update([seg.track for seg in segments])
self.segments.extend(segments) | def add_segments(self, segments) | Add a list of segments to the composition
:param segments: Segments to add to composition
:type segments: list of :py:class:`radiotool.composer.Segment` | 5.338167 | 5.256291 | 1.015577 |
f = Fade(segment.track, segment.comp_location_in_seconds,
duration, 0.0, 1.0, fade_type=fade_type)
self.add_dynamic(f)
return f | def fade_in(self, segment, duration, fade_type="linear") | Adds a fade in to a segment in the composition
:param segment: Segment to fade in to
:type segment: :py:class:`radiotool.composer.Segment`
:param duration: Duration of fade-in (in seconds)
:type duration: float
:returns: The fade that has been added to the composition
:r... | 6.938213 | 8.843815 | 0.784527 |
score_loc_in_seconds = segment.comp_location_in_seconds +\
segment.duration_in_seconds - duration
f = Fade(segment.track, score_loc_in_seconds, duration, 1.0, 0.0,
fade_type=fade_type)
# bug fixing... perhaps
f.comp_location = segment.comp_location ... | def fade_out(self, segment, duration, fade_type="linear") | Adds a fade out to a segment in the composition
:param segment: Segment to fade out
:type segment: :py:class:`radiotool.composer.Segment`
:param duration: Duration of fade-out (in seconds)
:type duration: float
:returns: The fade that has been added to the composition
:r... | 6.118009 | 6.194796 | 0.987605 |
dur = int(duration * segment.track.samplerate)
if segment.start - dur >= 0:
segment.start -= dur
else:
raise Exception(
"Cannot create fade-in that extends "
"past the track's beginning")
if segment.comp_location - dur >= 0... | def extended_fade_in(self, segment, duration) | Add a fade-in to a segment that extends the beginning of the
segment.
:param segment: Segment to fade in
:type segment: :py:class:`radiotool.composer.Segment`
:param duration: Duration of fade-in (in seconds)
:returns: The fade that has been added to the composition
:rty... | 5.206656 | 4.909741 | 1.060475 |
dur = int(duration * segment.track.samplerate)
if segment.start + segment.duration + dur <\
segment.track.duration:
segment.duration += dur
else:
raise Exception(
"Cannot create fade-out that extends past the track's end")
... | def extended_fade_out(self, segment, duration) | Add a fade-out to a segment that extends the beginning of the
segment.
:param segment: Segment to fade out
:type segment: :py:class:`radiotool.composer.Segment`
:param duration: Duration of fade-out (in seconds)
:returns: The fade that has been added to the composition
:... | 5.535709 | 5.31666 | 1.041201 |
if seg1.comp_location + seg1.duration - seg2.comp_location < 2:
dur = int(duration * seg1.track.samplerate)
if dur % 2 == 1:
dur -= 1
if dur / 2 > seg1.duration:
dur = seg1.duration * 2
if dur / 2 > seg2.duration:
... | def cross_fade(self, seg1, seg2, duration) | Add a linear crossfade to the composition between two
segments.
:param seg1: First segment (fading out)
:type seg1: :py:class:`radiotool.composer.Segment`
:param seg2: Second segment (fading in)
:type seg2: :py:class:`radiotool.composer.Segment`
:param duration: Duration... | 2.877566 | 2.817379 | 1.021363 |
for seg in self.segments:
# starts in range
if seg.comp_location_in_seconds >= time and\
seg.comp_location_in_seconds < time + duration:
return False
# or, ends in range
elif seg.comp_location_in_seconds + seg.duration_in_s... | def empty_over_span(self, time, duration) | Helper method that tests whether composition contains any segments
at a given time for a given duration.
:param time: Time (in seconds) to start span
:param duration: Duration (in seconds) of span
:returns: `True` if there are no segments in the composition that overlap the span starti... | 2.384142 | 2.354148 | 1.012741 |
# remove audio from the composition starting at time
# for duration
contract_dur = 0.0
contract_start = time
if self.empty_over_span(time, duration):
contract_dur = duration
contract_start = time
else:
starts = [s.comp_locat... | def contract(self, time, duration, min_contraction=0.0) | Remove empty gaps from the composition starting at a given
time for a given duration. | 2.225327 | 2.150763 | 1.034669 |
self.tracks.add(track)
pre_fade = 3
post_fade = 3
if padding_before + pre_fade > song_cue:
padding_before = song_cue - pre_fade
if padding_before + pre_fade > score_cue:
padding_before = score_cue - pre_fade
... | def add_music_cue(self, track, comp_cue, song_cue, duration=6.0,
padding_before=12.0, padding_after=12.0) | Add a music cue to the composition. This doesn't do any audio
analysis, it just aligns a specified point in the track
(presumably music) with a location in the composition. See
UnderScore_ for a visualization of what this is doing to the
music track.
.. _UnderScore: http://vis.b... | 2.936548 | 2.975617 | 0.98687 |
if track_list is None:
track_list = self.tracks
if channels is None:
channels = self.channels
parts = {}
starts = {}
# for universal volume adjustment
all_frames = np.array([])
song_frames = np.array([])
speech_f... | def build(self, track_list=None, adjust_dynamics=False,
min_length=None, channels=None) | Create a numpy array from the composition.
:param track_list: List of tracks to include in composition generation (``None`` means all tracks will be used)
:type track_list: list of :py:class:`radiotool.composer.Track`
:param int min_length: Minimum length of output array (in frames). Will zero ... | 2.553942 | 2.598001 | 0.983041 |
# get optional args
filename = kwargs.pop('filename', 'out')
filetype = kwargs.pop('filetype', 'wav')
adjust_dynamics = kwargs.pop('adjust_dynamics', False)
samplerate = kwargs.pop('samplerate', None)
channels = kwargs.pop('channels', self.channels)
separ... | def export(self, **kwargs) | Generate audio file from composition.
:param str. filename: Output filename (no extension)
:param str. filetype: Output file type (only .wav supported for now)
:param integer samplerate: Sample rate of output audio
:param integer channels: Channels in output audio, if different than ori... | 2.989227 | 2.821052 | 1.059614 |
cur = db.cursor()
cur.execute('SELECT id, name, prefix FROM episode_type')
for type_id, name, prefix in cur:
yield EpisodeType(type_id, name, prefix) | def get_episode_types(db) -> Iterator[EpisodeType] | Get all episode types. | 2.449568 | 2.321564 | 1.055137 |
return '{}{}'.format(self[episode.type].prefix, episode.number) | def get_epno(self, episode: Episode) | Return epno for an Episode instance.
epno is a string formatted with the episode number and type, e.g., S1,
T2.
>>> x = EpisodeTypes([EpisodeType(1, 'foo', 'F')])
>>> ep = Episode(type=1, number=2)
>>> x.get_epno(ep)
'F2' | 22.024113 | 16.074644 | 1.370115 |
for service in self.configurables[Service].values():
if service.discovery == name:
service.reset_status() | def on_discovery_update(self, name, new_config) | Once a Discovery is updated we update each associated Service to reset
its up/down status so that the next iteration of the `check_loop`
loop does the proper reporting again. | 12.616426 | 7.262613 | 1.737175 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.