code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def make_tutor(user):
tutor_group, owner_group = _get_user_groups()
user.is_staff = True
user.is_superuser = False
user.save()
owner_group.user_set.remove(user)
owner_group.save()
tutor_group.user_set.add(user)
tutor_group.save()
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier false expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Makes the given user a tutor.
|
def single_user_mode(self, command=None, options=None):
cmd = [self._pgcommand('postgres'), '--single', '-D', self._data_dir]
for opt, val in sorted((options or {}).items()):
cmd.extend(['-c', '{0}={1}'.format(opt, val)])
cmd.append(self._database)
return self.cancellable_subprocess_call(cmd, communicate_input=command)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list call attribute parenthesized_expression boolean_operator identifier dictionary identifier argument_list block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
|
run a given command in a single-user mode. If the command is empty - then just start and stop
|
def HTMLHelpWorkshop(self):
if self.vc_ver < 11.0:
return []
return [os.path.join(self.si.ProgramFilesx86, 'HTML Help Workshop')]
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier float block return_statement list return_statement list call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end
|
Microsoft HTML Help Workshop
|
def add(self, split_info):
if split_info.name in self:
raise ValueError("Split {} already present".format(split_info.name))
super(SplitDict, self).__setitem__(split_info.name, split_info)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list attribute identifier identifier identifier
|
Add the split info.
|
def refresh(self):
self._screen.block_transfer(self._buffer, self._dx, self._dy)
|
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Flush the canvas content to the underlying screen.
|
def unblock_all(self):
self.unblock()
for em in self._emitters.values():
em.unblock()
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list
|
Unblock all emitters in this group.
|
def update_wrapper(self, process_list):
self.set_count(len(process_list))
if self.should_update():
return self.update(process_list)
else:
return self.result()
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier if_statement call attribute identifier identifier argument_list block return_statement call attribute identifier identifier argument_list identifier else_clause block return_statement call attribute identifier identifier argument_list
|
Wrapper for the children update
|
def _setup_preferred_paths(self, preferred_conversion_paths):
for path in preferred_conversion_paths:
for pair in pair_looper(path):
if pair not in self.converters:
log.warning('Invalid conversion path %s, unknown step %s' %
(repr(path), repr(pair)))
break
else:
self.dgraph.add_preferred_path(*path)
|
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block for_statement identifier call identifier argument_list identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list identifier call identifier argument_list identifier break_statement else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list list_splat identifier
|
Add given valid preferred conversion paths
|
def load_dynamic_class(fqn, subclass):
if not isinstance(fqn, basestring):
return fqn
cls = load_class_from_name(fqn)
if cls == subclass or not issubclass(cls, subclass):
raise TypeError("%s is not a valid %s" % (fqn, subclass.__name__))
return cls
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator identifier identifier not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier return_statement identifier
|
Dynamically load fqn class and verify it's a subclass of subclass
|
def sevenths(key):
if _sevenths_cache.has_key(key):
return _sevenths_cache[key]
res = map(lambda x: seventh(x, key), keys.get_notes(key))
_sevenths_cache[key] = res
return res
|
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement subscript identifier identifier expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier call identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
|
Return all the sevenths chords in key in a list.
|
def stats(self, metrics, **kwargs):
return self.__class__.all_stats(self.account, [self.id], metrics, **kwargs)
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier list attribute identifier identifier identifier dictionary_splat identifier
|
Pulls a list of metrics for the current object instance.
|
def cleanup(config_dir):
stdout_path = os.path.join(config_dir, 'pueue.stdout')
stderr_path = os.path.join(config_dir, 'pueue.stderr')
if os._exists(stdout_path):
os.remove(stdout_path)
if os._exists(stderr_path):
os.remove(stderr_path)
socketPath = os.path.join(config_dir, 'pueue.sock')
if os.path.exists(socketPath):
os.remove(socketPath)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Remove temporary stderr and stdout files as well as the daemon socket.
|
def purge_cache(self, object_type):
if object_type in self.mapping:
cache = self.mapping[object_type]
log.debug("Purging [{}] cache of {} values.".format(object_type, len(cache)))
cache.purge()
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Purge the named cache of all values. If no cache exists for object_type, nothing is done
|
def executions(self) -> List[Execution]:
return list(fill.execution for fill in self.wrapper.fills.values())
|
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block return_statement call identifier generator_expression attribute identifier identifier for_in_clause identifier call attribute attribute attribute identifier identifier identifier identifier argument_list
|
List of all executions from this session.
|
def _generate_ipaddressfield(self, **kwargs):
field = kwargs['field']
if field.default != NOT_PROVIDED:
return self._generate_field_with_default(**kwargs)
num_octets = 4
octets = [str(random.randint(0, 255)) for n in range(num_octets)]
return '.'.join(octets)
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator attribute identifier identifier identifier block return_statement call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier integer expression_statement assignment identifier list_comprehension call identifier argument_list call attribute identifier identifier argument_list integer integer for_in_clause identifier call identifier argument_list identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier
|
Currently only IPv4 fields.
|
def template(cls, address=None, target=None, commandtuple=None,
userdata=None, cmd2=-1, flags=None):
msgraw = bytearray([0x02, cls._code])
msgraw.extend(bytes(cls._receivedSize))
msg = ExtendedReceive.from_raw_message(msgraw)
if commandtuple:
cmd1 = commandtuple.get('cmd1')
cmd2out = commandtuple.get('cmd2')
else:
cmd1 = None
cmd2out = None
if cmd2 is not -1:
cmd2out = cmd2
msg._address = Address(address)
msg._target = Address(target)
msg._messageFlags = MessageFlags(flags)
msg._cmd1 = cmd1
msg._cmd2 = cmd2out
msg._userdata = Userdata.create_pattern(userdata)
return msg
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier unary_operator integer default_parameter identifier none block expression_statement assignment identifier call identifier argument_list list integer attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute 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 string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier none expression_statement assignment identifier none if_statement comparison_operator identifier unary_operator integer block expression_statement assignment identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier
|
Create message template for callbacks.
|
def rightStatus(self, sheet):
'Compose right side of status bar.'
if sheet.currentThreads:
gerund = (' '+sheet.progresses[0].gerund) if sheet.progresses else ''
status = '%9d %2d%%%s' % (len(sheet), sheet.progressPct, gerund)
else:
status = '%9d %s' % (len(sheet), sheet.rowtype)
return status, 'color_status'
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier conditional_expression parenthesized_expression binary_operator string string_start string_content string_end attribute subscript attribute identifier identifier integer identifier attribute identifier identifier string string_start string_end expression_statement assignment identifier binary_operator string string_start string_content string_end tuple call identifier argument_list identifier attribute identifier identifier identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple call identifier argument_list identifier attribute identifier identifier return_statement expression_list identifier string string_start string_content string_end
|
Compose right side of status bar.
|
def queue_manager_stats(self, queue_manager, tags):
for mname, pymqi_value in iteritems(metrics.queue_manager_metrics()):
try:
m = queue_manager.inquire(pymqi_value)
mname = '{}.queue_manager.{}'.format(self.METRIC_PREFIX, mname)
self.gauge(mname, m, tags=tags)
self.service_check(self.QUEUE_MANAGER_SERVICE_CHECK, AgentCheck.OK, tags)
except pymqi.Error as e:
self.warning("Error getting queue manager stats: {}".format(e))
self.service_check(self.QUEUE_MANAGER_SERVICE_CHECK, AgentCheck.CRITICAL, tags)
|
module function_definition identifier parameters identifier identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier
|
Get stats from the queue manager
|
def remote_pdb_handler(signum, frame):
try:
from remote_pdb import RemotePdb
rdb = RemotePdb(host="127.0.0.1", port=0)
rdb.set_trace(frame=frame)
except ImportError:
log.warning(
"remote_pdb unavailable. Please install remote_pdb to "
"allow remote debugging."
)
signal.signal(signum, remote_pdb_handler)
|
module function_definition identifier parameters identifier identifier block try_statement block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier
|
Handler to drop us into a remote debugger upon receiving SIGUSR1
|
def equal_set(self, a, b):
"See if a and b have the same elements"
if len(a) != len(b):
return 0
if a == b:
return 1
return self.subset(a, b) and self.subset(b, a)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block return_statement integer if_statement comparison_operator identifier identifier block return_statement integer return_statement boolean_operator call attribute identifier identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier identifier
|
See if a and b have the same elements
|
def show_env(environment):
if not environment:
print("You need to supply an environment name")
return
parser = read_config()
try:
commands = parser.get(environment, "cmd").split("\n")
except KeyError:
print("Unknown environment type '%s'" % environment)
return
print("Environment: %s\n" % environment)
for cmd in commands:
print(cmd)
|
module function_definition identifier parameters identifier block if_statement not_operator identifier block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier call identifier argument_list try_statement block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier argument_list string string_start string_content escape_sequence string_end except_clause identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier for_statement identifier identifier block expression_statement call identifier argument_list identifier
|
Show the commands for a given environment.
|
def upgrade_api(request, client, version):
min_ver, max_ver = api_versions._get_server_version_range(client)
if min_ver <= api_versions.APIVersion(version) <= max_ver:
client = _nova.novaclient(request, version)
return client
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier call attribute identifier identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
|
Ugrade the nova API to the specified version if possible.
|
def limit(self, limit):
clone = self._clone()
if isinstance(limit, int):
clone._limit = limit
return clone
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier identifier return_statement identifier
|
Limit number of records
|
def select_date(self, rows: List[Row], column: DateColumn) -> Date:
dates: List[Date] = []
for row in rows:
cell_value = row.values[column.name]
if isinstance(cell_value, Date):
dates.append(cell_value)
return dates[0] if dates else Date(-1, -1, -1)
|
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier type generic_type identifier type_parameter type identifier list for_statement identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement conditional_expression subscript identifier integer identifier call identifier argument_list unary_operator integer unary_operator integer unary_operator integer
|
Select function takes a row as a list and a column name and returns the date in that column.
|
def interactive(self):
while True:
line = sys.stdin.readline().strip()
if line == 'quit':
sys.exit()
elif line == 'validate':
self.check_syntax()
self.check_imports()
self.check_install_json()
self.check_layout_json()
self.print_json()
self.validation_data = self._validation_data
|
module function_definition identifier parameters identifier block while_statement true block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier
|
Run in interactive mode.
|
def guess_unmatched(self, token):
if token.lower() in ['apt', 'apartment']:
return False
if token.strip() == '-':
return True
if len(token) <= 2:
return False
if self.street_suffix is None and self.street is None and self.street_prefix is None and self.house_number is None:
if re.match(r"[A-Za-z]", token):
if self.line_number >= 0:
pass
else:
pass
self.street = self._clean(token.capitalize())
return True
return False
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end block return_statement false if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true if_statement comparison_operator call identifier argument_list identifier integer block return_statement false if_statement boolean_operator boolean_operator boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none block if_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier block if_statement comparison_operator attribute identifier identifier integer block pass_statement else_clause block pass_statement expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement true return_statement false
|
When we find something that doesn't match, we can make an educated guess and log it as such.
|
def close(self):
if self.pyb and self.pyb.serial:
self.pyb.serial.close()
self.pyb = None
|
module function_definition identifier parameters identifier block if_statement boolean_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none
|
Closes the serial port.
|
def save_model(self, request, obj, form, change):
like_metrics = self.model.objects.filter(name=obj.name)
updates = {}
for key in form.changed_data:
updates[key] = form.cleaned_data[key]
like_metrics.update(**updates)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list dictionary_splat identifier
|
Updates all metrics with the same name
|
def namedb_open( path ):
con = sqlite3.connect( path, isolation_level=None, timeout=2**30 )
db_query_execute(con, 'pragma mmap_size=536870912', ())
con.row_factory = namedb_row_factory
version = namedb_get_version(con)
if not semver_equal(version, VERSION):
raise Exception('Database has version {}, but this node is version {}. Please update your node database (such as with fast_sync).'.format(version, VERSION))
return con
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier none keyword_argument identifier binary_operator integer integer expression_statement call identifier argument_list identifier string string_start string_content string_end tuple expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement identifier
|
Open a connection to our database
|
def load_module(name, filename):
if sys.version_info < (3, 5):
import imp
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore", RuntimeWarning)
return imp.load_source(name, filename)
else:
from importlib.machinery import SourceFileLoader
loader = SourceFileLoader(name, filename)
return loader.load_module()
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier tuple integer integer block import_statement dotted_name identifier import_statement dotted_name identifier with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier identifier else_clause block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list
|
Load a module into name given its filename
|
def _call_api_single_related_resource(self, resource, full_resource_url,
method_name, **kwargs):
url = full_resource_url
params = {
'headers': self.get_http_headers(
resource.Meta.name, method_name, **kwargs),
'url': url
}
prepared_request = self.prepare_http_request(
'GET', params, **kwargs)
response = self.session.send(prepared_request)
return self._handle_response(
response, resource.Meta.valid_status_codes, resource)
|
module function_definition identifier parameters identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier dictionary_splat identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier dictionary_splat identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier attribute attribute identifier identifier identifier identifier
|
For HypermediaResource - make an API call to a known URL
|
def xmlrpc_save2file(self, filename):
savefile = open(filename,'wb')
try:
pickle.dump({'scheduled':self.scheduled_tasks,
'reschedule':self.reschedule},savefile)
except pickle.PicklingError:
return -1
savefile.close()
return 1
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier identifier except_clause attribute identifier identifier block return_statement unary_operator integer expression_statement call attribute identifier identifier argument_list return_statement integer
|
Save results and own state into file.
|
def deep_unicode(s, encodings=None):
if encodings is None:
encodings = ['utf-8', 'latin-1']
if isinstance(s, (list, tuple)):
return [deep_unicode(i) for i in s]
if isinstance(s, dict):
return dict([
(deep_unicode(key), deep_unicode(s[key]))
for key in s
])
elif isinstance(s, str):
for encoding in encodings:
try:
return s.decode(encoding)
except:
pass
return s
|
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end if_statement call identifier argument_list identifier tuple identifier identifier block return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list list_comprehension tuple call identifier argument_list identifier call identifier argument_list subscript identifier identifier for_in_clause identifier identifier elif_clause call identifier argument_list identifier identifier block for_statement identifier identifier block try_statement block return_statement call attribute identifier identifier argument_list identifier except_clause block pass_statement return_statement identifier
|
decode "DEEP" S using the codec registered for encoding.
|
def _terminate_instance(self):
try:
self.resource.resource_groups.delete(self.running_instance_id)
except Exception as error:
raise AzureCloudException(
'Unable to terminate resource group: {0}.'.format(error)
)
|
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
|
Terminate the resource group and instance.
|
def _check_1d_array_object(parameter, name_param):
if isinstance(parameter, (np.ndarray, list, tuple, np.matrix)):
parameter = np.array(parameter)
if parameter.ndim != 1:
raise TypeError("{} should be a 1d array type object".format(name_param))
else:
raise TypeError("{} should be a 1d array type object".format(name_param))
return parameter
|
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier tuple attribute identifier identifier identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
|
Checks whether given parameter is a 1d array like object, and returns a numpy array object
|
def _is_multiframe_4d(dicom_input):
if not common.is_multiframe_dicom(dicom_input):
return False
header = dicom_input[0]
number_of_stack_slices = common.get_ss_value(header[Tag(0x2001, 0x105f)][0][Tag(0x2001, 0x102d)])
number_of_stacks = int(int(header.NumberOfFrames) / number_of_stack_slices)
if number_of_stacks <= 1:
return False
return True
|
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block return_statement false expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list subscript subscript subscript identifier call identifier argument_list integer integer integer call identifier argument_list integer integer expression_statement assignment identifier call identifier argument_list binary_operator call identifier argument_list attribute identifier identifier identifier if_statement comparison_operator identifier integer block return_statement false return_statement true
|
Use this function to detect if a dicom series is a philips multiframe 4D dataset
|
def _process_regex(cls, regex, rflags, state):
if isinstance(regex, Future):
regex = regex.get()
return re.compile(regex, rflags).match
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement attribute call attribute identifier identifier argument_list identifier identifier identifier
|
Preprocess the regular expression component of a token definition.
|
def getMaskArray(self, signature):
if signature in self.masklist:
mask = self.masklist[signature]
else:
mask = None
return mask
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier else_clause block expression_statement assignment identifier none return_statement identifier
|
Returns the appropriate StaticMask array for the image.
|
def __json_strnum_to_bignum(json_object):
for key in ('id', 'week', 'in_reply_to_id', 'in_reply_to_account_id', 'logins', 'registrations', 'statuses'):
if (key in json_object and isinstance(json_object[key], six.text_type)):
try:
json_object[key] = int(json_object[key])
except ValueError:
pass
return json_object
|
module function_definition identifier parameters identifier block for_statement identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block if_statement parenthesized_expression boolean_operator comparison_operator identifier identifier call identifier argument_list subscript identifier identifier attribute identifier identifier block try_statement block expression_statement assignment subscript identifier identifier call identifier argument_list subscript identifier identifier except_clause identifier block pass_statement return_statement identifier
|
Converts json string numerals to native python bignums.
|
def SignFiles(self, filenames):
file_list = " ".join(filenames)
subprocess.check_call("%s %s" % (self._signing_cmdline, file_list))
if self._verification_cmdline:
subprocess.check_call("%s %s" % (self._verification_cmdline, file_list))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier
|
Signs multiple files at once.
|
def _prependstore(self, store):
if not store.bitlength:
return
store = offsetcopy(store, (self.offset - store.bitlength) % 8)
assert (store.offset + store.bitlength) % 8 == self.offset % 8
bit_offset = self.offset % 8
if bit_offset:
store.setbyte(-1, (store.getbyte(-1) & (255 ^ (255 >> bit_offset)) | \
(self._rawarray[self.byteoffset] & (255 >> bit_offset))))
store._rawarray.extend(self._rawarray[self.byteoffset + 1: self.byteoffset + self.bytelength])
else:
store._rawarray.extend(self._rawarray[self.byteoffset: self.byteoffset + self.bytelength])
self._rawarray = store._rawarray
self.offset = store.offset
self.bitlength += store.bitlength
|
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment identifier call identifier argument_list identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier integer assert_statement comparison_operator binary_operator parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier integer binary_operator attribute identifier identifier integer expression_statement assignment identifier binary_operator attribute identifier identifier integer if_statement identifier block expression_statement call attribute identifier identifier argument_list unary_operator integer parenthesized_expression binary_operator binary_operator call attribute identifier identifier argument_list unary_operator integer parenthesized_expression binary_operator integer parenthesized_expression binary_operator integer identifier line_continuation parenthesized_expression binary_operator subscript attribute identifier identifier attribute identifier identifier parenthesized_expression binary_operator integer identifier expression_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier slice binary_operator attribute identifier identifier integer binary_operator attribute identifier identifier attribute identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier slice attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier
|
Join another store on to the start of this one.
|
def components(self) -> List['DAGCircuit']:
comps = nx.weakly_connected_component_subgraphs(self.graph)
return [DAGCircuit(comp) for comp in comps]
|
module function_definition identifier parameters identifier type generic_type identifier type_parameter type string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier
|
Split DAGCircuit into independent components
|
def _delete_handler(self, handler_class):
to_remove = self._get_handler(handler_class)
if not to_remove:
logging.warning('Error we should have an element to remove')
else:
self.handlers.remove(to_remove)
self.logger.removeHandler(to_remove)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Delete a specific handler from our logger.
|
def region_path(cls, project, region):
return google.api_core.path_template.expand(
"projects/{project}/regions/{region}", project=project, region=region
)
|
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier
|
Return a fully-qualified region string.
|
def emulate_rel(self, key_code, value, timeval):
return self.create_event_object(
"Relative",
key_code,
value,
timeval)
|
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier
|
Emulate the relative changes of the mouse cursor.
|
def shared_options(rq):
"Default class options to pass to the CLI commands."
return {
'url': rq.redis_url,
'config': None,
'worker_class': rq.worker_class,
'job_class': rq.job_class,
'queue_class': rq.queue_class,
'connection_class': rq.connection_class,
}
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end none pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier
|
Default class options to pass to the CLI commands.
|
def save(self):
check_bind(self)
creating = self.id is None
if creating and not self.__class__._has_schema_method("create"):
raise MethodNotSupported("{} do not support creating.".format(self.__class__.__name__))
if not creating and not self.__class__._has_schema_method("update"):
raise MethodNotSupported("{} do not support updating.".format(self.__class__.__name__))
try:
self._resource.save()
except HTTPError as e:
if e.response.status_code == 400:
err_json = e.response.json().get("errors", [])
msg = pretty_print_error(err_json)
raise ServerError(msg)
elif e.response.status_code == 404:
action = "creating" if creating else "updating"
raise MethodNotSupported(
"{} do not support {}.".format(self.__class__.__name__, action)
)
elif e.response.status_code == 409:
raise ServerError("This {} object already exists".format(self.__class__.__name__))
else:
raise e
|
module function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier comparison_operator attribute identifier identifier none if_statement boolean_operator identifier not_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier if_statement boolean_operator not_operator identifier not_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute attribute identifier identifier identifier integer block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end list expression_statement assignment identifier call identifier argument_list identifier raise_statement call identifier argument_list identifier elif_clause comparison_operator attribute attribute identifier identifier identifier integer block expression_statement assignment identifier conditional_expression string string_start string_content string_end identifier string string_start string_content string_end raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier identifier elif_clause comparison_operator attribute attribute identifier identifier identifier integer block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier else_clause block raise_statement identifier
|
Either create or persist changes on this object back to the One Codex server.
|
def stop(self) -> None:
end_time = datetime.datetime.now()
elapsed_time = end_time - self.start_time
elapsed_seconds = elapsed_time.seconds
hours, remainder = divmod(int(elapsed_seconds), 3600)
minutes, seconds = divmod(remainder, 60)
as_str = "%sh %sm %ss %dms" % (
hours,
minutes,
seconds,
elapsed_time.microseconds / 1000,
)
info("%s took %s" % (self.description, as_str))
|
module function_definition identifier parameters identifier type none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier binary_operator identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier integer expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier integer expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier binary_operator attribute identifier identifier integer expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier
|
Stop the timer and emit a nice log
|
def find_best_server(filename):
servers = [si for si in notebookapp.list_running_servers()
if filename.startswith(si['notebook_dir'])]
try:
return max(servers, key=lambda si: len(si['notebook_dir']))
except ValueError:
return None
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end try_statement block return_statement call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list subscript identifier string string_start string_content string_end except_clause identifier block return_statement none
|
Find the best server to open a notebook with.
|
def refresh(self):
self.trace(list(self._fnames.keys()), _refresh=True)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true
|
Re-traces modules modified since the time they were traced.
|
def hello_rivescript():
from_number = request.values.get("From", "unknown")
message = request.values.get("Body")
reply = "(Internal error)"
if message:
reply = bot.reply(from_number, message)
resp = twilio.twiml.Response()
resp.message(reply)
return str(resp)
|
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
|
Receive an inbound SMS and send a reply from RiveScript.
|
def transform(self, attrs):
self.collect(attrs)
self.add_missing_implementations()
self.fill_attrs(attrs)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
|
Perform all actions on a given attribute dict.
|
def generate_static_site(self, output_root=None, extra_context=None):
self.app.config['BUILD_PATH'] = output_root
self.call_hook("generate", self, output_root, extra_context)
if output_root is not None:
self.app.config['FREEZER_DESTINATION'] = os.path.realpath(output_root)
self.freezer.freeze()
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
|
Bake out static site
|
def find_module(self, fullname, path=None):
if not fullname.startswith(self._module_name + '.'):
return None
submodule = fullname[len(self._module_name) + 1:]
parts = submodule.split('.')
if self._teams:
team = parts.pop(0)
else:
team = None
if len(parts) == 2:
store, pkg = PackageStore.find_package(team, parts[0], parts[1])
if pkg is not None:
return PackageLoader(store, pkg)
else:
return None
for store_dir in PackageStore.find_store_dirs():
store = PackageStore(store_dir)
if len(parts) == 0:
assert self._teams
path = store.team_path(team)
elif len(parts) == 1:
path = store.user_path(team, parts[0])
if os.path.isdir(path):
return FakeLoader(path)
return None
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement not_operator call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end block return_statement none expression_statement assignment identifier subscript identifier slice binary_operator call identifier argument_list attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer else_clause block expression_statement assignment identifier none if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier subscript identifier integer subscript identifier integer if_statement comparison_operator identifier none block return_statement call identifier argument_list identifier identifier else_clause block return_statement none for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block assert_statement attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript identifier integer if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement call identifier argument_list identifier return_statement none
|
Looks up the table based on the module path.
|
def _type_description(self):
iexec = self._element.target
if iexec is not None:
result = "method() | " + iexec.summary
else:
result = "Type Method: points to executable in module."
return result
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier else_clause block expression_statement assignment identifier string string_start string_content string_end return_statement identifier
|
Gets the completion description for a TypeExecutable.
|
def _proportions(self):
return self._slice.proportions(
axis=self._axis, include_mr_cat=self._include_mr_cat
)
|
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
ndarray representing slice proportions along correct axis.
|
def mark(self):
def pos(text, index):
return ParseError.loc_info(text, index)
@Parser
def mark_parser(text, index):
res = self(text, index)
if res.status:
return Value.success(res.index, (pos(text, index), res.value, pos(text, res.index)))
else:
return res
return mark_parser
|
module function_definition identifier parameters identifier block function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier identifier decorated_definition decorator identifier function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement attribute identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier tuple call identifier argument_list identifier identifier attribute identifier identifier call identifier argument_list identifier attribute identifier identifier else_clause block return_statement identifier return_statement identifier
|
Mark the line and column information of the result of this parser.
|
def _interpret_oserror(exc, cwd, cmd):
if len(cmd) == 0:
raise dbt.exceptions.CommandError(cwd, cmd)
if os.name == 'nt':
_handle_windows_error(exc, cwd, cmd)
else:
_handle_posix_error(exc, cwd, cmd)
raise dbt.exceptions.InternalException(
'Unhandled exception in _interpret_oserror: {}'.format(exc)
)
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier identifier identifier else_clause block expression_statement call identifier argument_list identifier identifier identifier raise_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
|
Interpret an OSError exc and raise the appropriate dbt exception.
|
def res(arg):
def _res(ctx):
_arg = arg(ctx) if callable(arg) else arg
return I(arg)
return _res
|
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression call identifier argument_list identifier call identifier argument_list identifier identifier return_statement call identifier argument_list identifier return_statement identifier
|
Convert the argument into an IRI ref
|
def getDayStart(self, dateTime):
return ensure_localtime(dateTime).replace(hour=0,minute=0,second=0,microsecond=0)
|
module function_definition identifier parameters identifier identifier block return_statement call attribute call identifier argument_list identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer
|
Ensure local time and get the beginning of the day
|
def _validate_other_keys(optional, types, missing, validated, data,
to_validate):
errors = []
for key in to_validate:
value = data[key]
if key in optional:
errors.extend(
_validate_optional_key(
key, missing, value, validated, optional))
continue
errors.extend(_validate_type_key(key, value, types, validated))
return errors
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier identifier identifier continue_statement expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier identifier return_statement identifier
|
Validate the rest of the keys present in the data.
|
def prepend_schema(self, name):
return '.'.join([self.schema, name]) if self.schema else name
|
module function_definition identifier parameters identifier identifier block return_statement conditional_expression call attribute string string_start string_content string_end identifier argument_list list attribute identifier identifier identifier attribute identifier identifier identifier
|
Prepend schema name to 'name' when a schema is specified
|
def removetmp():
for path in _tmp_paths:
if os.path.exists(path):
try:
os.remove(path)
except PermissionError:
pass
|
module function_definition identifier parameters block for_statement identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement
|
Remove the temporary files created by gettemp
|
def create(cls, selection, config, **kwargs):
if selection['target'] is not None:
return cls.create_from_source(selection['target'],
config, **kwargs)
else:
target_skydir = wcs_utils.get_target_skydir(selection)
return cls.create_from_position(target_skydir, config, **kwargs)
|
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end none block return_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier dictionary_splat identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier
|
Create an ROIModel instance.
|
def parse(self, rec):
final_studies = []
for study in rec.studies:
source_data = self._parse_study(study.metadata["Study File Name"],
["Source Name", "Sample Name", "Comment[ENA_SAMPLE]"])
if source_data:
study.nodes = source_data
final_assays = []
for assay in study.assays:
cur_assay = ISATabAssayRecord(assay)
assay_data = self._parse_study(assay["Study Assay File Name"],
["Sample Name","Extract Name","Raw Data File","Derived Data File", "Image File", "Acquisition Parameter Data File", "Free Induction Decay Data File"])
cur_assay.nodes = assay_data
self._get_process_nodes(assay["Study Assay File Name"], cur_assay)
final_assays.append(cur_assay)
study.assays = final_assays
self._get_process_nodes(study.metadata["Study File Name"], study)
final_studies.append(study)
rec.studies = final_studies
return rec
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end 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 string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
|
Retrieve row data from files associated with the ISATabRecord.
|
def translate_v3(vec, amount):
return Vec3(vec.x+amount, vec.y+amount, vec.z+amount)
|
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list binary_operator attribute identifier identifier identifier binary_operator attribute identifier identifier identifier binary_operator attribute identifier identifier identifier
|
Return a new Vec3 that is translated version of vec.
|
def close(self):
import sys, os
for store in self.stores:
if hasattr(store, 'save'):
store.save(reimport=False)
path, filename = os.path.split(store._filename)
modname = filename[:-3]
if modname in sys.modules:
del sys.modules[modname]
super().close()
|
module function_definition identifier parameters identifier block import_statement dotted_name identifier dotted_name identifier for_statement identifier attribute identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list keyword_argument identifier false expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript identifier slice unary_operator integer if_statement comparison_operator identifier attribute identifier identifier block delete_statement subscript attribute identifier identifier identifier expression_statement call attribute call identifier argument_list identifier argument_list
|
Commit changes and close the database.
|
def update(self, value):
"Updates the progress bar to a new value."
if value <= 0.1:
value = 0
assert 0 <= value <= self.maxval
self.currval = value
if not self._need_update() or self.finished:
return
if not self.start_time:
self.start_time = time.time()
self.seconds_elapsed = time.time() - self.start_time
self.prev_percentage = self.percentage()
if value != self.maxval:
self.fd.write(self._format_line() + '\r')
else:
self.finished = True
self.fd.write(self._format_line() + '\n')
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement comparison_operator identifier float block expression_statement assignment identifier integer assert_statement comparison_operator integer identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement boolean_operator not_operator call attribute identifier identifier argument_list attribute identifier identifier block return_statement if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier binary_operator call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end else_clause block expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end
|
Updates the progress bar to a new value.
|
def raises(self) -> T.List[DocstringRaises]:
return [
DocstringRaises.from_meta(meta)
for meta in self.meta
if meta.args[0] in {"raises", "raise", "except", "exception"}
]
|
module function_definition identifier parameters identifier type subscript attribute identifier identifier identifier block return_statement list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator subscript attribute identifier identifier integer set 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
|
Return exceptions indicated in docstring.
|
def add_f95_to_env(env):
try:
F95Suffixes = env['F95FILESUFFIXES']
except KeyError:
F95Suffixes = ['.f95']
try:
F95PPSuffixes = env['F95PPFILESUFFIXES']
except KeyError:
F95PPSuffixes = []
DialectAddToEnv(env, "F95", F95Suffixes, F95PPSuffixes,
support_module = 1)
|
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause identifier block expression_statement assignment identifier list string string_start string_content string_end try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause identifier block expression_statement assignment identifier list expression_statement call identifier argument_list identifier string string_start string_content string_end identifier identifier keyword_argument identifier integer
|
Add Builders and construction variables for f95 to an Environment.
|
def _IncrementNestLevel():
if getattr(_import_local, 'nest_level', None) is None:
_import_local.nest_level = 0
if _import_local.nest_level == 0:
_import_local.names = set()
_import_local.nest_level += 1
|
module function_definition identifier parameters block if_statement comparison_operator call identifier argument_list identifier string string_start string_content string_end none none block expression_statement assignment attribute identifier identifier integer if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement augmented_assignment attribute identifier identifier integer
|
Increments the per thread nest level of imports.
|
async def popHiveKey(self, path):
perm = ('hive:pop',) + path
self.user.allowed(perm)
return await self.cell.hive.pop(path)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator tuple string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement await call attribute attribute attribute identifier identifier identifier identifier argument_list identifier
|
Remove and return the value of a key in the cell default hive
|
def _load(self, scale=0.001):
with open_workbook(self.path) as wb_:
for sheet in wb_.sheets():
if sheet.name in ['Plot of AllBands', ]:
continue
ch_name = OLI_BAND_NAMES.get(sheet.name.strip())
if ch_name != self.bandname:
continue
wvl = sheet.col_values(0, 2)
resp = sheet.col_values(1, 2)
self.rsr = {'wavelength': np.array(wvl) / 1000.,
'response': np.array(resp)}
break
|
module function_definition identifier parameters identifier default_parameter identifier float block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier as_pattern_target identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list integer integer expression_statement assignment identifier call attribute identifier identifier argument_list integer integer expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end binary_operator call attribute identifier identifier argument_list identifier float pair string string_start string_content string_end call attribute identifier identifier argument_list identifier break_statement
|
Load the Landsat OLI relative spectral responses
|
def to_serializable_dict(self, attrs_to_serialize=None,
rels_to_expand=None,
rels_to_serialize=None,
key_modifications=None):
return self.todict(
attrs_to_serialize=attrs_to_serialize,
rels_to_expand=rels_to_expand, rels_to_serialize=rels_to_serialize,
key_modifications=key_modifications)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
An alias for `todict`
|
def my_version():
if os.path.exists(resource_filename(__name__, 'version')):
return resource_string(__name__, 'version')
return open(os.path.join(os.path.dirname(__file__),
"..", "version")).read()
|
module function_definition identifier parameters block if_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end block return_statement call identifier argument_list identifier string string_start string_content string_end return_statement call attribute call identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list
|
Return the version, checking both packaged and development locations
|
def _checkJobGraphAcylicDFS(self, stack, visited, extraEdges):
if self not in visited:
visited.add(self)
stack.append(self)
for successor in self._children + self._followOns + extraEdges[self]:
successor._checkJobGraphAcylicDFS(stack, visited, extraEdges)
assert stack.pop() == self
if self in stack:
stack.append(self)
raise JobGraphDeadlockException("A cycle of job dependencies has been detected '%s'" % stack)
|
module function_definition identifier parameters identifier identifier identifier identifier block 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 for_statement identifier binary_operator binary_operator attribute identifier identifier attribute identifier identifier subscript identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier assert_statement comparison_operator call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
|
DFS traversal to detect cycles in augmented job graph.
|
def safe_chmod(path, mode):
if stat.S_IMODE(os.stat(path).st_mode) != mode:
os.chmod(path, mode)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list attribute call attribute identifier identifier argument_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
|
Set the permissions mode on path, but only if it differs from the current mode.
|
def io_check(*args, func=None):
func = func or inspect.stack()[2][3]
for var in args:
if not isinstance(var, io.IOBase):
name = type(var).__name__
raise IOObjError(
f'Function {func} expected file-like object, {name} got instead.')
|
module function_definition identifier parameters list_splat_pattern identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier subscript subscript call attribute identifier identifier argument_list integer integer for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier attribute call identifier argument_list identifier identifier raise_statement call identifier argument_list string string_start string_content interpolation identifier string_content interpolation identifier string_content string_end
|
Check if arguments are file-like object.
|
def filter_oauth_params(params):
is_oauth = lambda kv: kv[0].startswith("oauth_")
if isinstance(params, dict):
return list(filter(is_oauth, list(params.items())))
else:
return list(filter(is_oauth, params))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier lambda lambda_parameters identifier call attribute subscript identifier integer identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list call identifier argument_list identifier call identifier argument_list call attribute identifier identifier argument_list else_clause block return_statement call identifier argument_list call identifier argument_list identifier identifier
|
Removes all non oauth parameters from a dict or a list of params.
|
def _fire_task(self, exclude=None):
connection = mail.get_connection(fail_silently=True)
connection.open()
for m in self._mails(self._users_watching(exclude=exclude)):
connection.send_messages([m])
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier true expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier
|
Build and send the emails as a celery task.
|
def _gauss_funct(p, fjac=None, x=None, y=None, err=None,
weights=None):
if p[2] != 0.0:
Z = (x - p[1]) / p[2]
model = p[0] * np.e ** (-Z ** 2 / 2.0)
else:
model = np.zeros(np.size(x))
status = 0
if weights is not None:
if err is not None:
print("Warning: Ignoring errors and using weights.\n")
return [status, (y - model) * weights]
elif err is not None:
return [status, (y - model) / err]
else:
return [status, y - model]
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement comparison_operator subscript identifier integer float block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier subscript identifier integer subscript identifier integer expression_statement assignment identifier binary_operator subscript identifier integer binary_operator attribute identifier identifier parenthesized_expression binary_operator unary_operator binary_operator identifier integer float else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier integer if_statement comparison_operator identifier none block if_statement comparison_operator identifier none block expression_statement call identifier argument_list string string_start string_content escape_sequence string_end return_statement list identifier binary_operator parenthesized_expression binary_operator identifier identifier identifier elif_clause comparison_operator identifier none block return_statement list identifier binary_operator parenthesized_expression binary_operator identifier identifier identifier else_clause block return_statement list identifier binary_operator identifier identifier
|
Defines the gaussian function to be used as the model.
|
def samples(self):
names = self.series.dimensions
for n, offset in enumerate(self.series.offsets):
dt = datetime.timedelta(microseconds=offset * 1000)
d = {"ts": self.ts + dt}
for name in names:
d[name] = getattr(self.series, name)[n]
yield d
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier binary_operator identifier integer expression_statement assignment identifier dictionary pair string string_start string_content string_end binary_operator attribute identifier identifier identifier for_statement identifier identifier block expression_statement assignment subscript identifier identifier subscript call identifier argument_list attribute identifier identifier identifier identifier expression_statement yield identifier
|
Yield samples as dictionaries, keyed by dimensions.
|
def verify_verify(self, id, token):
return Verify().load(self.request('verify/' + str(id), params={'token': token}))
|
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute call identifier argument_list identifier argument_list call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier keyword_argument identifier dictionary pair string string_start string_content string_end identifier
|
Verify the token of a specific verification.
|
def _stringify_column(self, column_index):
table_column = TableTranspose(self.table)[column_index]
prior_cell = None
for row_index in range(self.start[0], self.end[0]):
cell, changed = self._check_interpret_cell(table_column[row_index], prior_cell, row_index, column_index)
if changed:
table_column[row_index] = cell
prior_cell = cell
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript call identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier none for_statement identifier call identifier argument_list subscript attribute identifier identifier integer subscript attribute identifier identifier integer block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list subscript identifier identifier identifier identifier identifier if_statement identifier block expression_statement assignment subscript identifier identifier identifier expression_statement assignment identifier identifier
|
Same as _stringify_row but for columns.
|
def generate_hash(self, length=30):
import random, string
chars = string.ascii_letters + string.digits
ran = random.SystemRandom().choice
hash = ''.join(ran(chars) for i in range(length))
return hash
|
module function_definition identifier parameters identifier default_parameter identifier integer block import_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier return_statement identifier
|
Generate random string of given length
|
def conrad(self):
repo = self.def_repos_dict["conrad"]
log = self.log_path + "conrad/"
lib = self.lib_path + "conrad_repo/"
repo_name = log[:-1].split("/")[-1]
lib_file = "PACKAGES.TXT"
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
if not os.path.exists(log):
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = "{0}{1}".format(repo, lib_file)
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}".format(repo, md5_file)
ChangeLog_txt = "{0}{1}".format(repo, log_file)
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
self.down(lib, CHECKSUMS_MD5, repo_name)
self.down(log, ChangeLog_txt, repo_name)
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
FILELIST_TXT, repo_name)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript call attribute subscript identifier slice unary_operator integer identifier argument_list string string_start string_content string_end unary_operator integer expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier
|
Creating slackers local library
|
def init_tables(self):
for model in self.models:
_log.debug('Checking for table {0}'.format(model))
assert not model.__table__.exists(self.session.bind)
_log.debug('Creating {0}'.format(self.models))
self.migration_model.metadata.create_all(
self.session.bind,
tables=[model.__table__ for model in self.models])
|
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier assert_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier
|
Create all tables relative to this package
|
def checkpat(self, pattern):
if pattern is None:
return
try:
re.match(pattern, "")
except re.error:
print3("\nBad user-defined singular pattern:\n\t%s\n" % pattern)
raise BadUserDefinedPatternError
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement try_statement block expression_statement call attribute identifier identifier argument_list identifier string string_start string_end except_clause attribute identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end identifier raise_statement identifier
|
check for errors in a regex pattern
|
def flush(self, parser):
if self._verbose:
show = self._verbose if isinstance(self._verbose, str) else None
self.show(show)
parser.parse(self._filter(self.clear(), parser))
|
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier conditional_expression attribute identifier identifier call identifier argument_list attribute identifier identifier identifier none expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
|
Flush all current commands to the GLIR interpreter.
|
def connect_to_apple_tv(details, loop, protocol=None, session=None):
service = _get_service_used_to_connect(details, protocol)
if session is None:
session = ClientSession(loop=loop)
airplay = _setup_airplay(loop, session, details)
if service.protocol == PROTOCOL_DMAP:
return DmapAppleTV(loop, session, details, airplay)
return MrpAppleTV(loop, session, details, airplay)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier if_statement comparison_operator attribute identifier identifier identifier block return_statement call identifier argument_list identifier identifier identifier identifier return_statement call identifier argument_list identifier identifier identifier identifier
|
Connect and logins to an Apple TV.
|
def updateMesh(self, polydata):
self.poly = polydata
self.mapper.SetInputData(polydata)
self.mapper.Modified()
return self
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list return_statement identifier
|
Overwrite the polygonal mesh of the actor with a new one.
|
def view_rect(self) -> QRectF:
top_left = self.mapToScene(0, 0)
bottom_right = self.mapToScene(self.viewport().width() - 1, self.viewport().height() - 1)
return QRectF(top_left, bottom_right)
|
module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer integer expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator call attribute call attribute identifier identifier argument_list identifier argument_list integer binary_operator call attribute call attribute identifier identifier argument_list identifier argument_list integer return_statement call identifier argument_list identifier identifier
|
Return the boundaries of the view in scene coordinates
|
def _is_under_root(self, full_path):
if (path.abspath(full_path) + path.sep)\
.startswith(path.abspath(self.root) + path.sep):
return True
else:
return False
|
module function_definition identifier parameters identifier identifier block if_statement call attribute parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier attribute identifier identifier line_continuation identifier argument_list binary_operator call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier block return_statement true else_clause block return_statement false
|
Guard against arbitrary file retrieval.
|
def render(self):
data = self.prepare_data()
if self.field.readable:
return self.env.template.render(self.template, **data)
return ''
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement attribute attribute identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier dictionary_splat identifier return_statement string string_start string_end
|
Renders widget to template
|
def from_response(cls, response):
hash_key = None
range_key = None
if 'KeySchema' in response:
attrs = dict(((d['AttributeName'],
DynamoKey(d['AttributeName'], d['AttributeType']))
for d in response['AttributeDefinitions']))
hash_key = attrs[response['KeySchema'][0]['AttributeName']]
if len(response['KeySchema']) > 1:
range_key = attrs[response['KeySchema'][1]['AttributeName']]
indexes = []
for idx in response.get('LocalSecondaryIndexes', []):
indexes.append(LocalIndex.from_response(idx, attrs))
global_indexes = []
for idx in response.get('GlobalSecondaryIndexes', []):
global_indexes.append(GlobalIndex.from_response(idx, attrs))
table = cls(
name=response['TableName'],
hash_key=hash_key,
range_key=range_key,
indexes=indexes,
global_indexes=global_indexes,
throughput=Throughput.from_response(
response['ProvisionedThroughput']),
status=response['TableStatus'],
size=response['TableSizeBytes'],
)
table.response = response
return table
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier none if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call identifier argument_list generator_expression tuple subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end for_in_clause identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier subscript subscript subscript identifier string string_start string_content string_end integer string string_start string_content string_end if_statement comparison_operator call identifier argument_list subscript identifier string string_start string_content string_end integer block expression_statement assignment identifier subscript identifier subscript subscript subscript identifier string string_start string_content string_end integer string string_start string_content string_end expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier return_statement identifier
|
Create a Table from returned Dynamo data
|
def estimate_map(interface, state, label, inp):
out = interface.output(0)
centers = {}
for row in inp:
row = row.strip().split(state["delimiter"])
if len(row) > 1:
x = [(0 if row[i] in state["missing_vals"] else float(row[i])) for i in state["X_indices"]]
cluster = min((state['dist'](c, x), i) for i, c in state['centers'])[1]
vertex = state['create'](x, 1.0)
centers[cluster] = vertex if cluster not in centers else state["update"](centers[cluster], vertex)
for cluster, values in centers.iteritems():
out.add(cluster, values)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier list_comprehension parenthesized_expression conditional_expression integer comparison_operator subscript identifier identifier subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier identifier for_in_clause identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript call identifier generator_expression tuple call subscript identifier string string_start string_content string_end argument_list identifier identifier identifier for_in_clause pattern_list identifier identifier subscript identifier string string_start string_content string_end integer expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier float expression_statement assignment subscript identifier identifier conditional_expression identifier comparison_operator identifier identifier call subscript identifier string string_start string_content string_end argument_list subscript identifier identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier identifier
|
Find the cluster `i` that is closest to the datapoint `e`.
|
def setup_client_rpc(self):
self.clnt = rpc.DfaRpcClient(self._url, constants.DFA_SERVER_QUEUE,
exchange=constants.DFA_EXCHANGE)
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Setup RPC client for dfa agent.
|
async def dispatch(request):
if session:
message = ''
data = await request.json()
try:
log.info("Dispatching {}".format(data))
_id = data.get('token')
if not _id:
message = '"token" field required for calibration requests'
raise AssertionError
command = data.get('command')
if not command:
message = '"command" field required for calibration requests'
raise AssertionError
if _id == session.id:
res = await router[command](data)
else:
res = web.json_response(
{'message': 'Invalid token: {}'.format(_id)}, status=403)
except AssertionError:
res = web.json_response({'message': message}, status=400)
except Exception as e:
res = web.json_response(
{'message': 'Exception {} raised by dispatch of {}: {}'.format(
type(e), data, e)},
status=500)
else:
res = web.json_response(
{'message': 'Session must be started before issuing commands'},
status=418)
return res
|
module function_definition identifier parameters identifier block if_statement identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier await call attribute identifier identifier argument_list try_statement block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier await call subscript identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier integer except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier keyword_argument identifier integer except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier identifier keyword_argument identifier integer else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end keyword_argument identifier integer return_statement identifier
|
Routes commands to subhandlers based on the command field in the body.
|
def _GetDebuggeeDescription(self):
return '-'.join(self._debuggee_labels[label]
for label in _DESCRIPTION_LABELS
if label in self._debuggee_labels)
|
module function_definition identifier parameters identifier block return_statement call attribute string string_start string_content string_end identifier generator_expression subscript attribute identifier identifier identifier for_in_clause identifier identifier if_clause comparison_operator identifier attribute identifier identifier
|
Formats debuggee description based on debuggee labels.
|
def drop(self, force=False):
if not self.exists:
logger.info("Schema named `{database}` does not exist. Doing nothing.".format(database=self.database))
elif (not config['safemode'] or
force or
user_choice("Proceed to delete entire schema `%s`?" % self.database, default='no') == 'yes'):
logger.info("Dropping `{database}`.".format(database=self.database))
try:
self.connection.query("DROP DATABASE `{database}`".format(database=self.database))
logger.info("Schema `{database}` was dropped successfully.".format(database=self.database))
except pymysql.OperationalError:
raise DataJointError("An attempt to drop schema `{database}` "
"has failed. Check permissions.".format(database=self.database))
|
module function_definition identifier parameters identifier default_parameter identifier false block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier elif_clause parenthesized_expression boolean_operator boolean_operator not_operator subscript identifier string string_start string_content string_end identifier comparison_operator call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier keyword_argument identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier except_clause attribute identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier
|
Drop the associated schema if it exists
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.