Dataset Viewer
code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def cli(family_file, family_type, to_json, to_madeline, to_ped, to_dict,
outfile, logfile, loglevel):
from pprint import pprint as pp
my_parser = FamilyParser(family_file, family_type)
if to_json:
if outfile:
outfile.write(my_parser.to_json())
else:
print(my_parser.to_json())
elif to_madeline:
for line in my_parser.to_madeline():
if outfile:
outfile.write(line + '\n')
else:
print(line)
elif to_ped:
for line in my_parser.to_ped():
if outfile:
outfile.write(line + '\n')
else:
print(line)
elif to_dict:
pp(my_parser.to_dict())
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier block import_from_statement dotted_name identifier aliased_import dotted_name identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement call identifier argument_list call attribute identifier identifier argument_list elif_clause identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content escape_sequence string_end else_clause block expression_statement call identifier argument_list identifier elif_clause identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content escape_sequence string_end else_clause block expression_statement call identifier argument_list identifier elif_clause identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list
|
Cli for testing the ped parser.
|
def view_admin_log():
build = g.build
log_list = (
models.AdminLog.query
.filter_by(build_id=build.id)
.order_by(models.AdminLog.created.desc())
.all())
return render_template(
'view_admin_log.html',
build=build,
log_list=log_list)
|
module function_definition identifier parameters block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier parenthesized_expression call attribute call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list identifier argument_list return_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier
|
Page for viewing the log of admin activity.
|
def caesar_app(parser, cmd, args):
parser.add_argument('shift', type=int, help='the shift to apply')
parser.add_argument('value', help='the value to caesar crypt, read from stdin if omitted', nargs='?')
parser.add_argument(
'-s', '--shift-range',
dest='shift_ranges',
action='append',
help='specify a character range to shift (defaults to a-z, A-Z)'
)
args = parser.parse_args(args)
if not args.shift_ranges:
args.shift_ranges = ['az', 'AZ']
return caesar(args.shift, pwnypack.main.string_value_or_stdin(args.value), args.shift_ranges)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end return_statement call identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier
|
Caesar crypt a value with a key.
|
def close(self):
if self._closing or self._handle.closed:
return
elif self._protocol is None:
raise TransportError('transport not started')
if self._write_buffer_size == 0:
self._handle.close(self._on_close_complete)
assert self._handle.closed
else:
self._closing = True
|
module function_definition identifier parameters identifier block if_statement boolean_operator attribute identifier identifier attribute attribute identifier identifier identifier block return_statement elif_clause comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier assert_statement attribute attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier true
|
Close the transport after all oustanding data has been written.
|
def gas_price_strategy_middleware(make_request, web3):
def middleware(method, params):
if method == 'eth_sendTransaction':
transaction = params[0]
if 'gasPrice' not in transaction:
generated_gas_price = web3.eth.generateGasPrice(transaction)
if generated_gas_price is not None:
transaction = assoc(transaction, 'gasPrice', generated_gas_price)
return make_request(method, [transaction])
return make_request(method, params)
return middleware
|
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier integer if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end identifier return_statement call identifier argument_list identifier list identifier return_statement call identifier argument_list identifier identifier return_statement identifier
|
Includes a gas price using the gas price strategy
|
def _validate_and_parse_course_key(self, course_key):
try:
return CourseKey.from_string(course_key)
except InvalidKeyError:
raise ValidationError(_("Invalid course key: {}").format(course_key))
|
module function_definition identifier parameters identifier identifier block try_statement block return_statement call attribute identifier identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list call attribute call identifier argument_list string string_start string_content string_end identifier argument_list identifier
|
Returns a validated parsed CourseKey deserialized from the given course_key.
|
def __add_item(self, item, keys=None):
if(not keys or not len(keys)):
raise Exception('Error in %s.__add_item(%s, keys=tuple/list of items): need to specify a tuple/list containing at least one key!'
% (self.__class__.__name__, str(item)))
direct_key = tuple(keys)
for key in keys:
key_type = str(type(key))
if(not key_type in self.__dict__):
self.__setattr__(key_type, dict())
self.__dict__[key_type][key] = direct_key
if(not 'items_dict' in self.__dict__):
self.items_dict = dict()
self.items_dict[direct_key] = item
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement parenthesized_expression boolean_operator not_operator identifier not_operator call identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute attribute identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier if_statement parenthesized_expression not_operator comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list expression_statement assignment subscript subscript attribute identifier identifier identifier identifier identifier if_statement parenthesized_expression not_operator comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier identifier
|
Internal method to add an item to the multi-key dictionary
|
def clear(self):
self.__modified_data__ = {}
self.__deleted_fields__ = [field for field in self.__original_data__.keys()]
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier list_comprehension identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list
|
Clears all the data in the object, keeping original data
|
def getDownloader(self, url):
filename = self.namer(url, self.stripUrl)
if filename is None:
filename = url.rsplit('/', 1)[1]
dirname = getDirname(self.name)
return ComicImage(self.name, url, self.stripUrl, dirname, filename, self.session, text=self.text)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer integer expression_statement assignment identifier call identifier argument_list attribute identifier identifier return_statement call identifier argument_list attribute identifier identifier identifier attribute identifier identifier identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Get an image downloader.
|
def validate(self, password, user=None):
user_inputs = []
if user is not None:
for attribute in self.user_attributes:
if hasattr(user, attribute):
user_inputs.append(getattr(user, attribute))
results = zxcvbn(password, user_inputs=user_inputs)
if results.get('score', 0) < self.min_score:
feedback = ', '.join(
results.get('feedback', {}).get('suggestions', []))
raise ValidationError(_(feedback), code=self.code, params={})
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier list if_statement comparison_operator identifier none block for_statement identifier attribute identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end integer attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end list raise_statement call identifier argument_list call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier dictionary
|
Validate method, run zxcvbn and check score.
|
def getLogger(name):
log = logging.getLogger(name)
log.addHandler(_NullHandler())
return log
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list return_statement identifier
|
Create and return a logger with the specified name.
|
def find_one(self, cls, id):
found = self.find_by_index(cls, 'id', id)
return found[0] if found else None
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier return_statement conditional_expression subscript identifier integer identifier none
|
Find single keyed row - as per the gludb spec.
|
def detect_lang(path):
blob = FileBlob(path, os.getcwd())
if blob.is_text:
print('Programming language of the file detected: {0}'.format(blob.language.name))
return blob.language.name
else:
print('File not a text file. Exiting...')
sys.exit()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier return_statement attribute attribute identifier identifier identifier else_clause block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
|
Detect the language used in the given file.
|
def show_bandwidth_limit_rule(self, rule, policy, body=None):
return self.get(self.qos_bandwidth_limit_rule_path %
(policy, rule), body=body)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier tuple identifier identifier keyword_argument identifier identifier
|
Fetches information of a certain bandwidth limit rule.
|
def all_collections(db):
include_pattern = r'(?!system\.)'
return (
db[name]
for name in db.list_collection_names()
if re.match(include_pattern, name)
)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end return_statement generator_expression subscript identifier identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause call attribute identifier identifier argument_list identifier identifier
|
Yield all non-sytem collections in db.
|
def database_current_migration(self):
if not self.migration_table.exists(self.session.bind):
return None
if self.migration_data is None:
return None
return self.migration_data.version
|
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier block return_statement none if_statement comparison_operator attribute identifier identifier none block return_statement none return_statement attribute attribute identifier identifier identifier
|
Return the current migration in the database.
|
def _check_file_io(self):
folder = 'Model' + str(self.flags['RUN_NUM']) + '/'
folder_restore = 'Model' + str(self.flags['MODEL_RESTORE']) + '/'
self.flags['RESTORE_DIRECTORY'] = self.flags['SAVE_DIRECTORY'] + self.flags[
'MODEL_DIRECTORY'] + folder_restore
self.flags['LOGGING_DIRECTORY'] = self.flags['SAVE_DIRECTORY'] + self.flags[
'MODEL_DIRECTORY'] + folder
self.make_directory(self.flags['LOGGING_DIRECTORY'])
sys.stdout = Logger(self.flags['LOGGING_DIRECTORY'] + 'ModelInformation.log')
print(self.flags)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end binary_operator binary_operator subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end binary_operator binary_operator subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier
|
Create and define logging directory
|
def image(self):
if self._image is None:
self._populate_from_rasterio_object(read_image=True)
return self._image
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list keyword_argument identifier true return_statement attribute identifier identifier
|
Raster bitmap in numpy array.
|
def cli(location, **kwargs):
locations = []
try:
for line in fileinput.input():
locations.append(line.strip())
except:
pass
for item in location:
if os.path.exists(item):
with open(item, 'rb') as f:
locations += f.read().splitlines()
else:
locations.append(item)
if kwargs['distance']:
d = geocoder.distance(locations, **kwargs)
click.echo(d)
return
for location in locations:
g = geocoder.get(location.strip(), **kwargs)
try:
click.echo(json.dumps(getattr(g, kwargs['output'])))
except IOError:
return
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier list try_statement block for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list except_clause block pass_statement for_statement identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement augmented_assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier return_statement for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list dictionary_splat identifier try_statement block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier subscript identifier string string_start string_content string_end except_clause identifier block return_statement
|
Geocode an arbitrary number of strings from Command Line.
|
def as_python(self, name: str) -> str:
if self._map_valuetype:
return self.map_as_python(name)
else:
return self.obj_as_python(name)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block if_statement attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier else_clause block return_statement call attribute identifier identifier argument_list identifier
|
Return the python representation of the class represented by this object
|
def _unpack_lookupswitch(bc, offset):
jump = (offset % 4)
if jump:
offset += (4 - jump)
(default, npairs), offset = _unpack(_struct_ii, bc, offset)
switches = list()
for _index in range(npairs):
pair, offset = _unpack(_struct_ii, bc, offset)
switches.append(pair)
return (default, switches), offset
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier parenthesized_expression binary_operator identifier integer if_statement identifier block expression_statement augmented_assignment identifier parenthesized_expression binary_operator integer identifier expression_statement assignment pattern_list tuple_pattern identifier identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier call identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement expression_list tuple identifier identifier identifier
|
function for unpacking the lookupswitch op arguments
|
def import_description(text):
xml = ''
is_in_ul = False
for line in text.split('\n'):
line = line.strip()
if len(line) == 0:
continue
line_li = _import_description_to_list_element(line)
if line_li:
if not is_in_ul:
xml += '<ul>\n'
is_in_ul = True
xml += '<li>' + _import_description_sentence_case(line_li) + '</li>\n'
continue
if is_in_ul:
xml += '</ul>\n'
is_in_ul = False
xml += '<p>' + _import_description_sentence_case(line) + '</p>\n'
if is_in_ul:
xml += '</ul>\n'
return xml
|
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier false for_statement identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block continue_statement expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block if_statement not_operator identifier block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier true expression_statement augmented_assignment identifier binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content escape_sequence string_end continue_statement if_statement identifier block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier false expression_statement augmented_assignment identifier binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content escape_sequence string_end if_statement identifier block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end return_statement identifier
|
Convert ASCII text to AppStream markup format
|
def to_dict(self):
d = super(TargetExecutionContext, self).to_dict()
d['id'] = self.id
return d
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier
|
Save this target execution context into a dictionary.
|
def delete(request, obj_id=None):
data = request.DELETE or json.loads(request.body)
guids = data.get('guids').split(',')
objects = getObjectsFromGuids(guids)
gallery = Gallery.objects.get(pk=obj_id)
LOGGER.info('{} removed {} from {}'.format(request.user.email, guids, gallery))
for o in objects:
if isinstance(o, Image):
gallery.images.remove(o)
elif isinstance(o, Video):
gallery.videos.remove(o)
res = Result()
return JsonResponse(res.asDict())
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier identifier identifier for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list return_statement call identifier argument_list call attribute identifier identifier argument_list
|
Removes ImageVideo objects from Gallery
|
def delete_source(ident):
source = get_source(ident)
source.deleted = datetime.now()
source.save()
signals.harvest_source_deleted.send(source)
return source
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
|
Delete an harvest source
|
def scale(self, scale_xy):
"Returns the pix object rescaled according to the proportions given."
with _LeptonicaErrorTrap():
return Pix(lept.pixScale(self._cdata, scale_xy[0], scale_xy[1]))
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end with_statement with_clause with_item call identifier argument_list block return_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier subscript identifier integer subscript identifier integer
|
Returns the pix object rescaled according to the proportions given.
|
def first_n_items(array, n_desired):
if n_desired < 1:
raise ValueError('must request at least one item')
if array.size == 0:
return []
if n_desired < array.size:
indexer = _get_indexer_at_least_n_items(array.shape, n_desired,
from_end=False)
array = array[indexer]
return np.asarray(array).flat[:n_desired]
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block return_statement list if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier keyword_argument identifier false expression_statement assignment identifier subscript identifier identifier return_statement subscript attribute call attribute identifier identifier argument_list identifier identifier slice identifier
|
Returns the first n_desired items of an array
|
def rowkey(self, row):
'returns a tuple of the key for the given row'
return tuple(c.getTypedValueOrException(row) for c in self.keyCols)
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end return_statement call identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier
|
returns a tuple of the key for the given row
|
def accel_decrease_transparency(self, *args):
transparency = self.settings.styleBackground.get_int('transparency')
if int(transparency) + 2 < MAX_TRANSPARENCY:
self.settings.styleBackground.set_int('transparency', int(transparency) + 2)
return True
|
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator binary_operator call identifier argument_list identifier integer identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end binary_operator call identifier argument_list identifier integer return_statement true
|
Callback to decrease transparency.
|
def handle(self, *args, **options):
for plan_data in Plan.api_list():
plan = Plan.sync_from_stripe_data(plan_data)
print("Synchronized plan {0}".format(plan.id))
|
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier
|
Call sync_from_stripe_data for each plan returned by api_list.
|
def CalcRad(lat):
"Radius of curvature in meters at specified latitude."
a = 6378.137
e2 = 0.081082 * 0.081082
sc = math.sin(Deg2Rad(lat))
x = a * (1.0 - e2)
z = 1.0 - e2 * sc * sc
y = pow(z, 1.5)
r = x / y
r = r * 1000.0
return r
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier float expression_statement assignment identifier binary_operator float float expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator float identifier expression_statement assignment identifier binary_operator float binary_operator binary_operator identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier float expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier float return_statement identifier
|
Radius of curvature in meters at specified latitude.
|
def emitCurrentChanged(self):
if not self.signalsBlocked():
self.currentIndexChanged.emit(self.currentIndex())
self.currentUrlChanged.emit(self.currentUrl())
self.canGoBackChanged.emit(self.canGoBack())
self.canGoForwardChanged.emit(self.canGoForward())
|
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list
|
Emits the current index changed signal provided signals are not blocked.
|
def _find_fuzzy_line(
py_line_no, py_by_line_no, cheetah_by_line_no, prefer_first
):
stripped_line = _fuzz_py_line(py_by_line_no[py_line_no])
cheetah_lower_bound, cheetah_upper_bound = _find_bounds(
py_line_no, py_by_line_no, cheetah_by_line_no,
)
sliced = list(enumerate(cheetah_by_line_no))[
cheetah_lower_bound:cheetah_upper_bound
]
if not prefer_first:
sliced = reversed(sliced)
for line_no, line in sliced:
if stripped_line in _fuzz_cheetah_line(line):
return line_no
else:
return 0
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list subscript identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier subscript call identifier argument_list call identifier argument_list identifier slice identifier identifier if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier call identifier argument_list identifier block return_statement identifier else_clause block return_statement integer
|
Attempt to fuzzily find matching lines.
|
def set(self, val):
msg = ExtendedSend(
address=self._address,
commandtuple=COMMAND_THERMOSTAT_SET_HEAT_SETPOINT_0X6D_NONE,
cmd2=int(val * 2),
userdata=Userdata())
msg.set_checksum()
self._send_method(msg, self._set_heat_point_ack)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier call identifier argument_list binary_operator identifier integer keyword_argument identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
|
Set the heat set point.
|
def on(self):
on_command = ExtendedSend(self._address,
COMMAND_LIGHT_ON_0X11_NONE,
self._udata,
cmd2=0xff)
on_command.set_checksum()
self._send_method(on_command, self._on_message_received)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier attribute identifier identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
|
Send an ON message to device group.
|
def add_soup(response, soup_config):
if ("text/html" in response.headers.get("Content-Type", "") or
Browser.__looks_like_html(response)):
response.soup = bs4.BeautifulSoup(response.content, **soup_config)
else:
response.soup = None
|
module function_definition identifier parameters identifier identifier block if_statement parenthesized_expression boolean_operator comparison_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end call attribute identifier identifier argument_list identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier dictionary_splat identifier else_clause block expression_statement assignment attribute identifier identifier none
|
Attaches a soup object to a requests response.
|
def help(self):
result = [
'=' * 50,
self.name
]
if self.doc:
result.extend([
'=' * 30,
self.doc
])
override = self.overrides
while override:
if isinstance(override, Shovel):
result.append('Overrides module')
else:
result.append('Overrides %s' % override.file)
override = override.overrides
result.extend([
'=' * 30,
'From %s on line %i' % (self.file, self.line),
'=' * 30,
'%s%s' % (self.name, str(Args(self.spec)))
])
return os.linesep.join(result)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list binary_operator string string_start string_content string_end integer attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list list binary_operator string string_start string_content string_end integer attribute identifier identifier expression_statement assignment identifier attribute identifier identifier while_statement identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list list binary_operator string string_start string_content string_end integer binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier binary_operator string string_start string_content string_end integer binary_operator string string_start string_content string_end tuple attribute identifier identifier call identifier argument_list call identifier argument_list attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Return the help string of the task
|
def _get_cores_and_type(numcores, paralleltype, scheduler):
if scheduler is not None:
paralleltype = "ipython"
if paralleltype is None:
paralleltype = "local"
if not numcores or int(numcores) < 1:
numcores = 1
return paralleltype, int(numcores)
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end if_statement boolean_operator not_operator identifier comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier integer return_statement expression_list identifier call identifier argument_list identifier
|
Return core and parallelization approach from command line providing sane defaults.
|
def clean(self):
if not self.metrics:
self.metrics = dict(
(name, spec.default)
for name, spec in (metric_catalog.get(self.__class__, {})
.items()))
return super(WithMetrics, self).clean()
|
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier generator_expression tuple identifier attribute identifier identifier for_in_clause pattern_list identifier identifier parenthesized_expression call attribute call attribute identifier identifier argument_list attribute identifier identifier dictionary identifier argument_list return_statement call attribute call identifier argument_list identifier identifier identifier argument_list
|
Fill metrics with defaults on create
|
def main(argv: Optional[Sequence[str]] = None) -> None:
parser = ArgumentParser(description="Convert Jupyter Notebook exams to PDFs")
parser.add_argument(
"--exam",
type=int,
required=True,
help="Exam number to convert",
dest="exam_num",
)
parser.add_argument(
"--time", type=str, required=True, help="Time of exam to convert"
)
parser.add_argument(
"--date", type=str, required=True, help="The date the exam will take place"
)
args = parser.parse_args(argv)
process(args.exam_num, args.time, args.date)
|
module function_definition identifier parameters typed_default_parameter identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier none type none block expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Parse arguments and process the exam assignment.
|
def add_package(self, package):
self._data.setdefault('packages', {})
self._data['packages'][package.name] = package.source
for package in package.deploy_packages:
self.add_package(package)
self._save()
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Add a package to this project
|
def experimental(name=None):
def inner(func):
@functools.wraps(func)
def wrapper(*fargs, **kw):
fname = name
if name is None:
fname = func.__name__
warnings.warn("%s" % fname, category=ExperimentalWarning,
stacklevel=2)
return func(*fargs, **kw)
return wrapper
return inner
|
module function_definition identifier parameters default_parameter identifier none block function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier identifier keyword_argument identifier integer return_statement call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier return_statement identifier
|
A simple decorator to mark functions and methods as experimental.
|
def read_plain_float(file_obj, count):
return struct.unpack("<{}f".format(count).encode("utf-8"), file_obj.read(4 * count))
|
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call attribute call attribute string string_start string_content string_end identifier argument_list identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list binary_operator integer identifier
|
Read `count` 32-bit floats using the plain encoding.
|
def _bridge(self, channel):
channel.setblocking(False)
channel.settimeout(0.0)
self._tasks = [
gevent.spawn(self._forward_inbound, channel),
gevent.spawn(self._forward_outbound, channel)
]
gevent.joinall(self._tasks)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list false expression_statement call attribute identifier identifier argument_list float expression_statement assignment attribute identifier identifier list call attribute identifier identifier argument_list attribute identifier identifier identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Full-duplex bridge between a websocket and a SSH channel
|
def density(self):
r = self.radius * _Rsun
m = self.mass * _Msun
return 0.75 * m / (np.pi * r * r * r)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier identifier return_statement binary_operator binary_operator float identifier parenthesized_expression binary_operator binary_operator binary_operator attribute identifier identifier identifier identifier identifier
|
Stellar density in CGS units
|
def intersect(a, b):
if a[x0] == a[x1] or a[y0] == a[y1]:
return False
if b[x0] == b[x1] or b[y0] == b[y1]:
return False
return a[x0] <= b[x1] and b[x0] <= a[x1] and a[y0] <= b[y1] and b[y0] <= a[y1]
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator subscript identifier identifier subscript identifier identifier comparison_operator subscript identifier identifier subscript identifier identifier block return_statement false if_statement boolean_operator comparison_operator subscript identifier identifier subscript identifier identifier comparison_operator subscript identifier identifier subscript identifier identifier block return_statement false return_statement boolean_operator boolean_operator boolean_operator comparison_operator subscript identifier identifier subscript identifier identifier comparison_operator subscript identifier identifier subscript identifier identifier comparison_operator subscript identifier identifier subscript identifier identifier comparison_operator subscript identifier identifier subscript identifier identifier
|
Check if two rectangles intersect
|
def starmodel_props(self):
props = {}
mags = self.mags
mag_errs = self.mag_errs
for b in mags.keys():
if np.size(mags[b])==2:
props[b] = mags[b]
elif np.size(mags[b])==1:
mag = mags[b]
try:
e_mag = mag_errs[b]
except:
e_mag = 0.05
props[b] = (mag, e_mag)
if self.Teff is not None:
props['Teff'] = self.Teff
if self.logg is not None:
props['logg'] = self.logg
if self.feh is not None:
props['feh'] = self.feh
return props
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator call attribute identifier identifier argument_list subscript identifier identifier integer block expression_statement assignment subscript identifier identifier subscript identifier identifier elif_clause comparison_operator call attribute identifier identifier argument_list subscript identifier identifier integer block expression_statement assignment identifier subscript identifier identifier try_statement block expression_statement assignment identifier subscript identifier identifier except_clause block expression_statement assignment identifier float expression_statement assignment subscript identifier identifier tuple identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier
|
Default mag_err is 0.05, arbitrarily
|
def generate_predict_json(position1_result, position2_result, ids, passage_tokens):
predict_len = len(position1_result)
logger.debug('total prediction num is %s', str(predict_len))
answers = {}
for i in range(predict_len):
sample_id = ids[i]
passage, tokens = passage_tokens[i]
kbest = find_best_answer_span(
position1_result[i], position2_result[i], len(tokens), 23)
_, start, end = kbest[0]
answer = passage[tokens[start]['char_begin']:tokens[end]['char_end']]
answers[sample_id] = answer
logger.debug('generate predict done.')
return answers
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment pattern_list identifier identifier subscript identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier identifier subscript identifier identifier call identifier argument_list identifier integer expression_statement assignment pattern_list identifier identifier identifier subscript identifier integer expression_statement assignment identifier subscript identifier slice subscript subscript identifier identifier string string_start string_content string_end subscript subscript identifier identifier string string_start string_content string_end expression_statement assignment subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
|
Generate json by prediction.
|
def generate(self,**kwargs):
import collections
all_params = cartesian_dicts({k:kwargs[k] for k in kwargs.keys() if isinstance(kwargs[k], collections.Iterable)})
for pi,p in enumerate(all_params):
if self.name_mode == 'int':
n = str(len(self.containers))
else:
n = None
self.containers.append(PDContainer(name=n,params=p,parent=self))
self.parameters.update({ k: kwargs[k] for k in kwargs.keys() if not isinstance(kwargs[k], collections.Iterable) })
self.save()
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block import_statement dotted_name identifier expression_statement assignment identifier call identifier argument_list dictionary_comprehension pair identifier subscript identifier identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause call identifier argument_list subscript identifier identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier none expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list dictionary_comprehension pair identifier subscript identifier identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause not_operator call identifier argument_list subscript identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list
|
run once to create all children containers for each combination of the keywords
|
def getBriefModuleInfoFromFile(fileName):
modInfo = BriefModuleInfo()
_cdmpyparser.getBriefModuleInfoFromFile(modInfo, fileName)
modInfo.flush()
return modInfo
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
|
Builds the brief module info from file
|
def notify_listeners(self, msg_type, params):
for c in self.listeners:
c.notify(msg_type, params)
|
module function_definition identifier parameters identifier identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
|
Send a message to all the observers.
|
def check_server_running(pid):
if pid == os.getpid():
return False
try:
os.kill(pid, 0)
return True
except OSError as oe:
if oe.errno == errno.ESRCH:
return False
else:
raise
|
module function_definition identifier parameters identifier block if_statement comparison_operator identifier call attribute identifier identifier argument_list block return_statement false try_statement block expression_statement call attribute identifier identifier argument_list identifier integer return_statement true except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement false else_clause block raise_statement
|
Determine if the given process is running
|
def load_empty(cls, path:PathOrStr, fn:PathOrStr):
"Load the state in `fn` to create an empty `LabelList` for inference."
return cls.load_state(path, pickle.load(open(Path(path)/fn, 'rb')))
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list call identifier argument_list binary_operator call identifier argument_list identifier identifier string string_start string_content string_end
|
Load the state in `fn` to create an empty `LabelList` for inference.
|
def _prepare_workdir(self):
pants_jar_base_dir = os.path.join(self.versioned_workdir, 'cache')
safe_mkdir(pants_jar_base_dir)
return pants_jar_base_dir
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list identifier return_statement identifier
|
Prepare the location in our task workdir to store all the hardlinks to coursier cache dir.
|
def render_te_response(self, data):
if 'submit_label' in data and 'url' not in data:
data['url'] = self.request.get_full_path()
return JsonResponse(data)
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list return_statement call identifier argument_list identifier
|
Render data to JsonResponse
|
def parse_known_args(self, args=None, namespace=None):
self.no_input_file_err = True
self._unset_required()
opts, extra_opts = super(ResultsArgumentParser, self).parse_known_args(
args, namespace)
self.no_input_file_err = False
self._reset_required()
opts, extra_opts = super(ResultsArgumentParser, self).parse_known_args(
args, opts)
if opts.parameters is None:
parameters = get_common_parameters(opts.input_file,
collection='variable_params')
self.actions['parameters'](self, opts, parameters)
unknown = []
for fn in opts.input_file:
fp = loadfile(fn, 'r')
sampler_parser, _ = fp.extra_args_parser(skip_args=self.skip_args)
if sampler_parser is not None:
opts, still_unknown = sampler_parser.parse_known_args(
extra_opts, namespace=opts)
unknown.append(set(still_unknown))
if len(unknown) > 0:
unknown = set.intersection(*unknown)
return opts, list(unknown)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier false expression_statement call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call subscript attribute identifier identifier string string_start string_content string_end argument_list identifier identifier identifier expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier return_statement expression_list identifier call identifier argument_list identifier
|
Parse args method to handle input-file dependent arguments.
|
def transfer_and_wait(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
amount: TokenAmount,
target: Address,
identifier: PaymentID = None,
transfer_timeout: int = None,
secret: Secret = None,
secret_hash: SecretHash = None,
):
payment_status = self.transfer_async(
registry_address=registry_address,
token_address=token_address,
amount=amount,
target=target,
identifier=identifier,
secret=secret,
secret_hash=secret_hash,
)
payment_status.payment_done.wait(timeout=transfer_timeout)
return payment_status
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier return_statement identifier
|
Do a transfer with `target` with the given `amount` of `token_address`.
|
def update(self, obj):
self._dict.update(obj)
for k, v in obj.items():
if env.verbosity > 2:
self._log(k, v)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list identifier identifier
|
Redefine update to trigger logging message
|
def create(self, image, geometry, options):
image = self.cropbox(image, geometry, options)
image = self.orientation(image, geometry, options)
image = self.colorspace(image, geometry, options)
image = self.remove_border(image, options)
image = self.scale(image, geometry, options)
image = self.crop(image, geometry, options)
image = self.rounded(image, geometry, options)
image = self.blur(image, geometry, options)
image = self.padding(image, geometry, options)
return image
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier
|
Processing conductor, returns the thumbnail as an image engine instance
|
def remove_callback(self, callback):
if callback in self._async_callbacks:
self._async_callbacks.remove(callback)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Remove callback previously registered.
|
def save_feature(self, cat, img, feature, data):
filename = self.path(cat, img, feature)
mkdir(filename)
savemat(filename, {'output':data})
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier dictionary pair string string_start string_content string_end identifier
|
Saves a new feature.
|
def user_provenance(self, document):
self.self_check()
(username, fullname) = _whoami()
if not self.full_name:
self.full_name = fullname
document.add_namespace(UUID)
document.add_namespace(ORCID)
document.add_namespace(FOAF)
account = document.agent(
ACCOUNT_UUID, {provM.PROV_TYPE: FOAF["OnlineAccount"],
"prov:label": username,
FOAF["accountName"]: username})
user = document.agent(
self.orcid or USER_UUID,
{provM.PROV_TYPE: PROV["Person"],
"prov:label": self.full_name,
FOAF["name"]: self.full_name,
FOAF["account"]: account})
document.actedOnBehalfOf(account, user)
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment tuple_pattern identifier identifier call identifier argument_list if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary pair attribute identifier identifier subscript identifier string string_start string_content string_end pair string string_start string_content string_end identifier pair subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list boolean_operator attribute identifier identifier identifier dictionary pair attribute identifier identifier subscript identifier string string_start string_content string_end pair string string_start string_content string_end attribute identifier identifier pair subscript identifier string string_start string_content string_end attribute identifier identifier pair subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier identifier
|
Add the user provenance.
|
def task_wait(meow, heartbeat, polling_interval, timeout, task_id, timeout_exit_code):
task_wait_with_io(
meow, heartbeat, polling_interval, timeout, task_id, timeout_exit_code
)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement call identifier argument_list identifier identifier identifier identifier identifier identifier
|
Executor for `globus task wait`
|
def reorient_wf(name='ReorientWorkflow'):
workflow = pe.Workflow(name=name)
inputnode = pe.Node(niu.IdentityInterface(fields=['in_file']),
name='inputnode')
outputnode = pe.Node(niu.IdentityInterface(
fields=['out_file']), name='outputnode')
deoblique = pe.Node(afni.Refit(deoblique=True), name='deoblique')
reorient = pe.Node(afni.Resample(
orientation='RPI', outputtype='NIFTI_GZ'), name='reorient')
workflow.connect([
(inputnode, deoblique, [('in_file', 'in_file')]),
(deoblique, reorient, [('out_file', 'in_file')]),
(reorient, outputnode, [('out_file', 'out_file')])
])
return workflow
|
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier true keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list tuple identifier identifier list tuple string string_start string_content string_end string string_start string_content string_end tuple identifier identifier list tuple string string_start string_content string_end string string_start string_content string_end tuple identifier identifier list tuple string string_start string_content string_end string string_start string_content string_end return_statement identifier
|
A workflow to reorient images to 'RPI' orientation
|
def _map_arg_names(source, mapping):
return {cartopy_name: source[cf_name] for cartopy_name, cf_name in mapping
if cf_name in source}
|
module function_definition identifier parameters identifier identifier block return_statement dictionary_comprehension pair identifier subscript identifier identifier for_in_clause pattern_list identifier identifier identifier if_clause comparison_operator identifier identifier
|
Map one set of keys to another.
|
def _fetchone(self, query, vars):
cursor = self.get_db().cursor()
self._log(cursor, query, vars)
cursor.execute(query, vars)
return cursor.fetchone()
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list
|
Return none or one row.
|
def MessageSizer(field_number, is_repeated, is_packed):
tag_size = _TagSize(field_number)
local_VarintSize = _VarintSize
assert not is_packed
if is_repeated:
def RepeatedFieldSize(value):
result = tag_size * len(value)
for element in value:
l = element.ByteSize()
result += local_VarintSize(l) + l
return result
return RepeatedFieldSize
else:
def FieldSize(value):
l = value.ByteSize()
return tag_size + local_VarintSize(l) + l
return FieldSize
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier identifier assert_statement not_operator identifier if_statement identifier block function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement augmented_assignment identifier binary_operator call identifier argument_list identifier identifier return_statement identifier return_statement identifier else_clause block function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement binary_operator binary_operator identifier call identifier argument_list identifier identifier return_statement identifier
|
Returns a sizer for a message field.
|
def nvrtcGetPTX(self, prog):
size = c_size_t()
code = self._lib.nvrtcGetPTXSize(prog, byref(size))
self._throw_on_error(code)
buf = create_string_buffer(size.value)
code = self._lib.nvrtcGetPTX(prog, buf)
self._throw_on_error(code)
return buf.value.decode('utf-8')
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
|
Returns the compiled PTX for the NVRTC program object.
|
def update_eol(self, os_name):
os_name = to_text_string(os_name)
value = {"nt": "CRLF", "posix": "LF"}.get(os_name, "CR")
self.set_value(value)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
|
Update end of line status.
|
def running(opts):
ret = []
proc_dir = os.path.join(opts['cachedir'], 'proc')
if not os.path.isdir(proc_dir):
return ret
for fn_ in os.listdir(proc_dir):
path = os.path.join(proc_dir, fn_)
try:
data = _read_proc_file(path, opts)
if data is not None:
ret.append(data)
except (IOError, OSError):
pass
return ret
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement identifier for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier block pass_statement return_statement identifier
|
Return the running jobs on this minion
|
def _validate_input_column(self, column):
if column != self.column and column.unspecialize() != self.column:
raise ValueError("Can't load unknown column %s" % column)
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
|
Make sure a passed column is our column.
|
def reconstruct(self, b, X=None):
if X is None:
X = self.getcoef()
Xf = sl.rfftn(X, None, self.cbpdn.cri.axisN)
slc = (slice(None),)*self.dimN + \
(slice(self.chncs[b], self.chncs[b+1]),)
Sf = np.sum(self.cbpdn.Df[slc] * Xf, axis=self.cbpdn.cri.axisM)
return sl.irfftn(Sf, self.cbpdn.cri.Nv, self.cbpdn.cri.axisN)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier none attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier binary_operator binary_operator tuple call identifier argument_list none attribute identifier identifier line_continuation tuple call identifier argument_list subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator subscript attribute attribute identifier identifier identifier identifier identifier keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier
|
Reconstruct representation of signal b in signal set.
|
def _get_id2gos(self, associations, **kws):
options = AnnoOptions(self.evobj, **kws)
assc = self.reduce_annotations(associations, options)
return self._get_dbid2goids(assc) if options.b_geneid2gos else self._get_goid2dbids(assc)
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement conditional_expression call attribute identifier identifier argument_list identifier attribute identifier identifier call attribute identifier identifier argument_list identifier
|
Return given associations in a dict, id2gos
|
def close_async(self):
if self._stream is None or self._stream.closed():
self._stream = None
return
send_data = struct.pack('<i', 1) + int2byte(COMMAND.COM_QUIT)
yield self._stream.write(send_data)
self.close()
|
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none call attribute attribute identifier identifier identifier argument_list block expression_statement assignment attribute identifier identifier none return_statement expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer call identifier argument_list attribute identifier identifier expression_statement yield call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Send the quit message and close the socket
|
def convert(self, json="", table_attributes='border="1"', clubbing=True, encode=False, escape=True):
self.table_init_markup = "<table %s>" % table_attributes
self.clubbing = clubbing
self.escape = escape
json_input = None
if not json:
json_input = {}
elif type(json) in text_types:
try:
json_input = json_parser.loads(json, object_pairs_hook=OrderedDict)
except ValueError as e:
if u"Expecting property name" in text(e):
raise e
json_input = json
else:
json_input = json
converted = self.convert_json_node(json_input)
if encode:
return converted.encode('ascii', 'xmlcharrefreplace')
return converted
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier string string_start string_content string_end default_parameter identifier true default_parameter identifier false default_parameter identifier true block expression_statement assignment attribute identifier identifier binary_operator string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier none if_statement not_operator identifier block expression_statement assignment identifier dictionary elif_clause comparison_operator call identifier argument_list identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator string string_start string_content string_end call identifier argument_list identifier block raise_statement identifier expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
|
Convert JSON to HTML Table format
|
def _tegra_id(self):
board_value = self.detector.get_device_model()
if 'tx1' in board_value:
return JETSON_TX1
elif 'quill' in board_value:
return JETSON_TX2
elif 'xavier' in board_value:
return JETSON_XAVIER
elif 'nano' in board_value:
return JETSON_NANO
return None
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block return_statement identifier elif_clause comparison_operator string string_start string_content string_end identifier block return_statement identifier elif_clause comparison_operator string string_start string_content string_end identifier block return_statement identifier elif_clause comparison_operator string string_start string_content string_end identifier block return_statement identifier return_statement none
|
Try to detect the id of aarch64 board.
|
def from_json(cls, service_dict):
sd = service_dict.copy()
service_endpoint = sd.get(cls.SERVICE_ENDPOINT)
if not service_endpoint:
logger.error(
'Service definition in DDO document is missing the "serviceEndpoint" key/value.')
raise IndexError
_type = sd.get('type')
if not _type:
logger.error('Service definition in DDO document is missing the "type" key/value.')
raise IndexError
sd.pop(cls.SERVICE_ENDPOINT)
sd.pop('type')
return cls(
service_endpoint,
_type,
sd
)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list 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 call attribute identifier identifier argument_list string string_start string_content string_end raise_statement identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier identifier identifier
|
Create a service object from a JSON string.
|
def simple_parse_bytes(data: bytes) -> Feed:
pairs = (
(rss.parse_rss_bytes, _adapt_rss_channel),
(atom.parse_atom_bytes, _adapt_atom_feed),
(json_feed.parse_json_feed_bytes, _adapt_json_feed)
)
return _simple_parse(pairs, data)
|
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier tuple tuple attribute identifier identifier identifier tuple attribute identifier identifier identifier tuple attribute identifier identifier identifier return_statement call identifier argument_list identifier identifier
|
Parse an Atom, RSS or JSON feed from a byte-string containing data.
|
def qteReplayKeysequenceHook(self, msgObj):
if self.recorded_keysequence.toString() == '':
return
if self.qteRecording:
return
self.qteMain.qteEmulateKeypresses(self.recorded_keysequence)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_end block return_statement if_statement attribute identifier identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
|
Replay the macro sequence.
|
def to_url(self, url=None, replace=False, **kwargs):
params = copy.deepcopy(self.filter_values)
if self._query:
params['q'] = self._query
if self.page_size != DEFAULT_PAGE_SIZE:
params['page_size'] = self.page_size
if kwargs:
for key, value in kwargs.items():
if not replace and key in params:
if not isinstance(params[key], (list, tuple)):
params[key] = [params[key], value]
else:
params[key].append(value)
else:
params[key] = value
else:
params['page'] = self.page
href = Href(url or request.base_url)
return href(params)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator not_operator identifier comparison_operator identifier identifier block if_statement not_operator call identifier argument_list subscript identifier identifier tuple identifier identifier block expression_statement assignment subscript identifier identifier list subscript identifier identifier identifier else_clause block expression_statement call attribute subscript identifier identifier identifier argument_list identifier else_clause block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call identifier argument_list boolean_operator identifier attribute identifier identifier return_statement call identifier argument_list identifier
|
Serialize the query into an URL
|
def needs_sync(self):
affected_attributes = [
'css_files', 'js_files',
'scss_files', 'widgets']
for attr in affected_attributes:
if len(getattr(self, attr)) > 0:
return True
return False
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block if_statement comparison_operator call identifier argument_list call identifier argument_list identifier identifier integer block return_statement true return_statement false
|
Indicates whater module needs templates, static etc.
|
def load_object_by_name(object_name):
mod_name, attr = object_name.rsplit('.', 1)
mod = import_module(mod_name)
return getattr(mod, attr)
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list identifier identifier
|
Load an object from a module by name
|
def _parse_names_dict(feature_names):
feature_collection = OrderedDict()
for feature_name, new_feature_name in feature_names.items():
if isinstance(feature_name, str) and (isinstance(new_feature_name, str) or
new_feature_name is ...):
feature_collection[feature_name] = new_feature_name
else:
if not isinstance(feature_name, str):
raise ValueError('Failed to parse {}, expected string'.format(feature_name))
else:
raise ValueError('Failed to parse {}, expected string or Ellipsis'.format(new_feature_name))
return feature_collection
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator call identifier argument_list identifier identifier parenthesized_expression boolean_operator call identifier argument_list identifier identifier comparison_operator identifier ellipsis block expression_statement assignment subscript identifier identifier identifier else_clause block 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 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
|
Helping function of `_parse_feature_names` that parses a dictionary of feature names.
|
def in_SCAT_box(x, y, low_bound, high_bound, x_max, y_max):
passing = True
upper_limit = high_bound(x)
lower_limit = low_bound(x)
if x > x_max or y > y_max:
passing = False
if x < 0 or y < 0:
passing = False
if y > upper_limit:
passing = False
if y < lower_limit:
passing = False
return passing
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier true expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block expression_statement assignment identifier false if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block expression_statement assignment identifier false if_statement comparison_operator identifier identifier block expression_statement assignment identifier false if_statement comparison_operator identifier identifier block expression_statement assignment identifier false return_statement identifier
|
determines if a particular point falls within a box
|
def draw(self):
from calysto.display import display, clear_output
canvas = self.render()
clear_output(wait=True)
display(canvas)
|
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list keyword_argument identifier true expression_statement call identifier argument_list identifier
|
Render and draw the world and robots.
|
def create_code_cell(block):
code_cell = nbbase.new_code_cell(source=block['content'])
attr = block['attributes']
if not attr.is_empty:
code_cell.metadata \
= nbbase.NotebookNode({'attributes': attr.to_dict()})
execution_count = attr.kvs.get('n')
if not execution_count:
code_cell.execution_count = None
else:
code_cell.execution_count = int(execution_count)
return code_cell
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier line_continuation call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment attribute identifier identifier none else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list identifier return_statement identifier
|
Create a notebook code cell from a block.
|
def get(self, key, transaction=None):
return self._client.get(key, transaction=transaction)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier
|
Retrieves an entity given its key.
|
def to_dict(self):
return {
'definition': self.definition,
'id': self.term_id,
'image': self.image.to_dict(),
'rank': self.rank,
'term': self.term
}
|
module function_definition identifier parameters identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier
|
Convert Term into raw dictionary data.
|
def _get_exe(prog):
if prog in prog_to_env_var:
env_var = prog_to_env_var[prog]
if env_var in os.environ:
return os.environ[env_var]
return prog_to_default[prog]
|
module function_definition identifier parameters identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier attribute identifier identifier block return_statement subscript attribute identifier identifier identifier return_statement subscript identifier identifier
|
Given a program name, return what we expect its exectuable to be called
|
def delete(self, namespace, key):
if not self.dbconfig.key_exists(namespace, key):
return self.make_response('No such config entry exists: {}/{}'.format(namespace, key), HTTP.BAD_REQUEST)
self.dbconfig.delete(namespace, key)
auditlog(event='configItem.delete', actor=session['user'].username, data={'namespace': namespace, 'key': key})
return self.make_response('Config entry deleted')
|
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute subscript identifier string string_start string_content string_end identifier keyword_argument identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end
|
Delete a specific configuration item
|
def mode(self):
if self.is_in_schedule_mode:
return "schedule"
resource = "modes"
mode_event = self.publish_and_get_event(resource)
if mode_event:
properties = mode_event.get('properties')
active_mode = properties.get('active')
modes = properties.get('modes')
if not modes:
return None
for mode in modes:
if mode.get('id') == active_mode:
return mode.get('type') \
if mode.get('type') is not None else mode.get('name')
return None
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier 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 expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block return_statement none for_statement identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier block return_statement conditional_expression call attribute identifier identifier argument_list string string_start string_content string_end line_continuation comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none call attribute identifier identifier argument_list string string_start string_content string_end return_statement none
|
Return current mode key.
|
def paula_etree_to_string(tree, dtd_filename):
return etree.tostring(
tree, pretty_print=True, xml_declaration=True,
encoding="UTF-8", standalone='no',
doctype='<!DOCTYPE paula SYSTEM "{0}">'.format(dtd_filename))
|
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier true keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list identifier
|
convert a PAULA etree into an XML string.
|
def json_repr(obj):
def serialize(obj):
if obj is None:
return None
if isinstance(obj, Enum):
return str(obj)
if isinstance(obj, (bool, int, float, str)):
return obj
if isinstance(obj, dict):
obj = obj.copy()
for key in sorted(obj.keys()):
obj[key] = serialize(obj[key])
return obj
if isinstance(obj, list):
return [serialize(item) for item in obj]
if isinstance(obj, tuple):
return tuple(serialize([item for item in obj]))
if hasattr(obj, '__dict__'):
return serialize(obj.__dict__)
return repr(obj)
return json.dumps(serialize(obj))
|
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block if_statement comparison_operator identifier none block return_statement none if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier if_statement call identifier argument_list identifier tuple identifier identifier identifier identifier block return_statement identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier call identifier argument_list subscript identifier identifier return_statement identifier if_statement call identifier argument_list 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 call identifier argument_list list_comprehension identifier for_in_clause identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement call identifier argument_list attribute identifier identifier return_statement call identifier argument_list identifier return_statement call attribute identifier identifier argument_list call identifier argument_list identifier
|
Represent instance of a class as JSON.
|
def compute_md5(self):
import hashlib
with open(self.path, "rt") as fh:
text = fh.read()
m = hashlib.md5(text.encode("utf-8"))
return m.hexdigest()
|
module function_definition identifier parameters identifier block import_statement dotted_name identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list
|
Compute and erturn MD5 hash value.
|
def type(self, name: str):
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF
and f._name == name):
return f
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier block for_statement identifier attribute identifier identifier block if_statement parenthesized_expression boolean_operator boolean_operator call identifier argument_list identifier string string_start string_content string_end comparison_operator attribute attribute identifier identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier identifier block return_statement identifier
|
return the first complete definition of type 'name
|
def change_last_focused_widget(self, old, now):
if (now is None and QApplication.activeWindow() is not None):
QApplication.activeWindow().setFocus()
self.last_focused_widget = QApplication.focusWidget()
elif now is not None:
self.last_focused_widget = now
self.previous_focused_widget = old
|
module function_definition identifier parameters identifier identifier identifier block if_statement parenthesized_expression boolean_operator comparison_operator identifier none comparison_operator call attribute identifier identifier argument_list none block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list elif_clause comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
|
To keep track of to the last focused widget
|
def InternalSend(self, cmd, payload):
length_to_send = len(payload)
max_payload = self.packet_size - 7
first_frame = payload[0:max_payload]
first_packet = UsbHidTransport.InitPacket(self.packet_size, self.cid, cmd,
len(payload), first_frame)
del payload[0:max_payload]
length_to_send -= len(first_frame)
self.InternalSendPacket(first_packet)
seq = 0
while length_to_send > 0:
max_payload = self.packet_size - 5
next_frame = payload[0:max_payload]
del payload[0:max_payload]
length_to_send -= len(next_frame)
next_packet = UsbHidTransport.ContPacket(self.packet_size, self.cid, seq,
next_frame)
self.InternalSendPacket(next_packet)
seq += 1
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier subscript identifier slice integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier call identifier argument_list identifier identifier delete_statement subscript identifier slice integer identifier expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier integer while_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier subscript identifier slice integer identifier delete_statement subscript identifier slice integer identifier expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier integer
|
Sends a message to the device, including fragmenting it.
|
def _version_header(self):
if not self._cached_version_header:
self._cached_version_header = urlparse.urlencode(
self._version_values())
return self._cached_version_header
|
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement attribute identifier identifier
|
Generate the client version header to send on each request.
|
def dprint(s):
import inspect
frameinfo = inspect.stack()[1]
callerframe = frameinfo.frame
d = callerframe.f_locals
if (isinstance(s,str)):
val = eval(s, d)
else:
val = s
cc = frameinfo.code_context[0]
import re
regex = re.compile("dprint\((.*)\)")
res = regex.search(cc)
s = res.group(1)
text = ''
text += bcolors.OKBLUE + "At <{}>\n".format(str(frameinfo)) + bcolors.ENDC
text += bcolors.WARNING + "{}: ".format(s) + bcolors.ENDC
text += str(val)
text += str()
print(text)
|
module function_definition identifier parameters identifier block import_statement dotted_name identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement parenthesized_expression call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier subscript attribute identifier identifier integer import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier string string_start string_end expression_statement augmented_assignment identifier binary_operator binary_operator attribute identifier identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list call identifier argument_list identifier attribute identifier identifier expression_statement augmented_assignment identifier binary_operator binary_operator attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement augmented_assignment identifier call identifier argument_list expression_statement call identifier argument_list identifier
|
Prints `s` with additional debugging informations
|
def make_request(name, params=None, version="V001", key=None, api_type="web",
fetcher=get_page, base=None, language="en_us"):
params = params or {}
params["key"] = key or API_KEY
params["language"] = language
if not params["key"]:
raise ValueError("API key not set, please set DOTA2_API_KEY")
url = url_map("%s%s/%s/" % (base or BASE_URL, name, version), params)
return fetcher(url)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier boolean_operator identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end boolean_operator identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement not_operator subscript identifier string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end tuple boolean_operator identifier identifier identifier identifier identifier return_statement call identifier argument_list identifier
|
Make an API request
|
End of preview. Expand
in Data Studio
No dataset card yet
- Downloads last month
- 4