_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q6400 | TdsTypeInferrer.from_value | train | def from_value(self, value):
""" Function infers TDS type from Python value.
:param value: value from which to infer TDS type
:return: An instance of subclass of :class:`BaseType`
"""
if value is None:
sql_type = NVarCharType(size=1)
else:
sql_typ... | python | {
"resource": ""
} |
q6401 | dict_row_strategy | train | def dict_row_strategy(column_names):
""" Dict row strategy, rows returned as dictionaries
"""
# replace empty column names with indices
column_names = [(name or idx) for idx, name in enumerate(column_names)]
def row_factory(row):
return dict(zip(column_names, row))
return row_factory | python | {
"resource": ""
} |
q6402 | namedtuple_row_strategy | train | def namedtuple_row_strategy(column_names):
""" Namedtuple row strategy, rows returned as named tuples
Column names that are not valid Python identifiers will be replaced
with col<number>_
"""
import collections
# replace empty column names with placeholders
column_names = [name if is_valid_... | python | {
"resource": ""
} |
q6403 | recordtype_row_strategy | train | def recordtype_row_strategy(column_names):
""" Recordtype row strategy, rows returned as recordtypes
Column names that are not valid Python identifiers will be replaced
with col<number>_
"""
try:
from namedlist import namedlist as recordtype # optional dependency
except ImportError:
... | python | {
"resource": ""
} |
q6404 | _get_servers_deque | train | def _get_servers_deque(servers, database):
""" Returns deque of servers for given tuple of servers and
database name.
This deque have active server at the begining, if first server
is not accessible at the moment the deque will be rotated,
second server will be moved to the first position, thirt to ... | python | {
"resource": ""
} |
q6405 | _parse_connection_string | train | def _parse_connection_string(connstr):
"""
MSSQL style connection string parser
Returns normalized dictionary of connection string parameters
"""
res = {}
for item in connstr.split(';'):
item = item.strip()
if not item:
continue
key, value = item.split('=', 1... | python | {
"resource": ""
} |
q6406 | Connection.commit | train | def commit(self):
"""
Commit transaction which is currently in progress.
"""
self._assert_open()
if self._autocommit:
return
if not self._conn.tds72_transaction:
return
self._main_cursor._commit(cont=True, isolation_level=self._isolation_le... | python | {
"resource": ""
} |
q6407 | Connection.cursor | train | def cursor(self):
"""
Return cursor object that can be used to make queries and fetch
results from the database.
"""
self._assert_open()
if self.mars_enabled:
in_tran = self._conn.tds72_transaction
if in_tran and self._dirty:
try:
... | python | {
"resource": ""
} |
q6408 | Connection.rollback | train | def rollback(self):
"""
Roll back transaction which is currently in progress.
"""
try:
if self._autocommit:
return
if not self._conn or not self._conn.is_connected():
return
if not self._conn.tds72_transaction:
... | python | {
"resource": ""
} |
q6409 | Connection.close | train | def close(self):
""" Close connection to an MS SQL Server.
This function tries to close the connection and free all memory used.
It can be called more than once in a row. No exception is raised in
this case.
"""
if self._conn:
if self._pooling:
... | python | {
"resource": ""
} |
q6410 | Cursor.get_proc_return_status | train | def get_proc_return_status(self):
""" Last stored proc result
"""
if self._session is None:
return None
if not self._session.has_status:
self._session.find_return_status()
return self._session.ret_status if self._session.has_status else None | python | {
"resource": ""
} |
q6411 | Cursor.cancel | train | def cancel(self):
""" Cancel current statement
"""
conn = self._assert_open()
conn._try_activate_cursor(self)
self._session.cancel_if_pending() | python | {
"resource": ""
} |
q6412 | Cursor.execute | train | def execute(self, operation, params=()):
""" Execute the query
:param operation: SQL statement
:type operation: str
"""
conn = self._assert_open()
conn._try_activate_cursor(self)
self._execute(operation, params)
# for compatibility with pyodbc
ret... | python | {
"resource": ""
} |
q6413 | Cursor.execute_scalar | train | def execute_scalar(self, query_string, params=None):
"""
This method sends a query to the MS SQL Server to which this object
instance is connected, then returns first column of first row from
result. An exception is raised on failure. If there are pending
results or rows prior t... | python | {
"resource": ""
} |
q6414 | Cursor.fetchone | train | def fetchone(self):
""" Fetches next row, or ``None`` if there are no more rows
"""
row = self._session.fetchone()
if row:
return self._row_factory(row) | python | {
"resource": ""
} |
q6415 | JobDirectory.calculate_path | train | def calculate_path(self, remote_path, input_type):
""" Verify remote_path is in directory for input_type inputs
and create directory if needed.
"""
directory, allow_nested_files = self._directory_for_file_type(input_type)
path = get_mapped_file(directory, remote_path, allow_neste... | python | {
"resource": ""
} |
q6416 | BaseJobClient.setup | train | def setup(self, tool_id=None, tool_version=None, preserve_galaxy_python_environment=None):
"""
Setup remote Pulsar server to run this job.
"""
setup_args = {"job_id": self.job_id}
if tool_id:
setup_args["tool_id"] = tool_id
if tool_version:
setup_a... | python | {
"resource": ""
} |
q6417 | JobClient.launch | train | def launch(self, command_line, dependencies_description=None, env=[], remote_staging=[], job_config=None):
"""
Queue up the execution of the supplied `command_line` on the remote
server. Called launch for historical reasons, should be renamed to
enqueue or something like that.
*... | python | {
"resource": ""
} |
q6418 | FileActionMapper.__process_action | train | def __process_action(self, action, file_type):
""" Extension point to populate extra action information after an
action has been created.
"""
if getattr(action, "inject_url", False):
self.__inject_url(action, file_type)
if getattr(action, "inject_ssh_properties", Fals... | python | {
"resource": ""
} |
q6419 | _handle_default | train | def _handle_default(value, script_name):
""" There are two potential variants of these scripts,
the Bash scripts that are meant to be run within PULSAR_ROOT
for older-style installs and the binaries created by setup.py
as part of a proper pulsar installation.
This method first looks for the newer s... | python | {
"resource": ""
} |
q6420 | JobInputs.rewrite_paths | train | def rewrite_paths(self, local_path, remote_path):
"""
Rewrite references to `local_path` with `remote_path` in job inputs.
"""
self.__rewrite_command_line(local_path, remote_path)
self.__rewrite_config_files(local_path, remote_path) | python | {
"resource": ""
} |
q6421 | TransferTracker.rewrite_input_paths | train | def rewrite_input_paths(self):
"""
For each file that has been transferred and renamed, updated
command_line and configfiles to reflect that rewrite.
"""
for local_path, remote_path in self.file_renames.items():
self.job_inputs.rewrite_paths(local_path, remote_path) | python | {
"resource": ""
} |
q6422 | PulsarExchange.__get_payload | train | def __get_payload(self, uuid, failed):
"""Retry reading a message from the publish_uuid_store once, delete on the second failure."""
# Caller should have the publish_uuid_store lock
try:
return self.publish_uuid_store[uuid]
except Exception as exc:
msg = "Failed t... | python | {
"resource": ""
} |
q6423 | __job_complete_dict | train | def __job_complete_dict(complete_status, manager, job_id):
""" Build final dictionary describing completed job for consumption by
Pulsar client.
"""
return_code = manager.return_code(job_id)
if return_code == PULSAR_UNKNOWN_RETURN_CODE:
return_code = None
stdout_contents = manager.stdout... | python | {
"resource": ""
} |
q6424 | submit_job | train | def submit_job(manager, job_config):
""" Launch new job from specified config. May have been previously 'setup'
if 'setup_params' in job_config is empty.
"""
# job_config is raw dictionary from JSON (from MQ or HTTP endpoint).
job_id = job_config.get('job_id')
try:
command_line = job_con... | python | {
"resource": ""
} |
q6425 | PulsarApp.__setup_tool_config | train | def __setup_tool_config(self, conf):
"""
Setups toolbox object and authorization mechanism based
on supplied toolbox_path.
"""
tool_config_files = conf.get("tool_config_files", None)
if not tool_config_files:
# For compatibity with Galaxy, allow tool_config_fi... | python | {
"resource": ""
} |
q6426 | PulsarApp.only_manager | train | def only_manager(self):
"""Convience accessor for tests and contexts with sole manager."""
assert len(self.managers) == 1, MULTIPLE_MANAGERS_MESSAGE
return list(self.managers.values())[0] | python | {
"resource": ""
} |
q6427 | app_factory | train | def app_factory(global_conf, **local_conf):
"""
Returns the Pulsar WSGI application.
"""
configuration_file = global_conf.get("__file__", None)
webapp = init_webapp(ini_path=configuration_file, local_conf=local_conf)
return webapp | python | {
"resource": ""
} |
q6428 | check_dependencies | train | def check_dependencies():
"""Make sure virtualenv is in the path."""
print 'Checking dependencies...'
if not HAS_VIRTUALENV:
print 'Virtual environment not found.'
# Try installing it via easy_install...
if HAS_EASY_INSTALL:
print 'Installing virtualenv via easy_install.... | python | {
"resource": ""
} |
q6429 | ClientManager.get_client | train | def get_client(self, destination_params, job_id, **kwargs):
"""Build a client given specific destination parameters and job_id."""
destination_params = _parse_destination_params(destination_params)
destination_params.update(**kwargs)
job_manager_interface_class = self.job_manager_interfa... | python | {
"resource": ""
} |
q6430 | CliInterface.get_plugins | train | def get_plugins(self, shell_params, job_params):
"""
Return shell and job interface defined by and configured via
specified params.
"""
shell = self.get_shell_plugin(shell_params)
job_interface = self.get_job_interface(job_params)
return shell, job_interface | python | {
"resource": ""
} |
q6431 | atomicish_move | train | def atomicish_move(source, destination, tmp_suffix="_TMP"):
"""Move source to destination without risk of partial moves.
> from tempfile import mkdtemp
> from os.path import join, exists
> temp_dir = mkdtemp()
> source = join(temp_dir, "the_source")
> destination = join(temp_dir, "the_dest")
... | python | {
"resource": ""
} |
q6432 | env_to_statement | train | def env_to_statement(env):
''' Return the abstraction description of an environment variable definition
into a statement for shell script.
>>> env_to_statement(dict(name='X', value='Y'))
'X="Y"; export X'
>>> env_to_statement(dict(name='X', value='Y', raw=True))
'X=Y; export X'
>>> env_to_s... | python | {
"resource": ""
} |
q6433 | copy_to_temp | train | def copy_to_temp(object):
"""
Copy file-like object to temp file and return
path.
"""
temp_file = NamedTemporaryFile(delete=False)
_copy_and_close(object, temp_file)
return temp_file.name | python | {
"resource": ""
} |
q6434 | build_submit_description | train | def build_submit_description(executable, output, error, user_log, query_params):
"""
Build up the contents of a condor submit description file.
>>> submit_args = dict(executable='/path/to/script', output='o', error='e', user_log='ul')
>>> submit_args['query_params'] = dict()
>>> default_description... | python | {
"resource": ""
} |
q6435 | condor_submit | train | def condor_submit(submit_file):
"""
Submit a condor job described by the given file. Parse an external id for
the submission or return None and a reason for the failure.
"""
external_id = None
try:
submit = Popen(('condor_submit', submit_file), stdout=PIPE, stderr=STDOUT)
message... | python | {
"resource": ""
} |
q6436 | condor_stop | train | def condor_stop(external_id):
"""
Stop running condor job and return a failure_message if this
fails.
"""
failure_message = None
try:
check_call(('condor_rm', external_id))
except CalledProcessError:
failure_message = "condor_rm failed"
except Exception as e:
"err... | python | {
"resource": ""
} |
q6437 | LockManager.get_lock | train | def get_lock(self, path):
""" Get a job lock corresponding to the path - assumes parent
directory exists but the file itself does not.
"""
if self.lockfile:
return self.lockfile.LockFile(path)
else:
with self.job_locks_lock:
if path not in ... | python | {
"resource": ""
} |
q6438 | build | train | def build(client, destination_args):
""" Build a SetupHandler object for client from destination parameters.
"""
# Have defined a remote job directory, lets do the setup locally.
if client.job_directory:
handler = LocalSetupHandler(client, destination_args)
else:
handler = RemoteSetu... | python | {
"resource": ""
} |
q6439 | DrmaaSession.run_job | train | def run_job(self, **kwds):
"""
Create a DRMAA job template, populate with specified properties,
run the job, and return the external_job_id.
"""
template = DrmaaSession.session.createJobTemplate()
try:
for key in kwds:
setattr(template, key, kw... | python | {
"resource": ""
} |
q6440 | url_to_destination_params | train | def url_to_destination_params(url):
"""Convert a legacy runner URL to a job destination
>>> params_simple = url_to_destination_params("http://localhost:8913/")
>>> params_simple["url"]
'http://localhost:8913/'
>>> params_simple["private_token"] is None
True
>>> advanced_url = "https://1234x... | python | {
"resource": ""
} |
q6441 | ensure_port_cleanup | train | def ensure_port_cleanup(bound_addresses, maxtries=30, sleeptime=2):
"""
This makes sure any open ports are closed.
Does this by connecting to them until they give connection
refused. Servers should call like::
import paste.script
ensure_port_cleanup([80, 443])
"""
atexit.regis... | python | {
"resource": ""
} |
q6442 | Command.standard_parser | train | def standard_parser(cls, verbose=True,
interactive=False,
no_interactive=False,
simulate=False,
quiet=False,
overwrite=False):
"""
Create a standard ``OptionParser`` instance.
... | python | {
"resource": ""
} |
q6443 | Command.quote_first_command_arg | train | def quote_first_command_arg(self, arg):
"""
There's a bug in Windows when running an executable that's
located inside a path with a space in it. This method handles
that case, or on non-Windows systems or an executable with no
spaces, it just leaves well enough alone.
""... | python | {
"resource": ""
} |
q6444 | Command.logging_file_config | train | def logging_file_config(self, config_file):
"""
Setup logging via the logging module's fileConfig function with the
specified ``config_file``, if applicable.
ConfigParser defaults are specified for the special ``__file__``
and ``here`` variables, similar to PasteDeploy config lo... | python | {
"resource": ""
} |
q6445 | finish_job | train | def finish_job(client, cleanup_job, job_completed_normally, client_outputs, pulsar_outputs):
"""Process for "un-staging" a complete Pulsar job.
This function is responsible for downloading results from remote
server and cleaning up Pulsar staging directory (if needed.)
"""
collection_failure_except... | python | {
"resource": ""
} |
q6446 | BaseDrmaaManager.shutdown | train | def shutdown(self, timeout=None):
"""Cleanup DRMAA session and call shutdown of parent."""
try:
super(BaseDrmaaManager, self).shutdown(timeout)
except Exception:
pass
self.drmaa_session.close() | python | {
"resource": ""
} |
q6447 | Cache.cache_file | train | def cache_file(self, local_path, ip, path):
"""
Move a file from a temporary staging area into the cache.
"""
destination = self.__destination(ip, path)
atomicish_move(local_path, destination) | python | {
"resource": ""
} |
q6448 | build_managers | train | def build_managers(app, conf):
"""
Takes in a config file as outlined in job_managers.ini.sample and builds
a dictionary of job manager objects from them.
"""
# Load default options from config file that apply to all
# managers.
default_options = _get_default_options(conf)
manager_descr... | python | {
"resource": ""
} |
q6449 | fix_type_error | train | def fix_type_error(exc_info, callable, varargs, kwargs):
"""
Given an exception, this will test if the exception was due to a
signature error, and annotate the error with better information if
so.
Usage::
try:
val = callable(*args, **kw)
except TypeError:
exc_info =... | python | {
"resource": ""
} |
q6450 | RemoteJobDirectory.calculate_path | train | def calculate_path(self, remote_relative_path, input_type):
""" Only for used by Pulsar client, should override for managers to
enforce security and make the directory if needed.
"""
directory, allow_nested_files = self._directory_for_file_type(input_type)
return self.path_helper... | python | {
"resource": ""
} |
q6451 | StatefulManagerProxy.get_status | train | def get_status(self, job_id):
""" Compute status used proxied manager and handle state transitions
and track additional state information needed.
"""
job_directory = self._proxied_manager.job_directory(job_id)
with job_directory.lock("status"):
proxy_status, state_cha... | python | {
"resource": ""
} |
q6452 | StatefulManagerProxy.__proxy_status | train | def __proxy_status(self, job_directory, job_id):
""" Determine state with proxied job manager and if this job needs
to be marked as deactivated (this occurs when job first returns a
complete status from proxy.
"""
state_change = None
if job_directory.has_metadata(JOB_FILE... | python | {
"resource": ""
} |
q6453 | PulsarOutputs.output_extras | train | def output_extras(self, output_file):
"""
Returns dict mapping local path to remote name.
"""
output_directory = dirname(output_file)
def local_path(name):
return join(output_directory, self.path_helper.local_name(name))
files_directory = "%s_files%s" % (bas... | python | {
"resource": ""
} |
q6454 | sudo_popen | train | def sudo_popen(*args, **kwargs):
"""
Helper method for building and executing Popen command. This is potentially
sensetive code so should probably be centralized.
"""
user = kwargs.get("user", None)
full_command = [SUDO_PATH, SUDO_PRESERVE_ENVIRONMENT_ARG]
if user:
full_command.exten... | python | {
"resource": ""
} |
q6455 | LineManager.add_family | train | def add_family(self, major_number):
"""
Expand to a new release line with given ``major_number``.
This will flesh out mandatory buckets like ``unreleased_bugfix`` and do
other necessary bookkeeping.
"""
# Normally, we have separate buckets for bugfixes vs features
... | python | {
"resource": ""
} |
q6456 | parse_changelog | train | def parse_changelog(path, **kwargs):
"""
Load and parse changelog file from ``path``, returning data structures.
This function does not alter any files on disk; it is solely for
introspecting a Releases ``changelog.rst`` and programmatically answering
questions like "are there any unreleased bugfix... | python | {
"resource": ""
} |
q6457 | get_doctree | train | def get_doctree(path, **kwargs):
"""
Obtain a Sphinx doctree from the RST file at ``path``.
Performs no Releases-specific processing; this code would, ideally, be in
Sphinx itself, but things there are pretty tightly coupled. So we wrote
this.
Any additional kwargs are passed unmodified into a... | python | {
"resource": ""
} |
q6458 | load_conf | train | def load_conf(srcdir):
"""
Load ``conf.py`` from given ``srcdir``.
:returns: Dictionary derived from the conf module.
"""
path = os.path.join(srcdir, 'conf.py')
mylocals = {'__file__': path}
with open(path) as fd:
exec(fd.read(), mylocals)
return mylocals | python | {
"resource": ""
} |
q6459 | make_app | train | def make_app(**kwargs):
"""
Create a dummy Sphinx app, filling in various hardcoded assumptions.
For example, Sphinx assumes the existence of various source/dest
directories, even if you're only calling internals that never generate (or
sometimes, even read!) on-disk files. This function creates sa... | python | {
"resource": ""
} |
q6460 | _log | train | def _log(txt, config):
"""
Log debug output if debug setting is on.
Intended to be partial'd w/ config at top of functions. Meh.
"""
if config.releases_debug:
sys.stderr.write(str(txt) + "\n")
sys.stderr.flush() | python | {
"resource": ""
} |
q6461 | scan_for_spec | train | def scan_for_spec(keyword):
"""
Attempt to return some sort of Spec from given keyword value.
Returns None if one could not be derived.
"""
# Both 'spec' formats are wrapped in parens, discard
keyword = keyword.lstrip('(').rstrip(')')
# First, test for intermediate '1.2+' style
matches ... | python | {
"resource": ""
} |
q6462 | append_unreleased_entries | train | def append_unreleased_entries(app, manager, releases):
"""
Generate new abstract 'releases' for unreleased issues.
There's one for each combination of bug-vs-feature & major release line.
When only one major release line exists, that dimension is ignored.
"""
for family, lines in six.iteritems... | python | {
"resource": ""
} |
q6463 | handle_first_release_line | train | def handle_first_release_line(entries, manager):
"""
Set up initial line-manager entry for first encountered release line.
To be called at start of overall process; afterwards, subsequent major
lines are generated by `handle_upcoming_major_release`.
"""
# It's remotely possible the changelog is... | python | {
"resource": ""
} |
q6464 | Issue.minor_releases | train | def minor_releases(self, manager):
"""
Return all minor release line labels found in ``manager``.
"""
# TODO: yea deffo need a real object for 'manager', heh. E.g. we do a
# very similar test for "do you have any actual releases yet?"
# elsewhere. (This may be fodder for ... | python | {
"resource": ""
} |
q6465 | Issue.default_spec | train | def default_spec(self, manager):
"""
Given the current release-lines structure, return a default Spec.
Specifics:
* For feature-like issues, only the highest major release is used, so
given a ``manager`` with top level keys of ``[1, 2]``, this would
return ``Spec(">... | python | {
"resource": ""
} |
q6466 | Issue.add_to_manager | train | def add_to_manager(self, manager):
"""
Given a 'manager' structure, add self to one or more of its 'buckets'.
"""
# Derive version spec allowing us to filter against major/minor buckets
spec = self.spec or self.default_spec(manager)
# Only look in appropriate major versio... | python | {
"resource": ""
} |
q6467 | DocBuilder.cleanParagraph | train | def cleanParagraph(self):
"""
Compress text runs, remove whitespace at start and end,
skip empty blocks, etc
"""
runs = self.block.content
if not runs:
self.block = None
return
if not self.clean_paragraphs:
return
jo... | python | {
"resource": ""
} |
q6468 | CSS.parse_css | train | def parse_css(self, css):
"""
Parse a css style sheet into the CSS object.
For the moment this will only work for very simple css
documents. It works by using regular expression matching css
syntax. This is not bullet proof.
"""
rulesets = self.ruleset_re.finda... | python | {
"resource": ""
} |
q6469 | CSS.parse_declarations | train | def parse_declarations(self, declarations):
"""
parse a css declaration list
"""
declarations = self.declaration_re.findall(declarations)
return dict(declarations) | python | {
"resource": ""
} |
q6470 | CSS.parse_selector | train | def parse_selector(self, selector):
"""
parse a css selector
"""
tag, klass = self.selector_re.match(selector).groups()
return Selector(tag, klass) | python | {
"resource": ""
} |
q6471 | CSS.get_properties | train | def get_properties(self, node):
"""
return a dict of all the properties of a given BeautifulSoup
node found by applying the css style.
"""
ret = {}
# Try all the rules one by one
for rule in self.rules:
if rule.selector(node):
ret.updat... | python | {
"resource": ""
} |
q6472 | namedModule | train | def namedModule(name):
"""Return a module given its name."""
topLevel = __import__(name)
packages = name.split(".")[1:]
m = topLevel
for p in packages:
m = getattr(m, p)
return m | python | {
"resource": ""
} |
q6473 | namedObject | train | def namedObject(name):
"""Get a fully named module-global object.
"""
classSplit = name.split('.')
module = namedModule('.'.join(classSplit[:-1]))
return getattr(module, classSplit[-1]) | python | {
"resource": ""
} |
q6474 | RSTWriter.text | train | def text(self, text):
"""
process a pyth text and return the formatted string
"""
ret = u"".join(text.content)
if 'url' in text.properties:
return u"`%s`_" % ret
if 'bold' in text.properties:
return u"**%s**" % ret
if 'italic' in text.prope... | python | {
"resource": ""
} |
q6475 | RSTWriter.paragraph | train | def paragraph(self, paragraph, prefix=""):
"""
process a pyth paragraph into the target
"""
content = []
for text in paragraph.content:
content.append(self.text(text))
content = u"".join(content).encode("utf-8")
for line in content.split("\n"):
... | python | {
"resource": ""
} |
q6476 | RSTWriter.list | train | def list(self, list, prefix=None):
"""
Process a pyth list into the target
"""
self.indent += 1
for (i, entry) in enumerate(list.content):
for (j, paragraph) in enumerate(entry.content):
prefix = "- " if j == 0 else " "
handler = self.... | python | {
"resource": ""
} |
q6477 | XHTMLReader.format | train | def format(self, soup):
"""format a BeautifulSoup document
This will transform the block elements content from
multi-lines text into single line.
This allow us to avoid having to deal with further text
rendering once this step has been done.
"""
# Remove all the... | python | {
"resource": ""
} |
q6478 | XHTMLReader.url | train | def url(self, node):
"""
return the url of a BeautifulSoup node or None if there is no
url.
"""
a_node = node.findParent('a')
if not a_node:
return None
if self.link_callback is None:
return a_node.get('href')
else:
ret... | python | {
"resource": ""
} |
q6479 | XHTMLReader.process_text | train | def process_text(self, node):
"""
Return a pyth Text object from a BeautifulSoup node or None if
the text is empty.
"""
text = node.string.strip()
if not text:
return
# Set all the properties
properties=dict()
if self.is_bold(node):
... | python | {
"resource": ""
} |
q6480 | XHTMLReader.process_into | train | def process_into(self, node, obj):
"""
Process a BeautifulSoup node and fill its elements into a pyth
base object.
"""
if isinstance(node, BeautifulSoup.NavigableString):
text = self.process_text(node)
if text:
obj.append(text)
... | python | {
"resource": ""
} |
q6481 | _PythBase.append | train | def append(self, item):
"""
Try to add an item to this element.
If the item is of the wrong type, and if this element has a sub-type,
then try to create such a sub-type and insert the item into that, instead.
This happens recursively, so (in python-markup):
L ... | python | {
"resource": ""
} |
q6482 | LatexWriter.write | train | def write(klass, document, target=None, stylesheet=""):
"""
convert a pyth document to a latex document
we can specify a stylesheet as a latex document fragment that
will be inserted after the headers. This way we can override
the default style.
"""
writer = Lat... | python | {
"resource": ""
} |
q6483 | LatexWriter.full_stylesheet | train | def full_stylesheet(self):
"""
Return the style sheet that will ultimately be inserted into
the latex document.
This is the user given style sheet plus some additional parts
to add the meta data.
"""
latex_fragment = r"""
\usepackage[colorlinks=true,linkc... | python | {
"resource": ""
} |
q6484 | Endpoints.get_stream_url | train | def get_stream_url(self, session_id, stream_id=None):
""" this method returns the url to get streams information """
url = self.api_url + '/v2/project/' + self.api_key + '/session/' + session_id + '/stream'
if stream_id:
url = url + '/' + stream_id
return url | python | {
"resource": ""
} |
q6485 | Endpoints.force_disconnect_url | train | def force_disconnect_url(self, session_id, connection_id):
""" this method returns the force disconnect url endpoint """
url = (
self.api_url + '/v2/project/' + self.api_key + '/session/' +
session_id + '/connection/' + connection_id
)
return url | python | {
"resource": ""
} |
q6486 | Endpoints.set_archive_layout_url | train | def set_archive_layout_url(self, archive_id):
""" this method returns the url to set the archive layout """
url = self.api_url + '/v2/project/' + self.api_key + '/archive/' + archive_id + '/layout'
return url | python | {
"resource": ""
} |
q6487 | Endpoints.set_stream_class_lists_url | train | def set_stream_class_lists_url(self, session_id):
""" this method returns the url to set the stream class list """
url = self.api_url + '/v2/project/' + self.api_key + '/session/' + session_id + '/stream'
return url | python | {
"resource": ""
} |
q6488 | Endpoints.broadcast_url | train | def broadcast_url(self, broadcast_id=None, stop=False, layout=False):
""" this method returns urls for working with broadcast """
url = self.api_url + '/v2/project/' + self.api_key + '/broadcast'
if broadcast_id:
url = url + '/' + broadcast_id
if stop:
url = url ... | python | {
"resource": ""
} |
q6489 | Archive.attrs | train | def attrs(self):
"""
Returns a dictionary of the archive's attributes.
"""
return dict((k, v) for k, v in iteritems(self.__dict__) if k is not "sdk") | python | {
"resource": ""
} |
q6490 | OpenTok.create_session | train | def create_session(self, location=None, media_mode=MediaModes.relayed, archive_mode=ArchiveModes.manual):
"""
Creates a new OpenTok session and returns the session ID, which uniquely identifies
the session.
For example, when using the OpenTok JavaScript library, use the session ID when ... | python | {
"resource": ""
} |
q6491 | OpenTok.start_archive | train | def start_archive(self, session_id, has_audio=True, has_video=True, name=None, output_mode=OutputModes.composed, resolution=None):
"""
Starts archiving an OpenTok session.
Clients must be actively connected to the OpenTok session for you to successfully start
recording an archive.
... | python | {
"resource": ""
} |
q6492 | OpenTok.delete_archive | train | def delete_archive(self, archive_id):
"""
Deletes an OpenTok archive.
You can only delete an archive which has a status of "available" or "uploaded". Deleting an
archive removes its record from the list of archives. For an "available" archive, it also
removes the archive file, m... | python | {
"resource": ""
} |
q6493 | OpenTok.get_archive | train | def get_archive(self, archive_id):
"""Gets an Archive object for the given archive ID.
:param String archive_id: The archive ID.
:rtype: The Archive object.
"""
response = requests.get(self.endpoints.archive_url(archive_id), headers=self.json_headers(), proxies=self.proxies, ti... | python | {
"resource": ""
} |
q6494 | OpenTok.get_archives | train | def get_archives(self, offset=None, count=None, session_id=None):
"""Returns an ArchiveList, which is an array of archives that are completed and in-progress,
for your API key.
:param int: offset Optional. The index offset of the first archive. 0 is offset
of the most recently started... | python | {
"resource": ""
} |
q6495 | OpenTok.signal | train | def signal(self, session_id, payload, connection_id=None):
"""
Send signals to all participants in an active OpenTok session or to a specific client
connected to that session.
:param String session_id: The session ID of the OpenTok session that receives the signal
:param Dictio... | python | {
"resource": ""
} |
q6496 | OpenTok.force_disconnect | train | def force_disconnect(self, session_id, connection_id):
"""
Sends a request to disconnect a client from an OpenTok session
:param String session_id: The session ID of the OpenTok session from which the
client will be disconnected
:param String connection_id: The connection ID of... | python | {
"resource": ""
} |
q6497 | OpenTok.set_archive_layout | train | def set_archive_layout(self, archive_id, layout_type, stylesheet=None):
"""
Use this method to change the layout of videos in an OpenTok archive
:param String archive_id: The ID of the archive that will be updated
:param String layout_type: The layout type for the archive. Valid values... | python | {
"resource": ""
} |
q6498 | OpenTok.dial | train | def dial(self, session_id, token, sip_uri, options=[]):
"""
Use this method to connect a SIP platform to an OpenTok session. The audio from the end
of the SIP call is added to the OpenTok session as an audio-only stream. The OpenTok Media
Router mixes audio from other streams in the sess... | python | {
"resource": ""
} |
q6499 | OpenTok.set_stream_class_lists | train | def set_stream_class_lists(self, session_id, payload):
"""
Use this method to change layout classes for OpenTok streams. The layout classes
define how the streams are displayed in the layout of a composed OpenTok archive
:param String session_id: The ID of the session of the streams tha... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.