_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q276200 | admin_footer | test | def admin_footer(parser, token):
"""
Template tag that renders the footer information based on the
authenticated user's permissions.
"""
# split_contents() doesn't know how to split quoted strings.
tag_name = token.split_contents()
if len(tag_name) > 1:
raise base.TemplateSyntaxErro... | python | {
"resource": ""
} |
q276201 | build_payment_parameters | test | def build_payment_parameters(amount: Money, client_ref: str) -> PaymentParameters:
"""
Builds the parameters needed to present the user with a datatrans payment form.
:param amount: The amount and currency we want the user to pay
:param client_ref: A unique reference for this payment
:return: The p... | python | {
"resource": ""
} |
q276202 | build_register_credit_card_parameters | test | def build_register_credit_card_parameters(client_ref: str) -> PaymentParameters:
"""
Builds the parameters needed to present the user with a datatrans form to register a credit card.
Contrary to a payment form, datatrans will not show an amount.
:param client_ref: A unique reference for this alias capt... | python | {
"resource": ""
} |
q276203 | pay_with_alias | test | def pay_with_alias(amount: Money, alias_registration_id: str, client_ref: str) -> Payment:
"""
Charges money using datatrans, given a previously registered credit card alias.
:param amount: The amount and currency we want to charge
:param alias_registration_id: The alias registration to use
:param ... | python | {
"resource": ""
} |
q276204 | get_version | test | def get_version(version=None):
"""
Return full version nr, inc. rc, beta etc tags.
For example: `2.0.0a1`
:rtype: str
"""
v = version or __version__
if len(v) == 4:
return '{0}{1}'.format(short_version(v), v[3])
return short_version(v) | python | {
"resource": ""
} |
q276205 | FilesystemBrowser._construct | test | def _construct(self):
'''Construct widget.'''
self.setLayout(QtGui.QVBoxLayout())
self._headerLayout = QtGui.QHBoxLayout()
self._locationWidget = QtGui.QComboBox()
self._headerLayout.addWidget(self._locationWidget, stretch=1)
self._upButton = QtGui.QToolButton()
... | python | {
"resource": ""
} |
q276206 | FilesystemBrowser._postConstruction | test | def _postConstruction(self):
'''Perform post-construction operations.'''
self.setWindowTitle('Filesystem Browser')
self._filesystemWidget.sortByColumn(0, QtCore.Qt.AscendingOrder)
# TODO: Remove once bookmarks widget implemented.
self._bookmarksWidget.hide()
self._accep... | python | {
"resource": ""
} |
q276207 | FilesystemBrowser._configureShortcuts | test | def _configureShortcuts(self):
'''Add keyboard shortcuts to navigate the filesystem.'''
self._upShortcut = QtGui.QShortcut(
QtGui.QKeySequence('Backspace'), self
)
self._upShortcut.setAutoRepeat(False)
self._upShortcut.activated.connect(self._onNavigateUpButtonClicked... | python | {
"resource": ""
} |
q276208 | FilesystemBrowser._onActivateItem | test | def _onActivateItem(self, index):
'''Handle activation of item in listing.'''
item = self._filesystemWidget.model().item(index)
if not isinstance(item, riffle.model.File):
self._acceptButton.setDisabled(True)
self.setLocation(item.path, interactive=True) | python | {
"resource": ""
} |
q276209 | FilesystemBrowser._onSelectItem | test | def _onSelectItem(self, selection, previousSelection):
'''Handle selection of item in listing.'''
self._acceptButton.setEnabled(True)
del self._selected[:]
item = self._filesystemWidget.model().item(selection)
self._selected.append(item.path) | python | {
"resource": ""
} |
q276210 | FilesystemBrowser._onNavigate | test | def _onNavigate(self, index):
'''Handle selection of path segment.'''
if index > 0:
self.setLocation(
self._locationWidget.itemData(index), interactive=True
) | python | {
"resource": ""
} |
q276211 | BuildResources.finalize_options | test | def finalize_options(self):
'''Finalize options to be used.'''
self.resource_source_path = os.path.join(RESOURCE_PATH, 'resource.qrc')
self.resource_target_path = RESOURCE_TARGET_PATH | python | {
"resource": ""
} |
q276212 | BuildResources.run | test | def run(self):
'''Run build.'''
if ON_READ_THE_DOCS:
# PySide not available.
return
try:
pyside_rcc_command = 'pyside-rcc'
# On Windows, pyside-rcc is not automatically available on the
# PATH so try to find it manually.
i... | python | {
"resource": ""
} |
q276213 | Clean.run | test | def run(self):
'''Run clean.'''
relative_resource_path = os.path.relpath(
RESOURCE_TARGET_PATH, ROOT_PATH
)
if os.path.exists(relative_resource_path):
os.remove(relative_resource_path)
else:
distutils.log.warn(
'\'{0}\' does not... | python | {
"resource": ""
} |
q276214 | Item.fetchChildren | test | def fetchChildren(self):
'''Fetch and return new children.
Will only fetch children whilst canFetchMore is True.
.. note::
It is the caller's responsibility to add each fetched child to this
parent if desired using :py:meth:`Item.addChild`.
'''
if not ... | python | {
"resource": ""
} |
q276215 | Item.refetch | test | def refetch(self):
'''Reload children.'''
# Reset children
for child in self.children[:]:
self.removeChild(child)
# Enable children fetching
self._fetched = False | python | {
"resource": ""
} |
q276216 | FilesystemSortProxy.icon | test | def icon(self, index):
'''Return icon for index.'''
sourceModel = self.sourceModel()
if not sourceModel:
return None
return sourceModel.icon(self.mapToSource(index)) | python | {
"resource": ""
} |
q276217 | call | test | def call(args, stdout=None, stderr=None, stdin=None, daemonize=False,
preexec_fn=None, shell=False, cwd=None, env=None):
"""
Run an external command in a separate process and detach it from the current process. Excepting
`stdout`, `stderr`, and `stdin` all file descriptors are closed after forking.... | python | {
"resource": ""
} |
q276218 | Detach._get_max_fd | test | def _get_max_fd(self):
"""Return the maximum file descriptor value."""
limits = resource.getrlimit(resource.RLIMIT_NOFILE)
result = limits[1]
if result == resource.RLIM_INFINITY:
result = maxfd
return result | python | {
"resource": ""
} |
q276219 | Detach._close_fd | test | def _close_fd(self, fd):
"""Close a file descriptor if it is open."""
try:
os.close(fd)
except OSError, exc:
if exc.errno != errno.EBADF:
msg = "Failed to close file descriptor {}: {}".format(fd, exc)
raise Error(msg) | python | {
"resource": ""
} |
q276220 | Detach._close_open_fds | test | def _close_open_fds(self):
"""Close open file descriptors."""
maxfd = self._get_max_fd()
for fd in reversed(range(maxfd)):
if fd not in self.exclude_fds:
self._close_fd(fd) | python | {
"resource": ""
} |
q276221 | Detach._redirect | test | def _redirect(self, stream, target):
"""Redirect a system stream to the provided target."""
if target is None:
target_fd = os.open(os.devnull, os.O_RDWR)
else:
target_fd = target.fileno()
os.dup2(target_fd, stream.fileno()) | python | {
"resource": ""
} |
q276222 | set_form_widgets_attrs | test | def set_form_widgets_attrs(form, attrs):
"""Applies a given HTML attributes to each field widget of a given form.
Example:
set_form_widgets_attrs(my_form, {'class': 'clickable'})
"""
for _, field in form.fields.items():
attrs_ = dict(attrs)
for name, val in attrs.items():
... | python | {
"resource": ""
} |
q276223 | import_app_module | test | def import_app_module(app_name, module_name):
"""Returns a module from a given app by its name.
:param str app_name:
:param str module_name:
:rtype: module or None
"""
name_split = app_name.split('.')
if name_split[-1][0].isupper(): # Seems that we have app config class path here.
... | python | {
"resource": ""
} |
q276224 | import_project_modules | test | def import_project_modules(module_name):
"""Imports modules from registered apps using given module name
and returns them as a list.
:param str module_name:
:rtype: list
"""
from django.conf import settings
submodules = []
for app in settings.INSTALLED_APPS:
module = import_ap... | python | {
"resource": ""
} |
q276225 | include_ | test | def include_(parser, token):
"""Similar to built-in ``include`` template tag, but allowing
template variables to be used in template name and a fallback template,
thus making the tag more dynamic.
.. warning:: Requires Django 1.8+
Example:
{% load etc_misc %}
{% include_ "sub_{{ p... | python | {
"resource": ""
} |
q276226 | gravatar_get_url | test | def gravatar_get_url(obj, size=65, default='identicon'):
"""Returns Gravatar image URL for a given string or UserModel.
Example:
{% load gravatar %}
{% gravatar_get_url user_model %}
:param UserModel, str obj:
:param int size:
:param str default:
:return:
"""
return ge... | python | {
"resource": ""
} |
q276227 | gravatar_get_img | test | def gravatar_get_img(obj, size=65, default='identicon'):
"""Returns Gravatar image HTML tag for a given string or UserModel.
Example:
{% load gravatar %}
{% gravatar_get_img user_model %}
:param UserModel, str obj:
:param int size:
:param str default:
:return:
"""
url ... | python | {
"resource": ""
} |
q276228 | Port.is_valid_filesys | test | def is_valid_filesys(path):
"""Checks if the path is correct and exists, must be abs-> a dir -> and not a file."""
if os.path.isabs(path) and os.path.isdir(path) and \
not os.path.isfile(path):
return True
else:
raise LocalPortValidationError(
... | python | {
"resource": ""
} |
q276229 | Port.is_valid_s3_url | test | def is_valid_s3_url(url):
"""Checks if the url contains S3. Not an accurate validation of the url"""
# Skip if the url start with source: (gbdxtools syntax)
if url.startswith('source:'):
return True
scheme, netloc, path, _, _, _ = urlparse(url)
port_except = RemoteP... | python | {
"resource": ""
} |
q276230 | TaskController._get_template_abs_path | test | def _get_template_abs_path(filename):
"""
Return a valid absolute path. filename can be relative or absolute.
"""
if os.path.isabs(filename) and os.path.isfile(filename):
return filename
else:
return os.path.join(os.getcwd(), filename) | python | {
"resource": ""
} |
q276231 | AccountStorageService.list | test | def list(self, s3_folder='', full_key_data=False):
"""Get a list of keys for the accounts"""
if not s3_folder.startswith('/'):
s3_folder = '/' + s3_folder
s3_prefix = self.prefix + s3_folder
bucket_data = self.client.list_objects(Bucket=self.bucket, Prefix=s3_prefix)
... | python | {
"resource": ""
} |
q276232 | Workflow._build_worklfow_json | test | def _build_worklfow_json(self):
"""
Build a workflow definition from the cloud_harness task.
"""
wf_json = {'tasks': [], 'name': 'cloud-harness_%s' % str(uuid.uuid4())}
task_def = json.loads(self.task_template.json())
d = {
"name": task_def['name'],
... | python | {
"resource": ""
} |
q276233 | Workflow.execute | test | def execute(self, override_wf_json=None):
"""
Execute the cloud_harness task.
"""
r = self.gbdx.post(
self.URL,
json=self.json if override_wf_json is None else override_wf_json
)
try:
r.raise_for_status()
except:
pr... | python | {
"resource": ""
} |
q276234 | archive | test | def archive(folder, dry_run=False):
"Move an active project to the archive."
# error handling on archive_dir already done in main()
for f in folder:
if not os.path.exists(f):
bail('folder does not exist: ' + f)
_archive_safe(folder, PROJ_ARCHIVE, dry_run=dry_run) | python | {
"resource": ""
} |
q276235 | _mkdir | test | def _mkdir(p):
"The equivalent of 'mkdir -p' in shell."
isdir = os.path.isdir
stack = [os.path.abspath(p)]
while not isdir(stack[-1]):
parent_dir = os.path.dirname(stack[-1])
stack.append(parent_dir)
while stack:
p = stack.pop()
if not isdir(p):
os.mkdir... | python | {
"resource": ""
} |
q276236 | list | test | def list(pattern=()):
"List the contents of the archive directory."
# strategy: pick the intersection of all the patterns the user provides
globs = ['*{0}*'.format(p) for p in pattern] + ['*']
matches = []
offset = len(PROJ_ARCHIVE) + 1
for suffix in globs:
glob_pattern = os.path.join(P... | python | {
"resource": ""
} |
q276237 | restore | test | def restore(folder):
"Restore a project from the archive."
if os.path.isdir(folder):
bail('a folder of the same name already exists!')
pattern = os.path.join(PROJ_ARCHIVE, '*', '*', folder)
matches = glob.glob(pattern)
if not matches:
bail('no project matches: ' + folder)
if le... | python | {
"resource": ""
} |
q276238 | Client.new | test | def new(cls, access_token, environment='prod'):
'''Create new storage service client.
Arguments:
environment(str): The service environment to be used for the client.
'prod' or 'dev'.
access_token(str): The access token used to authenticate with th... | python | {
"resource": ""
} |
q276239 | Client.list | test | def list(self, path):
'''List the entities found directly under the given path.
Args:
path (str): The path of the entity to be listed. Must start with a '/'.
Returns:
The list of entity names directly under the given path:
u'/12345/folder_1'
Ra... | python | {
"resource": ""
} |
q276240 | Client.download_file | test | def download_file(self, path, target_path):
'''Download a file from storage service to local disk.
Existing files on the target path will be overwritten.
The download is not recursive, as it only works on files.
Args:
path (str): The path of the entity to be downloaded. Mus... | python | {
"resource": ""
} |
q276241 | Client.exists | test | def exists(self, path):
'''Check if a certain path exists in the storage service.
Args:
path (str): The path to be checked
Returns:
True if the path exists, False otherwise
Raises:
StorageArgumentException: Invalid arguments
StorageForbi... | python | {
"resource": ""
} |
q276242 | Client.get_parent | test | def get_parent(self, path):
'''Get the parent entity of the entity pointed by the given path.
Args:
path (str): The path of the entity whose parent is needed
Returns:
A JSON object of the parent entity if found.
Raises:
StorageArgumentException: Inv... | python | {
"resource": ""
} |
q276243 | Client.mkdir | test | def mkdir(self, path):
'''Create a folder in the storage service pointed by the given path.
Args:
path (str): The path of the folder to be created
Returns:
None
Raises:
StorageArgumentException: Invalid arguments
StorageForbiddenExceptio... | python | {
"resource": ""
} |
q276244 | Client.upload_file | test | def upload_file(self, local_file, dest_path, mimetype):
'''Upload local file content to a storage service destination folder.
Args:
local_file(str)
dest_path(str):
absolute Storage service path '/project' prefix is essential
su... | python | {
"resource": ""
} |
q276245 | Client.delete | test | def delete(self, path):
''' Delete an entity from the storage service using its path.
Args:
path(str): The path of the entity to be delete
Returns:
The uuid of created file entity as string
Raises:
StorageArgumentException: I... | python | {
"resource": ""
} |
q276246 | Client.__validate_storage_path | test | def __validate_storage_path(cls, path, projects_allowed=True):
'''Validate a string as a valid storage path'''
if not path or not isinstance(path, str) or path[0] != '/' or path == '/':
raise StorageArgumentException(
'The path must be a string, start with a slash (/), and b... | python | {
"resource": ""
} |
q276247 | Client.new | test | def new(cls, access_token, environment='prod'):
'''Creates a new cross-service client.'''
return cls(
storage_client=StorageClient.new(access_token, environment=environment)) | python | {
"resource": ""
} |
q276248 | ApiClient.new | test | def new(cls, access_token, environment='prod'):
'''Create a new storage service REST client.
Arguments:
environment: The service environment to be used for the client
access_token: The access token used to authenticate with the
service
... | python | {
"resource": ""
} |
q276249 | ApiClient.get_entity_details | test | def get_entity_details(self, entity_id):
'''Get generic entity by UUID.
Args:
entity_id (str): The UUID of the requested entity.
Returns:
A dictionary describing the entity::
{
u'collab_id': 2271,
u'created_by':... | python | {
"resource": ""
} |
q276250 | ApiClient.set_metadata | test | def set_metadata(self, entity_type, entity_id, metadata):
'''Set metadata for an entity.
Args:
entity_type (str): Type of the entity. Admitted values: ['project',
'folder', 'file'].
entity_id (str): The UUID of the entity to be modified.
metadata (dic... | python | {
"resource": ""
} |
q276251 | ApiClient.get_metadata | test | def get_metadata(self, entity_type, entity_id):
'''Get metadata of an entity.
Args:
entity_type (str): Type of the entity. Admitted values: ['project',
'folder', 'file'].
entity_id (str): The UUID of the entity to be modified.
Returns:
A dict... | python | {
"resource": ""
} |
q276252 | ApiClient.update_metadata | test | def update_metadata(self, entity_type, entity_id, metadata):
'''Update the metadata of an entity.
Existing non-modified metadata will not be affected.
Args:
entity_type (str): Type of the entity. Admitted values: 'project',
'folder', 'file'.
entity_id (s... | python | {
"resource": ""
} |
q276253 | ApiClient.delete_metadata | test | def delete_metadata(self, entity_type, entity_id, metadata_keys):
'''Delete the selected metadata entries of an entity.
Only deletes selected metadata keys, for a complete wipe, use set_metadata.
Args:
entity_type (str): Type of the entity. Admitted values: ['project',
... | python | {
"resource": ""
} |
q276254 | ApiClient.list_projects | test | def list_projects(self, hpc=None, access=None, name=None, collab_id=None,
page_size=DEFAULT_PAGE_SIZE, page=None, ordering=None):
'''List all the projects the user have access to.
This function does not retrieve all results, pages have
to be manually retrieved by t... | python | {
"resource": ""
} |
q276255 | ApiClient.get_project_details | test | def get_project_details(self, project_id):
'''Get information on a given project
Args:
project_id (str): The UUID of the requested project.
Returns:
A dictionary describing the project::
{
u'collab_id': 2271,
u'created_by': u... | python | {
"resource": ""
} |
q276256 | ApiClient.create_project | test | def create_project(self, collab_id):
'''Create a new project.
Args:
collab_id (int): The id of the collab the project should be created in.
Returns:
A dictionary of details of the created project::
{
u'collab_id': 12998,
... | python | {
"resource": ""
} |
q276257 | ApiClient.delete_project | test | def delete_project(self, project):
'''Delete a project. It will recursively delete all the content.
Args:
project (str): The UUID of the project to be deleted.
Returns:
None
Raises:
StorageArgumentException: Invalid arguments
StorageForb... | python | {
"resource": ""
} |
q276258 | ApiClient.create_folder | test | def create_folder(self, name, parent):
'''Create a new folder.
Args:
name (srt): The name of the folder.
parent (str): The UUID of the parent entity. The parent must be a
project or a folder.
Returns:
A dictionary of details of the created fo... | python | {
"resource": ""
} |
q276259 | ApiClient.get_folder_details | test | def get_folder_details(self, folder):
'''Get information on a given folder.
Args:
folder (str): The UUID of the requested folder.
Returns:
A dictionary of the folder details if found::
{
u'created_by': u'303447',
... | python | {
"resource": ""
} |
q276260 | ApiClient.delete_folder | test | def delete_folder(self, folder):
'''Delete a folder. It will recursively delete all the content.
Args:
folder_id (str): The UUID of the folder to be deleted.
Returns:
None
Raises:
StorageArgumentException: Invalid arguments
StorageForbid... | python | {
"resource": ""
} |
q276261 | ApiClient.upload_file_content | test | def upload_file_content(self, file_id, etag=None, source=None, content=None):
'''Upload a file content. The file entity must already exist.
If an ETag is provided the file stored on the server is verified
against it. If it does not match, StorageException is raised.
This means the clien... | python | {
"resource": ""
} |
q276262 | ApiClient.copy_file_content | test | def copy_file_content(self, file_id, source_file):
'''Copy file content from source file to target file.
Args:
file_id (str): The UUID of the file whose content is written.
source_file (str): The UUID of the file whose content is copied.
Returns:
None
... | python | {
"resource": ""
} |
q276263 | ApiClient.download_file_content | test | def download_file_content(self, file_id, etag=None):
'''Download file content.
Args:
file_id (str): The UUID of the file whose content is requested
etag (str): If the content is not changed since the provided ETag,
the content won't be downloaded. If the content ... | python | {
"resource": ""
} |
q276264 | ApiClient.get_signed_url | test | def get_signed_url(self, file_id):
'''Get a signed unauthenticated URL.
It can be used to download the file content without the need for a
token. The signed URL expires after 5 seconds.
Args:
file_id (str): The UUID of the file to get the link for.
Returns:
... | python | {
"resource": ""
} |
q276265 | MongoDBHandler.emit | test | def emit(self, record):
""" pymongo expects a dict """
msg = self.format(record)
if not isinstance(msg, dict):
msg = json.loads(msg)
self.collection.insert(msg) | python | {
"resource": ""
} |
q276266 | RequestBuilder.to_service | test | def to_service(self, service, version):
'''Sets the service name and version the request should target
Args:
service (str): The name of the service as displayed in the services.json file
version (str): The version of the service as displayed in the services.json file
Re... | python | {
"resource": ""
} |
q276267 | RequestBuilder.with_headers | test | def with_headers(self, headers):
'''Adds headers to the request
Args:
headers (dict): The headers to add the request headers
Returns:
The request builder instance in order to chain calls
'''
copy = headers.copy()
copy.update(self._headers)
... | python | {
"resource": ""
} |
q276268 | RequestBuilder.with_params | test | def with_params(self, params):
'''Adds parameters to the request params
Args:
params (dict): The parameters to add to the request params
Returns:
The request builder instance in order to chain calls
'''
copy = params.copy()
copy.update(self._para... | python | {
"resource": ""
} |
q276269 | RequestBuilder.throw | test | def throw(self, exception_class, should_throw):
'''Defines if the an exception should be thrown after the request is sent
Args:
exception_class (class): The class of the exception to instantiate
should_throw (function): The predicate that should indicate if the exception
... | python | {
"resource": ""
} |
q276270 | AdminBooleanMixin.get_list_display | test | def get_list_display(self, request):
"""
Return a sequence containing the fields to be displayed on the
changelist.
"""
list_display = []
for field_name in self.list_display:
try:
db_field = self.model._meta.get_field(field_name)
... | python | {
"resource": ""
} |
q276271 | map_job | test | def map_job(job, func, inputs, *args):
"""
Spawns a tree of jobs to avoid overloading the number of jobs spawned by a single parent.
This function is appropriate to use when batching samples greater than 1,000.
:param JobFunctionWrappingJob job: passed automatically by Toil
:param function func: Fu... | python | {
"resource": ""
} |
q276272 | gatk_genotype_gvcfs | test | def gatk_genotype_gvcfs(job,
gvcfs,
ref, fai, ref_dict,
annotations=None,
emit_threshold=10.0, call_threshold=30.0,
unsafe_mode=False):
"""
Runs GenotypeGVCFs on one or more gVCFs generated by... | python | {
"resource": ""
} |
q276273 | run_oncotator | test | def run_oncotator(job, vcf_id, oncotator_db):
"""
Uses Oncotator to add cancer relevant variant annotations to a VCF file. Oncotator can accept
other genome builds, but the output VCF is based on hg19.
:param JobFunctionWrappingJob job: passed automatically by Toil
:param str vcf_id: FileStoreID fo... | python | {
"resource": ""
} |
q276274 | DatapointArray.sort | test | def sort(self, f=lambda d: d["t"]):
"""Sort here works by sorting by timestamp by default"""
list.sort(self, key=f)
return self | python | {
"resource": ""
} |
q276275 | DatapointArray.t | test | def t(self):
"""Returns just the timestamp portion of the datapoints as a list.
The timestamps are in python datetime's date format."""
return list(map(lambda x: datetime.datetime.fromtimestamp(x["t"]), self.raw())) | python | {
"resource": ""
} |
q276276 | DatapointArray.loadExport | test | def loadExport(self, folder):
"""Adds the data from a ConnectorDB export. If it is a stream export, then the folder
is the location of the export. If it is a device export, then the folder is the export folder
with the stream name as a subdirectory
If it is a user export, you will use t... | python | {
"resource": ""
} |
q276277 | DatapointArray.tshift | test | def tshift(self, t):
"""Shifts all timestamps in the datapoint array by the given number of seconds.
It is the same as the 'tshift' pipescript transform.
Warning: The shift is performed in-place! This means that it modifies the underlying array::
d = DatapointArray([{"t":56,"d":1}]... | python | {
"resource": ""
} |
q276278 | DatapointArray.sum | test | def sum(self):
"""Gets the sum of the data portions of all datapoints within"""
raw = self.raw()
s = 0
for i in range(len(raw)):
s += raw[i]["d"]
return s | python | {
"resource": ""
} |
q276279 | rfxcom | test | def rfxcom(device):
"""Start the event loop to collect data from the serial device."""
# If the device isn't passed in, look for it in the config.
if device is None:
device = app.config.get('DEVICE')
# If the device is *still* none, error.
if device is None:
print("The serial devic... | python | {
"resource": ""
} |
q276280 | create_user | test | def create_user(username):
"Create a new user."
password = prompt_pass("Enter password")
user = User(username=username, password=password)
db.session.add(user)
db.session.commit() | python | {
"resource": ""
} |
q276281 | parse_vn_results | test | async def parse_vn_results(soup):
"""
Parse Visual Novel search pages.
:param soup: The BS4 class object
:return: A list of dictionaries containing a name and id.
"""
soup = soup.find_all('td', class_='tc1')
vns = []
for item in soup[1:]:
vns.append({'name': item.string, 'id': ... | python | {
"resource": ""
} |
q276282 | parse_release_results | test | async def parse_release_results(soup):
"""
Parse Releases search pages.
:param soup: The BS4 class object
:return: A list of dictionaries containing a release dictionary. This is the same as the one returned in get_novel.
It contains a Date released, Platform, Ages group and Name.
"""
... | python | {
"resource": ""
} |
q276283 | parse_prod_staff_results | test | async def parse_prod_staff_results(soup):
"""
Parse a page of producer or staff results
:param soup: The BS4 class object
:return: A list of dictionaries containing a name and nationality.
"""
soup = soup.find_all('li')
producers = []
for item in soup:
producers.append({'nationa... | python | {
"resource": ""
} |
q276284 | parse_character_results | test | async def parse_character_results(soup):
"""
Parse a page of character results.
:param soup: The BS4 class object
:return: Returns a list of dictionaries containing a name, gender and list of dictionaries containing a game name/id pair
for games they appeared in.
"""
soup = list(so... | python | {
"resource": ""
} |
q276285 | parse_tag_results | test | async def parse_tag_results(soup):
"""
Parse a page of tag or trait results. Same format.
:param soup: BS4 Class Object
:return: A list of tags, Nothing else really useful there
"""
soup = soup.find_all('td', class_='tc3')
tags = []
for item in soup:
tags.append(item.a.string)
... | python | {
"resource": ""
} |
q276286 | parse_user_results | test | async def parse_user_results(soup):
"""
Parse a page of user results
:param soup: Bs4 Class object
:return: A list of dictionaries containing a name and join date
"""
soup = list(soup.find_all('table', class_='stripe')[0].children)[1:]
users = []
for item in soup:
t_u = {'name':... | python | {
"resource": ""
} |
q276287 | tarball_files | test | def tarball_files(tar_name, file_paths, output_dir='.', prefix=''):
"""
Creates a tarball from a group of files
:param str tar_name: Name of tarball
:param list[str] file_paths: Absolute file paths to include in the tarball
:param str output_dir: Output destination for tarball
:param str prefix... | python | {
"resource": ""
} |
q276288 | __forall_files | test | def __forall_files(file_paths, output_dir, op):
"""
Applies a function to a set of files and an output directory.
:param str output_dir: Output directory
:param list[str] file_paths: Absolute file paths to move
"""
for file_path in file_paths:
if not file_path.startswith('/'):
... | python | {
"resource": ""
} |
q276289 | copy_file_job | test | def copy_file_job(job, name, file_id, output_dir):
"""
Job version of move_files for one file
:param JobFunctionWrappingJob job: passed automatically by Toil
:param str name: Name of output file (including extension)
:param str file_id: FileStoreID of file
:param str output_dir: Location to pla... | python | {
"resource": ""
} |
q276290 | _make_parameters | test | def _make_parameters(master_ip, default_parameters, memory, arguments, override_parameters):
"""
Makes a Spark Submit style job submission line.
:param masterIP: The Spark leader IP address.
:param default_parameters: Application specific Spark configuration parameters.
:param memory: The memory to... | python | {
"resource": ""
} |
q276291 | MasterAddress.docker_parameters | test | def docker_parameters(self, docker_parameters=None):
"""
Augment a list of "docker run" arguments with those needed to map the notional Spark master address to the
real one, if they are different.
"""
if self != self.actual:
add_host_option = '--add-host=spark-master... | python | {
"resource": ""
} |
q276292 | ConnectorObject.refresh | test | def refresh(self):
"""Refresh reloads data from the server. It raises an error if it fails to get the object's metadata"""
self.metadata = self.db.read(self.path).json() | python | {
"resource": ""
} |
q276293 | run_mutect | test | def run_mutect(job, normal_bam, normal_bai, tumor_bam, tumor_bai, ref, ref_dict, fai, cosmic, dbsnp):
"""
Calls MuTect to perform variant analysis
:param JobFunctionWrappingJob job: passed automatically by Toil
:param str normal_bam: Normal BAM FileStoreID
:param str normal_bai: Normal BAM index Fi... | python | {
"resource": ""
} |
q276294 | Device.create | test | def create(self, public=False, **kwargs):
"""Creates the device. Attempts to create private devices by default,
but if public is set to true, creates public devices.
You can also set other default properties by passing in the relevant information.
For example, setting a device with the ... | python | {
"resource": ""
} |
q276295 | Device.streams | test | def streams(self):
"""Returns the list of streams that belong to the device"""
result = self.db.read(self.path, {"q": "ls"})
if result is None or result.json() is None:
return []
streams = []
for s in result.json():
strm = self[s["name"]]
strm... | python | {
"resource": ""
} |
q276296 | Device.export | test | def export(self, directory):
"""Exports the device to the given directory. The directory can't exist.
You can later import this device by running import_device on a user.
"""
if os.path.exists(directory):
raise FileExistsError(
"The device export directory al... | python | {
"resource": ""
} |
q276297 | Shosetsu.search_vndb | test | async def search_vndb(self, stype, term):
"""
Search vndb.org for a term and return matching results from type.
:param stype: type to search for.
Type should be one of:
v - Visual Novels
r - Releases
p - Producers
s - S... | python | {
"resource": ""
} |
q276298 | Shosetsu.parse_search | test | async def parse_search(self, stype, soup):
"""
This is our parsing dispatcher
:param stype: Search type category
:param soup: The beautifulsoup object that contains the parsed html
"""
if stype == 'v':
return await parse_vn_results(soup)
elif stype ==... | python | {
"resource": ""
} |
q276299 | Dataset.addStream | test | def addStream(self, stream, interpolator="closest", t1=None, t2=None, dt=None, limit=None, i1=None, i2=None, transform=None,colname=None):
"""Adds the given stream to the query construction. Additionally, you can choose the interpolator to use for this stream, as well as a special name
for the column in... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.