code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def flavor_list(request):
try:
return api.nova.flavor_list(request)
except Exception:
exceptions.handle(request,
_('Unable to retrieve instance flavors.'))
return []
|
module function_definition identifier parameters identifier block try_statement block return_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end return_statement list
|
Utility method to retrieve a list of flavors.
|
def _set_unique_id(self, unique_id):
assert isinstance(unique_id, int), "unique_id must be an integer"
if PolygonFilter.instace_exists(unique_id):
newid = max(PolygonFilter._instance_counter, unique_id+1)
msg = "PolygonFilter with unique_id '{}' exists.".format(unique_id)
msg += " Using new unique id '{}'.".format(newid)
warnings.warn(msg, FilterIdExistsWarning)
unique_id = newid
ic = max(PolygonFilter._instance_counter, unique_id+1)
PolygonFilter._instance_counter = ic
self.unique_id = unique_id
|
module function_definition identifier parameters identifier identifier block assert_statement call identifier argument_list identifier identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier binary_operator identifier integer expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier binary_operator identifier integer expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
|
Define a unique id
|
def copy_node(node):
if not isinstance(node, gast.AST):
return [copy_node(n) for n in node]
new_node = copy.deepcopy(node)
setattr(new_node, anno.ANNOTATION_FIELD,
getattr(node, anno.ANNOTATION_FIELD, {}).copy())
return new_node
|
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier attribute identifier identifier call attribute call identifier argument_list identifier attribute identifier identifier dictionary identifier argument_list return_statement identifier
|
Copy a node but keep its annotations intact.
|
def uniquify(model):
seen = set()
to_remove = set()
for ix, (o, r, t, a) in model:
hashable_link = (o, r, t) + tuple(sorted(a.items()))
if hashable_link in seen:
to_remove.add(ix)
seen.add(hashable_link)
model.remove(to_remove)
return
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier tuple_pattern identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator tuple identifier identifier identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement
|
Remove all duplicate relationships
|
def parse_wrap_facets(facets):
valid_forms = ['~ var1', '~ var1 + var2']
error_msg = ("Valid formula for 'facet_wrap' look like"
" {}".format(valid_forms))
if isinstance(facets, (list, tuple)):
return facets
if not isinstance(facets, str):
raise PlotnineError(error_msg)
if '~' in facets:
variables_pattern = r'(\w+(?:\s*\+\s*\w+)*|\.)'
pattern = r'\s*~\s*{0}\s*'.format(variables_pattern)
match = re.match(pattern, facets)
if not match:
raise PlotnineError(error_msg)
facets = [var.strip() for var in match.group(1).split('+')]
elif re.match(r'\w+', facets):
facets = [facets]
else:
raise PlotnineError(error_msg)
return facets
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier parenthesized_expression call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier if_statement call identifier argument_list identifier tuple identifier identifier block return_statement identifier if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement not_operator identifier block raise_statement call identifier argument_list identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier call attribute call attribute identifier identifier argument_list integer identifier argument_list string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier list identifier else_clause block raise_statement call identifier argument_list identifier return_statement identifier
|
Return list of facetting variables
|
def disconnect(self):
self.connState = Client.DISCONNECTED
if self.conn is not None:
self._logger.info('Disconnecting')
self.conn.disconnect()
self.wrapper.connectionClosed()
self.reset()
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement 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 expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
|
Disconnect from IB connection.
|
def fprint(self, obj, stream=None, **kwargs):
if stream is None:
stream = sys.stdout
options = self.options
options.update(kwargs)
if isinstance(obj, dimod.SampleSet):
self._print_sampleset(obj, stream, **options)
return
raise TypeError("cannot format type {}".format(type(obj)))
|
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier return_statement raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier
|
Prints the formatted representation of the object on stream
|
def _draw_tiles(self, x_offset, y_offset, bg):
count = 0
for layer_name, c_filters, t_filters in self._get_features():
colour = (self._256_PALETTE[layer_name]
if self._screen.colours >= 256 else self._16_PALETTE[layer_name])
for x, y, z, tile, satellite in sorted(self._tiles.values(), key=lambda k: k[0]):
if satellite != self._satellite or z != self._zoom:
continue
x *= self._size
y *= self._size
if satellite:
count += self._draw_satellite_tile(
tile,
int((x-x_offset + self._screen.width // 4) * 2),
int(y-y_offset + self._screen.height // 2))
else:
count += self._draw_tile_layer(tile, layer_name, c_filters, colour, t_filters,
x - x_offset, y - y_offset, bg)
return count
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier integer for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier parenthesized_expression conditional_expression subscript attribute identifier identifier identifier comparison_operator attribute attribute identifier identifier identifier integer subscript attribute identifier identifier identifier for_statement pattern_list identifier identifier identifier identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier subscript identifier integer block if_statement boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator identifier attribute identifier identifier block continue_statement expression_statement augmented_assignment identifier attribute identifier identifier expression_statement augmented_assignment identifier attribute identifier identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier call identifier argument_list binary_operator parenthesized_expression binary_operator binary_operator identifier identifier binary_operator attribute attribute identifier identifier identifier integer integer call identifier argument_list binary_operator binary_operator identifier identifier binary_operator attribute attribute identifier identifier identifier integer else_clause block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier binary_operator identifier identifier binary_operator identifier identifier identifier return_statement identifier
|
Render all visible tiles a layer at a time.
|
def play_NoteContainer(self, nc, channel=1, velocity=100):
self.notify_listeners(self.MSG_PLAY_NC, {'notes': nc,
'channel': channel, 'velocity': velocity})
if nc is None:
return True
for note in nc:
if not self.play_Note(note, channel, velocity):
return False
return True
|
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list attribute identifier identifier 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 if_statement comparison_operator identifier none block return_statement true for_statement identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier identifier identifier block return_statement false return_statement true
|
Play the Notes in the NoteContainer nc.
|
def build_attrs(self, *args, **kwargs):
attrs = super(Select2Mixin, self).build_attrs(*args, **kwargs)
if self.is_required:
attrs.setdefault('data-allow-clear', 'false')
else:
attrs.setdefault('data-allow-clear', 'true')
attrs.setdefault('data-placeholder', '')
attrs.setdefault('data-minimum-input-length', 0)
if 'class' in attrs:
attrs['class'] += ' django-select2'
else:
attrs['class'] = 'django-select2'
return attrs
|
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list 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 string string_start string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer if_statement comparison_operator string string_start string_content string_end identifier block expression_statement augmented_assignment subscript identifier string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier
|
Add select2 data attributes.
|
def _new_packet_cb(self, pk):
if pk.channel == READ_CHANNEL or pk.channel == WRITE_CHANNEL:
if self._useV2:
var_id = struct.unpack('<H', pk.data[:2])[0]
if pk.channel == READ_CHANNEL:
pk.data = pk.data[:2] + pk.data[3:]
else:
var_id = pk.data[0]
if (pk.channel != TOC_CHANNEL and self._req_param == var_id and
pk is not None):
self.updated_callback(pk)
self._req_param = -1
try:
self.wait_lock.release()
except Exception:
pass
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end subscript attribute identifier identifier slice integer integer if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier binary_operator subscript attribute identifier identifier slice integer subscript attribute identifier identifier slice integer else_clause block expression_statement assignment identifier subscript attribute identifier identifier integer if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier identifier comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier unary_operator integer try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause identifier block pass_statement
|
Callback for newly arrived packets
|
def _cells(nb):
if nb.nbformat < 4:
for ws in nb.worksheets:
for cell in ws.cells:
yield cell
else:
for cell in nb.cells:
yield cell
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block for_statement identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement yield identifier else_clause block for_statement identifier attribute identifier identifier block expression_statement yield identifier
|
Yield all cells in an nbformat-insensitive manner
|
def validate_accounting_equation(cls):
balances = [account.balance(raw=True) for account in Account.objects.root_nodes()]
if sum(balances, Balance()) != 0:
raise exceptions.AccountingEquationViolationError(
"Account balances do not sum to zero. They sum to {}".format(sum(balances))
)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list keyword_argument identifier true for_in_clause identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier call identifier argument_list integer block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier
|
Check that all accounts sum to 0
|
def escape_path(path):
path = quote(path, HTTP_PATH_SAFE)
path = ESCAPED_CHAR_RE.sub(uppercase_escaped_char, path)
return path
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
|
Escape any invalid characters in HTTP URL, and uppercase all escapes.
|
def walk(self,depth=0,fsNode=None) :
if not fsNode :
fsNode = FSNode(self.init_path,self.init_path,0)
if fsNode.isdir() :
if self.check_dir(fsNode) :
if self.check_return(fsNode) :
yield fsNode
for n in fsNode.children() :
if n.islink() :
continue
for n2 in self.walk(depth+1,n) :
if self.check_return(n2) :
yield n2
else :
if self.check_file(fsNode) :
if self.check_return(fsNode) :
yield fsNode
raise StopIteration
|
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier integer if_statement call attribute identifier identifier argument_list block if_statement call attribute identifier identifier argument_list identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement yield identifier for_statement identifier call attribute identifier identifier argument_list block if_statement call attribute identifier identifier argument_list block continue_statement for_statement identifier call attribute identifier identifier argument_list binary_operator identifier integer identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement yield identifier else_clause block if_statement call attribute identifier identifier argument_list identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement yield identifier raise_statement identifier
|
Note, this is a filtered walk
|
def use_any_status_assessment_part_view(self):
self._operable_views['assessment_part'] = ANY_STATUS
for session in self._get_provider_sessions():
try:
session.use_any_status_assessment_part_view()
except AttributeError:
pass
|
module function_definition identifier parameters identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement
|
Pass through to provider AssessmentPartLookupSession.use_any_status_assessment_part_view
|
def reset( self ):
dataSet = self.dataSet()
if ( not dataSet ):
dataSet = XScheme()
dataSet.reset()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement parenthesized_expression not_operator identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list
|
Resets the colors to the default settings.
|
def main():
parsed_args = generate_cli_main_parser().parse_args()
log_level = logging.getLevelName(parsed_args.log_level)
logging.basicConfig(stream=sys.stdout, level=log_level,
format='%(message)s')
logger.debug('Arguments: %s', parsed_args)
config = ConfigResolver()
config.with_args(parsed_args).with_env().with_config_dir(parsed_args.config_dir)
client = Client(config)
results = client.execute()
handle_output(results, parsed_args.output, config.resolve('lexicon:action'))
|
module function_definition identifier parameters block expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end
|
Main function of Lexicon.
|
def _list_available_hosts(self, *args):
return [ h for h in self.inventory.list_hosts(*args) if (h not in self.stats.failures) and (h not in self.stats.dark)]
|
module function_definition identifier parameters identifier list_splat_pattern identifier block return_statement list_comprehension identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list list_splat identifier if_clause boolean_operator parenthesized_expression comparison_operator identifier attribute attribute identifier identifier identifier parenthesized_expression comparison_operator identifier attribute attribute identifier identifier identifier
|
returns a list of hosts that haven't failed and aren't dark
|
def short_title(self):
if self.title and self.parent is not None and hasattr(self.parent, 'title') and self.parent.title:
if self.title.startswith(self.parent.title):
short = self.title[len(self.parent.title):].strip()
match = _punctuation_re.match(short)
if match:
short = short[match.end():].strip()
if short:
return short
return self.title
|
module function_definition identifier parameters identifier block if_statement boolean_operator boolean_operator boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier none call identifier argument_list attribute identifier identifier string string_start string_content string_end attribute attribute identifier identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute subscript attribute identifier identifier slice call identifier argument_list attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute subscript identifier slice call attribute identifier identifier argument_list identifier argument_list if_statement identifier block return_statement identifier return_statement attribute identifier identifier
|
Generates an abbreviated title by subtracting the parent's title from this instance's title.
|
def total_marks(self):
total = 0
for answer in self.answers:
for number, part in enumerate(answer):
if number>0:
if part[2]>0:
total+=part[2]
return total
|
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier integer block if_statement comparison_operator subscript identifier integer integer block expression_statement augmented_assignment identifier subscript identifier integer return_statement identifier
|
Compute the total mark for the assessment.
|
def _attach_arguments(self):
for arg in self.arguments:
self.parser.add_argument(*arg[0], **arg[1])
|
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list list_splat subscript identifier integer dictionary_splat subscript identifier integer
|
Add the registered arguments to the parser.
|
def show_slow_wave_dialog(self):
self.slow_wave_dialog.update_groups()
self.slow_wave_dialog.update_cycles()
self.slow_wave_dialog.show()
|
module function_definition identifier parameters identifier block 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
|
Create the SW detection dialog.
|
def scene_velocity(frames):
reader = MessageReader(frames)
results = reader.string("command").uint32("scene_id").uint32("velocity").assert_end().get()
if results.command != "scene.velocity":
raise MessageParserError("Command is not 'scene.velocity'")
return (results.scene_id, results.velocity/1000)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute call attribute call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end identifier argument_list identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end return_statement tuple attribute identifier identifier binary_operator attribute identifier identifier integer
|
parse a scene.velocity message
|
def xlim_change_check(self, idx):
if not self.xlim_pipe[1].poll():
return
xlim = self.xlim_pipe[1].recv()
if xlim is None:
return
if self.ax1 is not None and xlim != self.xlim:
self.xlim = xlim
self.fig.canvas.toolbar.push_current()
self.ax1.set_xlim(xlim)
self.ani.event_source._on_timer()
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute subscript attribute identifier identifier integer identifier argument_list block return_statement expression_statement assignment identifier call attribute subscript attribute identifier identifier integer identifier argument_list if_statement comparison_operator identifier none block return_statement if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list
|
handle xlim change requests from queue
|
def version(which="num"):
if which in VERSIONS:
return VERSIONS[which]
else:
raise CoconutException(
"invalid version type " + ascii(which),
extra="valid versions are " + ", ".join(VERSIONS),
)
|
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier keyword_argument identifier binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier
|
Get the Coconut version.
|
def send_invite_user_email(self, user, user_invitation):
if not self.user_manager.USER_ENABLE_EMAIL: return
if not self.user_manager.USER_ENABLE_INVITE_USER: return
invited_by_user = user
email = user_invitation.email
user = self.user_manager.db_manager.UserClass(email=email)
token = self.user_manager.generate_token(user_invitation.id)
accept_invitation_link = url_for('user.register', token=token, _external=True)
self._render_and_send_email(
email,
user,
self.user_manager.USER_INVITE_USER_EMAIL_TEMPLATE,
accept_invitation_link=accept_invitation_link,
invited_by_user=invited_by_user,
)
|
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator attribute attribute identifier identifier identifier block return_statement if_statement not_operator attribute attribute identifier identifier identifier block return_statement expression_statement assignment identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Send the 'user invitation' email.
|
def write(self, string):
self._output += self._options.indentation_character * \
self._indentation + string + '\n'
|
module function_definition identifier parameters identifier identifier block expression_statement augmented_assignment attribute identifier identifier binary_operator binary_operator binary_operator attribute attribute identifier identifier identifier line_continuation attribute identifier identifier identifier string string_start string_content escape_sequence string_end
|
Print provided string to the output.
|
def blit_np_array(self, array):
with sw("make_surface"):
raw_surface = pygame.surfarray.make_surface(array.transpose([1, 0, 2]))
with sw("draw"):
pygame.transform.scale(raw_surface, self.surf.get_size(), self.surf)
|
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list list integer integer integer with_statement with_clause with_item call identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
|
Fill this surface using the contents of a numpy array.
|
def fist() -> Histogram1D:
import numpy as np
from ..histogram1d import Histogram1D
widths = [0, 1.2, 0.2, 1, 0.1, 1, 0.1, 0.9, 0.1, 0.8]
edges = np.cumsum(widths)
heights = np.asarray([4, 1, 7.5, 6, 7.6, 6, 7.5, 6, 7.2]) + 5
return Histogram1D(edges, heights, axis_name="Is this a fist?", title="Physt \"logo\"")
|
module function_definition identifier parameters type identifier block import_statement aliased_import dotted_name identifier identifier import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier list integer float float integer float integer float float float float expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list list integer integer float integer float integer float integer float integer return_statement call identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content escape_sequence escape_sequence string_end
|
A simple histogram in the shape of a fist.
|
def split_qs(string, delimiter='&'):
open_list = '[<{('
close_list = ']>})'
quote_chars = '"\''
level = index = last_index = 0
quoted = False
result = []
for index, letter in enumerate(string):
if letter in quote_chars:
if not quoted:
quoted = True
level += 1
else:
quoted = False
level -= 1
elif letter in open_list:
level += 1
elif letter in close_list:
level -= 1
elif letter == delimiter and level == 0:
element = string[last_index: index]
if element:
result.append(element)
last_index = index + 1
if index:
element = string[last_index: index + 1]
if element:
result.append(element)
return result
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier assignment identifier assignment identifier integer expression_statement assignment identifier false expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier identifier block if_statement not_operator identifier block expression_statement assignment identifier true expression_statement augmented_assignment identifier integer else_clause block expression_statement assignment identifier false expression_statement augmented_assignment identifier integer elif_clause comparison_operator identifier identifier block expression_statement augmented_assignment identifier integer elif_clause comparison_operator identifier identifier block expression_statement augmented_assignment identifier integer elif_clause boolean_operator comparison_operator identifier identifier comparison_operator identifier integer block expression_statement assignment identifier subscript identifier slice identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator identifier integer if_statement identifier block expression_statement assignment identifier subscript identifier slice identifier binary_operator identifier integer if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Split a string by the specified unquoted, not enclosed delimiter
|
def formatTime(self, record, datefmt=None):
_seconds_fraction = record.created - int(record.created)
_datetime_utc = time.mktime(time.gmtime(record.created))
_datetime_utc += _seconds_fraction
_created = self.converter(_datetime_utc)
if datefmt:
time_string = _created.strftime(datefmt)
else:
time_string = _created.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
time_string = "%s,%03d" % (time_string, record.msecs)
return time_string
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier binary_operator attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement augmented_assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier return_statement identifier
|
Format the log timestamp.
|
def setModel(self, model):
"Sets the StimulusModel for this editor"
self._model = model
self.ui.aofsSpnbx.setValue(model.samplerate())
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list
|
Sets the StimulusModel for this editor
|
def check_unique_tokens(sender, instance, **kwargs):
if isinstance(instance, CallbackToken):
if CallbackToken.objects.filter(key=instance.key, is_active=True).exists():
instance.key = generate_numeric_token()
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block if_statement call identifier argument_list identifier identifier block if_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier true identifier argument_list block expression_statement assignment attribute identifier identifier call identifier argument_list
|
Ensures that mobile and email tokens are unique or tries once more to generate.
|
def clear_session_value(self, name):
self.redis().hdel(self._session_key, name)
self._update_session_expiration()
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
|
Removes a session value
|
def to_unicode(string):
if isinstance(string, six.binary_type):
return string.decode('utf8')
if isinstance(string, six.text_type):
return string
if six.PY2:
return unicode(string)
return str(string)
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier attribute identifier identifier block return_statement identifier if_statement attribute identifier identifier block return_statement call identifier argument_list identifier return_statement call identifier argument_list identifier
|
Ensure a passed string is unicode
|
def response_from_mixed(mixed):
if mixed is None:
return Response()
if not isinstance(mixed, Response):
return Response(mixed)
return mixed
|
module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block return_statement call identifier argument_list if_statement not_operator call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier return_statement identifier
|
Create Response from mixed input.
|
def init(args=None):
if args is None:
args = []
arr = (ctypes.c_char_p * len(args))()
arr[:] = args
_LIB.RabitInit(len(arr), arr)
|
module function_definition identifier parameters default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier list expression_statement assignment identifier call parenthesized_expression binary_operator attribute identifier identifier call identifier argument_list identifier argument_list expression_statement assignment subscript identifier slice identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier
|
Initialize the rabit library with arguments
|
def stop(self, signum=None, frame=None):
BackgroundProcess.objects.filter(pk=self.process_id
).update(pid=0, last_update=now(), message='stopping..')
self.cleanup()
BackgroundProcess.objects.filter(pk=self.process_id).update(pid=0,
last_update=now(),
message='stopped')
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end
|
handel's a termination signal
|
def db_get(self, db_number):
logger.debug("db_get db_number: %s" % db_number)
_buffer = buffer_type()
result = self.library.Cli_DBGet(
self.pointer, db_number, byref(_buffer),
byref(c_int(buffer_size)))
check_error(result, context="client")
return bytearray(_buffer)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier call identifier argument_list identifier call identifier argument_list call identifier argument_list identifier expression_statement call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end return_statement call identifier argument_list identifier
|
Uploads a DB from AG.
|
def make_file_readable (filename):
if not os.path.islink(filename):
util.set_mode(filename, stat.S_IRUSR)
|
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
|
Make file user readable if it is not a link.
|
def getRequestedNameIface(self, iface_num=0, num=None, default_hostname=None, default_domain=None):
full_name = self.getValue("net_interface.%d.dns_name" % iface_num)
if full_name:
replaced_full_name = system.replaceTemplateName(full_name, num)
(hostname, domain) = replaced_full_name
if not domain:
domain = default_domain
return (hostname, domain)
else:
if default_hostname:
(hostname, _) = system.replaceTemplateName(default_hostname, num)
return (hostname, default_domain)
else:
return None
|
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment tuple_pattern identifier identifier identifier if_statement not_operator identifier block expression_statement assignment identifier identifier return_statement tuple identifier identifier else_clause block if_statement identifier block expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement tuple identifier identifier else_clause block return_statement none
|
Return the dns name associated to the net interface.
|
def can_regex(self, field):
from django.conf import settings
if settings.DATABASES['default']['ENGINE'].endswith('sqlite3'):
return not isinstance(get_real_field(self.model, field), UNSUPPORTED_REGEX_FIELDS)
else:
return True
|
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier identifier dotted_name identifier if_statement call attribute subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end block return_statement not_operator call identifier argument_list call identifier argument_list attribute identifier identifier identifier identifier else_clause block return_statement true
|
Test if a given field supports regex lookups
|
def AA(n):
if (n<=1):return Context('10\n00')
else:
AA1=AA(n-1)
r1 = C1(2**(n-1),2**(n-1)) - AA1
r2 = AA1 - AA1
return r1 + r2
|
module function_definition identifier parameters identifier block if_statement parenthesized_expression comparison_operator identifier integer block return_statement call identifier argument_list string string_start string_content escape_sequence string_end else_clause block expression_statement assignment identifier call identifier argument_list binary_operator identifier integer expression_statement assignment identifier binary_operator call identifier argument_list binary_operator integer parenthesized_expression binary_operator identifier integer binary_operator integer parenthesized_expression binary_operator identifier integer identifier expression_statement assignment identifier binary_operator identifier identifier return_statement binary_operator identifier identifier
|
constructs the AA context
|
def phrases_reduce(key, values):
if len(values) < 10:
return
counts = {}
for filename in values:
counts[filename] = counts.get(filename, 0) + 1
words = re.sub(r":", " ", key)
threshold = len(values) / 2
for filename, count in counts.items():
if count > threshold:
yield "%s:%s\n" % (words, filename)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment subscript identifier identifier binary_operator call attribute identifier identifier argument_list identifier integer integer 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 expression_statement assignment identifier binary_operator call identifier argument_list identifier integer for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement yield binary_operator string string_start string_content escape_sequence string_end tuple identifier identifier
|
Phrases demo reduce function.
|
def _merge_alocs(self, other_region):
merging_occurred = False
for aloc_id, aloc in other_region.alocs.items():
if aloc_id not in self.alocs:
self.alocs[aloc_id] = aloc.copy()
merging_occurred = True
else:
merging_occurred |= self.alocs[aloc_id].merge(aloc)
return merging_occurred
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier false for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier true else_clause block expression_statement augmented_assignment identifier call attribute subscript attribute identifier identifier identifier identifier argument_list identifier return_statement identifier
|
Helper function for merging.
|
def write_badge(self, file_path, overwrite=False):
if file_path.endswith('/'):
raise Exception('File location may not be a directory.')
path = os.path.abspath(file_path)
if not path.lower().endswith('.svg'):
path += '.svg'
if not overwrite and os.path.exists(path):
raise Exception('File "{}" already exists.'.format(path))
with open(path, mode='w') as file_handle:
file_handle.write(self.badge_svg_text)
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end if_statement boolean_operator not_operator identifier call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Write badge to file.
|
def open(self):
self.fd = open('/dev/net/tun', 'rb+', buffering=0)
tun_flags = IFF_TAP | IFF_NO_PI | IFF_PERSIST
ifr = struct.pack('16sH', self.name, tun_flags)
fcntl.ioctl(self.fd, TUNSETIFF, ifr)
fcntl.ioctl(self.fd, TUNSETOWNER, os.getuid())
self.ifflags = self.ifflags | IFF_RUNNING
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier integer expression_statement assignment identifier binary_operator binary_operator identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier identifier
|
Open file corresponding to the TUN device.
|
def re_pipe(FlowRate, Diam, Nu):
ut.check_range([FlowRate, ">0", "Flow rate"], [Diam, ">0", "Diameter"],
[Nu, ">0", "Nu"])
return (4 * FlowRate) / (np.pi * Diam * Nu)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier string string_start string_content string_end string string_start string_content string_end list identifier string string_start string_content string_end string string_start string_content string_end list identifier string string_start string_content string_end string string_start string_content string_end return_statement binary_operator parenthesized_expression binary_operator integer identifier parenthesized_expression binary_operator binary_operator attribute identifier identifier identifier identifier
|
Return the Reynolds Number for a pipe.
|
def at(self, year, month, day):
path = partial(_path, self.adapter)
path = partial(path, int(year))
path = partial(path, int(month))
path = path(int(day))
return self._get(path)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
|
time entries by year, month and day.
|
def _validate_partition_boundary(boundary):
boundary = six.text_type(boundary)
match = re.search(r'^([\d.]+)(\D*)$', boundary)
if match:
unit = match.group(2)
if not unit or unit in VALID_UNITS:
return
raise CommandExecutionError(
'Invalid partition boundary passed: "{0}"'.format(boundary)
)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement boolean_operator not_operator identifier comparison_operator identifier identifier block return_statement raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
|
Ensure valid partition boundaries are supplied.
|
def file(ctx, data_dir, data_file):
if not ctx.file:
ctx.data_file = data_file
if not ctx.data_dir:
ctx.data_dir = data_dir
ctx.type = 'file'
|
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier string string_start string_content string_end
|
Use the File SWAG Backend
|
def prep_directory(self, target_dir):
dirname = path.dirname(target_dir)
if dirname:
dirname = path.join(settings.BUILD_DIR, dirname)
if not self.fs.exists(dirname):
logger.debug("Creating directory at {}{}".format(self.fs_name, dirname))
self.fs.makedirs(dirname)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Prepares a new directory to store the file at the provided path, if needed.
|
def input_format(self, content_type):
return getattr(self, '_input_format', {}).get(content_type, hug.defaults.input_format.get(content_type, None))
|
module function_definition identifier parameters identifier identifier block return_statement call attribute call identifier argument_list identifier string string_start string_content string_end dictionary identifier argument_list identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier none
|
Returns the set input_format handler for the given content_type
|
def build_js(ctx, force=False):
for fname in JSX_FILENAMES:
jstools.babel(
ctx,
'{pkg.source_js}/' + fname,
'{pkg.django_static}/{pkg.name}/js/' + fname + '.js',
force=force
)
|
module function_definition identifier parameters identifier default_parameter identifier false block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end keyword_argument identifier identifier
|
Build all javascript files.
|
def freeze(self, tmp_dir):
for sfile in self.secrets():
src_file = hard_path(sfile, self.opt.secrets)
if not os.path.exists(src_file):
raise aomi_excep.IceFile("%s secret not found at %s" %
(self, src_file))
dest_file = "%s/%s" % (tmp_dir, sfile)
dest_dir = os.path.dirname(dest_file)
if not os.path.isdir(dest_dir):
os.mkdir(dest_dir, 0o700)
shutil.copy(src_file, dest_file)
LOG.debug("Froze %s %s", self, sfile)
|
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier attribute attribute identifier identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier
|
Copies a secret into a particular location
|
def changepassword(self, event):
old = event.data['old']
new = event.data['new']
uuid = event.user.uuid
user = objectmodels['user'].find_one({'uuid': uuid})
if std_hash(old, self.salt) == user.passhash:
user.passhash = std_hash(new, self.salt)
user.save()
packet = {
'component': 'hfos.enrol.enrolmanager',
'action': 'changepassword',
'data': True
}
self.fireEvent(send(event.client.uuid, packet))
self.log('Successfully changed password for user', uuid)
else:
packet = {
'component': 'hfos.enrol.enrolmanager',
'action': 'changepassword',
'data': False
}
self.fireEvent(send(event.client.uuid, packet))
self.log('User tried to change password without supplying old one', lvl=warn)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list dictionary pair string string_start string_content string_end identifier if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end true expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end false expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier
|
An enrolled user wants to change their password
|
def stats(self, conn, args=None):
if args is None:
args = b''
conn.writer.write(b''.join((b'stats ', args, b'\r\n')))
result = {}
resp = yield from conn.reader.readline()
while resp != b'END\r\n':
terms = resp.split()
if len(terms) == 2 and terms[0] == b'STAT':
result[terms[1]] = None
elif len(terms) == 3 and terms[0] == b'STAT':
result[terms[1]] = terms[2]
elif len(terms) >= 3 and terms[0] == b'STAT':
result[terms[1]] = b' '.join(terms[2:])
else:
raise ClientException('stats failed', resp)
resp = yield from conn.reader.readline()
return result
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_end expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_end identifier argument_list tuple string string_start string_content string_end identifier string string_start string_content escape_sequence escape_sequence string_end expression_statement assignment identifier dictionary expression_statement assignment identifier yield call attribute attribute identifier identifier identifier argument_list while_statement comparison_operator identifier string string_start string_content escape_sequence escape_sequence string_end block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment subscript identifier subscript identifier integer none elif_clause boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment subscript identifier subscript identifier integer subscript identifier integer elif_clause boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment subscript identifier subscript identifier integer call attribute string string_start string_content string_end identifier argument_list subscript identifier slice integer else_clause block raise_statement call identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier yield call attribute attribute identifier identifier identifier argument_list return_statement identifier
|
Runs a stats command on the server.
|
def diff(actual, expected):
return '\n'.join(list(
difflib.unified_diff(actual.splitlines(), expected.splitlines())
))
|
module function_definition identifier parameters identifier identifier block return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list
|
normalize whitespace in actual and expected and return unified diff
|
def string_to_file(path, input):
mkdir_p(os.path.dirname(path))
with codecs.open(path, "w+", "UTF-8") as file:
file.write(input)
|
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Write a file from a given string.
|
def _release_command_buffer(self, command_buffer):
if command_buffer.closed:
return
self._cb_poll.unregister(command_buffer.host_id)
self.connection_pool.release(command_buffer.connection)
command_buffer.connection = None
|
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier none
|
This is called by the command buffer when it closes.
|
def setup(cls, client_id, client_secret):
cls.client_id = client_id
cls.client_secret = client_secret
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
|
Configure client in session
|
def populate_values(self):
obj = self._get_base_state()
self.base_state = json.dumps(obj)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier
|
Add values from the underlying dash layout configuration
|
def _handle_tag_salt_auth_creds(self, tag, data):
key = tuple(data['key'])
log.debug(
'Updating auth data for %s: %s -> %s',
key, salt.crypt.AsyncAuth.creds_map.get(key), data['creds']
)
salt.crypt.AsyncAuth.creds_map[tuple(data['key'])] = data['creds']
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript attribute attribute attribute identifier identifier identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end
|
Handle a salt_auth_creds event
|
def should_include_link_text(self, link_text, link_url):
elements = ElementSelector(
world.browser,
str('//a[@href="%s"][contains(., %s)]' %
(link_url, string_literal(link_text))),
filter_displayed=True,
)
if not elements:
raise AssertionError("Expected link not found.")
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier call identifier argument_list binary_operator string string_start string_content string_end tuple identifier call identifier argument_list identifier keyword_argument identifier true if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end
|
Assert a link containing the provided text points to the provided URL.
|
def save_json_representation(self, dir_path):
file_name = self.__class__.__name__+ '.json'
file_path = os.path.join(dir_path, file_name)
with open(file_path, 'w') as outfile:
json.dump(self.get_json_representation(), outfile)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
|
Save the app's JSON representation object to a JSON file.
|
def to_dict(self):
result = {}
for meta in self.intervals.values():
result[meta.display] = meta.value
return result
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier attribute identifier identifier attribute identifier identifier return_statement identifier
|
Pack the load averages into a nicely-keyed dictionary.
|
def _get_queryset_methods(cls, queryset_class):
def create_method(name, method):
def manager_method(self, *args, **kwargs):
return getattr(self.get_queryset(), name)(*args, **kwargs)
manager_method.__name__ = method.__name__
manager_method.__doc__ = method.__doc__
return manager_method
orig_method = models.Manager._get_queryset_methods
new_methods = orig_method(queryset_class)
inspect_func = inspect.isfunction
for name, method in inspect.getmembers(queryset_class, predicate=inspect_func):
if hasattr(cls, name) or name in new_methods:
continue
queryset_only = getattr(method, 'queryset_only', None)
if queryset_only or (queryset_only is None and name.startswith('_')):
continue
new_methods[name] = create_method(name, method)
return new_methods
|
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call call identifier argument_list call attribute identifier identifier argument_list identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator identifier identifier block continue_statement expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement boolean_operator identifier parenthesized_expression boolean_operator comparison_operator identifier none call attribute identifier identifier argument_list string string_start string_content string_end block continue_statement expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier return_statement identifier
|
Django overrloaded method for add cyfunction.
|
def from_df(cls, df):
t = cls()
labels = df.columns
for label in df.columns:
t.append_column(label, df[label])
return t
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier subscript identifier identifier return_statement identifier
|
Convert a Pandas DataFrame into a Table.
|
def _refresh_nvr(self):
rpm_info = juicer.utils.rpm_info(self.path)
self.name = rpm_info['name']
self.version = rpm_info['version']
self.release = rpm_info['release']
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end
|
Refresh our name-version-release attributes.
|
def modify_fw_device(self, tenant_id, fw_id, data):
drvr_dict, mgmt_ip = self.sched_obj.get_fw_dev_map(fw_id)
return drvr_dict.get('drvr_obj').modify_fw(tenant_id, data)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list identifier identifier
|
Modifies the firewall cfg.
|
def check_gaps(matches, gap_threshold = 0):
gaps = []
prev = None
for match in sorted(matches, key = itemgetter(0)):
if prev is None:
prev = match
continue
if match[0] - prev[1] >= gap_threshold:
gaps.append([prev, match])
prev = match
return [[i[0][1], i[1][0]] for i in gaps]
|
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier list expression_statement assignment identifier none for_statement identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list integer block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier continue_statement if_statement comparison_operator binary_operator subscript identifier integer subscript identifier integer identifier block expression_statement call attribute identifier identifier argument_list list identifier identifier expression_statement assignment identifier identifier return_statement list_comprehension list subscript subscript identifier integer integer subscript subscript identifier integer integer for_in_clause identifier identifier
|
check for large gaps between alignment windows
|
def make_horizontal_box(cls, children, layout=Layout()):
"Make a horizontal box with `children` and `layout`."
return widgets.HBox(children, layout=layout)
|
module function_definition identifier parameters identifier identifier default_parameter identifier call identifier argument_list block expression_statement string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
|
Make a horizontal box with `children` and `layout`.
|
def convert_toml_outline_tables(parsed):
def convert_tomlkit_table(section):
for key, value in section._body:
if not key:
continue
if hasattr(value, "keys") and not isinstance(value, tomlkit.items.InlineTable):
table = tomlkit.inline_table()
table.update(value.value)
section[key.key] = table
def convert_toml_table(section):
for package, value in section.items():
if hasattr(value, "keys") and not isinstance(value, toml.decoder.InlineTableDict):
table = toml.TomlDecoder().get_empty_inline_table()
table.update(value)
section[package] = table
is_tomlkit_parsed = isinstance(parsed, tomlkit.container.Container)
for section in ("packages", "dev-packages"):
table_data = parsed.get(section, {})
if not table_data:
continue
if is_tomlkit_parsed:
convert_tomlkit_table(table_data)
else:
convert_toml_table(table_data)
return parsed
|
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block for_statement pattern_list identifier identifier attribute identifier identifier block if_statement not_operator identifier block continue_statement if_statement boolean_operator call identifier argument_list identifier string string_start string_content string_end not_operator call identifier argument_list identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier attribute identifier identifier identifier function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator call identifier argument_list identifier string string_start string_content string_end not_operator call identifier argument_list identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier attribute attribute identifier identifier identifier for_statement identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary if_statement not_operator identifier block continue_statement if_statement identifier block expression_statement call identifier argument_list identifier else_clause block expression_statement call identifier argument_list identifier return_statement identifier
|
Converts all outline tables to inline tables.
|
def _valid_pdf(self, path, filename):
if os.path.isfile(path) and path.lower().endswith(".pdf"):
return True
else:
full_path = os.path.join(path, filename)
if os.path.isfile(full_path) and full_path.lower().endswith(".pdf"):
return True
elif os.path.isfile(os.path.join(path, filename + ".pdf")):
return True
elif os.path.isfile(os.path.join(path, filename + ".PDF")):
return True
return False
|
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator call attribute attribute identifier identifier identifier argument_list identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end block return_statement true else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement boolean_operator call attribute attribute identifier identifier identifier argument_list identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end block return_statement true elif_clause call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier binary_operator identifier string string_start string_content string_end block return_statement true elif_clause call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier binary_operator identifier string string_start string_content string_end block return_statement true return_statement false
|
Verify that the file exists and has a PDF extension.
|
def busy_disp_off(dobj):
dobj.kill(block=False)
sys.stdout.write("\033[D \033[D")
sys.stdout.flush()
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier false expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list
|
Turn OFF busy_display to indicate completion.
|
def gen_postinits(self, cls: ClassDefinition) -> str:
post_inits = []
if not cls.abstract:
pkeys = self.primary_keys_for(cls)
for pkey in pkeys:
post_inits.append(self.gen_postinit(cls, pkey))
for slotname in cls.slots:
slot = self.schema.slots[slotname]
if not (slot.primary_key or slot.identifier):
post_inits.append(self.gen_postinit(cls, slotname))
post_inits_line = '\n\t\t'.join([p for p in post_inits if p])
return (f
+ '\n') if post_inits_line else ''
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier list if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier if_statement not_operator parenthesized_expression boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute string string_start string_content escape_sequence escape_sequence escape_sequence string_end identifier argument_list list_comprehension identifier for_in_clause identifier identifier if_clause identifier return_statement conditional_expression parenthesized_expression binary_operator identifier string string_start string_content escape_sequence string_end identifier string string_start string_end
|
Generate all the typing and existence checks post initialize
|
def reading(self):
try:
proxies = {}
try:
proxies["http_proxy"] = os.environ['http_proxy']
except KeyError:
pass
try:
proxies["https_proxy"] = os.environ['https_proxy']
except KeyError:
pass
if len(proxies) != 0:
proxy = urllib2.ProxyHandler(proxies)
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
f = urllib2.urlopen(self.link)
return f.read()
except (urllib2.URLError, ValueError):
print("\n{0}Can't read the file '{1}'{2}".format(
self.meta.color["RED"], self.link.split("/")[-1],
self.meta.color["ENDC"]))
return " "
|
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier dictionary try_statement block expression_statement assignment subscript identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end except_clause identifier block pass_statement try_statement block expression_statement assignment subscript identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end except_clause identifier block pass_statement if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list except_clause tuple attribute identifier identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list subscript attribute attribute identifier identifier identifier string string_start string_content string_end subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end unary_operator integer subscript attribute attribute identifier identifier identifier string string_start string_content string_end return_statement string string_start string_content string_end
|
Open url and read
|
def load(self, filename='classifier.dump'):
ifile = open(filename, 'r+')
self.classifier = pickle.load(ifile)
ifile.close()
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Unpickles the classifier used
|
def cli(env, identifier, enabled, port, weight, healthcheck_type, ip_address):
mgr = SoftLayer.LoadBalancerManager(env.client)
loadbal_id, group_id = loadbal.parse_id(identifier)
ip_address_id = None
if ip_address:
ip_service = env.client['Network_Subnet_IpAddress']
ip_record = ip_service.getByIpAddress(ip_address)
if len(ip_record) > 0:
ip_address_id = ip_record['id']
mgr.add_service(loadbal_id,
group_id,
ip_address_id=ip_address_id,
enabled=enabled,
port=port,
weight=weight,
hc_type=healthcheck_type)
env.fout('Load balancer service is being added!')
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier none if_statement identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
|
Adds a new load balancer service.
|
def stop_ckan(self):
remove_container(self._get_container_name('web'), force=True)
remove_container(self._get_container_name('datapusher'), force=True)
|
module function_definition identifier parameters identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true expression_statement call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true
|
Stop and remove the web container
|
def new_values(self):
def get_new_values_and_key(item):
values = item.new_values
if item.past_dict:
values.update({self._key: item.past_dict[self._key]})
else:
values.update({self._key: item.current_dict[self._key]})
return values
return [get_new_values_and_key(el)
for el in self._get_recursive_difference('all')
if el.diffs and el.current_dict]
|
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list dictionary pair attribute identifier identifier subscript attribute identifier identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list dictionary pair attribute identifier identifier subscript attribute identifier identifier attribute identifier identifier return_statement identifier return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end if_clause boolean_operator attribute identifier identifier attribute identifier identifier
|
Returns the new values from the diff
|
def _ensure_image_registry(self, image):
image_with_registry = image.copy()
if self.parent_registry:
if image.registry and image.registry != self.parent_registry:
error = (
"Registry specified in dockerfile image doesn't match configured one. "
"Dockerfile: '%s'; expected registry: '%s'"
% (image, self.parent_registry))
self.log.error("%s", error)
raise RuntimeError(error)
image_with_registry.registry = self.parent_registry
return image_with_registry
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement attribute identifier identifier block if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier parenthesized_expression binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier raise_statement call identifier argument_list identifier expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier
|
If plugin configured with a parent registry, ensure the image uses it
|
def list_lbaas_pools(self, retrieve_all=True, **_params):
return self.list('pools', self.lbaas_pools_path,
retrieve_all, **_params)
|
module function_definition identifier parameters identifier default_parameter identifier true dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier dictionary_splat identifier
|
Fetches a list of all lbaas_pools for a project.
|
def get(self):
'Retrieve the most recent value generated'
return tuple([(x.name(), x.get()) for x in self._generators])
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end return_statement call identifier argument_list list_comprehension tuple call attribute identifier identifier argument_list call attribute identifier identifier argument_list for_in_clause identifier attribute identifier identifier
|
Retrieve the most recent value generated
|
def purge_cache(self):
if len(self._cache) > self.max_cache_size:
items = sorted(self._cache.items(), key=lambda (k, v): v['expiry'])
self._cache = {k: v for k, v in items[self.max_cache_size:]
if not self._expired(v)}
|
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier lambda lambda_parameters tuple_pattern identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier subscript identifier slice attribute identifier identifier if_clause not_operator call attribute identifier identifier argument_list identifier
|
Purge expired cached tokens and oldest tokens if more than cache_size
|
def start(self):
_log.debug('starting %s', self)
self.started = True
with _log_time('started %s', self):
self.extensions.all.setup()
self.extensions.all.start()
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier true with_statement with_clause with_item call identifier argument_list string string_start string_content string_end identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list
|
Start a container by starting all of its extensions.
|
def recover(self, requeue=False, cb=None):
args = Writer()
args.write_bit(requeue)
self._recover_cb.append(cb)
self.send_frame(MethodFrame(self.channel_id, 60, 110, args))
self.channel.add_synchronous_cb(self._recv_recover_ok)
|
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier none block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier integer integer identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
|
Ask server to redeliver all unacknowledged messages.
|
def save(self):
data = {
'waitForSync': self.waitForSync,
'journalSize': self.journalSize,
}
self.resource(self.name).properties.put(data)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute call attribute identifier identifier argument_list attribute identifier identifier identifier identifier argument_list identifier
|
Updates only waitForSync and journalSize
|
def update_famplex():
famplex_url_pattern = \
'https://raw.githubusercontent.com/sorgerlab/famplex/master/%s.csv'
csv_names = ['entities', 'equivalences', 'gene_prefixes',
'grounding_map', 'relations']
for csv_name in csv_names:
url = famplex_url_pattern % csv_name
save_from_http(url, os.path.join(path,'famplex/%s.csv' % csv_name))
|
module function_definition identifier parameters block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier binary_operator identifier identifier expression_statement call identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier
|
Update all the CSV files that form the FamPlex resource.
|
def segment_length(curve, start, end, start_point, end_point,
error=LENGTH_ERROR, min_depth=LENGTH_MIN_DEPTH, depth=0):
mid = (start + end)/2
mid_point = curve.point(mid)
length = abs(end_point - start_point)
first_half = abs(mid_point - start_point)
second_half = abs(end_point - mid_point)
length2 = first_half + second_half
if (length2 - length > error) or (depth < min_depth):
depth += 1
return (segment_length(curve, start, mid, start_point, mid_point,
error, min_depth, depth) +
segment_length(curve, mid, end, mid_point, end_point,
error, min_depth, depth))
return length2
|
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier identifier default_parameter identifier identifier default_parameter identifier integer block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier if_statement boolean_operator parenthesized_expression comparison_operator binary_operator identifier identifier identifier parenthesized_expression comparison_operator identifier identifier block expression_statement augmented_assignment identifier integer return_statement parenthesized_expression binary_operator call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier return_statement identifier
|
Recursively approximates the length by straight lines
|
def append(self, context, data):
return ContextStack(self._contexts + [context], self._data + [data])
|
module function_definition identifier parameters identifier identifier identifier block return_statement call identifier argument_list binary_operator attribute identifier identifier list identifier binary_operator attribute identifier identifier list identifier
|
Returns new context, which contains current stack and new frame
|
def stackToList(stack):
if isinstance(stack, types.TracebackType):
while stack.tb_next:
stack = stack.tb_next
stack = stack.tb_frame
out = []
while stack:
out.append(stack)
stack = stack.f_back
return out
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier attribute identifier identifier block while_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier list while_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier return_statement identifier
|
Convert a chain of traceback or frame objects into a list of frames.
|
def columnCount(self, parent):
if parent.isValid():
return parent.internalPointer().columnCount()
else:
return self.root.columnCount()
|
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list block return_statement call attribute call attribute identifier identifier argument_list identifier argument_list else_clause block return_statement call attribute attribute identifier identifier identifier argument_list
|
Returns the number of columns for the children of the given parent.
|
def toggle(self, discord_token, discord_client_id):
if self.state == 'off':
self.start(discord_token, discord_client_id)
elif self.state == 'on':
self.stop()
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list
|
Toggles Modis on or off
|
def norm_package_version(version):
if version:
version = ','.join(v.strip() for v in version.split(',')).strip()
if version.startswith('(') and version.endswith(')'):
version = version[1:-1]
version = ''.join(v for v in version if v.strip())
else:
version = ''
return version
|
module function_definition identifier parameters identifier block if_statement identifier block expression_statement assignment identifier call attribute call attribute string string_start string_content string_end identifier generator_expression call attribute identifier identifier argument_list for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list if_statement boolean_operator 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 block expression_statement assignment identifier subscript identifier slice integer unary_operator integer expression_statement assignment identifier call attribute string string_start string_end identifier generator_expression identifier for_in_clause identifier identifier if_clause call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier string string_start string_end return_statement identifier
|
Normalize a version by removing extra spaces and parentheses.
|
def focus_prev_unfolded(self):
self.focus_property(lambda x: not x.is_collapsed(x.root),
self._tree.prev_position)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier not_operator call attribute identifier identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier
|
focus previous unfolded message in depth first order
|
def wr_py_sections_new(self, fout_py, doc=None):
sections = self.grprobj.get_sections_2d()
return self.wr_py_sections(fout_py, sections, doc)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier identifier identifier
|
Write the first sections file.
|
def _handle_delete_file(self, data):
file = self.room.filedict.get(data)
if file:
self.room.filedict = data, None
self.conn.enqueue_data("delete_file", file)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment attribute attribute identifier identifier identifier expression_list identifier none expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier
|
Handle files being removed
|
def add_scm_info(self):
scm = get_scm()
if scm:
revision = scm.commit_id
branch = scm.branch_name or revision
else:
revision, branch = 'none', 'none'
self.add_infos(('revision', revision), ('branch', branch))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list if_statement identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier boolean_operator attribute identifier identifier identifier else_clause block expression_statement assignment pattern_list identifier identifier expression_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier
|
Adds SCM-related info.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.