code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def buildpack(self, url):
cmd = ["heroku", "buildpacks:add", url, "--app", self.name]
self._run(cmd) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Add a buildpack by URL. |
def route(self):
dst = self.dst
if isinstance(dst, Gen):
dst = next(iter(dst))
return conf.route6.route(dst) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier | Used to select the L2 address |
def _handle_tag_removeobject(self):
obj = _make_object("RemoveObject")
obj.CharacterId = unpack_ui16(self._src)
obj.Depth = unpack_ui16(self._src)
return obj | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier return_statement identifier | Handle the RemoveObject tag. |
def __get_nondirect_init(self, init):
crc = init
for i in range(self.Width):
bit = crc & 0x01
if bit:
crc^= self.Poly
crc >>= 1
if bit:
crc |= self.MSB_Mask
return crc & self.Mask | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier binary_operator identifier integer if_statement identifier block expression_statement augmented_assignment identifier attribute identifier identifier expression_statement augmented_assignment identifier integer if_statement identifier block expression_statement augmented_assignment identifier attribute identifier identifier return_statement binary_operator identifier attribute identifier identifier | return the non-direct init if the direct algorithm has been selected. |
def call(exe, *argv):
exes = which(exe)
if not exes:
returnValue(None)
stdout, stderr, value = yield getProcessOutputAndValue(
exes[0], argv, env=os.environ.copy()
)
if value:
returnValue(None)
returnValue(stdout.decode('utf-8').rstrip('\n')) | module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block expression_statement call identifier argument_list none expression_statement assignment pattern_list identifier identifier identifier yield call identifier argument_list subscript identifier integer identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list if_statement identifier block expression_statement call identifier argument_list none expression_statement call identifier argument_list call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content escape_sequence string_end | Run a command, returning its output, or None if it fails. |
def replace_in_files(search, replace, depth=0, paths=None, confirm=True):
if paths==None:
paths = _s.dialogs.MultipleFiles('DIS AND DAT|*.*')
if paths == []: return
for path in paths:
lines = read_lines(path)
if depth: N=min(len(lines),depth)
else: N=len(lines)
for n in range(0,N):
if lines[n].find(search) >= 0:
lines[n] = lines[n].replace(search,replace)
print(path.split(_os.path.pathsep)[-1]+ ': "'+lines[n]+'"')
if not confirm:
_os.rename(path, path+".backup")
write_to_file(path, join(lines, ''))
if confirm:
if input("yes? ")=="yes":
replace_in_files(search,replace,depth,paths,False)
return | module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier none default_parameter identifier true block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier list block return_statement for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call identifier argument_list integer identifier block if_statement comparison_operator call attribute subscript identifier identifier identifier argument_list identifier integer block expression_statement assignment subscript identifier identifier call attribute subscript identifier identifier identifier argument_list identifier identifier expression_statement call identifier argument_list binary_operator binary_operator binary_operator subscript call attribute identifier identifier argument_list attribute attribute identifier identifier identifier unary_operator integer string string_start string_content string_end subscript identifier identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier string string_start string_content string_end expression_statement call identifier argument_list identifier call identifier argument_list identifier string string_start string_end if_statement identifier block if_statement comparison_operator call identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement call identifier argument_list identifier identifier identifier identifier false return_statement | Does a line-by-line search and replace, but only up to the "depth" line. |
def update_repository_configuration(id, external_repository=None, prebuild_sync=None):
to_update_id = id
rc_to_update = pnc_api.repositories.get_specific(id=to_update_id).content
if external_repository is None:
external_repository = rc_to_update.external_url
else:
rc_to_update.external_url = external_repository
if prebuild_sync is not None:
rc_to_update.pre_build_sync_enabled = prebuild_sync
if not external_repository and prebuild_sync:
logging.error("You cannot enable prebuild sync without external repository")
return
response = utils.checked_api_call(pnc_api.repositories, 'update', id=to_update_id, body=rc_to_update)
if response:
return response.content | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier identifier expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier if_statement boolean_operator not_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block return_statement attribute identifier identifier | Update an existing RepositoryConfiguration with new information |
def dump_raw(self, text, stream=None):
encrypted = self.vault.encrypt(text)
if stream:
stream.write(encrypted)
else:
return encrypted | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block return_statement identifier | Encrypt raw data and write to stream. |
def makeProductPicker(self):
productPicker = liveform.LiveForm(
self.coerceProduct,
[liveform.Parameter(
str(id(product)),
liveform.FORM_INPUT,
liveform.LiveForm(
lambda selectedProduct, product=product: selectedProduct and product,
[liveform.Parameter(
'selectedProduct',
liveform.RADIO_INPUT,
bool,
repr(product))]
))
for product
in self.original.store.parent.query(Product)],
u"Product to Install")
return productPicker | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier list_comprehension call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier attribute identifier identifier call attribute identifier identifier argument_list lambda lambda_parameters identifier default_parameter identifier identifier boolean_operator identifier identifier list call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier call identifier argument_list identifier for_in_clause identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier string string_start string_content string_end return_statement identifier | Make a LiveForm with radio buttons for each Product in the store. |
def reset(self):
for alternative in self.alternatives:
alternative.reset()
self.reset_winner()
self.increment_version() | module function_definition identifier parameters identifier block for_statement identifier attribute 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 | Delete all data for this experiment. |
def stop_trial(self, trial_id):
response = requests.put(
urljoin(self._path, "trials/{}".format(trial_id)))
return self._deserialize(response) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier | Requests to stop trial by trial_id. |
def train_position_scales(self, layout, layers):
_layout = layout.layout
panel_scales_x = layout.panel_scales_x
panel_scales_y = layout.panel_scales_y
for layer in layers:
data = layer.data
match_id = match(data['PANEL'], _layout['PANEL'])
if panel_scales_x:
x_vars = list(set(panel_scales_x[0].aesthetics) &
set(data.columns))
SCALE_X = _layout['SCALE_X'].iloc[match_id].tolist()
panel_scales_x.train(data, x_vars, SCALE_X)
if panel_scales_y:
y_vars = list(set(panel_scales_y[0].aesthetics) &
set(data.columns))
SCALE_Y = _layout['SCALE_Y'].iloc[match_id].tolist()
panel_scales_y.train(data, y_vars, SCALE_Y)
return self | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list binary_operator call identifier argument_list attribute subscript identifier integer identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute subscript attribute subscript identifier string string_start string_content string_end identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list binary_operator call identifier argument_list attribute subscript identifier integer identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute subscript attribute subscript identifier string string_start string_content string_end identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier | Compute ranges for the x and y scales |
def start(self):
self._configs = self._client.config_get('slow-*')
self._client.config_set('slowlog-max-len', 100000)
self._client.config_set('slowlog-log-slower-than', 0)
self._client.execute_command('slowlog', 'reset') | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end | Get ready for a profiling run |
def _pretty_type(s, offset=0):
tc = s[offset]
if tc == "V":
return "void"
elif tc == "Z":
return "boolean"
elif tc == "C":
return "char"
elif tc == "B":
return "byte"
elif tc == "S":
return "short"
elif tc == "I":
return "int"
elif tc == "J":
return "long"
elif tc == "D":
return "double"
elif tc == "F":
return "float"
elif tc == "L":
return _pretty_class(s[offset + 1:-1])
elif tc == "[":
return "%s[]" % _pretty_type(s, offset + 1)
elif tc == "(":
return "(%s)" % ",".join(_pretty_typeseq(s[offset + 1:-1]))
elif tc == "T":
return "generic " + s[offset + 1:]
else:
raise Unimplemented("unknown type, %r" % tc) | module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list subscript identifier slice binary_operator identifier integer unary_operator integer elif_clause comparison_operator identifier string string_start string_content string_end block return_statement binary_operator string string_start string_content string_end call identifier argument_list identifier binary_operator identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block return_statement binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list subscript identifier slice binary_operator identifier integer unary_operator integer elif_clause comparison_operator identifier string string_start string_content string_end block return_statement binary_operator string string_start string_content string_end subscript identifier slice binary_operator identifier integer else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier | returns the pretty version of a type code |
def trunk(self, unique=True):
unique = False
res = []
if self.children:
if self.name is not None:
res.append(self)
for child in self.children:
for sub_child in child.trunk(unique=unique):
if not unique or sub_child not in res:
res.append(sub_child)
return res | module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier false expression_statement assignment identifier list if_statement attribute identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list keyword_argument identifier identifier block if_statement boolean_operator not_operator identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Get the trunk of the tree starting at this root. |
def should_be_hidden_as_cause(exc):
from valid8.validation_lib.types import HasWrongType, IsWrongType
return isinstance(exc, (HasWrongType, IsWrongType)) | module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier dotted_name identifier return_statement call identifier argument_list identifier tuple identifier identifier | Used everywhere to decide if some exception type should be displayed or hidden as the casue of an error |
def _flatten_mesh(self, Xs, term):
n = Xs[0].size
if self.terms[term].istensor:
terms = self.terms[term]
else:
terms = [self.terms[term]]
X = np.zeros((n, self.statistics_['m_features']))
for term_, x in zip(terms, Xs):
X[:, term_.feature] = x.ravel()
return X | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute subscript identifier integer identifier if_statement attribute subscript attribute identifier identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier else_clause block expression_statement assignment identifier list subscript attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier subscript attribute identifier identifier string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block expression_statement assignment subscript identifier slice attribute identifier identifier call attribute identifier identifier argument_list return_statement identifier | flatten the mesh and distribute into a feature matrix |
def _fuzzdb_integers(limit=0):
'Helper to grab some integers from fuzzdb'
path = os.path.join(BASE_PATH, 'integer-overflow/integer-overflows.txt')
stream = _open_fuzzdb_file(path)
for line in _limit_helper(stream, limit):
yield int(line.decode('utf-8'), 0) | module function_definition identifier parameters default_parameter identifier integer block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call identifier argument_list identifier identifier block expression_statement yield call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end integer | Helper to grab some integers from fuzzdb |
def generate(env):
global TeXLaTeXAction
if TeXLaTeXAction is None:
TeXLaTeXAction = SCons.Action.Action(TeXLaTeXFunction,
strfunction=TeXLaTeXStrFunction)
env.AppendUnique(LATEXSUFFIXES=SCons.Tool.LaTeXSuffixes)
generate_common(env)
from . import dvi
dvi.generate(env)
bld = env['BUILDERS']['DVI']
bld.add_action('.tex', TeXLaTeXAction)
bld.add_emitter('.tex', tex_eps_emitter) | module function_definition identifier parameters identifier block global_statement identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier expression_statement call identifier argument_list identifier import_from_statement relative_import import_prefix dotted_name identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier | Add Builders and construction variables for TeX to an Environment. |
def flipHorizontal(self):
self.flipH = not self.flipH
self._transmogrophy(self.angle, self.percent, self.scaleFromCenter, self.flipH, self.flipV) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier not_operator attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier | flips an image object horizontally |
def part(self, channels, message=""):
self.send_items('PART', ','.join(always_iterable(channels)), message) | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier | Send a PART command. |
def _query(event=None,
method='GET',
args=None,
header_dict=None,
data=None):
secret_key = __salt__['config.get']('ifttt.secret_key') or \
__salt__['config.get']('ifttt:secret_key')
path = 'https://maker.ifttt.com/trigger/{0}/with/key/{1}'.format(event, secret_key)
if header_dict is None:
header_dict = {'Content-type': 'application/json'}
if method != 'POST':
header_dict['Accept'] = 'application/json'
result = salt.utils.http.query(
path,
method,
params={},
data=data,
header_dict=header_dict,
decode=True,
decode_type='auto',
text=True,
status=True,
cookies=True,
persist_session=True,
opts=__opts__,
backend='requests'
)
return result | module function_definition identifier parameters default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier boolean_operator call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end line_continuation call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary pair 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 assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier keyword_argument identifier dictionary keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier true keyword_argument identifier true keyword_argument identifier true keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end return_statement identifier | Make a web call to IFTTT. |
def _set_from_ini(self, namespace, ini_file):
global_vars = dict((key, val)
for key, val in namespace.items()
if isinstance(val, basestring)
)
for section in ini_file.sections():
if section == "GLOBAL":
raw_vars = global_vars
else:
raw_vars = namespace.setdefault(section.lower(), {})
raw_vars.update(dict(ini_file.items(section, raw=True)))
if section == "FORMATS":
self._interpolation_escape(raw_vars)
raw_vars.update(dict(
(key, validate(key, val))
for key, val in ini_file.items(section, vars=raw_vars)
))
namespace.update(global_vars) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier generator_expression tuple identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause call identifier argument_list identifier identifier for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list dictionary expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier true if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier generator_expression tuple identifier call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Copy values from loaded INI file to namespace. |
def Put(self, key, obj):
node = self._hash.pop(key, None)
if node:
self._age.Unlink(node)
node = Node(key=key, data=obj)
self._hash[key] = node
self._age.AppendNode(node)
self.Expire()
return key | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier none if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement identifier | Add the object to the cache. |
def split_by_rand_pct(self, valid_pct:float=0.2, seed:int=None)->'ItemLists':
"Split the items randomly by putting `valid_pct` in the validation set, optional `seed` can be passed."
if valid_pct==0.: return self.split_none()
if seed is not None: np.random.seed(seed)
rand_idx = np.random.permutation(range_of(self))
cut = int(valid_pct * len(self))
return self.split_by_idx(rand_idx[:cut]) | module function_definition identifier parameters identifier typed_default_parameter identifier type identifier float typed_default_parameter identifier type identifier none type string string_start string_content string_end block expression_statement string string_start string_content string_end if_statement comparison_operator identifier float block return_statement call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list subscript identifier slice identifier | Split the items randomly by putting `valid_pct` in the validation set, optional `seed` can be passed. |
def clean_cache(self, request):
treenav.delete_cache()
self.message_user(request, _('Cache menuitem cache cleaned successfully.'))
info = self.model._meta.app_label, self.model._meta.model_name
changelist_url = reverse('admin:%s_%s_changelist' % info, current_app=self.admin_site.name)
return redirect(changelist_url) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier expression_list attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier attribute attribute identifier identifier identifier return_statement call identifier argument_list identifier | Remove all MenuItems from Cache. |
def propget(self, prop, rev, path=None):
rev, prefix = self._maprev(rev)
if path is None:
return self._propget(prop, str(rev), None)
else:
path = type(self).cleanPath(_join(prefix, path))
return self._propget(prop, str(rev), path) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement call attribute identifier identifier argument_list identifier call identifier argument_list identifier none else_clause block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier | Get Subversion property value of the path |
def table_top_abs(self):
table_height = np.array([0, 0, self.table_full_size[2]])
return string_to_array(self.floor.get("pos")) + table_height | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list integer integer subscript attribute identifier identifier integer return_statement binary_operator call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier | Returns the absolute position of table top |
def call_fdel(self, obj) -> None:
self.fdel(obj)
try:
del vars(obj)[self.name]
except KeyError:
pass | module function_definition identifier parameters identifier identifier type none block expression_statement call attribute identifier identifier argument_list identifier try_statement block delete_statement subscript call identifier argument_list identifier attribute identifier identifier except_clause identifier block pass_statement | Remove the predefined custom value and call the delete function. |
def read_header(self):
format = '!HHHHHH'
length = struct.calcsize(format)
info = struct.unpack(format,
self.data[self.offset:self.offset + length])
self.offset += length
self.id = info[0]
self.flags = info[1]
self.num_questions = info[2]
self.num_answers = info[3]
self.num_authorities = info[4]
self.num_additionals = info[5] | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript attribute identifier identifier slice attribute identifier identifier binary_operator attribute identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier subscript identifier integer expression_statement assignment attribute identifier identifier subscript identifier integer expression_statement assignment attribute identifier identifier subscript identifier integer expression_statement assignment attribute identifier identifier subscript identifier integer expression_statement assignment attribute identifier identifier subscript identifier integer expression_statement assignment attribute identifier identifier subscript identifier integer | Reads header portion of packet |
def run_deferred(self, deferred):
for handler, scope, offset in deferred:
self.scope_stack = scope
self.offset = offset
handler() | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call identifier argument_list | Run the callables in deferred using their associated scope stack. |
def checkout(self, ref, cb=None):
if self.is_api:
return self._checkout_api(ref, cb=cb)
else:
return self._checkout_fs(ref, cb=cb) | module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier else_clause block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier | Checkout a bundle from the remote. Returns a file-like object |
def gridOn(self):
return (self._gridOn and (self._has_default_loc()
or transforms.interval_contains(self.get_view_interval(), self.get_loc()))) | module function_definition identifier parameters identifier block return_statement parenthesized_expression boolean_operator attribute identifier identifier parenthesized_expression boolean_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list | Control whether the gridline is drawn for this tick. |
def _syscall(self, command, input=None, env=None, *params):
return Popen([command] + list(params), stdout=PIPE, stdin=PIPE, stderr=STDOUT,
env=env or os.environ).communicate(input=input) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none list_splat_pattern identifier block return_statement call attribute call identifier argument_list binary_operator list identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier boolean_operator identifier attribute identifier identifier identifier argument_list keyword_argument identifier identifier | Call an external system command. |
def element_not_focused(step, id):
elem = world.browser.find_element_by_xpath(str('id("{id}")'.format(id=id)))
focused = world.browser.switch_to_active_element()
assert_false(step, elem == focused) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call identifier argument_list identifier comparison_operator identifier identifier | Check if the element is not focused |
def send_stop_audio(self):
assert self._session_id != VoiceService.SESSION_ID_INVALID
self._pebble.send_packet(AudioStream(session_id=self._session_id, data=StopTransfer())) | module function_definition identifier parameters identifier block assert_statement comparison_operator attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call identifier argument_list | Stop an audio streaming session |
def _square_segment(radius, origin):
return np.array(((origin[0] - radius, origin[1] - radius),
(origin[0] - radius, origin[1] + radius),
(origin[0] + radius, origin[1] + radius),
(origin[0] + radius, origin[1] - radius))) | module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list tuple tuple binary_operator subscript identifier integer identifier binary_operator subscript identifier integer identifier tuple binary_operator subscript identifier integer identifier binary_operator subscript identifier integer identifier tuple binary_operator subscript identifier integer identifier binary_operator subscript identifier integer identifier tuple binary_operator subscript identifier integer identifier binary_operator subscript identifier integer identifier | Vertices for a square |
async def _cleanup_subprocess(self, process):
if process.returncode is None:
try:
process.kill()
return await asyncio.wait_for(process.wait(), 1)
except concurrent.futures.TimeoutError:
self._log.debug('Waiting for process to close failed, may have zombie process.')
except ProcessLookupError:
pass
except OSError:
if os.name != 'nt':
raise
elif process.returncode > 0:
raise TSharkCrashException('TShark seems to have crashed (retcode: %d). '
'Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshark.'
% process.returncode) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block try_statement block expression_statement call attribute identifier identifier argument_list return_statement await call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer except_clause attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end except_clause identifier block pass_statement except_clause identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block raise_statement elif_clause comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier | Kill the given process and properly closes any pipes connected to it. |
def std_byte(self):
try:
return self.std_name[self.pos]
except IndexError:
self.failed = 1
return ord('?') | module function_definition identifier parameters identifier block try_statement block return_statement subscript attribute identifier identifier attribute identifier identifier except_clause identifier block expression_statement assignment attribute identifier identifier integer return_statement call identifier argument_list string string_start string_content string_end | Copy byte from 8-bit representation. |
def iso8601_to_dt(iso8601):
parser = DateTimeParser()
try:
arrow_dt = arrow.Arrow.fromdatetime(parser.parse_iso(iso8601))
return arrow_dt.to('utc').datetime
except ParserError as pe:
raise ValueError("Provided was not a valid ISO8601 string: %r" % pe) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement attribute call attribute identifier identifier argument_list string string_start string_content string_end 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 identifier | Given an ISO8601 string as returned by Device Cloud, convert to a datetime object |
def shared_dataset_ids(self):
shared_ids = set(self.scenes[0].keys())
for scene in self.scenes[1:]:
shared_ids &= set(scene.keys())
return shared_ids | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute subscript attribute identifier identifier integer identifier argument_list for_statement identifier subscript attribute identifier identifier slice integer block expression_statement augmented_assignment identifier call identifier argument_list call attribute identifier identifier argument_list return_statement identifier | Dataset IDs shared by all children. |
def _group_matching(tlist, cls):
opens = []
tidx_offset = 0
for idx, token in enumerate(list(tlist)):
tidx = idx - tidx_offset
if token.is_whitespace:
continue
if token.is_group and not isinstance(token, cls):
_group_matching(token, cls)
continue
if token.match(*cls.M_OPEN):
opens.append(tidx)
elif token.match(*cls.M_CLOSE):
try:
open_idx = opens.pop()
except IndexError:
continue
close_idx = tidx
tlist.group_tokens(cls, open_idx, close_idx)
tidx_offset += close_idx - open_idx | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier integer for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier binary_operator identifier identifier if_statement attribute identifier identifier block continue_statement if_statement boolean_operator attribute identifier identifier not_operator call identifier argument_list identifier identifier block expression_statement call identifier argument_list identifier identifier continue_statement if_statement call attribute identifier identifier argument_list list_splat attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause call attribute identifier identifier argument_list list_splat attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause identifier block continue_statement expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement augmented_assignment identifier binary_operator identifier identifier | Groups Tokens that have beginning and end. |
def add_module(self, module):
if module in self._modules:
raise KeyError("module already added to this engine")
ffi.lib.LLVMPY_AddModule(self, module)
module._owned = True
self._modules.add(module) | 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 expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Ownership of module is transferred to the execution engine |
def create(self, fname, lname, group, type, group_api):
self.__username(fname, lname)
self.client.add(
self.__distinguished_name(type, fname=fname, lname=lname),
API.__object_class(),
self.__ldap_attr(fname, lname, type, group, group_api)) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier identifier identifier | Create an LDAP User. |
def potcar_symbols(self):
elements = self.poscar.site_symbols
potcar_symbols = []
settings = self._config_dict["POTCAR"]
if isinstance(settings[elements[-1]], dict):
for el in elements:
potcar_symbols.append(settings[el]['symbol']
if el in settings else el)
else:
for el in elements:
potcar_symbols.append(settings.get(el, el))
return potcar_symbols | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier list expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement call identifier argument_list subscript identifier subscript identifier unary_operator integer identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list conditional_expression subscript subscript identifier identifier string string_start string_content string_end comparison_operator identifier identifier identifier else_clause block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier return_statement identifier | List of POTCAR symbols. |
def convert_to_timestamp(time):
if time == -1:
return None
time = int(time*1000)
hour = time//1000//3600
minute = (time//1000//60) % 60
second = (time//1000) % 60
return str(hour).zfill(2)+":"+str(minute).zfill(2)+":"+str(second).zfill(2) | module function_definition identifier parameters identifier block if_statement comparison_operator identifier unary_operator integer block return_statement none expression_statement assignment identifier call identifier argument_list binary_operator identifier integer expression_statement assignment identifier binary_operator binary_operator identifier integer integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier integer integer integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer integer return_statement binary_operator binary_operator binary_operator binary_operator call attribute call identifier argument_list identifier identifier argument_list integer string string_start string_content string_end call attribute call identifier argument_list identifier identifier argument_list integer string string_start string_content string_end call attribute call identifier argument_list identifier identifier argument_list integer | Convert int to timestamp string. |
def prod():
common_conf()
env.user = settings.LOGIN_USER_PROD
env.machine = 'prod'
env.host_string = settings.HOST_PROD
env.hosts = [env.host_string, ] | module function_definition identifier parameters block expression_statement call identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier list attribute identifier identifier | Option to do something on the production server. |
def count_waiting_jobs(cls, names):
return sum([queue.waiting.llen() for queue in cls.get_all(names)]) | module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list list_comprehension call attribute attribute identifier identifier identifier argument_list for_in_clause identifier call attribute identifier identifier argument_list identifier | Return the number of all jobs waiting in queues with the given names |
def new_tmp(self):
self.tmp_idx += 1
return p.join(self.tmp_dir, 'tmp_' + str(self.tmp_idx)) | module function_definition identifier parameters identifier block expression_statement augmented_assignment attribute identifier identifier integer return_statement call attribute identifier identifier argument_list attribute identifier identifier binary_operator string string_start string_content string_end call identifier argument_list attribute identifier identifier | Create a new temp file allocation |
def filename(self):
if self._filename is None:
if os.path.splitext(self.destination)[1]:
target_file = self.destination
else:
target_file = os.path.join(self.destination,
self.build_filename(self.binary))
self._filename = os.path.abspath(target_file)
return self._filename | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block if_statement subscript call attribute attribute identifier identifier identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement attribute identifier identifier | Return the local filename of the build. |
def from_hostname(cls, hostname):
result = cls.list({'items_per_page': 500})
paas_hosts = {}
for host in result:
paas_hosts[host['name']] = host['id']
return paas_hosts.get(hostname) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end integer expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier | Retrieve paas instance id associated to a host. |
def update_contact(self, um_from_user, um_to_user, message):
contact, created = self.get_or_create(um_from_user,
um_to_user,
message)
if not created:
contact.latest_message = message
contact.save()
return contact | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement not_operator identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier | Get or update a contacts information |
def _release(self):
if self._in_use is None:
return
if not self._in_use.done():
self._in_use.set_result(None)
self._in_use = None
if self._proxy is not None:
self._proxy._detach()
self._proxy = None
self._pool._queue.put_nowait(self) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement if_statement not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list none expression_statement assignment attribute identifier identifier none if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier | Release this connection holder. |
def model_function(self, model_name, version, func_name):
assert func_name in ('serializer', 'loader', 'invalidator')
name = "%s_%s_%s" % (model_name.lower(), version, func_name)
return getattr(self, name) | module function_definition identifier parameters identifier identifier identifier identifier block assert_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list identifier identifier | Return the model-specific caching function. |
def find_cygwin_executables(cls):
exe_paths = glob.glob(cls.cygwin_path + r'\*.exe')
for c in exe_paths:
exe = c.split('\\')
name = exe[1].split('.')[0]
cls.command['windows'][name] = c | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier subscript call attribute subscript identifier integer identifier argument_list string string_start string_content string_end integer expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end identifier identifier | find the executables in cygwin |
async def _go_through_packets_from_fd(self, fd, packet_callback, packet_count=None):
packets_captured = 0
self._log.debug('Starting to go through packets')
psml_struct, data = await self._get_psml_struct(fd)
while True:
try:
packet, data = await self._get_packet_from_stream(fd, data, got_first_packet=packets_captured > 0,
psml_structure=psml_struct)
except EOFError:
self._log.debug('EOF reached')
break
if packet:
packets_captured += 1
try:
packet_callback(packet)
except StopCapture:
self._log.debug('User-initiated capture stop in callback')
break
if packet_count and packets_captured >= packet_count:
break | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier await call attribute identifier identifier argument_list identifier while_statement true block try_statement block expression_statement assignment pattern_list identifier identifier await call attribute identifier identifier argument_list identifier identifier keyword_argument identifier comparison_operator identifier integer keyword_argument identifier identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end break_statement if_statement identifier block expression_statement augmented_assignment identifier integer try_statement block expression_statement call identifier argument_list identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end break_statement if_statement boolean_operator identifier comparison_operator identifier identifier block break_statement | A coroutine which goes through a stream and calls a given callback for each XML packet seen in it. |
def _connect(self):
"Connects a socket to the server using options defined in `config`."
self.socket = socket.socket()
self.socket.connect((self.config['host'], self.config['port']))
self.cmd("NICK %s" % self.config['nick'])
self.cmd("USER %s %s bla :%s" %
(self.config['ident'], self.config['host'], self.config['realname'])) | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list tuple subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list 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 subscript attribute identifier identifier string string_start string_content string_end | Connects a socket to the server using options defined in `config`. |
def to_wav(mediafile):
if mediafile.endswith(".wav"):
yield mediafile
else:
wavfile = tempfile.mktemp(__name__) + ".wav"
try:
extract_wav(mediafile, wavfile)
yield wavfile
finally:
if os.path.exists(wavfile):
os.remove(wavfile) | module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement yield identifier else_clause block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end try_statement block expression_statement call identifier argument_list identifier identifier expression_statement yield identifier finally_clause block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier | Context manager providing a temporary WAV file created from the given media file. |
def _WritePartial(self, data):
chunk = self.offset // self.chunksize
chunk_offset = self.offset % self.chunksize
data = utils.SmartStr(data)
available_to_write = min(len(data), self.chunksize - chunk_offset)
fd = self._GetChunkForWriting(chunk)
fd.seek(chunk_offset)
fd.write(data[:available_to_write])
self.offset += available_to_write
return data[available_to_write:] | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier binary_operator attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript identifier slice identifier expression_statement augmented_assignment attribute identifier identifier identifier return_statement subscript identifier slice identifier | Writes at most one chunk of data. |
def list_from_json(source_list_json):
result = []
if source_list_json == [] or source_list_json == None:
return result
for list_item in source_list_json:
item = json.loads(list_item)
try:
if item['class_name'] == 'Departure':
temp = Departure()
elif item['class_name'] == 'Disruption':
temp = Disruption()
elif item['class_name'] == 'Station':
temp = Station()
elif item['class_name'] == 'Trip':
temp = Trip()
elif item['class_name'] == 'TripRemark':
temp = TripRemark()
elif item['class_name'] == 'TripStop':
temp = TripStop()
elif item['class_name'] == 'TripSubpart':
temp = TripSubpart()
else:
print('Unrecognised Class ' + item['class_name'] + ', skipping')
continue
temp.from_json(list_item)
result.append(temp)
except KeyError:
print('Unrecognised item with no class_name, skipping')
continue
return result | module function_definition identifier parameters identifier block expression_statement assignment identifier list if_statement boolean_operator comparison_operator identifier list comparison_operator identifier none block return_statement identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list elif_clause comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list elif_clause comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list elif_clause comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list elif_clause comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list elif_clause comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list elif_clause comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list else_clause block expression_statement call identifier argument_list binary_operator binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end string string_start string_content string_end continue_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call identifier argument_list string string_start string_content string_end continue_statement return_statement identifier | Deserialise all the items in source_list from json |
def _cluster(param, tom, imtls, gsims, grp_ids, pmap):
pmapclu = AccumDict({grp_id: ProbabilityMap(len(imtls.array), len(gsims))
for grp_id in grp_ids})
first = True
for nocc in range(0, 50):
ocr = tom.occurrence_rate
prob_n_occ = tom.get_probability_n_occurrences(ocr, nocc)
if first:
pmapclu = prob_n_occ * (~pmap)**nocc
first = False
else:
pmapclu += prob_n_occ * (~pmap)**nocc
pmap = ~pmapclu
return pmap | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list dictionary_comprehension pair identifier call identifier argument_list call identifier argument_list attribute identifier identifier call identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier true for_statement identifier call identifier argument_list integer integer block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier binary_operator identifier binary_operator parenthesized_expression unary_operator identifier identifier expression_statement assignment identifier false else_clause block expression_statement augmented_assignment identifier binary_operator identifier binary_operator parenthesized_expression unary_operator identifier identifier expression_statement assignment identifier unary_operator identifier return_statement identifier | Computes the probability map in case of a cluster group |
def _parseSections(self, data, imageDosHeader, imageNtHeaders, parse_header_only=False):
sections = []
optional_header_offset = imageDosHeader.header.e_lfanew + 4 + sizeof(IMAGE_FILE_HEADER)
offset = optional_header_offset + imageNtHeaders.header.FileHeader.SizeOfOptionalHeader
image_section_header_size = sizeof(IMAGE_SECTION_HEADER)
for sectionNo in range(imageNtHeaders.header.FileHeader.NumberOfSections):
ishdr = IMAGE_SECTION_HEADER.from_buffer(data, offset)
if parse_header_only:
raw = None
bytes_ = bytearray()
else:
size = ishdr.SizeOfRawData
raw = (c_ubyte * size).from_buffer(data, ishdr.PointerToRawData)
bytes_ = bytearray(raw)
sections.append(SectionData(header=ishdr, name=ishdr.Name.decode('ASCII', errors='ignore'), bytes=bytes_, raw=raw))
offset += image_section_header_size
return sections | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier false block expression_statement assignment identifier list expression_statement assignment identifier binary_operator binary_operator attribute attribute identifier identifier identifier integer call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call identifier argument_list attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute parenthesized_expression binary_operator identifier identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier expression_statement augmented_assignment identifier identifier return_statement identifier | Parses the sections in the memory and returns a list of them |
def display_multiple_ropes(self, rope, ax, y, linewidth, rope_var):
vals = dict(rope[rope_var][0])["rope"]
ax.plot(
vals,
(y + 0.05, y + 0.05),
lw=linewidth * 2,
color="C2",
solid_capstyle="round",
zorder=0,
alpha=0.7,
)
return ax | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier subscript call identifier argument_list subscript subscript identifier identifier integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier tuple binary_operator identifier float binary_operator identifier float keyword_argument identifier binary_operator identifier integer keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier float return_statement identifier | Display ROPE when more than one interval is provided. |
def tenant_exists(self, keystone, tenant):
self.log.debug('Checking if tenant exists ({})...'.format(tenant))
return tenant in [t.name for t in keystone.tenants.list()] | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement comparison_operator identifier list_comprehension attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list | Return True if tenant exists. |
def _formatSequence(tokens, categories, seqID, uniqueID):
record = {"_category":categories,
"_sequenceId":seqID}
data = []
reset = 1
for t in tokens:
tokenRecord = record.copy()
tokenRecord["_token"] = t
tokenRecord["_reset"] = reset
tokenRecord["ID"] = uniqueID
reset = 0
data.append(tokenRecord)
return data | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier list expression_statement assignment identifier integer for_statement identifier identifier block expression_statement assignment identifier call attribute 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 identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier integer expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Write the sequence of data records for this sample. |
def image_upload_to(self, filename):
now = timezone.now()
filename, extension = os.path.splitext(filename)
return os.path.join(
UPLOAD_TO,
now.strftime('%Y'),
now.strftime('%m'),
now.strftime('%d'),
'%s%s' % (slugify(filename), extension)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end tuple call identifier argument_list identifier identifier | Compute the upload path for the image field. |
def have_all_block_data(self):
if not (self.num_blocks_received == self.num_blocks_requested):
log.debug("num blocks received = %s, num requested = %s" % (self.num_blocks_received, self.num_blocks_requested))
return False
return True | module function_definition identifier parameters identifier block if_statement not_operator parenthesized_expression comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier return_statement false return_statement true | Have we received all block data? |
def rdy(self, count):
self.ready = count
self.last_ready_sent = count
return self.send(constants.RDY + ' ' + str(count)) | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list binary_operator binary_operator attribute identifier identifier string string_start string_content string_end call identifier argument_list identifier | Indicate that you're ready to receive |
def simple_generate_batch(klass, create, size, **kwargs):
return make_factory(klass, **kwargs).simple_generate_batch(create, size) | module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block return_statement call attribute call identifier argument_list identifier dictionary_splat identifier identifier argument_list identifier identifier | Create a factory for the given class, and simple_generate instances. |
def _on_throttle(self, conn, command, kwargs, response, capacity, seconds):
LOG.info(
"Throughput limit exceeded during %s. " "Sleeping for %d second%s",
command,
seconds,
plural(seconds),
) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier 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 identifier call identifier argument_list identifier | Print out a message when the query is throttled |
def handle_routine(self, que, opts, host, target, mine=False):
opts = copy.deepcopy(opts)
single = Single(
opts,
opts['argv'],
host,
mods=self.mods,
fsclient=self.fsclient,
thin=self.thin,
mine=mine,
**target)
ret = {'id': single.id}
stdout, stderr, retcode = single.run()
try:
data = salt.utils.json.find_json(stdout)
if len(data) < 2 and 'local' in data:
ret['ret'] = data['local']
else:
ret['ret'] = {
'stdout': stdout,
'stderr': stderr,
'retcode': retcode,
}
except Exception:
ret['ret'] = {
'stdout': stdout,
'stderr': stderr,
'retcode': retcode,
}
que.put(ret) | module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier dictionary_splat identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end else_clause block expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier except_clause identifier block expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier | Run the routine in a "Thread", put a dict on the queue |
def _maybe_apply_time_shift(da, time_offset=None, **DataAttrs):
if time_offset is not None:
time = times.apply_time_offset(da[TIME_STR], **time_offset)
da[TIME_STR] = time
return da | module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier identifier dictionary_splat identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier | Apply specified time shift to DataArray |
def advance_to_checkpoint(self, checkpoint):
if checkpoint in self._checkpoints:
for cp in self._checkpoints:
self.insert(cp)
if cp == checkpoint:
return cp
else:
raise InvalidCheckpointError(checkpoint) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block return_statement identifier else_clause block raise_statement call identifier argument_list identifier | Advance to the specified checkpoint, passing all preceding checkpoints including the specified checkpoint. |
def project_job_trigger_path(cls, project, job_trigger):
return google.api_core.path_template.expand(
"projects/{project}/jobTriggers/{job_trigger}",
project=project,
job_trigger=job_trigger,
) | module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier | Return a fully-qualified project_job_trigger string. |
def detach_all_classes(self):
classes = list(self._observers.keys())
for cls in classes:
self.detach_class(cls) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier | Detach from all tracked classes. |
def remove_duplicates(errors):
passed = defaultdict(list)
for error in errors:
key = error.linter, error.number
if key in DUPLICATES:
if key in passed[error.lnum]:
continue
passed[error.lnum] = DUPLICATES[key]
yield error | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier expression_list attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier identifier block if_statement comparison_operator identifier subscript identifier attribute identifier identifier block continue_statement expression_statement assignment subscript identifier attribute identifier identifier subscript identifier identifier expression_statement yield identifier | Filter duplicates from given error's list. |
def _serialize(self, value, attr, obj):
try:
return super(DateString, self)._serialize(
arrow.get(value).date(), attr, obj)
except ParserError:
return missing | module function_definition identifier parameters identifier identifier identifier identifier block try_statement block return_statement call attribute call identifier argument_list identifier identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier identifier except_clause identifier block return_statement identifier | Serialize an ISO8601-formatted date. |
def method_name(self):
if isinstance(self.view_func, str):
return self.view_func
return self.view_func.__name__ | module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier identifier block return_statement attribute identifier identifier return_statement attribute attribute identifier identifier identifier | The string name of this route's view function. |
def tokenize(self, s):
s = tf.compat.as_text(s)
if self.reserved_tokens:
substrs = self._reserved_tokens_re.split(s)
else:
substrs = [s]
toks = []
for substr in substrs:
if substr in self.reserved_tokens:
toks.append(substr)
else:
toks.extend(self._alphanum_re.split(substr))
toks = [t for t in toks if t]
return toks | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier list identifier expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause identifier return_statement identifier | Splits a string into tokens. |
def convert(value):
s0 = "Sbp" + value if value in COLLISIONS else value
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', s0)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() + "_t" | module function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression binary_operator string string_start string_content string_end identifier comparison_operator identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement binary_operator call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier argument_list string string_start string_content string_end | Converts to a C language appropriate identifier format. |
def _check(self):
super(Spectrum, self)._check()
err_str = None
has_data = self._KEYS.DATA in self
has_wave = self._KEYS.WAVELENGTHS in self
has_flux = self._KEYS.FLUXES in self
has_filename = self._KEYS.FILENAME in self
if not has_data:
if (not has_wave or not has_flux) and not has_filename:
err_str = (
"If `{}` not given".format(self._KEYS.DATA) +
"; `{}` or `{}` needed".format(
self._KEYS.WAVELENGTHS, self._KEYS.FLUXES))
if err_str is not None:
raise ValueError(err_str)
return | module function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement assignment identifier none expression_statement assignment identifier comparison_operator attribute attribute identifier identifier identifier identifier expression_statement assignment identifier comparison_operator attribute attribute identifier identifier identifier identifier expression_statement assignment identifier comparison_operator attribute attribute identifier identifier identifier identifier expression_statement assignment identifier comparison_operator attribute attribute identifier identifier identifier identifier if_statement not_operator identifier block if_statement boolean_operator parenthesized_expression boolean_operator not_operator identifier not_operator identifier not_operator identifier block expression_statement assignment identifier parenthesized_expression binary_operator call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list identifier return_statement | Check that spectrum has legal combination of attributes. |
def name_insert_prefix(records, prefix):
logging.info('Applying _name_insert_prefix generator: '
'Inserting prefix ' + prefix + ' for all '
'sequence IDs.')
for record in records:
new_id = prefix + record.id
_update_id(record, new_id)
yield record | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier concatenated_string string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier binary_operator identifier attribute identifier identifier expression_statement call identifier argument_list identifier identifier expression_statement yield identifier | Given a set of sequences, insert a prefix for each sequence's name. |
def main():
input_tif = "../tests/data/Jamaica_dem.tif"
output_tif = "../tests/data/tmp_results/log_dem.tif"
rst = RasterUtilClass.read_raster(input_tif)
rst_valid = rst.validValues
output_data = np.log(rst_valid)
RasterUtilClass.write_gtiff_file(output_tif, rst.nRows, rst.nCols, output_data, rst.geotrans,
rst.srs, rst.noDataValue, rst.dataType) | module function_definition identifier parameters block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier | Read GeoTiff raster data and perform log transformation. |
def generate_password(self) -> list:
characterset = self._get_password_characters()
if (
self.passwordlen is None
or not characterset
):
raise ValueError("Can't generate password: character set is "
"empty or passwordlen isn't set")
password = []
for _ in range(0, self.passwordlen):
password.append(randchoice(characterset))
self.last_result = password
return password | module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement parenthesized_expression boolean_operator comparison_operator attribute identifier identifier none not_operator identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list for_statement identifier call identifier argument_list integer attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier | Generate a list of random characters. |
def _parse_scale(scale_exp):
m = re.search("(\w+?)\{(.*?)\}", scale_exp)
if m is None:
raise InvalidFormat('Unable to parse the given time period.')
scale = m.group(1)
range = m.group(2)
if scale not in SCALES:
raise InvalidFormat('%s is not a valid scale.' % scale)
ranges = re.split("\s", range)
return scale, ranges | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement expression_list identifier identifier | Parses a scale expression and returns the scale, and a list of ranges. |
def generate_entities_doc(ctx, out_path, package):
from canari.commands.generate_entities_doc import generate_entities_doc
generate_entities_doc(ctx.project, out_path, package) | module function_definition identifier parameters identifier identifier identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement call identifier argument_list attribute identifier identifier identifier identifier | Create entities documentation from Canari python classes file. |
async def connect_service(bus_name, object_path, interface):
proxy = await proxy_new_for_bus(
Gio.BusType.SYSTEM,
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES |
Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS,
info=None,
name=bus_name,
object_path=object_path,
interface_name=interface,
)
return InterfaceProxy(proxy) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier await call identifier argument_list attribute attribute identifier identifier identifier binary_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier none keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call identifier argument_list identifier | Connect to the service object on DBus, return InterfaceProxy. |
def _initialize_with_array(self, data, rowBased=True):
if rowBased:
self.matrix = []
if len(data) != self._rows:
raise ValueError("Size of Matrix does not match")
for col in xrange(self._columns):
self.matrix.append([])
for row in xrange(self._rows):
if len(data[row]) != self._columns:
raise ValueError("Size of Matrix does not match")
self.matrix[col].append(data[row][col])
else:
if len(data) != self._columns:
raise ValueError("Size of Matrix does not match")
for col in data:
if len(col) != self._rows:
raise ValueError("Size of Matrix does not match")
self.matrix = copy.deepcopy(data) | module function_definition identifier parameters identifier identifier default_parameter identifier true block if_statement identifier block expression_statement assignment attribute identifier identifier list if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list list for_statement identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator call identifier argument_list subscript identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list subscript subscript identifier identifier identifier else_clause block if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier identifier block if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier | Set the matrix values from a two dimensional list. |
def default_link_tag(item):
text = item["value"]
target_url = item["href"]
if not item["href"] or item["type"] in ("span", "current_page"):
if item["attrs"]:
text = make_html_tag("span", **item["attrs"]) + text + "</span>"
return text
return make_html_tag("a", text=text, href=target_url, **item["attrs"]) | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement boolean_operator not_operator subscript identifier string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end block if_statement subscript identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator call identifier argument_list string string_start string_content string_end dictionary_splat subscript identifier string string_start string_content string_end identifier string string_start string_content string_end return_statement identifier return_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat subscript identifier string string_start string_content string_end | Create an A-HREF tag that points to another page. |
def save(self):
with open(self._filename, "w") as f:
self.config.write(f) | module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier | save current config to the file |
def download_files(file_list):
for _, source_data_file in file_list:
sql_gz_name = source_data_file['name'].split('/')[-1]
msg = 'Downloading: %s' % (sql_gz_name)
log.debug(msg)
new_data = objectstore.get_object(
handelsregister_conn, source_data_file, 'handelsregister')
with open('data/{}'.format(sql_gz_name), 'wb') as outputzip:
outputzip.write(new_data) | module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier subscript call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end unary_operator integer expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier | Download the latest data. |
def previous(self, type=None):
i = self.start - 1
s = self.sentence
while i > 0:
if s[i].chunk is not None and type in (s[i].chunk.type, None):
return s[i].chunk
i -= 1 | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier attribute identifier identifier while_statement comparison_operator identifier integer block if_statement boolean_operator comparison_operator attribute subscript identifier identifier identifier none comparison_operator identifier tuple attribute attribute subscript identifier identifier identifier identifier none block return_statement attribute subscript identifier identifier identifier expression_statement augmented_assignment identifier integer | Returns the next previous chunk in the sentence with the given type. |
def _to_number(cls, string):
try:
if float(string) - int(string) == 0:
return int(string)
return float(string)
except ValueError:
try:
return float(string)
except ValueError:
return string | module function_definition identifier parameters identifier identifier block try_statement block if_statement comparison_operator binary_operator call identifier argument_list identifier call identifier argument_list identifier integer block return_statement call identifier argument_list identifier return_statement call identifier argument_list identifier except_clause identifier block try_statement block return_statement call identifier argument_list identifier except_clause identifier block return_statement identifier | Convert string to int or float. |
def send(self, message):
if isinstance(message, bytes):
message = message.decode("utf8")
with self.send_lock:
try:
self.ws.send(message)
except socket.error:
chat_backend.unsubscribe(self) | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end with_statement with_clause with_item attribute identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier | Send a single message to the websocket. |
def output_shape(self):
if self._output_shape is None:
self._ensure_is_connected()
if callable(self._output_shape):
self._output_shape = tuple(self._output_shape())
return self._output_shape | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list if_statement call identifier argument_list attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list return_statement attribute identifier identifier | Returns the output shape. |
def merge(self, from_email, source_incidents):
if from_email is None or not isinstance(from_email, six.string_types):
raise MissingFromEmail(from_email)
add_headers = {'from': from_email, }
endpoint = '/'.join((self.endpoint, self.id, 'merge'))
incident_ids = [entity['id'] if isinstance(entity, Entity) else entity
for entity in source_incidents]
incident_references = [{'type': 'incident_reference', 'id': id_}
for id_ in incident_ids]
return self.__class__.create(
endpoint=endpoint,
api_key=self.api_key,
add_headers=add_headers,
data_key='source_incidents',
data=incident_references,
method='PUT',
) | module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator comparison_operator identifier none not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list tuple attribute identifier identifier attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier list_comprehension conditional_expression subscript identifier string string_start string_content string_end call identifier argument_list identifier identifier identifier for_in_clause identifier identifier expression_statement assignment identifier list_comprehension dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier for_in_clause identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end | Merge other incidents into this incident. |
def _get_metadap_dap(name, version=''):
m = metadap(name)
if not m:
raise DapiCommError('DAP {dap} not found.'.format(dap=name))
if not version:
d = m['latest_stable'] or m['latest']
if d:
d = data(d)
else:
d = dap(name, version)
if not d:
raise DapiCommError(
'DAP {dap} doesn\'t have version {version}.'.format(dap=name, version=version))
return m, d | module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier if_statement not_operator identifier block expression_statement assignment identifier boolean_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement not_operator identifier block raise_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement expression_list identifier identifier | Return data for dap of given or latest version. |
def send_login():
form_class = _security.passwordless_login_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_login_instructions(form.user)
if not request.is_json:
do_flash(*get_message('LOGIN_EMAIL_SENT', email=form.user.email))
if request.is_json:
return _render_json(form)
return _security.render_template(config_value('SEND_LOGIN_TEMPLATE'),
send_login_form=form,
**_ctx('send_login')) | module function_definition identifier parameters block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list if_statement call attribute identifier identifier argument_list block expression_statement call identifier argument_list attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement call identifier argument_list list_splat call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute attribute identifier identifier identifier if_statement attribute identifier identifier block return_statement call identifier argument_list identifier return_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier dictionary_splat call identifier argument_list string string_start string_content string_end | View function that sends login instructions for passwordless login |
def finish(self):
self.unset_env()
self.cov.stop()
self.cov.combine()
self.cov.save()
node_desc = self.get_node_desc(sys.platform, sys.version_info)
self.node_descs.add(node_desc) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Stop coverage, save data to file and set the list of coverage objects to report on. |
def setup_manifest(datadir):
manifest_dir = os.path.join(datadir, "manifest")
if not os.path.exists(manifest_dir):
os.makedirs(manifest_dir) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier | Create barebones manifest to be filled in during update |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.