code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def pitch_sim(SIMSTATE, GPS_RAW):
xacc = SIMSTATE.xacc - lowpass(delta(GPS_RAW.v,"v")*6.6, "v", 0.9)
zacc = SIMSTATE.zacc
zacc += SIMSTATE.ygyro * GPS_RAW.v;
if xacc/zacc >= 1:
return 0
if xacc/zacc <= -1:
return -0
return degrees(-asin(xacc/zacc)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier call identifier argument_list binary_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end float string string_start string_content string_end float expression_statement assignment identifier attribute identifier identifier expression_statement augmented_assignment identifier binary_operator attribute identifier identifier attribute identifier identifier if_statement comparison_operator binary_operator identifier identifier integer block return_statement integer if_statement comparison_operator binary_operator identifier identifier unary_operator integer block return_statement unary_operator integer return_statement call identifier argument_list unary_operator call identifier argument_list binary_operator identifier identifier | estimate pitch from SIMSTATE accels |
def random_path(instance, filename):
uuid_hex = get_uuid()
return os.path.join(uuid_hex[:3], uuid_hex[3:], filename) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list subscript identifier slice integer subscript identifier slice integer identifier | Random path generator for uploads, specify this for upload_to= argument of FileFields |
def create_cloud(self):
instances = []
for i in range(self.settings['NUMBER_NODES']):
new_instance = Instance.new(settings=self.settings, cluster=self)
instances.append(new_instance)
create_nodes = [instance.create(suffix=i) for i, instance in enumerate(instances)]
fetch_nodes = [instance.node for instance in instances]
self.driver.wait_until_running(fetch_nodes)
node_ids = [node.id for node in fetch_nodes]
all_nodes = self.driver.list_nodes()
new_nodes = [node for node in all_nodes if node.id in node_ids]
for instance, node in zip(instances, new_nodes):
instance.node = node
self.instances = instances | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list keyword_argument identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator attribute identifier identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier | Create instances for the cloud providers |
def choose_type(cls, content_type):
return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
else cls.type_cls.FILE | module function_definition identifier parameters identifier identifier block return_statement conditional_expression attribute attribute identifier identifier identifier comparison_operator identifier attribute identifier identifier line_continuation attribute attribute identifier identifier identifier | Choose object type from content type. |
def activation_shell_code(self, shell=None):
from rez.shells import create_shell
from rez.rex import RexExecutor
executor = RexExecutor(interpreter=create_shell(shell),
parent_variables=["PATH"],
shebang=False)
executor.env.PATH.append(self.tools_path)
return executor.get_output().strip() | module function_definition identifier parameters identifier default_parameter identifier none block import_from_statement dotted_name identifier identifier dotted_name identifier import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier list string string_start string_content string_end keyword_argument identifier false expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier return_statement call attribute call attribute identifier identifier argument_list identifier argument_list | Get shell code that should be run to activate this suite. |
def files(self):
filelist_p = new_gp_object("CameraList")
lib.gp_camera_folder_list_files(self._cam._cam, self.path.encode(),
filelist_p, self._cam._ctx)
for idx in range(lib.gp_list_count(filelist_p)):
fname = get_string(lib.gp_list_get_name, filelist_p, idx)
yield File(name=fname, directory=self, camera=self._cam)
lib.gp_list_free(filelist_p) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier attribute attribute identifier identifier identifier for_statement identifier call identifier argument_list call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier identifier expression_statement yield call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Get a generator that yields all files in the directory. |
def list_boards(self):
click.echo('\nSupported boards:\n')
BOARDLIST_TPL = ('{board:25} {fpga:20} {type:<5} {size:<5} {pack:<10}')
terminal_width, _ = click.get_terminal_size()
click.echo('-' * terminal_width)
click.echo(BOARDLIST_TPL.format(
board=click.style('Board', fg='cyan'), fpga='FPGA', type='Type',
size='Size', pack='Pack'))
click.echo('-' * terminal_width)
for board in self.boards:
fpga = self.boards.get(board).get('fpga')
click.echo(BOARDLIST_TPL.format(
board=click.style(board, fg='cyan'),
fpga=fpga,
type=self.fpgas.get(fpga).get('type'),
size=self.fpgas.get(fpga).get('size'),
pack=self.fpgas.get(fpga).get('pack')))
click.secho(BOARDS_MSG, fg='green') | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement assignment identifier parenthesized_expression string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end | Return a list with all the supported boards |
def install_program(self):
text = templ_program.render(**self.options)
config = Configuration(self.buildout, self.program + '.conf', {
'deployment': self.deployment_name,
'directory': os.path.join(self.options['etc-directory'], 'conf.d'),
'text': text})
return [config.install()] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier binary_operator attribute identifier identifier string string_start string_content string_end dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier return_statement list call attribute identifier identifier argument_list | install supervisor program config file |
def ReadUntilClose(self):
while True:
cmd, data = self.ReadUntil(b'CLSE', b'WRTE')
if cmd == b'CLSE':
self._Send(b'CLSE', arg0=self.local_id, arg1=self.remote_id)
break
if cmd != b'WRTE':
if cmd == b'FAIL':
raise usb_exceptions.AdbCommandFailureException(
'Command failed.', data)
raise InvalidCommandError('Expected a WRITE or a CLOSE, got %s (%s)',
cmd, data)
yield data | module function_definition identifier parameters identifier block while_statement true block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier break_statement if_statement comparison_operator identifier string string_start string_content string_end block if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier raise_statement call identifier argument_list string string_start string_content string_end identifier identifier expression_statement yield identifier | Yield packets until a Close packet is received. |
def doDup(self, WHAT={}, **params):
if hasattr(WHAT, '_modified'):
for key, value in WHAT._modified():
if WHAT.__new2old__.has_key(key):
self._addDBParam(WHAT.__new2old__[key].encode('utf-8'), value)
else:
self._addDBParam(key, value)
self._addDBParam('RECORDID', WHAT.RECORDID)
self._addDBParam('MODID', WHAT.MODID)
elif type(WHAT) == dict:
for key in WHAT:
self._addDBParam(key, WHAT[key])
else:
raise FMError, 'Python Runtime: Object type (%s) given to function doDup as argument WHAT cannot be used.' % type(WHAT)
if self._layout == '':
raise FMError, 'No layout was selected'
for key in params:
self._addDBParam(key, params[key])
if self._checkRecordID() == 0:
raise FMError, 'RecordID is missing'
return self._doAction('-dup') | module function_definition identifier parameters identifier default_parameter identifier dictionary dictionary_splat_pattern identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute subscript attribute identifier identifier identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier elif_clause comparison_operator call identifier argument_list identifier identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier subscript identifier identifier else_clause block raise_statement expression_list identifier binary_operator string string_start string_content string_end call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier string string_start string_end block raise_statement expression_list identifier string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier subscript identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list integer block raise_statement expression_list identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list string string_start string_content string_end | This function will perform the command -dup. |
def url_should_be(self, url):
if world.browser.current_url != url:
raise AssertionError(
"Browser URL expected to be {!r}, got {!r}.".format(
url, world.browser.current_url)) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute attribute identifier identifier identifier | Assert the absolute URL of the browser is as provided. |
async def sunion(self, keys, *args):
"Return the union of sets specified by ``keys``"
args = list_or_args(keys, args)
return await self.execute_command('SUNION', *args) | module function_definition identifier parameters identifier identifier list_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier return_statement await call attribute identifier identifier argument_list string string_start string_content string_end list_splat identifier | Return the union of sets specified by ``keys`` |
def _load_fast(filename):
it = json.load(open("{}_items.json".format(filename)))
words, unk_index, name = it["items"], it["unk_index"], it["name"]
vectors = np.load(open("{}_vectors.npy".format(filename), 'rb'))
return words, unk_index, name, vectors | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment pattern_list identifier identifier identifier expression_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end return_statement expression_list identifier identifier identifier identifier | Sub for fast loader. |
def getWorkingStandingZeroPoseToRawTrackingPose(self):
fn = self.function_table.getWorkingStandingZeroPoseToRawTrackingPose
pmatStandingZeroPoseToRawTrackingPose = HmdMatrix34_t()
result = fn(byref(pmatStandingZeroPoseToRawTrackingPose))
return result, pmatStandingZeroPoseToRawTrackingPose | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier return_statement expression_list identifier identifier | Returns the standing origin from the working copy. |
def insert_chunk(self, id_):
assert_valid_chunk_id(id_)
self.__fileobj.seek(self.__next_offset)
self.__fileobj.write(pack('>4si', id_.ljust(4).encode('ascii'), 0))
self.__fileobj.seek(self.__next_offset)
chunk = IFFChunk(self.__fileobj, self[u'FORM'])
self[u'FORM']._update_size(self[u'FORM'].data_size + chunk.size)
self.__chunks[id_] = chunk
self.__next_offset = chunk.offset + chunk.size | module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list string string_start string_content string_end call attribute call attribute identifier identifier argument_list integer identifier argument_list string string_start string_content string_end integer expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list binary_operator attribute subscript identifier string string_start string_content string_end identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier | Insert a new chunk at the end of the IFF file |
def _format_url(instrument_type,
instrument_ids,
start_date,
end_date,
earliest_allowed_date):
return (
"http://www.bankofcanada.ca/stats/results/csv"
"?lP=lookup_{instrument_type}_yields.php"
"&sR={restrict}"
"&se={instrument_ids}"
"&dF={start}"
"&dT={end}".format(
instrument_type=instrument_type,
instrument_ids='-'.join(map(prepend("L_"), instrument_ids)),
restrict=earliest_allowed_date.strftime("%Y-%m-%d"),
start=start_date.strftime("%Y-%m-%d"),
end=end_date.strftime("%Y-%m-%d"),
)
) | module function_definition identifier parameters identifier identifier identifier identifier identifier block return_statement parenthesized_expression call attribute 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 string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end | Format a URL for loading data from Bank of Canada. |
def evaluate(self):
try:
self.condition = self.terms.prune(ConditionBinOp)
except AttributeError:
raise ValueError("cannot process expression [{expr}], [{slf}] "
"is not a valid condition".format(expr=self.expr,
slf=self))
try:
self.filter = self.terms.prune(FilterBinOp)
except AttributeError:
raise ValueError("cannot process expression [{expr}], [{slf}] "
"is not a valid filter".format(expr=self.expr,
slf=self))
return self.condition, self.filter | module function_definition identifier parameters identifier block try_statement block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block raise_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 keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier try_statement block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block raise_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 keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier return_statement expression_list attribute identifier identifier attribute identifier identifier | create and return the numexpr condition and filter |
def multi_pop(d, *args):
retval = {}
for key in args:
if key in d:
retval[key] = d.pop(key)
return retval | module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier dictionary for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier | pops multiple keys off a dict like object |
def finish():
out.warn("Interrupted!")
for t in threads:
t.stop()
jobs.clear()
out.warn("Waiting for download threads to finish.") | module function_definition identifier parameters block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Print warning about interrupt and empty the job queue. |
def wrap(sig):
if isclass(sig) and issubclass(sig, Object):
return TypeSignature(sig)
elif isinstance(sig, TypeSignature):
return sig | module function_definition identifier parameters identifier block if_statement boolean_operator call identifier argument_list identifier call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block return_statement identifier | Convert a Python class into a type signature. |
def validate_is_non_abstract_vertex_type(self, vertex_classname):
element = self.get_vertex_schema_element_or_raise(vertex_classname)
if element.abstract:
raise InvalidClassError(u'Expected a non-abstract vertex class, but {} is abstract'
.format(vertex_classname)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier | Validate that a vertex classname corresponds to a non-abstract vertex class. |
def represent_float_as_str(value):
if not isinstance(value, float):
raise GraphQLInvalidArgumentError(u'Attempting to represent a non-float as a float: '
u'{}'.format(value))
with decimal.localcontext() as ctx:
ctx.prec = 20
return u'{:f}'.format(decimal.Decimal(value)) | module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_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 with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement assignment attribute identifier identifier integer return_statement call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier | Represent a float as a string without losing precision. |
def last_string(self):
cb = self.code_builder
len_cb = len(cb)
if len_cb > 0:
return cb[len_cb - 1]
else:
return None | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block return_statement subscript identifier binary_operator identifier integer else_clause block return_statement none | The last entry in code_builder, or ``None`` if none so far. |
def identify_id(id: str) -> bool:
return re.match(r'^https?://', id, flags=re.IGNORECASE) is not None | module function_definition identifier parameters typed_parameter identifier type identifier type identifier block return_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier attribute identifier identifier none | Try to identify whether this is an ActivityPub ID. |
def remove_profile(name, s3=False):
user = os.path.expanduser("~")
if s3:
f = os.path.join(user, S3_PROFILE_ID + name)
else:
f = os.path.join(user, DBPY_PROFILE_ID + name)
try:
try:
open(f)
except:
raise Exception("Profile '{0}' does not exist. Could not find file {1}".format(name, f))
os.remove(f)
except Exception as e:
raise Exception("Could not remove profile {0}! Excpetion: {1}".format(name, e)) | module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator identifier identifier try_statement block try_statement block expression_statement call identifier argument_list identifier except_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier | Removes a profile from your config |
def from_string(string):
mnemonics = {
"add": ReilMnemonic.ADD,
"sub": ReilMnemonic.SUB,
"mul": ReilMnemonic.MUL,
"div": ReilMnemonic.DIV,
"mod": ReilMnemonic.MOD,
"bsh": ReilMnemonic.BSH,
"and": ReilMnemonic.AND,
"or": ReilMnemonic.OR,
"xor": ReilMnemonic.XOR,
"ldm": ReilMnemonic.LDM,
"stm": ReilMnemonic.STM,
"str": ReilMnemonic.STR,
"bisz": ReilMnemonic.BISZ,
"jcc": ReilMnemonic.JCC,
"unkn": ReilMnemonic.UNKN,
"undef": ReilMnemonic.UNDEF,
"nop": ReilMnemonic.NOP,
"sext": ReilMnemonic.SEXT,
"sdiv": ReilMnemonic.SDIV,
"smod": ReilMnemonic.SMOD,
"smul": ReilMnemonic.SMUL,
}
return mnemonics[string] | module function_definition identifier parameters identifier block expression_statement assignment identifier 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 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 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 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 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 attribute identifier identifier return_statement subscript identifier identifier | Return the mnemonic represented by the given string. |
def accept(self, discovery: ControllerDiscovery):
if self.require_class is not None and not isinstance(discovery.controller, self.require_class):
return False
if self.snames is not None:
all_controls = discovery.controller.buttons.names + discovery.controller.axes.names
for sname in self.snames:
if sname not in all_controls:
return False
return True | module function_definition identifier parameters identifier typed_parameter identifier type identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none not_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block return_statement false if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier binary_operator attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block return_statement false return_statement true | Returns True if the supplied ControllerDiscovery matches this requirement, False otherwise |
def all_editable_exts():
exts = []
for (language, extensions) in languages.ALL_LANGUAGES.items():
exts.extend(list(extensions))
return ['.' + ext for ext in exts] | module function_definition identifier parameters block expression_statement assignment identifier list for_statement tuple_pattern identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement list_comprehension binary_operator string string_start string_content string_end identifier for_in_clause identifier identifier | Return a list of all editable extensions |
def assignPlugin(self):
self.uiOperatorDDL.blockSignals(True)
self.uiOperatorDDL.clear()
plugin = self.currentPlugin()
if plugin:
flags = 0
if not self.queryWidget().showReferencePlugins():
flags |= plugin.Flags.ReferenceRequired
self.uiOperatorDDL.addItems(plugin.operators(ignore=flags))
self.uiOperatorDDL.blockSignals(False)
self.assignEditor() | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list true expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier integer if_statement not_operator call attribute call attribute identifier identifier argument_list identifier argument_list block expression_statement augmented_assignment identifier attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list false expression_statement call attribute identifier identifier argument_list | Assigns an editor based on the current column for this schema. |
def images():
fields = [
('Name', 'name'),
('Registry', 'registry'),
('Tag', 'tag'),
('Digest', 'digest'),
('Size', 'size_bytes'),
('Aliases', 'aliases'),
]
with Session() as session:
try:
items = session.Image.list(fields=(item[1] for item in fields))
except Exception as e:
print_error(e)
sys.exit(1)
if len(items) == 0:
print('There are no registered images.')
return
print(tabulate((item.values() for item in items),
headers=(item[0] for item in fields),
floatfmt=',.0f')) | module function_definition identifier parameters block expression_statement assignment identifier list tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list as_pattern_target identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier generator_expression subscript identifier integer for_in_clause identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement call identifier argument_list call identifier argument_list generator_expression call attribute identifier identifier argument_list for_in_clause identifier identifier keyword_argument identifier generator_expression subscript identifier integer for_in_clause identifier identifier keyword_argument identifier string string_start string_content string_end | Show the list of registered images in this cluster. |
def complete_opt_allow_select_scan(self, text, *_):
return [t for t in ("true", "false", "yes", "no") if t.startswith(text.lower())] | module function_definition identifier parameters identifier identifier list_splat_pattern identifier block return_statement list_comprehension identifier for_in_clause identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_clause call attribute identifier identifier argument_list call attribute identifier identifier argument_list | Autocomplete for allow_select_scan option |
def run(self, args=None):
print(Colors.BLUE+"[INFO] Unlinking {}...".format(
args.names)+Colors.RESET)
for name in args.names:
self.unlink(Link.package_dir, name) | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement call identifier argument_list binary_operator binary_operator attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier | The name IS required here. |
def stop_task(self, task_name):
for greenlet in self.active[task_name]:
try:
gevent.kill(greenlet)
self.active[task_name] = []
except BaseException:
pass | module function_definition identifier parameters identifier identifier block for_statement identifier subscript attribute identifier identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier identifier list except_clause identifier block pass_statement | Stops a running or dead task |
def delete(self, name=None):
"Delete the shelve data file."
logger.info('clearing shelve data')
self.close()
for path in Path(self.create_path.parent, self.create_path.name), \
Path(self.create_path.parent, self.create_path.name + '.db'):
logger.debug(f'clearing {path} if exists: {path.exists()}')
if path.exists():
path.unlink()
break | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list for_statement identifier expression_list call identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier line_continuation call identifier argument_list attribute attribute identifier identifier identifier binary_operator attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_content interpolation call attribute identifier identifier argument_list string_end if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list break_statement | Delete the shelve data file. |
def parse_date(ims):
try:
ts = email.utils.parsedate_tz(ims)
return time.mktime(ts[:8] + (0,)) - (ts[9] or 0) - time.timezone
except (TypeError, ValueError, IndexError):
return None | module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement binary_operator binary_operator call attribute identifier identifier argument_list binary_operator subscript identifier slice integer tuple integer parenthesized_expression boolean_operator subscript identifier integer integer attribute identifier identifier except_clause tuple identifier identifier identifier block return_statement none | Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch. |
def keytype_path_to(args, keytype):
if keytype == "admin":
return '{cluster}.client.admin.keyring'.format(
cluster=args.cluster)
if keytype == "mon":
return '{cluster}.mon.keyring'.format(
cluster=args.cluster)
return '{cluster}.bootstrap-{what}.keyring'.format(
cluster=args.cluster,
what=keytype) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier | Get the local filename for a keyring type |
def skip(self, chars=spaceCharactersBytes):
p = self.position
while p < len(self):
c = self[p:p + 1]
if c not in chars:
self._position = p
return c
p += 1
self._position = p
return None | module function_definition identifier parameters identifier default_parameter identifier identifier block expression_statement assignment identifier attribute identifier identifier while_statement comparison_operator identifier call identifier argument_list identifier block expression_statement assignment identifier subscript identifier slice identifier binary_operator identifier integer if_statement comparison_operator identifier identifier block expression_statement assignment attribute identifier identifier identifier return_statement identifier expression_statement augmented_assignment identifier integer expression_statement assignment attribute identifier identifier identifier return_statement none | Skip past a list of characters |
def timestamps(self):
timestamps = set()
for series in self.groups.itervalues():
timestamps |= set(series.timestamps)
return sorted(list(timestamps)) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement augmented_assignment identifier call identifier argument_list attribute identifier identifier return_statement call identifier argument_list call identifier argument_list identifier | Get all timestamps from all series in the group. |
def __bytes_to_share_data(self, payload):
rbytes = payload[P_DATA]
mime = payload[P_MIME]
if mime is None or not self.__auto_encode_decode:
return rbytes, mime
mime = expand_idx_mimetype(mime).lower()
try:
if mime == 'application/ubjson':
return ubjloadb(rbytes), None
elif mime == 'text/plain; charset=utf8':
return rbytes.decode('utf-8'), None
else:
return rbytes, mime
except:
logger.warning('auto-decode failed, returning bytes', exc_info=DEBUG_ENABLED)
return rbytes, mime | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier subscript identifier identifier if_statement boolean_operator comparison_operator identifier none not_operator attribute identifier identifier block return_statement expression_list identifier identifier expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list try_statement block if_statement comparison_operator identifier string string_start string_content string_end block return_statement expression_list call identifier argument_list identifier none elif_clause comparison_operator identifier string string_start string_content string_end block return_statement expression_list call attribute identifier identifier argument_list string string_start string_content string_end none else_clause block return_statement expression_list identifier identifier except_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier return_statement expression_list identifier identifier | Attempt to auto-decode data |
def _readClusterSettings(self):
mdUrl = "http://169.254.169.254/metadata/instance?api-version=2017-08-01"
header = {'Metadata': 'True'}
request = urllib.request.Request(url=mdUrl, headers=header)
response = urllib.request.urlopen(request)
data = response.read()
dataStr = data.decode("utf-8")
metadata = json.loads(dataStr)
self._zone = metadata['compute']['location']
self.clusterName = metadata['compute']['resourceGroupName']
tagsStr = metadata['compute']['tags']
tags = dict(item.split(":") for item in tagsStr.split(";"))
self._owner = tags.get('owner', 'no-owner')
leader = self.getLeader()
self._leaderPrivateIP = leader.privateIP
self._setSSH()
self._masterPublicKeyFile = self.LEADER_HOME_DIR + '.ssh/id_rsa.pub'
map(lambda x: self._addToHosts(x), self.getProvisionedWorkers(None)) | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier generator_expression call attribute identifier identifier argument_list string string_start string_content string_end for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier 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 expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list none | Read the current instance's meta-data to get the cluster settings. |
def exists(self, qname):
try:
if self.conn.queue_exists(qname):
return True
return False
except pyrax.exceptions as err_msg:
log.error('RackSpace API got some problems during '
'existing queue check: %s',
err_msg)
return False | module function_definition identifier parameters identifier identifier block try_statement block if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement true return_statement false except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier return_statement false | Check to see if a Queue exists. |
def unsubscribe(self, sid):
if sid not in self.observers:
raise KeyError(
'Cannot disconnect a observer does not connected to subject'
)
del self.observers[sid] | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end delete_statement subscript attribute identifier identifier identifier | Disconnect an observer from this subject |
def dinfContributingArea(self,
contributing_area_grid,
flow_dir_grid,
outlet_shapefile=None,
weight_grid=None,
edge_contamination=False,
):
log("PROCESS: DinfContributingArea")
cmd = [os.path.join(self.taudem_exe_path, 'areadinf'),
'-ang', flow_dir_grid,
'-sca', contributing_area_grid,
]
if outlet_shapefile:
cmd += ['-o', outlet_shapefile]
if weight_grid:
cmd += ['-wg', weight_grid]
if not edge_contamination:
cmd = cmd + ['-nc']
self._run_mpi_cmd(cmd)
self._add_prj_file(flow_dir_grid,
contributing_area_grid) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end identifier if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier if_statement not_operator identifier block expression_statement assignment identifier binary_operator identifier list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier | Calculates contributing area with Dinf method. |
def load_env():
for key, envvar in [['cache_dir', 'INTAKE_CACHE_DIR'],
['catalog_path', 'INTAKE_PATH'],
['persist_path', 'INTAKE_PERSIST_PATH']]:
if envvar in os.environ:
conf[key] = make_path_posix(os.environ[envvar])
conf['catalog_path'] = intake_path_dirs(conf['catalog_path'])
for key, envvar in [['cache_disabled', 'INTAKE_DISABLE_CACHING'],
['cache_download_progress', 'INTAKE_CACHE_PROGRESS']]:
if envvar in os.environ:
conf[key] = os.environ[envvar].lower() in ['true', 't', 'y', 'yes']
if 'INTAKE_LOG_LEVEL' in os.environ:
conf['logging'] = os.environ['INTAKE_LOG_LEVEL'] | module function_definition identifier parameters block for_statement pattern_list identifier identifier list list string string_start string_content string_end string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list subscript attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end for_statement pattern_list identifier identifier list list string string_start string_content string_end string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier comparison_operator call attribute subscript attribute identifier identifier 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 if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end | Analyse enviroment variables and update conf accordingly |
def settings(self):
if not hasattr(self, '_settings'):
sett = self.connection.settings_dict.copy()
sett.update(settings.CONNECTORS.get(self.database_name, {}))
self._settings = sett
return self._settings | module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier | Mix of database and connector settings. |
def sim_combi(self):
n_samples = 500
sigma_glob = 1.8
X = np.zeros((n_samples,3))
X[:,0] = np.random.uniform(-sigma_glob,sigma_glob,n_samples)
X[:,1] = np.random.uniform(-sigma_glob,sigma_glob,n_samples)
func = self.funcs['tanh']
X[:,2] = (func(X[:,0])*sp.stats.norm.cdf(X[:,1],1,0.2))
pl.scatter(X[:,0],X[:,1],c=X[:,2],edgecolor='face')
pl.show()
pl.plot(X[:,1],X[:,2],'.')
pl.show()
return X | module function_definition identifier parameters identifier block expression_statement assignment identifier integer expression_statement assignment identifier float expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier integer expression_statement assignment subscript identifier slice integer call attribute attribute identifier identifier identifier argument_list unary_operator identifier identifier identifier expression_statement assignment subscript identifier slice integer call attribute attribute identifier identifier identifier argument_list unary_operator identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment subscript identifier slice integer parenthesized_expression binary_operator call identifier argument_list subscript identifier slice integer call attribute attribute attribute identifier identifier identifier identifier argument_list subscript identifier slice integer integer float expression_statement call attribute identifier identifier argument_list subscript identifier slice integer subscript identifier slice integer keyword_argument identifier subscript identifier slice integer keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list subscript identifier slice integer subscript identifier slice integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list return_statement identifier | Simulate data to model combi regulation. |
def _process_cities_file(self, file, city_country_mapping):
data = {'all_regions': list(), 'regions': list(), 'cities': list(), 'city_region_mapping': dict()}
allowed_countries = settings.IPGEOBASE_ALLOWED_COUNTRIES
for geo_info in self._line_to_dict(file, field_names=settings.IPGEOBASE_CITIES_FIELDS):
country_code = self._get_country_code_for_city(geo_info['city_id'], city_country_mapping, data['all_regions'])
new_region = {'name': geo_info['region_name'],
'country__code': country_code}
if new_region not in data['all_regions']:
data['all_regions'].append(new_region)
if allowed_countries and country_code not in allowed_countries:
continue
if new_region not in data['regions']:
data['regions'].append(new_region)
data['cities'].append({'region__name': geo_info['region_name'],
'name': geo_info['city_name'],
'id': geo_info['city_id'],
'latitude': Decimal(geo_info['latitude']),
'longitude': Decimal(geo_info['longitude'])})
return data | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list pair string string_start string_content string_end call identifier argument_list pair string string_start string_content string_end call identifier argument_list pair string string_start string_content string_end call identifier argument_list expression_statement assignment identifier attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end identifier if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier if_statement boolean_operator identifier comparison_operator identifier identifier block continue_statement if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end pair string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier | Iterate over cities info and extract useful data |
def scale_axes_dialog(self, show=True):
return ScaleAxesDialog(self.app_window, self, show=show) | module function_definition identifier parameters identifier default_parameter identifier true block return_statement call identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier | Open scale axes dialog |
def log_request(self, extra=''):
thread_name = threading.currentThread().getName().lower()
if thread_name == 'mainthread':
thread_name = ''
else:
thread_name = '-%s' % thread_name
if self.config['proxy']:
if self.config['proxy_userpwd']:
auth = ' with authorization'
else:
auth = ''
proxy_info = ' via %s proxy of type %s%s' % (
self.config['proxy'], self.config['proxy_type'], auth)
else:
proxy_info = ''
if extra:
extra = '[%s] ' % extra
logger_network.debug(
'[%s%s] %s%s %s%s',
('%02d' % self.request_counter
if self.request_counter is not None else 'NA'),
thread_name,
extra, self.request_method or 'GET',
self.config['url'], proxy_info) | module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list identifier argument_list identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_end else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement subscript attribute identifier identifier string string_start string_content string_end block if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier binary_operator string string_start string_content string_end tuple subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end identifier else_clause block expression_statement assignment identifier string string_start string_end if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end parenthesized_expression conditional_expression binary_operator string string_start string_content string_end attribute identifier identifier comparison_operator attribute identifier identifier none string string_start string_content string_end identifier identifier boolean_operator attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end identifier | Send request details to logging system. |
def to_networkx(self, labels=None, edge_labels=False):
import networkx as nx
graph = nx.DiGraph()
for node in self._traverse_nodes():
u = node.key
graph.add_node(u)
graph.nodes[u]['value'] = node.value
if labels is not None:
label = ','.join([str(getattr(node, k)) for k in labels])
graph.nodes[u]['label'] = label
if node.left is not None:
v = node.left.key
graph.add_node(v)
graph.add_edge(u, v)
if edge_labels:
graph.edge[u][v]['label'] = 'L'
if node.right is not None:
v = node.right.key
graph.add_node(v)
graph.add_edge(u, v)
if edge_labels:
graph.edge[u][v]['label'] = 'R'
return graph | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false block import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript subscript attribute identifier identifier identifier string string_start string_content string_end attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension call identifier argument_list call identifier argument_list identifier identifier for_in_clause identifier identifier expression_statement assignment subscript subscript attribute identifier identifier identifier string string_start string_content string_end identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment subscript subscript subscript attribute identifier identifier identifier identifier string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment subscript subscript subscript attribute identifier identifier identifier identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier | Get a networkx representation of the binary search tree. |
def string_tag(name, value):
return name.encode('utf-8') + \
len(value).to_bytes(4, byteorder='big') + \
value.encode('utf-8') | module function_definition identifier parameters identifier identifier block return_statement binary_operator binary_operator call attribute identifier identifier argument_list string string_start string_content string_end line_continuation call attribute call identifier argument_list identifier identifier argument_list integer keyword_argument identifier string string_start string_content string_end line_continuation call attribute identifier identifier argument_list string string_start string_content string_end | Create a DMAP tag with string data. |
def _load(self):
self.wavelength, self.irradiance = \
np.genfromtxt(self.filename, unpack=True) | module function_definition identifier parameters identifier block expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier line_continuation call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true | Read the tabulated spectral irradiance data from file |
def optional_names(self):
for name, var in self.items():
if var.get('optional', False):
yield name | module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call attribute identifier identifier argument_list string string_start string_content string_end false block expression_statement yield identifier | Get a list of the variables that are defined, but not required |
def stripped_args(args):
stripped_args = []
for arg in args:
stripped_args.append(arg.strip())
return stripped_args | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement identifier | Return the stripped version of the arguments. |
def iuniq(ible):
items = set()
for item in ible:
if item not in items:
items.add(item)
yield item | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement yield identifier | Get an iterator over unique items of `ible`. |
def by_median_home_value(self,
lower=-1,
upper=2 ** 31,
zipcode_type=ZipcodeType.Standard,
sort_by=SimpleZipcode.median_home_value.name,
ascending=False,
returns=DEFAULT_LIMIT):
return self.query(
median_home_value_lower=lower,
median_home_value_upper=upper,
sort_by=sort_by, zipcode_type=zipcode_type,
ascending=ascending, returns=returns,
) | module function_definition identifier parameters identifier default_parameter identifier unary_operator integer default_parameter identifier binary_operator integer integer default_parameter identifier attribute identifier identifier default_parameter identifier attribute attribute identifier identifier identifier default_parameter identifier false default_parameter identifier identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Search zipcode information by median home value. |
def setup_params(self, data):
if 'ymax' in data:
if any((data['ymin'] != 0) & (data['ymax'] != 0)):
warn("Stacking not well defined when not "
"anchored on the axis.", PlotnineWarning)
var = 'ymax'
elif 'y' in data:
var = 'y'
else:
warn("Stacking requires either ymin & ymax or y "
"aesthetics. Maybe you want position = 'identity'?",
PlotnineWarning)
var = None
params = self.params.copy()
params['var'] = var
params['fill'] = self.fill
return params | module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block if_statement call identifier argument_list binary_operator parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end integer parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end integer block expression_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier none expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier | Verify, modify & return a copy of the params. |
def all_same_proj(self):
all_areas = [x.attrs.get('area', None) for x in self.values()]
all_areas = [x for x in all_areas if x is not None]
return all(all_areas[0].proj_str == x.proj_str for x in all_areas[1:]) | module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none for_in_clause identifier call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier none return_statement call identifier generator_expression comparison_operator attribute subscript identifier integer identifier attribute identifier identifier for_in_clause identifier subscript identifier slice integer | All contained data array are in the same projection. |
def button(request):
if not authenticated_userid(request):
return markupsafe.Markup(SIGNIN_HTML)
else:
return markupsafe.Markup(SIGNOUT_HTML) | module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier block return_statement call attribute identifier identifier argument_list identifier else_clause block return_statement call attribute identifier identifier argument_list identifier | If the user is logged in, returns the logout button, otherwise returns the login button |
def stop_job(self, job_id):
method = 'PUT'
endpoint = '/rest/v1/{}/jobs/{}/stop'.format(
self.client.sauce_username, job_id)
return self.client.request(method, endpoint) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier | Terminates a running job. |
def build_ajax_votes(request, user_profile):
vote_list = ''
for profile in request.upvotes.all():
vote_list += \
'<li><a title="View Profile" href="{url}">{name}</a></li>'.format(
url=reverse(
'member_profile',
kwargs={'targetUsername': profile.user.username}
),
name='You' if profile.user == user_profile.user \
else profile.user.get_full_name(),
)
in_votes = user_profile in request.upvotes.all()
count = request.upvotes.all().count()
return (vote_list, in_votes, count) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier keyword_argument identifier conditional_expression string string_start string_content string_end comparison_operator attribute identifier identifier attribute identifier identifier line_continuation call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier comparison_operator identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list return_statement tuple identifier identifier identifier | Build vote information for the request. |
def reboot(self):
if self.get_power_state() == LsPower.CONST_STATE_DOWN:
self.set_power_state(LsPower.CONST_STATE_UP)
else:
self.set_power_state(LsPower.CONST_STATE_HARD_RESET_IMMEDIATE) | module function_definition identifier parameters identifier block if_statement comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier | Hard reset the power of this node. |
def ToDatetime(self):
return datetime.utcfromtimestamp(
self.seconds + self.nanos / float(_NANOS_PER_SECOND)) | module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier binary_operator attribute identifier identifier call identifier argument_list identifier | Converts Timestamp to datetime. |
def _get_default_values(self, default_values=None):
if not default_values:
default_values = self.DEFAULT_VALUES
if default_values:
api_version = str(self._connection._apiVersion)
values = default_values.get(api_version, {}).copy()
else:
values = {}
return values | module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier dictionary identifier argument_list else_clause block expression_statement assignment identifier dictionary return_statement identifier | Gets the default values set for a resource |
def tmpdir(self):
if self._tmpdir is None:
self._tmpdir = mkdtemp(prefix="colin-", dir="/var/tmp")
return self._tmpdir | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end return_statement attribute identifier identifier | Temporary directory holding all the runtime data. |
def parse_config(file_name='smarterling.config'):
if not os.path.exists(file_name) or not os.path.isfile(file_name):
raise SmarterlingError('Config file not found: %s' % file_name)
try:
contents = read_from_file(file_name)
contents_with_environment_variables_expanded = os.path.expandvars(contents)
return AttributeDict(yaml.load(contents_with_environment_variables_expanded))
except Exception as e:
raise SmarterlingError("Error paring config file: %s" % str(e)) | module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block if_statement boolean_operator not_operator call attribute attribute identifier identifier identifier argument_list identifier not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier | Parses a smarterling configuration file |
def prefix_iter(self, ns_uri):
ni = self.__lookup_uri(ns_uri)
return iter(ni.prefixes) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list attribute identifier identifier | Gets an iterator over the prefixes for the given namespace. |
def find_var_end(self, text):
return self.find_end(text, self.start_var_token, self.end_var_token) | module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier | find the of a variable |
def deps(ctx):
header(deps.__doc__)
with ctx.cd(ROOT):
ctx.run('pip install -r requirements/develop.pip -r requirements/doc.pip', pty=True) | module function_definition identifier parameters identifier block expression_statement call identifier argument_list attribute identifier identifier with_statement with_clause with_item call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true | Install or update development dependencies |
def create_pipeline(self):
pipelines = self.settings['pipeline']['pipeline_files']
self.log.info('Uploading manual Pipelines: %s', pipelines)
lookup = FileLookup(git_short=self.generated.gitlab()['main'], runway_dir=self.runway_dir)
for json_file in pipelines:
json_dict = lookup.json(filename=json_file)
json_dict.setdefault('application', self.app_name)
json_dict.setdefault('name', normalize_pipeline_name(name=json_file))
json_dict.setdefault('id', get_pipeline_id(app=json_dict['application'], name=json_dict['name']))
self.post_pipeline(json_dict)
return True | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement true | Use JSON files to create Pipelines. |
def _remove_some_work_units(self, work_spec_name, work_unit_names,
suffix='', priority_min='-inf',
priority_max='+inf'):
now = time.time()
if work_unit_names is None:
count = 0
while True:
with self.registry.lock(identifier=self.worker_id) as session:
names = session.filter(
WORK_UNITS_ + work_spec_name + suffix,
priority_min=priority_min, priority_max=priority_max,
limit=1000)
if not names: break
count += session.popmany(
WORK_UNITS_ + work_spec_name + suffix, *names)
else:
with self.registry.lock(identifier=self.worker_id) as session:
count = session.popmany(WORK_UNITS_ + work_spec_name + suffix,
*work_unit_names)
return count | module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier integer while_statement true block with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier integer if_statement not_operator identifier block break_statement expression_statement augmented_assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator identifier identifier identifier list_splat identifier else_clause block with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator identifier identifier identifier list_splat identifier return_statement identifier | Remove some units from somewhere. |
def save_hdf_metadata(filename, metadata, groupname="data", mode="a"):
with _h5py.File(filename, mode) as f:
for key, val in metadata.items():
f[groupname].attrs[key] = val | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier identifier as_pattern_target identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript attribute subscript identifier identifier identifier identifier identifier | Save a dictionary of metadata to a group's attrs. |
def on_model_change(self, form, User, is_created):
if form.password.data is not None:
pwd_ctx = current_app.extensions['security'].pwd_context
if pwd_ctx.identify(form.password.data) is None:
User.password = hash_password(form.password.data) | module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement assignment identifier attribute subscript attribute identifier identifier string string_start string_content string_end identifier if_statement comparison_operator call attribute identifier identifier argument_list attribute attribute identifier identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list attribute attribute identifier identifier identifier | Hash password when saving. |
def GetNotifications(user=None, token=None):
if not user:
user = getpass.getuser()
user_obj = aff4.FACTORY.Open(
aff4.ROOT_URN.Add("users").Add(user), token=token)
return list(user_obj.Get(user_obj.Schema.PENDING_NOTIFICATIONS)) | module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list identifier keyword_argument identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list attribute attribute identifier identifier identifier | Show pending notifications for a user. |
def ParseConfigCommandLine():
if flags.FLAGS.config:
_CONFIG.Initialize(filename=flags.FLAGS.config, must_exist=True)
else:
raise RuntimeError("A config file is not specified.")
if flags.FLAGS.secondary_configs:
for config_file in flags.FLAGS.secondary_configs:
_CONFIG.LoadSecondaryConfig(config_file)
for statement in flags.FLAGS.parameter:
if "=" not in statement:
raise RuntimeError("statement %s on command line not valid." % statement)
name, value = statement.split("=", 1)
_CONFIG.global_override[name] = value
for context in flags.FLAGS.context:
if context:
_CONFIG.AddContext(context)
if _CONFIG["Config.writeback"]:
_CONFIG.SetWriteBack(_CONFIG["Config.writeback"])
if flags.FLAGS.config_help:
print("Configuration overview.")
_CONFIG.PrintHelp()
sys.exit(0) | module function_definition identifier parameters block if_statement attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier true else_clause block raise_statement call identifier argument_list string string_start string_content string_end if_statement attribute attribute identifier identifier identifier block for_statement identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute attribute identifier identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment subscript attribute identifier identifier identifier identifier for_statement identifier attribute attribute identifier identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement attribute attribute identifier identifier 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 call attribute identifier identifier argument_list integer | Parse all the command line options which control the config system. |
def _create_create_tracking_event(instance):
event = _create_event(instance, CREATE)
for field in instance._tracked_fields:
if not isinstance(instance._meta.get_field(field), ManyToManyField):
_create_tracked_field(event, instance, field) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier identifier for_statement identifier attribute identifier identifier block if_statement not_operator call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier block expression_statement call identifier argument_list identifier identifier identifier | Create a TrackingEvent and TrackedFieldModification for a CREATE event. |
def topics(text):
detectors = [
detector_50_Cent
]
ts = []
for detector in detectors:
ts.append(detector(text))
return [t[0] for t in ts if t[1] > 0.95] | module function_definition identifier parameters identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement list_comprehension subscript identifier integer for_in_clause identifier identifier if_clause comparison_operator subscript identifier integer float | Return a list of topics. |
def credentials(self):
if self.filename:
db_filename = os.path.join(os.getcwd(), self.filename)
else:
db_filename = None
return {
"username": self.username,
"password": self.password,
"hostname": self.hostname,
"port": self.port,
"filename": db_filename,
"dbname": self.dbname,
"dbtype": self.dbtype,
"schemas": self.schemas,
"limit": self.limit,
"keys_per_column": self.keys_per_column,
} | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier none 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 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 attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier | Dict representation of all credentials for the database. |
def getObjectsInHouse(self, house):
res = [obj for obj in self if house.hasObject(obj)]
return ObjectList(res) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier | Returns a list with all objects in a house. |
def keypair():
fields = [
('User ID', 'user_id'),
('Access Key', 'access_key'),
('Secret Key', 'secret_key'),
('Active?', 'is_active'),
('Admin?', 'is_admin'),
('Created At', 'created_at'),
('Last Used', 'last_used'),
('Res.Policy', 'resource_policy'),
('Rate Limit', 'rate_limit'),
('Concur.Limit', 'concurrency_limit'),
('Concur.Used', 'concurrency_used'),
]
with Session() as session:
try:
kp = session.KeyPair(session.config.access_key)
info = kp.info(fields=(item[1] for item in fields))
except Exception as e:
print_error(e)
sys.exit(1)
rows = []
for name, key in fields:
rows.append((name, info[key]))
print(tabulate(rows, headers=('Field', 'Value'))) | module function_definition identifier parameters block expression_statement assignment identifier list tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list as_pattern_target identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier generator_expression subscript identifier integer for_in_clause identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list tuple identifier subscript identifier identifier expression_statement call identifier argument_list call identifier argument_list identifier keyword_argument identifier tuple string string_start string_content string_end string string_start string_content string_end | Show the server-side information of the currently configured access key. |
def summary_plot(data):
cats = OrderedDict()
cats = {
'inniepairs': {
'name': 'Combined innie pairs',
'color': '
},
'outiepairs': {
'name': 'Combined outie pairs',
'color': '
},
'uncombopairs': {
'name': 'Uncombined pairs',
'color': '
},
'discardpairs': {
'name': 'Discarded pairs',
'color': '
}
}
splotconfig = {'id': 'flash_combo_stats_plot',
'title': 'FLASh: Read combination statistics',
'ylab': 'Number of read pairs',
'hide_zero_cats': False }
return bargraph.plot(data, cats, splotconfig) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier dictionary pair 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_end pair 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_end pair 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_end pair 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_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end false return_statement call attribute identifier identifier argument_list identifier identifier identifier | Barplot of combined pairs |
def verify(path):
valid = False
try:
zf = zipfile.ZipFile(path)
except (zipfile.BadZipfile, IsADirectoryError):
pass
else:
names = sorted(zf.namelist())
names = [nn for nn in names if nn.endswith(".tif")]
names = [nn for nn in names if nn.startswith("SID PHA")]
for name in names:
with zf.open(name) as pt:
fd = io.BytesIO(pt.read())
if SingleTifPhasics.verify(fd):
valid = True
break
zf.close()
return valid | module function_definition identifier parameters identifier block expression_statement assignment identifier false try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause tuple attribute identifier identifier identifier block pass_statement else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier true break_statement expression_statement call attribute identifier identifier argument_list return_statement identifier | Verify that `path` is a zip file with Phasics TIFF files |
def validate_type(value, types, **kwargs):
if not is_value_of_any_type(value, types):
raise ValidationError(MESSAGES['type']['invalid'].format(
repr(value), get_type_for_value(value), types,
)) | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list call identifier argument_list identifier call identifier argument_list identifier identifier | Validate that the value is one of the provided primative types. |
def _init_predictor(self, input_shapes, type_dict=None):
shapes = {name: self.arg_params[name].shape for name in self.arg_params}
shapes.update(dict(input_shapes))
if self._pred_exec is not None:
arg_shapes, _, _ = self.symbol.infer_shape(**shapes)
assert arg_shapes is not None, "Incomplete input shapes"
pred_shapes = [x.shape for x in self._pred_exec.arg_arrays]
if arg_shapes == pred_shapes:
return
pred_exec = self.symbol.simple_bind(
self.ctx[0], grad_req='null', type_dict=type_dict, **shapes)
pred_exec.copy_params_from(self.arg_params, self.aux_params)
_check_arguments(self.symbol)
self._pred_exec = pred_exec | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier dictionary_comprehension pair identifier attribute subscript attribute identifier identifier identifier identifier for_in_clause identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment pattern_list identifier identifier identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier assert_statement comparison_operator identifier none string string_start string_content string_end expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier identifier block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier integer keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier identifier | Initialize the predictor module for running prediction. |
def aggregate(self, other=None):
if not self.status:
return self
if not other:
return self
if not other.status:
return other
return Value(True, other.index, self.value + other.value, None) | module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator attribute identifier identifier block return_statement identifier if_statement not_operator identifier block return_statement identifier if_statement not_operator attribute identifier identifier block return_statement identifier return_statement call identifier argument_list true attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier none | collect the furthest failure from self and other. |
def describe_variables(self, v):
reverse_mapping = {next(iter(var.variables)): k for k, var in self.eternal_tracked_variables.items()}
reverse_mapping.update({next(iter(var.variables)): k for k, var in self.temporal_tracked_variables.items() if k[-1] is not None})
for var in v.variables:
if var in reverse_mapping:
yield reverse_mapping[var] | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary_comprehension pair call identifier argument_list call identifier argument_list attribute identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary_comprehension pair call identifier argument_list call identifier argument_list attribute identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause comparison_operator subscript identifier unary_operator integer none for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement yield subscript identifier identifier | Given an AST, iterate over all the keys of all the BVS leaves in the tree which are registered. |
def verify_param(self, param, must=[], r=None):
if APIKEY not in param:
param[APIKEY] = self.apikey()
r = Result() if r is None else r
for p in must:
if p not in param:
r.code(Code.ARGUMENT_MISSING).detail('missing-' + p)
break
return r | module function_definition identifier parameters identifier identifier default_parameter identifier list default_parameter identifier none block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier conditional_expression call identifier argument_list comparison_operator identifier none identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier break_statement return_statement identifier | return Code.ARGUMENT_MISSING if every key in must not found in param |
def emit(self, sound, exclude=set()):
nearby = self.nearby()
try:
exclude = set(exclude)
except TypeError:
exclude = set([exclude])
exclude.add(self.entity)
listeners = nearby - exclude
for listener in listeners:
listener.tell(sound) | module function_definition identifier parameters identifier identifier default_parameter identifier call identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block expression_statement assignment identifier call identifier argument_list list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier | Send text to entities nearby this one. |
def connect(self, sid, namespace):
self.enter_room(sid, namespace, None)
self.enter_room(sid, namespace, sid) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier none expression_statement call attribute identifier identifier argument_list identifier identifier identifier | Register a client connection to a namespace. |
def on_window_vertical_displacement_value_changed(self, spin):
self.settings.general.set_int('window-vertical-displacement', int(spin.get_value())) | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list | Changes the value of window-vertical-displacement |
def count_by(records: Sequence[Dict], field_name: str) -> defaultdict:
counter = defaultdict(int)
for record in records:
name = record[field_name]
counter[name] += 1
return counter | module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement augmented_assignment subscript identifier identifier integer return_statement identifier | Frequency each value occurs in a record sequence for a given field name. |
def roles_add(user, role):
user, role = _datastore._prepare_role_modify_args(user, role)
if user is None:
raise click.UsageError('Cannot find user.')
if role is None:
raise click.UsageError('Cannot find role.')
if _datastore.add_role_to_user(user, role):
click.secho('Role "{0}" added to user "{1}" '
'successfully.'.format(role, user), fg='green')
else:
raise click.UsageError('Cannot add role to user.') | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end else_clause block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end | Add user to role. |
def next(self):
if self._cur_row >= len(self._table):
raise StopIteration
data = self._table[self._cur_row].copy()
self._cur_row += 1
return data | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier call identifier argument_list attribute identifier identifier block raise_statement identifier expression_statement assignment identifier call attribute subscript attribute identifier identifier attribute identifier identifier identifier argument_list expression_statement augmented_assignment attribute identifier identifier integer return_statement identifier | Returns the next row in the CSV, for iteration |
def rotated(self, angle_degrees_ccw):
angle = angle_degrees_ccw / 180.0 * pi
c, s = cos(angle), sin(angle)
return self @ PdfMatrix((c, s, -s, c, 0, 0)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator binary_operator identifier float identifier expression_statement assignment pattern_list identifier identifier expression_list call identifier argument_list identifier call identifier argument_list identifier return_statement binary_operator identifier call identifier argument_list tuple identifier identifier unary_operator identifier identifier integer integer | Concatenates a rotation matrix on this matrix |
def render_js_code(self, id_, *args, **kwargs):
if id_:
options = self.render_select2_options_code(
dict(self.get_options()), id_)
return mark_safe(self.html.format(id=id_, options=options))
return u'' | module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement string string_start string_end | Render html container for Select2 widget with options. |
def _gencode_gate_class(self):
channels, verts = self.coordinates
num_channels = len(channels)
gate_type_name = self.gate_type.__name__
if gate_type_name == 'ThresholdGate' and num_channels == 2:
gate_type_name = 'QuadGate'
return gate_type_name | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end return_statement identifier | Returns the class name that generates this gate. |
def validate_manifest_deployments(manifest: Dict[str, Any]) -> None:
if set(("contract_types", "deployments")).issubset(manifest):
all_contract_types = list(manifest["contract_types"].keys())
all_deployments = list(manifest["deployments"].values())
all_deployment_names = extract_contract_types_from_deployments(all_deployments)
missing_contract_types = set(all_deployment_names).difference(
all_contract_types
)
if missing_contract_types:
raise ValidationError(
f"Manifest missing references to contracts: {missing_contract_types}."
) | module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier type none block if_statement call attribute call identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list identifier if_statement identifier block raise_statement call identifier argument_list string string_start string_content interpolation identifier string_content string_end | Validate that a manifest's deployments contracts reference existing contract_types. |
def grok_template_file(src):
if not src.startswith('builtin:'):
return abspath(src)
builtin = src.split(':')[1]
builtin = "templates/%s.j2" % builtin
return resource_filename(__name__, builtin) | module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call identifier argument_list identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier binary_operator string string_start string_content string_end identifier return_statement call identifier argument_list identifier identifier | Determine the real deal template file |
def validate_range_values(request, label, kwargs):
value = kwargs.get(label, request.query.get(label))
if value:
kwargs[label] = int(value)
if kwargs[label] < 0 or kwargs[label] > MAX_PAGE_SIZE:
raise ValueError | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator subscript identifier identifier integer comparison_operator subscript identifier identifier identifier block raise_statement identifier | Ensure value contained in label is a positive integer. |
def match(self, attr, val):
self._lock.acquire()
try:
for x in self:
if getattr(x, attr) == val:
return x
finally:
self._lock.release() | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list try_statement block for_statement identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier identifier block return_statement identifier finally_clause block expression_statement call attribute attribute identifier identifier identifier argument_list | lookup object in directory with attribute matching value |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.