repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
ecell/ecell4
ecell4/extra/azure_batch.py
create_job
def create_job(batch_service_client, job_id, pool_id): """Creates a job with the specified ID, associated with the specified pool. :param batch_service_client: A Batch service client. :type batch_service_client: `azure.batch.BatchServiceClient` :param str job_id: The ID for the job. :param str pool...
python
def create_job(batch_service_client, job_id, pool_id): """Creates a job with the specified ID, associated with the specified pool. :param batch_service_client: A Batch service client. :type batch_service_client: `azure.batch.BatchServiceClient` :param str job_id: The ID for the job. :param str pool...
[ "def", "create_job", "(", "batch_service_client", ",", "job_id", ",", "pool_id", ")", ":", "print", "(", "'Creating job [{}]...'", ".", "format", "(", "job_id", ")", ")", "job", "=", "batch", ".", "models", ".", "JobAddParameter", "(", "id", "=", "job_id", ...
Creates a job with the specified ID, associated with the specified pool. :param batch_service_client: A Batch service client. :type batch_service_client: `azure.batch.BatchServiceClient` :param str job_id: The ID for the job. :param str pool_id: The ID for the pool.
[ "Creates", "a", "job", "with", "the", "specified", "ID", "associated", "with", "the", "specified", "pool", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/azure_batch.py#L234-L252
train
ecell/ecell4
ecell4/extra/azure_batch.py
add_tasks
def add_tasks(batch_service_client, job_id, loads, output_container_name, output_container_sas_token, task_file, acount_name): """Adds a task for each input file in the collection to the specified job. :param batch_service_client: A Batch service client. :type batch_service_clie...
python
def add_tasks(batch_service_client, job_id, loads, output_container_name, output_container_sas_token, task_file, acount_name): """Adds a task for each input file in the collection to the specified job. :param batch_service_client: A Batch service client. :type batch_service_clie...
[ "def", "add_tasks", "(", "batch_service_client", ",", "job_id", ",", "loads", ",", "output_container_name", ",", "output_container_sas_token", ",", "task_file", ",", "acount_name", ")", ":", "_log", ".", "info", "(", "'Adding {} tasks to job [{}]...'", ".", "format", ...
Adds a task for each input file in the collection to the specified job. :param batch_service_client: A Batch service client. :type batch_service_client: `azure.batch.BatchServiceClient` :param str job_id: The ID of the job to which to add the tasks. :param list input_files: A collection of input files....
[ "Adds", "a", "task", "for", "each", "input", "file", "in", "the", "collection", "to", "the", "specified", "job", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/azure_batch.py#L254-L302
train
ecell/ecell4
ecell4/extra/azure_batch.py
wait_for_tasks_to_complete
def wait_for_tasks_to_complete(batch_service_client, job_ids, timeout): """Returns when all tasks in the specified job reach the Completed state. :param batch_service_client: A Batch service client. :type batch_service_client: `azure.batch.BatchServiceClient` :param str job_id: The id of the job whose ...
python
def wait_for_tasks_to_complete(batch_service_client, job_ids, timeout): """Returns when all tasks in the specified job reach the Completed state. :param batch_service_client: A Batch service client. :type batch_service_client: `azure.batch.BatchServiceClient` :param str job_id: The id of the job whose ...
[ "def", "wait_for_tasks_to_complete", "(", "batch_service_client", ",", "job_ids", ",", "timeout", ")", ":", "timeout_expiration", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "+", "timeout", "print", "(", "\"Monitoring all tasks for 'Completed' state, timeout...
Returns when all tasks in the specified job reach the Completed state. :param batch_service_client: A Batch service client. :type batch_service_client: `azure.batch.BatchServiceClient` :param str job_id: The id of the job whose tasks should be to monitored. :param timedelta timeout: The duration to wai...
[ "Returns", "when", "all", "tasks", "in", "the", "specified", "job", "reach", "the", "Completed", "state", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/azure_batch.py#L304-L337
train
ecell/ecell4
ecell4/extra/azure_batch.py
download_blobs_from_container
def download_blobs_from_container(block_blob_client, container_name, directory_path, prefix=None): """Downloads all blobs from the specified Azure Blob storage container. :param block_blob_client: A blob service client. :type block_blob_cl...
python
def download_blobs_from_container(block_blob_client, container_name, directory_path, prefix=None): """Downloads all blobs from the specified Azure Blob storage container. :param block_blob_client: A blob service client. :type block_blob_cl...
[ "def", "download_blobs_from_container", "(", "block_blob_client", ",", "container_name", ",", "directory_path", ",", "prefix", "=", "None", ")", ":", "_log", ".", "info", "(", "'Downloading all files from container [{}]...'", ".", "format", "(", "container_name", ")", ...
Downloads all blobs from the specified Azure Blob storage container. :param block_blob_client: A blob service client. :type block_blob_client: `azure.storage.blob.BlockBlobService` :param container_name: The Azure Blob storage container from which to download files. :param directory_path: The loca...
[ "Downloads", "all", "blobs", "from", "the", "specified", "Azure", "Blob", "storage", "container", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/azure_batch.py#L339-L368
train
ecell/ecell4
ecell4/extra/azure_batch.py
singlerun
def singlerun(job, task_id=0, job_id=0): """This task is for an example.""" import ecell4_base import ecell4 import ecell4.util.simulation import ecell4.util.decorator print('ecell4_base.__version__ = {:s}'.format(ecell4_base.__version__)) print('ecell4.__version__ = {:s}'.format(ecell4.__v...
python
def singlerun(job, task_id=0, job_id=0): """This task is for an example.""" import ecell4_base import ecell4 import ecell4.util.simulation import ecell4.util.decorator print('ecell4_base.__version__ = {:s}'.format(ecell4_base.__version__)) print('ecell4.__version__ = {:s}'.format(ecell4.__v...
[ "def", "singlerun", "(", "job", ",", "task_id", "=", "0", ",", "job_id", "=", "0", ")", ":", "import", "ecell4_base", "import", "ecell4", "import", "ecell4", ".", "util", ".", "simulation", "import", "ecell4", ".", "util", ".", "decorator", "print", "(",...
This task is for an example.
[ "This", "task", "is", "for", "an", "example", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/azure_batch.py#L757-L779
train
ecell/ecell4
ecell4/util/viz.py
plot_number_observer
def plot_number_observer(*args, **kwargs): """ Generate a plot from NumberObservers and show it. See plot_number_observer_with_matplotlib and _with_nya for details. Parameters ---------- obs : NumberObserver (e.g. FixedIntervalNumberObserver) interactive : bool, default False Choose...
python
def plot_number_observer(*args, **kwargs): """ Generate a plot from NumberObservers and show it. See plot_number_observer_with_matplotlib and _with_nya for details. Parameters ---------- obs : NumberObserver (e.g. FixedIntervalNumberObserver) interactive : bool, default False Choose...
[ "def", "plot_number_observer", "(", "*", "args", ",", "**", "kwargs", ")", ":", "interactive", "=", "kwargs", ".", "pop", "(", "'interactive'", ",", "False", ")", "if", "interactive", ":", "plot_number_observer_with_nya", "(", "*", "args", ",", "**", "kwargs...
Generate a plot from NumberObservers and show it. See plot_number_observer_with_matplotlib and _with_nya for details. Parameters ---------- obs : NumberObserver (e.g. FixedIntervalNumberObserver) interactive : bool, default False Choose a visualizer. If False, show the plot with matplotlib....
[ "Generate", "a", "plot", "from", "NumberObservers", "and", "show", "it", ".", "See", "plot_number_observer_with_matplotlib", "and", "_with_nya", "for", "details", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L28-L58
train
ecell/ecell4
ecell4/util/viz.py
plot_world
def plot_world(*args, **kwargs): """ Generate a plot from received instance of World and show it. See also plot_world_with_elegans and plot_world_with_matplotlib. Parameters ---------- world : World or str World or a HDF5 filename to render. interactive : bool, default True ...
python
def plot_world(*args, **kwargs): """ Generate a plot from received instance of World and show it. See also plot_world_with_elegans and plot_world_with_matplotlib. Parameters ---------- world : World or str World or a HDF5 filename to render. interactive : bool, default True ...
[ "def", "plot_world", "(", "*", "args", ",", "**", "kwargs", ")", ":", "interactive", "=", "kwargs", ".", "pop", "(", "'interactive'", ",", "True", ")", "if", "interactive", ":", "plot_world_with_elegans", "(", "*", "args", ",", "**", "kwargs", ")", "else...
Generate a plot from received instance of World and show it. See also plot_world_with_elegans and plot_world_with_matplotlib. Parameters ---------- world : World or str World or a HDF5 filename to render. interactive : bool, default True Choose a visualizer. If False, show the plot ...
[ "Generate", "a", "plot", "from", "received", "instance", "of", "World", "and", "show", "it", ".", "See", "also", "plot_world_with_elegans", "and", "plot_world_with_matplotlib", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L60-L83
train
ecell/ecell4
ecell4/util/viz.py
plot_movie
def plot_movie(*args, **kwargs): """ Generate a movie from received instances of World and show them. See also plot_movie_with_elegans and plot_movie_with_matplotlib. Parameters ---------- worlds : list of World Worlds to render. interactive : bool, default True Choose a vis...
python
def plot_movie(*args, **kwargs): """ Generate a movie from received instances of World and show them. See also plot_movie_with_elegans and plot_movie_with_matplotlib. Parameters ---------- worlds : list of World Worlds to render. interactive : bool, default True Choose a vis...
[ "def", "plot_movie", "(", "*", "args", ",", "**", "kwargs", ")", ":", "interactive", "=", "kwargs", ".", "pop", "(", "'interactive'", ",", "False", ")", "if", "interactive", ":", "plot_movie_with_elegans", "(", "*", "args", ",", "**", "kwargs", ")", "els...
Generate a movie from received instances of World and show them. See also plot_movie_with_elegans and plot_movie_with_matplotlib. Parameters ---------- worlds : list of World Worlds to render. interactive : bool, default True Choose a visualizer. If False, show the plot with matplot...
[ "Generate", "a", "movie", "from", "received", "instances", "of", "World", "and", "show", "them", ".", "See", "also", "plot_movie_with_elegans", "and", "plot_movie_with_matplotlib", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L85-L103
train
ecell/ecell4
ecell4/util/viz.py
plot_trajectory
def plot_trajectory(*args, **kwargs): """ Generate a plot from received instance of TrajectoryObserver and show it See also plot_trajectory_with_elegans and plot_trajectory_with_matplotlib. Parameters ---------- obs : TrajectoryObserver TrajectoryObserver to render. interactive : bo...
python
def plot_trajectory(*args, **kwargs): """ Generate a plot from received instance of TrajectoryObserver and show it See also plot_trajectory_with_elegans and plot_trajectory_with_matplotlib. Parameters ---------- obs : TrajectoryObserver TrajectoryObserver to render. interactive : bo...
[ "def", "plot_trajectory", "(", "*", "args", ",", "**", "kwargs", ")", ":", "interactive", "=", "kwargs", ".", "pop", "(", "'interactive'", ",", "True", ")", "if", "interactive", ":", "plot_trajectory_with_elegans", "(", "*", "args", ",", "**", "kwargs", ")...
Generate a plot from received instance of TrajectoryObserver and show it See also plot_trajectory_with_elegans and plot_trajectory_with_matplotlib. Parameters ---------- obs : TrajectoryObserver TrajectoryObserver to render. interactive : bool, default True Choose a visualizer. If F...
[ "Generate", "a", "plot", "from", "received", "instance", "of", "TrajectoryObserver", "and", "show", "it", "See", "also", "plot_trajectory_with_elegans", "and", "plot_trajectory_with_matplotlib", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L105-L128
train
ecell/ecell4
ecell4/util/viz.py
plot_movie_with_elegans
def plot_movie_with_elegans( worlds, radius=None, width=500, height=500, config=None, grid=False, species_list=None): """ Generate a movie from received instances of World and show them on IPython notebook. Parameters ---------- worlds : list of World Worlds to render. ...
python
def plot_movie_with_elegans( worlds, radius=None, width=500, height=500, config=None, grid=False, species_list=None): """ Generate a movie from received instances of World and show them on IPython notebook. Parameters ---------- worlds : list of World Worlds to render. ...
[ "def", "plot_movie_with_elegans", "(", "worlds", ",", "radius", "=", "None", ",", "width", "=", "500", ",", "height", "=", "500", ",", "config", "=", "None", ",", "grid", "=", "False", ",", "species_list", "=", "None", ")", ":", "config", "=", "config"...
Generate a movie from received instances of World and show them on IPython notebook. Parameters ---------- worlds : list of World Worlds to render. radius : float, default None If this value is set, all particles in the world will be rendered as if their radius are the same....
[ "Generate", "a", "movie", "from", "received", "instances", "of", "World", "and", "show", "them", "on", "IPython", "notebook", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L476-L539
train
ecell/ecell4
ecell4/util/viz.py
plot_world_with_elegans
def plot_world_with_elegans( world, radius=None, width=350, height=350, config=None, grid=True, wireframe=False, species_list=None, debug=None, max_count=1000, camera_position=(-22, 23, 32), camera_rotation=(-0.6, 0.5, 0.6), return_id=False, predicator=None): """ Generate a plot ...
python
def plot_world_with_elegans( world, radius=None, width=350, height=350, config=None, grid=True, wireframe=False, species_list=None, debug=None, max_count=1000, camera_position=(-22, 23, 32), camera_rotation=(-0.6, 0.5, 0.6), return_id=False, predicator=None): """ Generate a plot ...
[ "def", "plot_world_with_elegans", "(", "world", ",", "radius", "=", "None", ",", "width", "=", "350", ",", "height", "=", "350", ",", "config", "=", "None", ",", "grid", "=", "True", ",", "wireframe", "=", "False", ",", "species_list", "=", "None", ","...
Generate a plot from received instance of World and show it on IPython notebook. This method returns the instance of dict that indicates color setting for each speices. You can use the dict as the parameter of plot_world, in order to use the same colors in another plot. Parameters ---------- wo...
[ "Generate", "a", "plot", "from", "received", "instance", "of", "World", "and", "show", "it", "on", "IPython", "notebook", ".", "This", "method", "returns", "the", "instance", "of", "dict", "that", "indicates", "color", "setting", "for", "each", "speices", "....
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L541-L648
train
ecell/ecell4
ecell4/util/viz.py
generate_html
def generate_html(keywords, tmpl_path, package_name='ecell4.util'): """ Generate static html file from JSON model and its own id. Parameters ---------- model : dict JSON model from which ecell4.viz generates a plot. model_id : string Unique id for the plot. Returns ----...
python
def generate_html(keywords, tmpl_path, package_name='ecell4.util'): """ Generate static html file from JSON model and its own id. Parameters ---------- model : dict JSON model from which ecell4.viz generates a plot. model_id : string Unique id for the plot. Returns ----...
[ "def", "generate_html", "(", "keywords", ",", "tmpl_path", ",", "package_name", "=", "'ecell4.util'", ")", ":", "from", "jinja2", "import", "Template", "import", "pkgutil", "template", "=", "Template", "(", "pkgutil", ".", "get_data", "(", "package_name", ",", ...
Generate static html file from JSON model and its own id. Parameters ---------- model : dict JSON model from which ecell4.viz generates a plot. model_id : string Unique id for the plot. Returns ------- html : A HTML object
[ "Generate", "static", "html", "file", "from", "JSON", "model", "and", "its", "own", "id", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L802-L825
train
ecell/ecell4
ecell4/util/viz.py
plot_trajectory2d_with_matplotlib
def plot_trajectory2d_with_matplotlib( obs, plane='xy', max_count=10, figsize=6, legend=True, wireframe=False, grid=True, noaxis=False, plot_range=None, **kwargs): """ Make a 2D plot from received instance of TrajectoryObserver and show it on IPython notebook. Parameters ---------- ...
python
def plot_trajectory2d_with_matplotlib( obs, plane='xy', max_count=10, figsize=6, legend=True, wireframe=False, grid=True, noaxis=False, plot_range=None, **kwargs): """ Make a 2D plot from received instance of TrajectoryObserver and show it on IPython notebook. Parameters ---------- ...
[ "def", "plot_trajectory2d_with_matplotlib", "(", "obs", ",", "plane", "=", "'xy'", ",", "max_count", "=", "10", ",", "figsize", "=", "6", ",", "legend", "=", "True", ",", "wireframe", "=", "False", ",", "grid", "=", "True", ",", "noaxis", "=", "False", ...
Make a 2D plot from received instance of TrajectoryObserver and show it on IPython notebook. Parameters ---------- obs : TrajectoryObserver TrajectoryObserver to render. plane : str, default 'xy' 'xy', 'yz', 'zx'. max_count : Integer, default 10 The maximum number of par...
[ "Make", "a", "2D", "plot", "from", "received", "instance", "of", "TrajectoryObserver", "and", "show", "it", "on", "IPython", "notebook", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L1243-L1304
train
ecell/ecell4
ecell4/util/viz.py
plot_world2d_with_matplotlib
def plot_world2d_with_matplotlib( world, plane='xy', marker_size=3, figsize=6, grid=True, wireframe=False, species_list=None, max_count=1000, angle=None, legend=True, noaxis=False, scale=1.0, **kwargs): """ Make a 2D plot from received instance of World and show it on IPython notebook. ...
python
def plot_world2d_with_matplotlib( world, plane='xy', marker_size=3, figsize=6, grid=True, wireframe=False, species_list=None, max_count=1000, angle=None, legend=True, noaxis=False, scale=1.0, **kwargs): """ Make a 2D plot from received instance of World and show it on IPython notebook. ...
[ "def", "plot_world2d_with_matplotlib", "(", "world", ",", "plane", "=", "'xy'", ",", "marker_size", "=", "3", ",", "figsize", "=", "6", ",", "grid", "=", "True", ",", "wireframe", "=", "False", ",", "species_list", "=", "None", ",", "max_count", "=", "10...
Make a 2D plot from received instance of World and show it on IPython notebook. Parameters ---------- world : World or str World to render. A HDF5 filename is also acceptable. plane : str, default 'xy' 'xy', 'yz', 'zx'. marker_size : float, default 3 Marker size for all spec...
[ "Make", "a", "2D", "plot", "from", "received", "instance", "of", "World", "and", "show", "it", "on", "IPython", "notebook", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L1908-L1974
train
ecell/ecell4
ecell4/util/viz.py
plot_world_with_plotly
def plot_world_with_plotly(world, species_list=None, max_count=1000): """ Plot a World on IPython Notebook """ if isinstance(world, str): from .simulation import load_world world = load_world(world) if species_list is None: species_list = [sp.serial() for sp in world.list_sp...
python
def plot_world_with_plotly(world, species_list=None, max_count=1000): """ Plot a World on IPython Notebook """ if isinstance(world, str): from .simulation import load_world world = load_world(world) if species_list is None: species_list = [sp.serial() for sp in world.list_sp...
[ "def", "plot_world_with_plotly", "(", "world", ",", "species_list", "=", "None", ",", "max_count", "=", "1000", ")", ":", "if", "isinstance", "(", "world", ",", "str", ")", ":", "from", ".", "simulation", "import", "load_world", "world", "=", "load_world", ...
Plot a World on IPython Notebook
[ "Plot", "a", "World", "on", "IPython", "Notebook" ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L2136-L2182
train
ecell/ecell4
ecell4/extra/_unit.py
getUnitRegistry
def getUnitRegistry(length="meter", time="second", substance="item", volume=None, other=()): """Return a pint.UnitRegistry made compatible with ecell4. Parameters ---------- length : str, optional A default unit for '[length]'. 'meter' is its default. time : str, optional A default ...
python
def getUnitRegistry(length="meter", time="second", substance="item", volume=None, other=()): """Return a pint.UnitRegistry made compatible with ecell4. Parameters ---------- length : str, optional A default unit for '[length]'. 'meter' is its default. time : str, optional A default ...
[ "def", "getUnitRegistry", "(", "length", "=", "\"meter\"", ",", "time", "=", "\"second\"", ",", "substance", "=", "\"item\"", ",", "volume", "=", "None", ",", "other", "=", "(", ")", ")", ":", "ureg", "=", "pint", ".", "UnitRegistry", "(", ")", "ureg",...
Return a pint.UnitRegistry made compatible with ecell4. Parameters ---------- length : str, optional A default unit for '[length]'. 'meter' is its default. time : str, optional A default unit for '[time]'. 'second' is its default. substance : str, optional A default unit for...
[ "Return", "a", "pint", ".", "UnitRegistry", "made", "compatible", "with", "ecell4", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/_unit.py#L32-L74
train
ecell/ecell4
ecell4/datasource/biogrid.py
biogridDataSource.interactor
def interactor(self, geneList=None, org=None): """ Supposing geneList returns an unique item. """ geneList = geneList or [] organisms = organisms or [] querydata = self.interactions(geneList, org) returnData = {} for i in querydata: if not ret...
python
def interactor(self, geneList=None, org=None): """ Supposing geneList returns an unique item. """ geneList = geneList or [] organisms = organisms or [] querydata = self.interactions(geneList, org) returnData = {} for i in querydata: if not ret...
[ "def", "interactor", "(", "self", ",", "geneList", "=", "None", ",", "org", "=", "None", ")", ":", "geneList", "=", "geneList", "or", "[", "]", "organisms", "=", "organisms", "or", "[", "]", "querydata", "=", "self", ".", "interactions", "(", "geneList...
Supposing geneList returns an unique item.
[ "Supposing", "geneList", "returns", "an", "unique", "item", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/datasource/biogrid.py#L96-L109
train
ecell/ecell4
ecell4/util/ports.py
save_sbml
def save_sbml(filename, model, y0=None, volume=1.0, is_valid=True): """ Save a model in the SBML format. Parameters ---------- model : NetworkModel y0 : dict Initial condition. volume : Real or Real3, optional A size of the simulation volume. is_valid : bool, optional ...
python
def save_sbml(filename, model, y0=None, volume=1.0, is_valid=True): """ Save a model in the SBML format. Parameters ---------- model : NetworkModel y0 : dict Initial condition. volume : Real or Real3, optional A size of the simulation volume. is_valid : bool, optional ...
[ "def", "save_sbml", "(", "filename", ",", "model", ",", "y0", "=", "None", ",", "volume", "=", "1.0", ",", "is_valid", "=", "True", ")", ":", "y0", "=", "y0", "or", "{", "}", "import", "libsbml", "document", "=", "export_sbml", "(", "model", ",", "...
Save a model in the SBML format. Parameters ---------- model : NetworkModel y0 : dict Initial condition. volume : Real or Real3, optional A size of the simulation volume. is_valid : bool, optional Check if the generated model is valid. True as a default.
[ "Save", "a", "model", "in", "the", "SBML", "format", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/ports.py#L220-L245
train
ecell/ecell4
ecell4/util/ports.py
load_sbml
def load_sbml(filename): """ Load a model from a SBML file. Parameters ---------- filename : str The input SBML filename. Returns ------- model : NetworkModel y0 : dict Initial condition. volume : Real or Real3, optional A size of the simulation volume. ...
python
def load_sbml(filename): """ Load a model from a SBML file. Parameters ---------- filename : str The input SBML filename. Returns ------- model : NetworkModel y0 : dict Initial condition. volume : Real or Real3, optional A size of the simulation volume. ...
[ "def", "load_sbml", "(", "filename", ")", ":", "import", "libsbml", "document", "=", "libsbml", ".", "readSBML", "(", "filename", ")", "document", ".", "validateSBML", "(", ")", "num_errors", "=", "(", "document", ".", "getNumErrors", "(", "libsbml", ".", ...
Load a model from a SBML file. Parameters ---------- filename : str The input SBML filename. Returns ------- model : NetworkModel y0 : dict Initial condition. volume : Real or Real3, optional A size of the simulation volume.
[ "Load", "a", "model", "from", "a", "SBML", "file", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/ports.py#L377-L411
train
ecell/ecell4
ecell4/util/decorator.py
get_model
def get_model(is_netfree=False, without_reset=False, seeds=None, effective=False): """ Generate a model with parameters in the global scope, ``SPECIES_ATTRIBUTES`` and ``REACTIONRULES``. Parameters ---------- is_netfree : bool, optional Return ``NetfreeModel`` if True, and ``NetworkMode...
python
def get_model(is_netfree=False, without_reset=False, seeds=None, effective=False): """ Generate a model with parameters in the global scope, ``SPECIES_ATTRIBUTES`` and ``REACTIONRULES``. Parameters ---------- is_netfree : bool, optional Return ``NetfreeModel`` if True, and ``NetworkMode...
[ "def", "get_model", "(", "is_netfree", "=", "False", ",", "without_reset", "=", "False", ",", "seeds", "=", "None", ",", "effective", "=", "False", ")", ":", "try", ":", "if", "seeds", "is", "not", "None", "or", "is_netfree", ":", "m", "=", "ecell4_bas...
Generate a model with parameters in the global scope, ``SPECIES_ATTRIBUTES`` and ``REACTIONRULES``. Parameters ---------- is_netfree : bool, optional Return ``NetfreeModel`` if True, and ``NetworkModel`` if else. Default is False. without_reset : bool, optional Do not reset ...
[ "Generate", "a", "model", "with", "parameters", "in", "the", "global", "scope", "SPECIES_ATTRIBUTES", "and", "REACTIONRULES", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/decorator.py#L143-L194
train
ecell/ecell4
ecell4/extra/ensemble.py
run_serial
def run_serial(target, jobs, n=1, **kwargs): """ Evaluate the given function with each set of arguments, and return a list of results. This function does in series. Parameters ---------- target : function A function to be evaluated. The function must accepts three arguments, whi...
python
def run_serial(target, jobs, n=1, **kwargs): """ Evaluate the given function with each set of arguments, and return a list of results. This function does in series. Parameters ---------- target : function A function to be evaluated. The function must accepts three arguments, whi...
[ "def", "run_serial", "(", "target", ",", "jobs", ",", "n", "=", "1", ",", "**", "kwargs", ")", ":", "return", "[", "[", "target", "(", "copy", ".", "copy", "(", "job", ")", ",", "i", "+", "1", ",", "j", "+", "1", ")", "for", "j", "in", "ran...
Evaluate the given function with each set of arguments, and return a list of results. This function does in series. Parameters ---------- target : function A function to be evaluated. The function must accepts three arguments, which are a list of arguments given as `jobs`, a job and tas...
[ "Evaluate", "the", "given", "function", "with", "each", "set", "of", "arguments", "and", "return", "a", "list", "of", "results", ".", "This", "function", "does", "in", "series", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/ensemble.py#L22-L71
train
ecell/ecell4
ecell4/extra/ensemble.py
run_multiprocessing
def run_multiprocessing(target, jobs, n=1, nproc=None, **kwargs): """ Evaluate the given function with each set of arguments, and return a list of results. This function does in parallel by using `multiprocessing`. Parameters ---------- target : function A function to be evaluated. The ...
python
def run_multiprocessing(target, jobs, n=1, nproc=None, **kwargs): """ Evaluate the given function with each set of arguments, and return a list of results. This function does in parallel by using `multiprocessing`. Parameters ---------- target : function A function to be evaluated. The ...
[ "def", "run_multiprocessing", "(", "target", ",", "jobs", ",", "n", "=", "1", ",", "nproc", "=", "None", ",", "**", "kwargs", ")", ":", "def", "consumer", "(", "f", ",", "q_in", ",", "q_out", ")", ":", "while", "True", ":", "val", "=", "q_in", "....
Evaluate the given function with each set of arguments, and return a list of results. This function does in parallel by using `multiprocessing`. Parameters ---------- target : function A function to be evaluated. The function must accepts three arguments, which are a list of arguments g...
[ "Evaluate", "the", "given", "function", "with", "each", "set", "of", "arguments", "and", "return", "a", "list", "of", "results", ".", "This", "function", "does", "in", "parallel", "by", "using", "multiprocessing", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/ensemble.py#L73-L147
train
ecell/ecell4
ecell4/extra/ensemble.py
run_azure
def run_azure(target, jobs, n=1, nproc=None, path='.', delete=True, config=None, **kwargs): """ Evaluate the given function with each set of arguments, and return a list of results. This function does in parallel with Microsoft Azure Batch. This function is the work in progress. The argument `nproc...
python
def run_azure(target, jobs, n=1, nproc=None, path='.', delete=True, config=None, **kwargs): """ Evaluate the given function with each set of arguments, and return a list of results. This function does in parallel with Microsoft Azure Batch. This function is the work in progress. The argument `nproc...
[ "def", "run_azure", "(", "target", ",", "jobs", ",", "n", "=", "1", ",", "nproc", "=", "None", ",", "path", "=", "'.'", ",", "delete", "=", "True", ",", "config", "=", "None", ",", "**", "kwargs", ")", ":", "import", "ecell4", ".", "extra", ".", ...
Evaluate the given function with each set of arguments, and return a list of results. This function does in parallel with Microsoft Azure Batch. This function is the work in progress. The argument `nproc` doesn't work yet. See `ecell4.extra.azure_batch.run_azure` for details. See Also --------...
[ "Evaluate", "the", "given", "function", "with", "each", "set", "of", "arguments", "and", "return", "a", "list", "of", "results", ".", "This", "function", "does", "in", "parallel", "with", "Microsoft", "Azure", "Batch", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/ensemble.py#L503-L523
train
ecell/ecell4
ecell4/extra/ensemble.py
getseed
def getseed(myseed, i): """ Return a single seed from a long seed given by `genseeds`. Parameters ---------- myseed : bytes A long seed given by `genseeds(n)`. i : int An index less than n. Returns ------- rndseed : int A seed (less than (2 ** 31)) """ ...
python
def getseed(myseed, i): """ Return a single seed from a long seed given by `genseeds`. Parameters ---------- myseed : bytes A long seed given by `genseeds(n)`. i : int An index less than n. Returns ------- rndseed : int A seed (less than (2 ** 31)) """ ...
[ "def", "getseed", "(", "myseed", ",", "i", ")", ":", "rndseed", "=", "int", "(", "myseed", "[", "(", "i", "-", "1", ")", "*", "8", ":", "i", "*", "8", "]", ",", "16", ")", "rndseed", "=", "rndseed", "%", "(", "2", "**", "31", ")", "return",...
Return a single seed from a long seed given by `genseeds`. Parameters ---------- myseed : bytes A long seed given by `genseeds(n)`. i : int An index less than n. Returns ------- rndseed : int A seed (less than (2 ** 31))
[ "Return", "a", "single", "seed", "from", "a", "long", "seed", "given", "by", "genseeds", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/ensemble.py#L543-L562
train
ecell/ecell4
ecell4/extra/ensemble.py
list_species
def list_species(model, seeds=None): """This function is deprecated.""" seeds = None or [] from ecell4_base.core import Species if not isinstance(seeds, list): seeds = list(seeds) expanded = model.expand([Species(serial) for serial in seeds]) species_list = [sp.serial() for sp in expa...
python
def list_species(model, seeds=None): """This function is deprecated.""" seeds = None or [] from ecell4_base.core import Species if not isinstance(seeds, list): seeds = list(seeds) expanded = model.expand([Species(serial) for serial in seeds]) species_list = [sp.serial() for sp in expa...
[ "def", "list_species", "(", "model", ",", "seeds", "=", "None", ")", ":", "seeds", "=", "None", "or", "[", "]", "from", "ecell4_base", ".", "core", "import", "Species", "if", "not", "isinstance", "(", "seeds", ",", "list", ")", ":", "seeds", "=", "li...
This function is deprecated.
[ "This", "function", "is", "deprecated", "." ]
a4a1229661c39b2059adbbacae9090e5ba664e01
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/ensemble.py#L582-L594
train
dlon/html2markdown
html2markdown.py
_escapeCharacters
def _escapeCharacters(tag): """non-recursively escape underlines and asterisks in the tag""" for i,c in enumerate(tag.contents): if type(c) != bs4.element.NavigableString: continue c.replace_with(_escapeCharSub(r'\\\1', c))
python
def _escapeCharacters(tag): """non-recursively escape underlines and asterisks in the tag""" for i,c in enumerate(tag.contents): if type(c) != bs4.element.NavigableString: continue c.replace_with(_escapeCharSub(r'\\\1', c))
[ "def", "_escapeCharacters", "(", "tag", ")", ":", "for", "i", ",", "c", "in", "enumerate", "(", "tag", ".", "contents", ")", ":", "if", "type", "(", "c", ")", "!=", "bs4", ".", "element", ".", "NavigableString", ":", "continue", "c", ".", "replace_wi...
non-recursively escape underlines and asterisks in the tag
[ "non", "-", "recursively", "escape", "underlines", "and", "asterisks", "in", "the", "tag" ]
5946da7136e69a67b3dd37fd0e896be4d6a5b482
https://github.com/dlon/html2markdown/blob/5946da7136e69a67b3dd37fd0e896be4d6a5b482/html2markdown.py#L148-L154
train
dlon/html2markdown
html2markdown.py
_breakRemNewlines
def _breakRemNewlines(tag): """non-recursively break spaces and remove newlines in the tag""" for i,c in enumerate(tag.contents): if type(c) != bs4.element.NavigableString: continue c.replace_with(re.sub(r' {2,}', ' ', c).replace('\n',''))
python
def _breakRemNewlines(tag): """non-recursively break spaces and remove newlines in the tag""" for i,c in enumerate(tag.contents): if type(c) != bs4.element.NavigableString: continue c.replace_with(re.sub(r' {2,}', ' ', c).replace('\n',''))
[ "def", "_breakRemNewlines", "(", "tag", ")", ":", "for", "i", ",", "c", "in", "enumerate", "(", "tag", ".", "contents", ")", ":", "if", "type", "(", "c", ")", "!=", "bs4", ".", "element", ".", "NavigableString", ":", "continue", "c", ".", "replace_wi...
non-recursively break spaces and remove newlines in the tag
[ "non", "-", "recursively", "break", "spaces", "and", "remove", "newlines", "in", "the", "tag" ]
5946da7136e69a67b3dd37fd0e896be4d6a5b482
https://github.com/dlon/html2markdown/blob/5946da7136e69a67b3dd37fd0e896be4d6a5b482/html2markdown.py#L156-L161
train
dlon/html2markdown
html2markdown.py
convert
def convert(html): """converts an html string to markdown while preserving unsupported markup.""" bs = BeautifulSoup(html, 'html.parser') _markdownify(bs) ret = unicode(bs).replace(u'\xa0', ' ') ret = re.sub(r'\n{3,}', r'\n\n', ret) # ! FIXME: hack ret = re.sub(r'<<<FLOATING LINK: (.+)>>>'...
python
def convert(html): """converts an html string to markdown while preserving unsupported markup.""" bs = BeautifulSoup(html, 'html.parser') _markdownify(bs) ret = unicode(bs).replace(u'\xa0', ' ') ret = re.sub(r'\n{3,}', r'\n\n', ret) # ! FIXME: hack ret = re.sub(r'<<<FLOATING LINK: (.+)>>>'...
[ "def", "convert", "(", "html", ")", ":", "bs", "=", "BeautifulSoup", "(", "html", ",", "'html.parser'", ")", "_markdownify", "(", "bs", ")", "ret", "=", "unicode", "(", "bs", ")", ".", "replace", "(", "u'\\xa0'", ",", "' '", ")", "ret", "=", "re...
converts an html string to markdown while preserving unsupported markup.
[ "converts", "an", "html", "string", "to", "markdown", "while", "preserving", "unsupported", "markup", "." ]
5946da7136e69a67b3dd37fd0e896be4d6a5b482
https://github.com/dlon/html2markdown/blob/5946da7136e69a67b3dd37fd0e896be4d6a5b482/html2markdown.py#L332-L347
train
timknip/pyswf
swf/filters.py
SWFFilterFactory.create
def create(cls, type): """ Return the specified Filter """ if type == 0: return FilterDropShadow(id) elif type == 1: return FilterBlur(id) elif type == 2: return FilterGlow(id) elif type == 3: return FilterBevel(id) elif type == 4: return FilterGradientGlow(id) el...
python
def create(cls, type): """ Return the specified Filter """ if type == 0: return FilterDropShadow(id) elif type == 1: return FilterBlur(id) elif type == 2: return FilterGlow(id) elif type == 3: return FilterBevel(id) elif type == 4: return FilterGradientGlow(id) el...
[ "def", "create", "(", "cls", ",", "type", ")", ":", "if", "type", "==", "0", ":", "return", "FilterDropShadow", "(", "id", ")", "elif", "type", "==", "1", ":", "return", "FilterBlur", "(", "id", ")", "elif", "type", "==", "2", ":", "return", "Filte...
Return the specified Filter
[ "Return", "the", "specified", "Filter" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/filters.py#L220-L231
train
timknip/pyswf
swf/movie.py
SWF.export
def export(self, exporter=None, force_stroke=False): """ Export this SWF using the specified exporter. When no exporter is passed in the default exporter used is swf.export.SVGExporter. Exporters should extend the swf.export.BaseExporter class. @param ...
python
def export(self, exporter=None, force_stroke=False): """ Export this SWF using the specified exporter. When no exporter is passed in the default exporter used is swf.export.SVGExporter. Exporters should extend the swf.export.BaseExporter class. @param ...
[ "def", "export", "(", "self", ",", "exporter", "=", "None", ",", "force_stroke", "=", "False", ")", ":", "exporter", "=", "SVGExporter", "(", ")", "if", "exporter", "is", "None", "else", "exporter", "if", "self", ".", "_data", "is", "None", ":", "raise...
Export this SWF using the specified exporter. When no exporter is passed in the default exporter used is swf.export.SVGExporter. Exporters should extend the swf.export.BaseExporter class. @param exporter : the exporter to use @param force_stroke : set to true ...
[ "Export", "this", "SWF", "using", "the", "specified", "exporter", ".", "When", "no", "exporter", "is", "passed", "in", "the", "default", "exporter", "used", "is", "swf", ".", "export", ".", "SVGExporter", ".", "Exporters", "should", "extend", "the", "swf", ...
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/movie.py#L114-L131
train
timknip/pyswf
swf/movie.py
SWF.parse
def parse(self, data): """ Parses the SWF. The @data parameter can be a file object or a SWFStream """ self._data = data = data if isinstance(data, SWFStream) else SWFStream(data) self._header = SWFHeader(self._data) if self._header.compressed: ...
python
def parse(self, data): """ Parses the SWF. The @data parameter can be a file object or a SWFStream """ self._data = data = data if isinstance(data, SWFStream) else SWFStream(data) self._header = SWFHeader(self._data) if self._header.compressed: ...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "self", ".", "_data", "=", "data", "=", "data", "if", "isinstance", "(", "data", ",", "SWFStream", ")", "else", "SWFStream", "(", "data", ")", "self", ".", "_header", "=", "SWFHeader", "(", "self", ...
Parses the SWF. The @data parameter can be a file object or a SWFStream
[ "Parses", "the", "SWF", ".", "The" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/movie.py#L137-L162
train
timknip/pyswf
swf/stream.py
int32
def int32(x): """ Return a signed or unsigned int """ if x>0xFFFFFFFF: raise OverflowError if x>0x7FFFFFFF: x=int(0x100000000-x) if x<2147483648: return -x else: return -2147483648 return x
python
def int32(x): """ Return a signed or unsigned int """ if x>0xFFFFFFFF: raise OverflowError if x>0x7FFFFFFF: x=int(0x100000000-x) if x<2147483648: return -x else: return -2147483648 return x
[ "def", "int32", "(", "x", ")", ":", "if", "x", ">", "0xFFFFFFFF", ":", "raise", "OverflowError", "if", "x", ">", "0x7FFFFFFF", ":", "x", "=", "int", "(", "0x100000000", "-", "x", ")", "if", "x", "<", "2147483648", ":", "return", "-", "x", "else", ...
Return a signed or unsigned int
[ "Return", "a", "signed", "or", "unsigned", "int" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L490-L500
train
timknip/pyswf
swf/stream.py
SWFStream.bin
def bin(self, s): """ Return a value as a binary string """ return str(s) if s<=1 else bin(s>>1) + str(s&1)
python
def bin(self, s): """ Return a value as a binary string """ return str(s) if s<=1 else bin(s>>1) + str(s&1)
[ "def", "bin", "(", "self", ",", "s", ")", ":", "return", "str", "(", "s", ")", "if", "s", "<=", "1", "else", "bin", "(", "s", ">>", "1", ")", "+", "str", "(", "s", "&", "1", ")" ]
Return a value as a binary string
[ "Return", "a", "value", "as", "a", "binary", "string" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L22-L24
train
timknip/pyswf
swf/stream.py
SWFStream.calc_max_bits
def calc_max_bits(self, signed, values): """ Calculates the maximim needed bits to represent a value """ b = 0 vmax = -10000000 for val in values: if signed: b = b | val if val >= 0 else b | ~val << 1 vmax = val if vmax < val else vmax...
python
def calc_max_bits(self, signed, values): """ Calculates the maximim needed bits to represent a value """ b = 0 vmax = -10000000 for val in values: if signed: b = b | val if val >= 0 else b | ~val << 1 vmax = val if vmax < val else vmax...
[ "def", "calc_max_bits", "(", "self", ",", "signed", ",", "values", ")", ":", "b", "=", "0", "vmax", "=", "-", "10000000", "for", "val", "in", "values", ":", "if", "signed", ":", "b", "=", "b", "|", "val", "if", "val", ">=", "0", "else", "b", "|...
Calculates the maximim needed bits to represent a value
[ "Calculates", "the", "maximim", "needed", "bits", "to", "represent", "a", "value" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L26-L42
train
timknip/pyswf
swf/stream.py
SWFStream.readbits
def readbits(self, bits): """ Read the specified number of bits from the stream. Returns 0 for bits == 0. """ if bits == 0: return 0 # fast byte-aligned path if bits % 8 == 0 and self._bits_pending == 0: return self._read_...
python
def readbits(self, bits): """ Read the specified number of bits from the stream. Returns 0 for bits == 0. """ if bits == 0: return 0 # fast byte-aligned path if bits % 8 == 0 and self._bits_pending == 0: return self._read_...
[ "def", "readbits", "(", "self", ",", "bits", ")", ":", "if", "bits", "==", "0", ":", "return", "0", "if", "bits", "%", "8", "==", "0", "and", "self", ".", "_bits_pending", "==", "0", ":", "return", "self", ".", "_read_bytes_aligned", "(", "bits", "...
Read the specified number of bits from the stream. Returns 0 for bits == 0.
[ "Read", "the", "specified", "number", "of", "bits", "from", "the", "stream", ".", "Returns", "0", "for", "bits", "==", "0", "." ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L56-L105
train
timknip/pyswf
swf/stream.py
SWFStream.readSB
def readSB(self, bits): """ Read a signed int using the specified number of bits """ shift = 32 - bits return int32(self.readbits(bits) << shift) >> shift
python
def readSB(self, bits): """ Read a signed int using the specified number of bits """ shift = 32 - bits return int32(self.readbits(bits) << shift) >> shift
[ "def", "readSB", "(", "self", ",", "bits", ")", ":", "shift", "=", "32", "-", "bits", "return", "int32", "(", "self", ".", "readbits", "(", "bits", ")", "<<", "shift", ")", ">>", "shift" ]
Read a signed int using the specified number of bits
[ "Read", "a", "signed", "int", "using", "the", "specified", "number", "of", "bits" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L111-L114
train
timknip/pyswf
swf/stream.py
SWFStream.readEncodedU32
def readEncodedU32(self): """ Read a encoded unsigned int """ self.reset_bits_pending(); result = self.readUI8(); if result & 0x80 != 0: result = (result & 0x7f) | (self.readUI8() << 7) if result & 0x4000 != 0: result = (result & 0x3fff) | (self.re...
python
def readEncodedU32(self): """ Read a encoded unsigned int """ self.reset_bits_pending(); result = self.readUI8(); if result & 0x80 != 0: result = (result & 0x7f) | (self.readUI8() << 7) if result & 0x4000 != 0: result = (result & 0x3fff) | (self.re...
[ "def", "readEncodedU32", "(", "self", ")", ":", "self", ".", "reset_bits_pending", "(", ")", "result", "=", "self", ".", "readUI8", "(", ")", "if", "result", "&", "0x80", "!=", "0", ":", "result", "=", "(", "result", "&", "0x7f", ")", "|", "(", "se...
Read a encoded unsigned int
[ "Read", "a", "encoded", "unsigned", "int" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L155-L167
train
timknip/pyswf
swf/stream.py
SWFStream.readFLOAT16
def readFLOAT16(self): """ Read a 2 byte float """ self.reset_bits_pending() word = self.readUI16() sign = -1 if ((word & 0x8000) != 0) else 1 exponent = (word >> 10) & 0x1f significand = word & 0x3ff if exponent == 0: if significand == 0: ...
python
def readFLOAT16(self): """ Read a 2 byte float """ self.reset_bits_pending() word = self.readUI16() sign = -1 if ((word & 0x8000) != 0) else 1 exponent = (word >> 10) & 0x1f significand = word & 0x3ff if exponent == 0: if significand == 0: ...
[ "def", "readFLOAT16", "(", "self", ")", ":", "self", ".", "reset_bits_pending", "(", ")", "word", "=", "self", ".", "readUI16", "(", ")", "sign", "=", "-", "1", "if", "(", "(", "word", "&", "0x8000", ")", "!=", "0", ")", "else", "1", "exponent", ...
Read a 2 byte float
[ "Read", "a", "2", "byte", "float" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L174-L192
train
timknip/pyswf
swf/stream.py
SWFStream.readSTYLECHANGERECORD
def readSTYLECHANGERECORD(self, states, fill_bits, line_bits, level = 1): """ Read a SWFShapeRecordStyleChange """ return SWFShapeRecordStyleChange(self, states, fill_bits, line_bits, level)
python
def readSTYLECHANGERECORD(self, states, fill_bits, line_bits, level = 1): """ Read a SWFShapeRecordStyleChange """ return SWFShapeRecordStyleChange(self, states, fill_bits, line_bits, level)
[ "def", "readSTYLECHANGERECORD", "(", "self", ",", "states", ",", "fill_bits", ",", "line_bits", ",", "level", "=", "1", ")", ":", "return", "SWFShapeRecordStyleChange", "(", "self", ",", "states", ",", "fill_bits", ",", "line_bits", ",", "level", ")" ]
Read a SWFShapeRecordStyleChange
[ "Read", "a", "SWFShapeRecordStyleChange" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L263-L265
train
timknip/pyswf
swf/stream.py
SWFStream.readTEXTRECORD
def readTEXTRECORD(self, glyphBits, advanceBits, previousRecord=None, level=1): """ Read a SWFTextRecord """ if self.readUI8() == 0: return None else: self.seek(self.tell() - 1) return SWFTextRecord(self, glyphBits, advanceBits, previousRecord, level)
python
def readTEXTRECORD(self, glyphBits, advanceBits, previousRecord=None, level=1): """ Read a SWFTextRecord """ if self.readUI8() == 0: return None else: self.seek(self.tell() - 1) return SWFTextRecord(self, glyphBits, advanceBits, previousRecord, level)
[ "def", "readTEXTRECORD", "(", "self", ",", "glyphBits", ",", "advanceBits", ",", "previousRecord", "=", "None", ",", "level", "=", "1", ")", ":", "if", "self", ".", "readUI8", "(", ")", "==", "0", ":", "return", "None", "else", ":", "self", ".", "see...
Read a SWFTextRecord
[ "Read", "a", "SWFTextRecord" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L271-L277
train
timknip/pyswf
swf/stream.py
SWFStream.readACTIONRECORD
def readACTIONRECORD(self): """ Read a SWFActionRecord """ action = None actionCode = self.readUI8() if actionCode != 0: actionLength = self.readUI16() if actionCode >= 0x80 else 0 #print "0x%x"%actionCode, actionLength action = SWFActionFactory.create...
python
def readACTIONRECORD(self): """ Read a SWFActionRecord """ action = None actionCode = self.readUI8() if actionCode != 0: actionLength = self.readUI16() if actionCode >= 0x80 else 0 #print "0x%x"%actionCode, actionLength action = SWFActionFactory.create...
[ "def", "readACTIONRECORD", "(", "self", ")", ":", "action", "=", "None", "actionCode", "=", "self", ".", "readUI8", "(", ")", "if", "actionCode", "!=", "0", ":", "actionLength", "=", "self", ".", "readUI16", "(", ")", "if", "actionCode", ">=", "0x80", ...
Read a SWFActionRecord
[ "Read", "a", "SWFActionRecord" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L307-L316
train
timknip/pyswf
swf/stream.py
SWFStream.readCLIPACTIONRECORD
def readCLIPACTIONRECORD(self, version): """ Read a SWFClipActionRecord """ pos = self.tell() flags = self.readUI32() if version >= 6 else self.readUI16() if flags == 0: return None else: self.seek(pos) return SWFClipActionRecord(self, version)
python
def readCLIPACTIONRECORD(self, version): """ Read a SWFClipActionRecord """ pos = self.tell() flags = self.readUI32() if version >= 6 else self.readUI16() if flags == 0: return None else: self.seek(pos) return SWFClipActionRecord(self, version)
[ "def", "readCLIPACTIONRECORD", "(", "self", ",", "version", ")", ":", "pos", "=", "self", ".", "tell", "(", ")", "flags", "=", "self", ".", "readUI32", "(", ")", "if", "version", ">=", "6", "else", "self", ".", "readUI16", "(", ")", "if", "flags", ...
Read a SWFClipActionRecord
[ "Read", "a", "SWFClipActionRecord" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L333-L341
train
timknip/pyswf
swf/stream.py
SWFStream.readRGB
def readRGB(self): """ Read a RGB color """ self.reset_bits_pending(); r = self.readUI8() g = self.readUI8() b = self.readUI8() return (0xff << 24) | (r << 16) | (g << 8) | b
python
def readRGB(self): """ Read a RGB color """ self.reset_bits_pending(); r = self.readUI8() g = self.readUI8() b = self.readUI8() return (0xff << 24) | (r << 16) | (g << 8) | b
[ "def", "readRGB", "(", "self", ")", ":", "self", ".", "reset_bits_pending", "(", ")", "r", "=", "self", ".", "readUI8", "(", ")", "g", "=", "self", ".", "readUI8", "(", ")", "b", "=", "self", ".", "readUI8", "(", ")", "return", "(", "0xff", "<<",...
Read a RGB color
[ "Read", "a", "RGB", "color" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L347-L353
train
timknip/pyswf
swf/stream.py
SWFStream.readRGBA
def readRGBA(self): """ Read a RGBA color """ self.reset_bits_pending(); r = self.readUI8() g = self.readUI8() b = self.readUI8() a = self.readUI8() return (a << 24) | (r << 16) | (g << 8) | b
python
def readRGBA(self): """ Read a RGBA color """ self.reset_bits_pending(); r = self.readUI8() g = self.readUI8() b = self.readUI8() a = self.readUI8() return (a << 24) | (r << 16) | (g << 8) | b
[ "def", "readRGBA", "(", "self", ")", ":", "self", ".", "reset_bits_pending", "(", ")", "r", "=", "self", ".", "readUI8", "(", ")", "g", "=", "self", ".", "readUI8", "(", ")", "b", "=", "self", ".", "readUI8", "(", ")", "a", "=", "self", ".", "r...
Read a RGBA color
[ "Read", "a", "RGBA", "color" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L355-L362
train
timknip/pyswf
swf/stream.py
SWFStream.readString
def readString(self): """ Read a string """ s = self.f.read(1) string = b"" while ord(s) > 0: string += s s = self.f.read(1) return string.decode()
python
def readString(self): """ Read a string """ s = self.f.read(1) string = b"" while ord(s) > 0: string += s s = self.f.read(1) return string.decode()
[ "def", "readString", "(", "self", ")", ":", "s", "=", "self", ".", "f", ".", "read", "(", "1", ")", "string", "=", "b\"\"", "while", "ord", "(", "s", ")", ">", "0", ":", "string", "+=", "s", "s", "=", "self", ".", "f", ".", "read", "(", "1"...
Read a string
[ "Read", "a", "string" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L368-L375
train
timknip/pyswf
swf/stream.py
SWFStream.readFILTER
def readFILTER(self): """ Read a SWFFilter """ filterId = self.readUI8() filter = SWFFilterFactory.create(filterId) filter.parse(self) return filter
python
def readFILTER(self): """ Read a SWFFilter """ filterId = self.readUI8() filter = SWFFilterFactory.create(filterId) filter.parse(self) return filter
[ "def", "readFILTER", "(", "self", ")", ":", "filterId", "=", "self", ".", "readUI8", "(", ")", "filter", "=", "SWFFilterFactory", ".", "create", "(", "filterId", ")", "filter", ".", "parse", "(", "self", ")", "return", "filter" ]
Read a SWFFilter
[ "Read", "a", "SWFFilter" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L377-L382
train
timknip/pyswf
swf/stream.py
SWFStream.readFILTERLIST
def readFILTERLIST(self): """ Read a length-prefixed list of FILTERs """ number = self.readUI8() return [self.readFILTER() for _ in range(number)]
python
def readFILTERLIST(self): """ Read a length-prefixed list of FILTERs """ number = self.readUI8() return [self.readFILTER() for _ in range(number)]
[ "def", "readFILTERLIST", "(", "self", ")", ":", "number", "=", "self", ".", "readUI8", "(", ")", "return", "[", "self", ".", "readFILTER", "(", ")", "for", "_", "in", "range", "(", "number", ")", "]" ]
Read a length-prefixed list of FILTERs
[ "Read", "a", "length", "-", "prefixed", "list", "of", "FILTERs" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L384-L387
train
timknip/pyswf
swf/stream.py
SWFStream.readBUTTONCONDACTIONSs
def readBUTTONCONDACTIONSs(self): """ Read zero or more button-condition actions """ out = [] while 1: action = self.readBUTTONCONDACTION() if action: out.append(action) else: break return out
python
def readBUTTONCONDACTIONSs(self): """ Read zero or more button-condition actions """ out = [] while 1: action = self.readBUTTONCONDACTION() if action: out.append(action) else: break return out
[ "def", "readBUTTONCONDACTIONSs", "(", "self", ")", ":", "out", "=", "[", "]", "while", "1", ":", "action", "=", "self", ".", "readBUTTONCONDACTION", "(", ")", "if", "action", ":", "out", ".", "append", "(", "action", ")", "else", ":", "break", "return"...
Read zero or more button-condition actions
[ "Read", "zero", "or", "more", "button", "-", "condition", "actions" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L427-L436
train
timknip/pyswf
swf/stream.py
SWFStream.readtag_header
def readtag_header(self): """ Read a tag header """ pos = self.tell() tag_type_and_length = self.readUI16() tag_length = tag_type_and_length & 0x003f if tag_length == 0x3f: # The SWF10 spec sez that this is a signed int. # Shouldn't it be an unsigned int? ...
python
def readtag_header(self): """ Read a tag header """ pos = self.tell() tag_type_and_length = self.readUI16() tag_length = tag_type_and_length & 0x003f if tag_length == 0x3f: # The SWF10 spec sez that this is a signed int. # Shouldn't it be an unsigned int? ...
[ "def", "readtag_header", "(", "self", ")", ":", "pos", "=", "self", ".", "tell", "(", ")", "tag_type_and_length", "=", "self", ".", "readUI16", "(", ")", "tag_length", "=", "tag_type_and_length", "&", "0x003f", "if", "tag_length", "==", "0x3f", ":", "tag_l...
Read a tag header
[ "Read", "a", "tag", "header" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/stream.py#L459-L468
train
timknip/pyswf
swf/tag.py
SWFTimelineContainer.get_dependencies
def get_dependencies(self): """ Returns the character ids this tag refers to """ s = super(SWFTimelineContainer, self).get_dependencies() for dt in self.all_tags_of_type(DefinitionTag): s.update(dt.get_dependencies()) return s
python
def get_dependencies(self): """ Returns the character ids this tag refers to """ s = super(SWFTimelineContainer, self).get_dependencies() for dt in self.all_tags_of_type(DefinitionTag): s.update(dt.get_dependencies()) return s
[ "def", "get_dependencies", "(", "self", ")", ":", "s", "=", "super", "(", "SWFTimelineContainer", ",", "self", ")", ".", "get_dependencies", "(", ")", "for", "dt", "in", "self", ".", "all_tags_of_type", "(", "DefinitionTag", ")", ":", "s", ".", "update", ...
Returns the character ids this tag refers to
[ "Returns", "the", "character", "ids", "this", "tag", "refers", "to" ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/tag.py#L151-L156
train
timknip/pyswf
swf/tag.py
SWFTimelineContainer.all_tags_of_type
def all_tags_of_type(self, type_or_types, recurse_into_sprites = True): """ Generator for all tags of the given type_or_types. Generates in breadth-first order, optionally including all sub-containers. """ for t in self.tags: if isinstance(t, type_or_types): ...
python
def all_tags_of_type(self, type_or_types, recurse_into_sprites = True): """ Generator for all tags of the given type_or_types. Generates in breadth-first order, optionally including all sub-containers. """ for t in self.tags: if isinstance(t, type_or_types): ...
[ "def", "all_tags_of_type", "(", "self", ",", "type_or_types", ",", "recurse_into_sprites", "=", "True", ")", ":", "for", "t", "in", "self", ".", "tags", ":", "if", "isinstance", "(", "t", ",", "type_or_types", ")", ":", "yield", "t", "if", "recurse_into_sp...
Generator for all tags of the given type_or_types. Generates in breadth-first order, optionally including all sub-containers.
[ "Generator", "for", "all", "tags", "of", "the", "given", "type_or_types", "." ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/tag.py#L197-L211
train
timknip/pyswf
swf/tag.py
SWFTimelineContainer.build_dictionary
def build_dictionary(self): """ Return a dictionary of characterIds to their defining tags. """ d = {} for t in self.all_tags_of_type(DefinitionTag, recurse_into_sprites = False): if t.characterId in d: #print 'redefinition of characterId %d:' % (t.cha...
python
def build_dictionary(self): """ Return a dictionary of characterIds to their defining tags. """ d = {} for t in self.all_tags_of_type(DefinitionTag, recurse_into_sprites = False): if t.characterId in d: #print 'redefinition of characterId %d:' % (t.cha...
[ "def", "build_dictionary", "(", "self", ")", ":", "d", "=", "{", "}", "for", "t", "in", "self", ".", "all_tags_of_type", "(", "DefinitionTag", ",", "recurse_into_sprites", "=", "False", ")", ":", "if", "t", ".", "characterId", "in", "d", ":", "raise", ...
Return a dictionary of characterIds to their defining tags.
[ "Return", "a", "dictionary", "of", "characterIds", "to", "their", "defining", "tags", "." ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/tag.py#L213-L225
train
timknip/pyswf
swf/tag.py
SWFTimelineContainer.collect_sound_streams
def collect_sound_streams(self): """ Return a list of sound streams in this timeline and its children. The streams are returned in order with respect to the timeline. A stream is returned as a list: the first element is the tag which introduced that stream; other elements are th...
python
def collect_sound_streams(self): """ Return a list of sound streams in this timeline and its children. The streams are returned in order with respect to the timeline. A stream is returned as a list: the first element is the tag which introduced that stream; other elements are th...
[ "def", "collect_sound_streams", "(", "self", ")", ":", "rc", "=", "[", "]", "current_stream", "=", "None", "for", "tag", "in", "self", ".", "all_tags_of_type", "(", "(", "TagSoundStreamHead", ",", "TagSoundStreamBlock", ")", ")", ":", "if", "isinstance", "("...
Return a list of sound streams in this timeline and its children. The streams are returned in order with respect to the timeline. A stream is returned as a list: the first element is the tag which introduced that stream; other elements are the tags which made up the stream body (if any)...
[ "Return", "a", "list", "of", "sound", "streams", "in", "this", "timeline", "and", "its", "children", ".", "The", "streams", "are", "returned", "in", "order", "with", "respect", "to", "the", "timeline", "." ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/tag.py#L227-L247
train
timknip/pyswf
swf/tag.py
SWFTimelineContainer.collect_video_streams
def collect_video_streams(self): """ Return a list of video streams in this timeline and its children. The streams are returned in order with respect to the timeline. A stream is returned as a list: the first element is the tag which introduced that stream; other elements are th...
python
def collect_video_streams(self): """ Return a list of video streams in this timeline and its children. The streams are returned in order with respect to the timeline. A stream is returned as a list: the first element is the tag which introduced that stream; other elements are th...
[ "def", "collect_video_streams", "(", "self", ")", ":", "rc", "=", "[", "]", "streams_by_id", "=", "{", "}", "for", "t", "in", "self", ".", "all_tags_of_type", "(", "TagDefineVideoStream", ")", ":", "stream", "=", "[", "t", "]", "streams_by_id", "[", "t",...
Return a list of video streams in this timeline and its children. The streams are returned in order with respect to the timeline. A stream is returned as a list: the first element is the tag which introduced that stream; other elements are the tags which made up the stream body (if any)...
[ "Return", "a", "list", "of", "video", "streams", "in", "this", "timeline", "and", "its", "children", ".", "The", "streams", "are", "returned", "in", "order", "with", "respect", "to", "the", "timeline", "." ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/tag.py#L249-L273
train
timknip/pyswf
swf/export.py
SVGExporter.export
def export(self, swf, force_stroke=False): """ Exports the specified SWF to SVG. @param swf The SWF. @param force_stroke Whether to force strokes on non-stroked fills. """ self.svg = self._e.svg(version=SVG_VERSION) self.force_stroke = force_stroke self.defs = s...
python
def export(self, swf, force_stroke=False): """ Exports the specified SWF to SVG. @param swf The SWF. @param force_stroke Whether to force strokes on non-stroked fills. """ self.svg = self._e.svg(version=SVG_VERSION) self.force_stroke = force_stroke self.defs = s...
[ "def", "export", "(", "self", ",", "swf", ",", "force_stroke", "=", "False", ")", ":", "self", ".", "svg", "=", "self", ".", "_e", ".", "svg", "(", "version", "=", "SVG_VERSION", ")", "self", ".", "force_stroke", "=", "force_stroke", "self", ".", "de...
Exports the specified SWF to SVG. @param swf The SWF. @param force_stroke Whether to force strokes on non-stroked fills.
[ "Exports", "the", "specified", "SWF", "to", "SVG", "." ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/export.py#L514-L546
train
timknip/pyswf
swf/export.py
SingleShapeSVGExporterMixin.export
def export(self, swf, shape, **export_opts): """ Exports the specified shape of the SWF to SVG. @param swf The SWF. @param shape Which shape to export, either by characterId(int) or as a Tag object. """ # If `shape` is given as int, find corresponding shape tag. if is...
python
def export(self, swf, shape, **export_opts): """ Exports the specified shape of the SWF to SVG. @param swf The SWF. @param shape Which shape to export, either by characterId(int) or as a Tag object. """ # If `shape` is given as int, find corresponding shape tag. if is...
[ "def", "export", "(", "self", ",", "swf", ",", "shape", ",", "**", "export_opts", ")", ":", "if", "isinstance", "(", "shape", ",", "Tag", ")", ":", "shape_tag", "=", "shape", "else", ":", "shapes", "=", "[", "x", "for", "x", "in", "swf", ".", "al...
Exports the specified shape of the SWF to SVG. @param swf The SWF. @param shape Which shape to export, either by characterId(int) or as a Tag object.
[ "Exports", "the", "specified", "shape", "of", "the", "SWF", "to", "SVG", "." ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/export.py#L827-L876
train
timknip/pyswf
swf/export.py
FrameSVGExporterMixin.export
def export(self, swf, frame, **export_opts): """ Exports a frame of the specified SWF to SVG. @param swf The SWF. @param frame Which frame to export, by 0-based index (int) """ self.wanted_frame = frame return super(FrameSVGExporterMixin, self).export(swf, *export_opts...
python
def export(self, swf, frame, **export_opts): """ Exports a frame of the specified SWF to SVG. @param swf The SWF. @param frame Which frame to export, by 0-based index (int) """ self.wanted_frame = frame return super(FrameSVGExporterMixin, self).export(swf, *export_opts...
[ "def", "export", "(", "self", ",", "swf", ",", "frame", ",", "**", "export_opts", ")", ":", "self", ".", "wanted_frame", "=", "frame", "return", "super", "(", "FrameSVGExporterMixin", ",", "self", ")", ".", "export", "(", "swf", ",", "*", "export_opts", ...
Exports a frame of the specified SWF to SVG. @param swf The SWF. @param frame Which frame to export, by 0-based index (int)
[ "Exports", "a", "frame", "of", "the", "specified", "SWF", "to", "SVG", "." ]
3740cc80d7650156831e728ea0d408819e5671eb
https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/export.py#L879-L886
train
scikit-hep/probfit
probfit/plotting.py
_get_args_and_errors
def _get_args_and_errors(self, minuit=None, args=None, errors=None): """ consistent algorithm to get argument and errors 1) get it from minuit if minuit is available 2) if not get it from args and errors 2.1) if args is dict parse it. 3) if all else fail get it from self.last_arg """ ret...
python
def _get_args_and_errors(self, minuit=None, args=None, errors=None): """ consistent algorithm to get argument and errors 1) get it from minuit if minuit is available 2) if not get it from args and errors 2.1) if args is dict parse it. 3) if all else fail get it from self.last_arg """ ret...
[ "def", "_get_args_and_errors", "(", "self", ",", "minuit", "=", "None", ",", "args", "=", "None", ",", "errors", "=", "None", ")", ":", "ret_arg", "=", "None", "ret_error", "=", "None", "if", "minuit", "is", "not", "None", ":", "ret_arg", "=", "minuit"...
consistent algorithm to get argument and errors 1) get it from minuit if minuit is available 2) if not get it from args and errors 2.1) if args is dict parse it. 3) if all else fail get it from self.last_arg
[ "consistent", "algorithm", "to", "get", "argument", "and", "errors", "1", ")", "get", "it", "from", "minuit", "if", "minuit", "is", "available", "2", ")", "if", "not", "get", "it", "from", "args", "and", "errors", "2", ".", "1", ")", "if", "args", "i...
de3593798ea3877dd2785062bed6877dd9058a02
https://github.com/scikit-hep/probfit/blob/de3593798ea3877dd2785062bed6877dd9058a02/probfit/plotting.py#L28-L55
train
scikit-hep/probfit
probfit/plotting.py
draw_residual
def draw_residual(x, y, yerr, xerr, show_errbars=True, ax=None, zero_line=True, grid=True, **kwargs): """Draw a residual plot on the axis. By default, if show_errbars if True, residuals are drawn as blue points with errorbars with no endcaps. If show_er...
python
def draw_residual(x, y, yerr, xerr, show_errbars=True, ax=None, zero_line=True, grid=True, **kwargs): """Draw a residual plot on the axis. By default, if show_errbars if True, residuals are drawn as blue points with errorbars with no endcaps. If show_er...
[ "def", "draw_residual", "(", "x", ",", "y", ",", "yerr", ",", "xerr", ",", "show_errbars", "=", "True", ",", "ax", "=", "None", ",", "zero_line", "=", "True", ",", "grid", "=", "True", ",", "**", "kwargs", ")", ":", "from", "matplotlib", "import", ...
Draw a residual plot on the axis. By default, if show_errbars if True, residuals are drawn as blue points with errorbars with no endcaps. If show_errbars is False, residuals are drawn as a bar graph with black bars. **Arguments** - **x** array of numbers, x-coordinates - **y** array ...
[ "Draw", "a", "residual", "plot", "on", "the", "axis", "." ]
de3593798ea3877dd2785062bed6877dd9058a02
https://github.com/scikit-hep/probfit/blob/de3593798ea3877dd2785062bed6877dd9058a02/probfit/plotting.py#L135-L193
train
scikit-hep/probfit
probfit/plotting.py
draw_pdf
def draw_pdf(f, arg, bound, bins=100, scale=1.0, density=True, normed_pdf=False, ax=None, **kwds): """ draw pdf with given argument and bounds. **Arguments** * **f** your pdf. The first argument is assumed to be independent variable * **arg** argument can be tuple o...
python
def draw_pdf(f, arg, bound, bins=100, scale=1.0, density=True, normed_pdf=False, ax=None, **kwds): """ draw pdf with given argument and bounds. **Arguments** * **f** your pdf. The first argument is assumed to be independent variable * **arg** argument can be tuple o...
[ "def", "draw_pdf", "(", "f", ",", "arg", ",", "bound", ",", "bins", "=", "100", ",", "scale", "=", "1.0", ",", "density", "=", "True", ",", "normed_pdf", "=", "False", ",", "ax", "=", "None", ",", "**", "kwds", ")", ":", "edges", "=", "np", "."...
draw pdf with given argument and bounds. **Arguments** * **f** your pdf. The first argument is assumed to be independent variable * **arg** argument can be tuple or list * **bound** tuple(xmin,xmax) * **bins** number of bins to plot pdf. Default 100. * **scale...
[ "draw", "pdf", "with", "given", "argument", "and", "bounds", "." ]
de3593798ea3877dd2785062bed6877dd9058a02
https://github.com/scikit-hep/probfit/blob/de3593798ea3877dd2785062bed6877dd9058a02/probfit/plotting.py#L519-L550
train
jmcarp/betfair.py
betfair/utils.py
get_chunks
def get_chunks(sequence, chunk_size): """Split sequence into chunks. :param list sequence: :param int chunk_size: """ return [ sequence[idx:idx + chunk_size] for idx in range(0, len(sequence), chunk_size) ]
python
def get_chunks(sequence, chunk_size): """Split sequence into chunks. :param list sequence: :param int chunk_size: """ return [ sequence[idx:idx + chunk_size] for idx in range(0, len(sequence), chunk_size) ]
[ "def", "get_chunks", "(", "sequence", ",", "chunk_size", ")", ":", "return", "[", "sequence", "[", "idx", ":", "idx", "+", "chunk_size", "]", "for", "idx", "in", "range", "(", "0", ",", "len", "(", "sequence", ")", ",", "chunk_size", ")", "]" ]
Split sequence into chunks. :param list sequence: :param int chunk_size:
[ "Split", "sequence", "into", "chunks", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/utils.py#L19-L28
train
jmcarp/betfair.py
betfair/utils.py
get_kwargs
def get_kwargs(kwargs): """Get all keys and values from dictionary where key is not `self`. :param dict kwargs: Input parameters """ return { key: value for key, value in six.iteritems(kwargs) if key != 'self' }
python
def get_kwargs(kwargs): """Get all keys and values from dictionary where key is not `self`. :param dict kwargs: Input parameters """ return { key: value for key, value in six.iteritems(kwargs) if key != 'self' }
[ "def", "get_kwargs", "(", "kwargs", ")", ":", "return", "{", "key", ":", "value", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "kwargs", ")", "if", "key", "!=", "'self'", "}" ]
Get all keys and values from dictionary where key is not `self`. :param dict kwargs: Input parameters
[ "Get", "all", "keys", "and", "values", "from", "dictionary", "where", "key", "is", "not", "self", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/utils.py#L31-L39
train
jmcarp/betfair.py
betfair/utils.py
check_status_code
def check_status_code(response, codes=None): """Check HTTP status code and raise exception if incorrect. :param Response response: HTTP response :param codes: List of accepted codes or callable :raises: ApiError if code invalid """ codes = codes or [httplib.OK] checker = ( codes ...
python
def check_status_code(response, codes=None): """Check HTTP status code and raise exception if incorrect. :param Response response: HTTP response :param codes: List of accepted codes or callable :raises: ApiError if code invalid """ codes = codes or [httplib.OK] checker = ( codes ...
[ "def", "check_status_code", "(", "response", ",", "codes", "=", "None", ")", ":", "codes", "=", "codes", "or", "[", "httplib", ".", "OK", "]", "checker", "=", "(", "codes", "if", "callable", "(", "codes", ")", "else", "lambda", "resp", ":", "resp", "...
Check HTTP status code and raise exception if incorrect. :param Response response: HTTP response :param codes: List of accepted codes or callable :raises: ApiError if code invalid
[ "Check", "HTTP", "status", "code", "and", "raise", "exception", "if", "incorrect", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/utils.py#L42-L56
train
jmcarp/betfair.py
betfair/utils.py
result_or_error
def result_or_error(response): """Get `result` field from Betfair response or raise exception if not found. :param Response response: :raises: ApiError if no results passed """ data = response.json() result = data.get('result') if result is not None: return result raise exce...
python
def result_or_error(response): """Get `result` field from Betfair response or raise exception if not found. :param Response response: :raises: ApiError if no results passed """ data = response.json() result = data.get('result') if result is not None: return result raise exce...
[ "def", "result_or_error", "(", "response", ")", ":", "data", "=", "response", ".", "json", "(", ")", "result", "=", "data", ".", "get", "(", "'result'", ")", "if", "result", "is", "not", "None", ":", "return", "result", "raise", "exceptions", ".", "Api...
Get `result` field from Betfair response or raise exception if not found. :param Response response: :raises: ApiError if no results passed
[ "Get", "result", "field", "from", "Betfair", "response", "or", "raise", "exception", "if", "not", "found", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/utils.py#L59-L70
train
jmcarp/betfair.py
betfair/utils.py
make_payload
def make_payload(base, method, params): """Build Betfair JSON-RPC payload. :param str base: Betfair base ("Sports" or "Account") :param str method: Betfair endpoint :param dict params: Request parameters """ payload = { 'jsonrpc': '2.0', 'method': '{base}APING/v1.0/{method}'.for...
python
def make_payload(base, method, params): """Build Betfair JSON-RPC payload. :param str base: Betfair base ("Sports" or "Account") :param str method: Betfair endpoint :param dict params: Request parameters """ payload = { 'jsonrpc': '2.0', 'method': '{base}APING/v1.0/{method}'.for...
[ "def", "make_payload", "(", "base", ",", "method", ",", "params", ")", ":", "payload", "=", "{", "'jsonrpc'", ":", "'2.0'", ",", "'method'", ":", "'{base}APING/v1.0/{method}'", ".", "format", "(", "**", "locals", "(", ")", ")", ",", "'params'", ":", "uti...
Build Betfair JSON-RPC payload. :param str base: Betfair base ("Sports" or "Account") :param str method: Betfair endpoint :param dict params: Request parameters
[ "Build", "Betfair", "JSON", "-", "RPC", "payload", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/utils.py#L100-L113
train
jmcarp/betfair.py
betfair/utils.py
requires_login
def requires_login(func, *args, **kwargs): """Decorator to check that the user is logged in. Raises `BetfairError` if instance variable `session_token` is absent. """ self = args[0] if self.session_token: return func(*args, **kwargs) raise exceptions.NotLoggedIn()
python
def requires_login(func, *args, **kwargs): """Decorator to check that the user is logged in. Raises `BetfairError` if instance variable `session_token` is absent. """ self = args[0] if self.session_token: return func(*args, **kwargs) raise exceptions.NotLoggedIn()
[ "def", "requires_login", "(", "func", ",", "*", "args", ",", "**", "kwargs", ")", ":", "self", "=", "args", "[", "0", "]", "if", "self", ".", "session_token", ":", "return", "func", "(", "*", "args", ",", "**", "kwargs", ")", "raise", "exceptions", ...
Decorator to check that the user is logged in. Raises `BetfairError` if instance variable `session_token` is absent.
[ "Decorator", "to", "check", "that", "the", "user", "is", "logged", "in", ".", "Raises", "BetfairError", "if", "instance", "variable", "session_token", "is", "absent", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/utils.py#L117-L124
train
jmcarp/betfair.py
betfair/price.py
nearest_price
def nearest_price(price, cutoffs=CUTOFFS): """Returns the nearest Betfair odds value to price. Adapted from Anton Zemlyanov's AlgoTrader project (MIT licensed). https://github.com/AlgoTrader/betfair-sports-api/blob/master/lib/betfair_price.js :param float price: Approximate Betfair price (i.e. decimal...
python
def nearest_price(price, cutoffs=CUTOFFS): """Returns the nearest Betfair odds value to price. Adapted from Anton Zemlyanov's AlgoTrader project (MIT licensed). https://github.com/AlgoTrader/betfair-sports-api/blob/master/lib/betfair_price.js :param float price: Approximate Betfair price (i.e. decimal...
[ "def", "nearest_price", "(", "price", ",", "cutoffs", "=", "CUTOFFS", ")", ":", "if", "price", "<=", "MIN_PRICE", ":", "return", "MIN_PRICE", "if", "price", ">", "MAX_PRICE", ":", "return", "MAX_PRICE", "price", "=", "as_dec", "(", "price", ")", "for", "...
Returns the nearest Betfair odds value to price. Adapted from Anton Zemlyanov's AlgoTrader project (MIT licensed). https://github.com/AlgoTrader/betfair-sports-api/blob/master/lib/betfair_price.js :param float price: Approximate Betfair price (i.e. decimal odds value) :param tuple cutoffs: Optional tu...
[ "Returns", "the", "nearest", "Betfair", "odds", "value", "to", "price", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/price.py#L49-L70
train
jmcarp/betfair.py
betfair/betfair.py
Betfair.login
def login(self, username, password): """Log in to Betfair. Sets `session_token` if successful. :param str username: Username :param str password: Password :raises: BetfairLoginError """ response = self.session.post( os.path.join(self.identity_url, 'certlogin'...
python
def login(self, username, password): """Log in to Betfair. Sets `session_token` if successful. :param str username: Username :param str password: Password :raises: BetfairLoginError """ response = self.session.post( os.path.join(self.identity_url, 'certlogin'...
[ "def", "login", "(", "self", ",", "username", ",", "password", ")", ":", "response", "=", "self", ".", "session", ".", "post", "(", "os", ".", "path", ".", "join", "(", "self", ".", "identity_url", ",", "'certlogin'", ")", ",", "cert", "=", "self", ...
Log in to Betfair. Sets `session_token` if successful. :param str username: Username :param str password: Password :raises: BetfairLoginError
[ "Log", "in", "to", "Betfair", ".", "Sets", "session_token", "if", "successful", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/betfair.py#L93-L117
train
jmcarp/betfair.py
betfair/betfair.py
Betfair.list_market_profit_and_loss
def list_market_profit_and_loss( self, market_ids, include_settled_bets=False, include_bsp_bets=None, net_of_commission=None): """Retrieve profit and loss for a given list of markets. :param list market_ids: List of markets to calculate profit and loss :param bool includ...
python
def list_market_profit_and_loss( self, market_ids, include_settled_bets=False, include_bsp_bets=None, net_of_commission=None): """Retrieve profit and loss for a given list of markets. :param list market_ids: List of markets to calculate profit and loss :param bool includ...
[ "def", "list_market_profit_and_loss", "(", "self", ",", "market_ids", ",", "include_settled_bets", "=", "False", ",", "include_bsp_bets", "=", "None", ",", "net_of_commission", "=", "None", ")", ":", "return", "self", ".", "make_api_request", "(", "'Sports'", ",",...
Retrieve profit and loss for a given list of markets. :param list market_ids: List of markets to calculate profit and loss :param bool include_settled_bets: Option to include settled bets :param bool include_bsp_bets: Option to include BSP bets :param bool net_of_commission: Option to r...
[ "Retrieve", "profit", "and", "loss", "for", "a", "given", "list", "of", "markets", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/betfair.py#L284-L301
train
jmcarp/betfair.py
betfair/betfair.py
Betfair.iter_list_market_book
def iter_list_market_book(self, market_ids, chunk_size, **kwargs): """Split call to `list_market_book` into separate requests. :param list market_ids: List of market IDs :param int chunk_size: Number of records per chunk :param dict kwargs: Arguments passed to `list_market_book` ...
python
def iter_list_market_book(self, market_ids, chunk_size, **kwargs): """Split call to `list_market_book` into separate requests. :param list market_ids: List of market IDs :param int chunk_size: Number of records per chunk :param dict kwargs: Arguments passed to `list_market_book` ...
[ "def", "iter_list_market_book", "(", "self", ",", "market_ids", ",", "chunk_size", ",", "**", "kwargs", ")", ":", "return", "itertools", ".", "chain", "(", "*", "(", "self", ".", "list_market_book", "(", "market_chunk", ",", "**", "kwargs", ")", "for", "ma...
Split call to `list_market_book` into separate requests. :param list market_ids: List of market IDs :param int chunk_size: Number of records per chunk :param dict kwargs: Arguments passed to `list_market_book`
[ "Split", "call", "to", "list_market_book", "into", "separate", "requests", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/betfair.py#L305-L315
train
jmcarp/betfair.py
betfair/betfair.py
Betfair.iter_list_market_profit_and_loss
def iter_list_market_profit_and_loss( self, market_ids, chunk_size, **kwargs): """Split call to `list_market_profit_and_loss` into separate requests. :param list market_ids: List of market IDs :param int chunk_size: Number of records per chunk :param dict kwargs: Arguments p...
python
def iter_list_market_profit_and_loss( self, market_ids, chunk_size, **kwargs): """Split call to `list_market_profit_and_loss` into separate requests. :param list market_ids: List of market IDs :param int chunk_size: Number of records per chunk :param dict kwargs: Arguments p...
[ "def", "iter_list_market_profit_and_loss", "(", "self", ",", "market_ids", ",", "chunk_size", ",", "**", "kwargs", ")", ":", "return", "itertools", ".", "chain", "(", "*", "(", "self", ".", "list_market_profit_and_loss", "(", "market_chunk", ",", "**", "kwargs",...
Split call to `list_market_profit_and_loss` into separate requests. :param list market_ids: List of market IDs :param int chunk_size: Number of records per chunk :param dict kwargs: Arguments passed to `list_market_profit_and_loss`
[ "Split", "call", "to", "list_market_profit_and_loss", "into", "separate", "requests", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/betfair.py#L317-L328
train
jmcarp/betfair.py
betfair/betfair.py
Betfair.place_orders
def place_orders(self, market_id, instructions, customer_ref=None): """Place new orders into market. This operation is atomic in that all orders will be placed or none will be placed. :param str market_id: The market id these orders are to be placed on :param list instructions: List of ...
python
def place_orders(self, market_id, instructions, customer_ref=None): """Place new orders into market. This operation is atomic in that all orders will be placed or none will be placed. :param str market_id: The market id these orders are to be placed on :param list instructions: List of ...
[ "def", "place_orders", "(", "self", ",", "market_id", ",", "instructions", ",", "customer_ref", "=", "None", ")", ":", "return", "self", ".", "make_api_request", "(", "'Sports'", ",", "'placeOrders'", ",", "utils", ".", "get_kwargs", "(", "locals", "(", ")",...
Place new orders into market. This operation is atomic in that all orders will be placed or none will be placed. :param str market_id: The market id these orders are to be placed on :param list instructions: List of `PlaceInstruction` objects :param str customer_ref: Optional order iden...
[ "Place", "new", "orders", "into", "market", ".", "This", "operation", "is", "atomic", "in", "that", "all", "orders", "will", "be", "placed", "or", "none", "will", "be", "placed", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/betfair.py#L384-L397
train
jmcarp/betfair.py
betfair/betfair.py
Betfair.update_orders
def update_orders(self, market_id, instructions, customer_ref=None): """Update non-exposure changing fields. :param str market_id: The market id these orders are to be placed on :param list instructions: List of `UpdateInstruction` objects :param str customer_ref: Optional order identif...
python
def update_orders(self, market_id, instructions, customer_ref=None): """Update non-exposure changing fields. :param str market_id: The market id these orders are to be placed on :param list instructions: List of `UpdateInstruction` objects :param str customer_ref: Optional order identif...
[ "def", "update_orders", "(", "self", ",", "market_id", ",", "instructions", ",", "customer_ref", "=", "None", ")", ":", "return", "self", ".", "make_api_request", "(", "'Sports'", ",", "'updateOrders'", ",", "utils", ".", "get_kwargs", "(", "locals", "(", ")...
Update non-exposure changing fields. :param str market_id: The market id these orders are to be placed on :param list instructions: List of `UpdateInstruction` objects :param str customer_ref: Optional order identifier string
[ "Update", "non", "-", "exposure", "changing", "fields", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/betfair.py#L432-L444
train
jmcarp/betfair.py
betfair/betfair.py
Betfair.transfer_funds
def transfer_funds(self, from_, to, amount): """Transfer funds between the UK Exchange and Australian Exchange wallets. :param Wallet from_: Source wallet :param Wallet to: Destination wallet :param float amount: Amount to transfer """ return self.make_api_request( ...
python
def transfer_funds(self, from_, to, amount): """Transfer funds between the UK Exchange and Australian Exchange wallets. :param Wallet from_: Source wallet :param Wallet to: Destination wallet :param float amount: Amount to transfer """ return self.make_api_request( ...
[ "def", "transfer_funds", "(", "self", ",", "from_", ",", "to", ",", "amount", ")", ":", "return", "self", ".", "make_api_request", "(", "'Account'", ",", "'transferFunds'", ",", "utils", ".", "get_kwargs", "(", "locals", "(", ")", ")", ",", "model", "=",...
Transfer funds between the UK Exchange and Australian Exchange wallets. :param Wallet from_: Source wallet :param Wallet to: Destination wallet :param float amount: Amount to transfer
[ "Transfer", "funds", "between", "the", "UK", "Exchange", "and", "Australian", "Exchange", "wallets", "." ]
116df2fdc512575d1b4c4f1749d4a5bf98e519ff
https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/betfair.py#L505-L517
train
edmondburnett/twitter-text-python
ttp/ttp.py
Parser.parse
def parse(self, text, html=True): '''Parse the text and return a ParseResult instance.''' self._urls = [] self._users = [] self._lists = [] self._tags = [] reply = REPLY_REGEX.match(text) reply = reply.groups(0)[0] if reply is not None else None parsed_h...
python
def parse(self, text, html=True): '''Parse the text and return a ParseResult instance.''' self._urls = [] self._users = [] self._lists = [] self._tags = [] reply = REPLY_REGEX.match(text) reply = reply.groups(0)[0] if reply is not None else None parsed_h...
[ "def", "parse", "(", "self", ",", "text", ",", "html", "=", "True", ")", ":", "self", ".", "_urls", "=", "[", "]", "self", ".", "_users", "=", "[", "]", "self", ".", "_lists", "=", "[", "]", "self", ".", "_tags", "=", "[", "]", "reply", "=", ...
Parse the text and return a ParseResult instance.
[ "Parse", "the", "text", "and", "return", "a", "ParseResult", "instance", "." ]
2a23ced35bfd34c4bc4b7148afd85771e9eb8669
https://github.com/edmondburnett/twitter-text-python/blob/2a23ced35bfd34c4bc4b7148afd85771e9eb8669/ttp/ttp.py#L125-L137
train
edmondburnett/twitter-text-python
ttp/ttp.py
Parser._text
def _text(self, text): '''Parse a Tweet without generating HTML.''' URL_REGEX.sub(self._parse_urls, text) USERNAME_REGEX.sub(self._parse_users, text) LIST_REGEX.sub(self._parse_lists, text) HASHTAG_REGEX.sub(self._parse_tags, text) return None
python
def _text(self, text): '''Parse a Tweet without generating HTML.''' URL_REGEX.sub(self._parse_urls, text) USERNAME_REGEX.sub(self._parse_users, text) LIST_REGEX.sub(self._parse_lists, text) HASHTAG_REGEX.sub(self._parse_tags, text) return None
[ "def", "_text", "(", "self", ",", "text", ")", ":", "URL_REGEX", ".", "sub", "(", "self", ".", "_parse_urls", ",", "text", ")", "USERNAME_REGEX", ".", "sub", "(", "self", ".", "_parse_users", ",", "text", ")", "LIST_REGEX", ".", "sub", "(", "self", "...
Parse a Tweet without generating HTML.
[ "Parse", "a", "Tweet", "without", "generating", "HTML", "." ]
2a23ced35bfd34c4bc4b7148afd85771e9eb8669
https://github.com/edmondburnett/twitter-text-python/blob/2a23ced35bfd34c4bc4b7148afd85771e9eb8669/ttp/ttp.py#L139-L145
train
edmondburnett/twitter-text-python
ttp/ttp.py
Parser._html
def _html(self, text): '''Parse a Tweet and generate HTML.''' html = URL_REGEX.sub(self._parse_urls, text) html = USERNAME_REGEX.sub(self._parse_users, html) html = LIST_REGEX.sub(self._parse_lists, html) return HASHTAG_REGEX.sub(self._parse_tags, html)
python
def _html(self, text): '''Parse a Tweet and generate HTML.''' html = URL_REGEX.sub(self._parse_urls, text) html = USERNAME_REGEX.sub(self._parse_users, html) html = LIST_REGEX.sub(self._parse_lists, html) return HASHTAG_REGEX.sub(self._parse_tags, html)
[ "def", "_html", "(", "self", ",", "text", ")", ":", "html", "=", "URL_REGEX", ".", "sub", "(", "self", ".", "_parse_urls", ",", "text", ")", "html", "=", "USERNAME_REGEX", ".", "sub", "(", "self", ".", "_parse_users", ",", "html", ")", "html", "=", ...
Parse a Tweet and generate HTML.
[ "Parse", "a", "Tweet", "and", "generate", "HTML", "." ]
2a23ced35bfd34c4bc4b7148afd85771e9eb8669
https://github.com/edmondburnett/twitter-text-python/blob/2a23ced35bfd34c4bc4b7148afd85771e9eb8669/ttp/ttp.py#L147-L152
train
edmondburnett/twitter-text-python
ttp/ttp.py
Parser._parse_urls
def _parse_urls(self, match): '''Parse URLs.''' mat = match.group(0) # Fix a bug in the regex concerning www...com and www.-foo.com domains # TODO fix this in the regex instead of working around it here domain = match.group(5) if domain[0] in '.-': return ma...
python
def _parse_urls(self, match): '''Parse URLs.''' mat = match.group(0) # Fix a bug in the regex concerning www...com and www.-foo.com domains # TODO fix this in the regex instead of working around it here domain = match.group(5) if domain[0] in '.-': return ma...
[ "def", "_parse_urls", "(", "self", ",", "match", ")", ":", "mat", "=", "match", ".", "group", "(", "0", ")", "domain", "=", "match", ".", "group", "(", "5", ")", "if", "domain", "[", "0", "]", "in", "'.-'", ":", "return", "mat", "if", "len", "(...
Parse URLs.
[ "Parse", "URLs", "." ]
2a23ced35bfd34c4bc4b7148afd85771e9eb8669
https://github.com/edmondburnett/twitter-text-python/blob/2a23ced35bfd34c4bc4b7148afd85771e9eb8669/ttp/ttp.py#L155-L195
train
edmondburnett/twitter-text-python
ttp/ttp.py
Parser._parse_users
def _parse_users(self, match): '''Parse usernames.''' # Don't parse lists here if match.group(2) is not None: return match.group(0) mat = match.group(0) if self._include_spans: self._users.append((mat[1:], match.span(0))) else: self._...
python
def _parse_users(self, match): '''Parse usernames.''' # Don't parse lists here if match.group(2) is not None: return match.group(0) mat = match.group(0) if self._include_spans: self._users.append((mat[1:], match.span(0))) else: self._...
[ "def", "_parse_users", "(", "self", ",", "match", ")", ":", "if", "match", ".", "group", "(", "2", ")", "is", "not", "None", ":", "return", "match", ".", "group", "(", "0", ")", "mat", "=", "match", ".", "group", "(", "0", ")", "if", "self", "....
Parse usernames.
[ "Parse", "usernames", "." ]
2a23ced35bfd34c4bc4b7148afd85771e9eb8669
https://github.com/edmondburnett/twitter-text-python/blob/2a23ced35bfd34c4bc4b7148afd85771e9eb8669/ttp/ttp.py#L197-L211
train
edmondburnett/twitter-text-python
ttp/ttp.py
Parser._parse_lists
def _parse_lists(self, match): '''Parse lists.''' # Don't parse usernames here if match.group(4) is None: return match.group(0) pre, at_char, user, list_name = match.groups() list_name = list_name[1:] if self._include_spans: self._lists.append((u...
python
def _parse_lists(self, match): '''Parse lists.''' # Don't parse usernames here if match.group(4) is None: return match.group(0) pre, at_char, user, list_name = match.groups() list_name = list_name[1:] if self._include_spans: self._lists.append((u...
[ "def", "_parse_lists", "(", "self", ",", "match", ")", ":", "if", "match", ".", "group", "(", "4", ")", "is", "None", ":", "return", "match", ".", "group", "(", "0", ")", "pre", ",", "at_char", ",", "user", ",", "list_name", "=", "match", ".", "g...
Parse lists.
[ "Parse", "lists", "." ]
2a23ced35bfd34c4bc4b7148afd85771e9eb8669
https://github.com/edmondburnett/twitter-text-python/blob/2a23ced35bfd34c4bc4b7148afd85771e9eb8669/ttp/ttp.py#L213-L228
train
edmondburnett/twitter-text-python
ttp/ttp.py
Parser._parse_tags
def _parse_tags(self, match): '''Parse hashtags.''' mat = match.group(0) # Fix problems with the regex capturing stuff infront of the # tag = None for i in '#\uff03': pos = mat.rfind(i) if pos != -1: tag = i break ...
python
def _parse_tags(self, match): '''Parse hashtags.''' mat = match.group(0) # Fix problems with the regex capturing stuff infront of the # tag = None for i in '#\uff03': pos = mat.rfind(i) if pos != -1: tag = i break ...
[ "def", "_parse_tags", "(", "self", ",", "match", ")", ":", "mat", "=", "match", ".", "group", "(", "0", ")", "tag", "=", "None", "for", "i", "in", "'#\\uff03'", ":", "pos", "=", "mat", ".", "rfind", "(", "i", ")", "if", "pos", "!=", "-", "1", ...
Parse hashtags.
[ "Parse", "hashtags", "." ]
2a23ced35bfd34c4bc4b7148afd85771e9eb8669
https://github.com/edmondburnett/twitter-text-python/blob/2a23ced35bfd34c4bc4b7148afd85771e9eb8669/ttp/ttp.py#L230-L253
train
edmondburnett/twitter-text-python
ttp/ttp.py
Parser._shorten_url
def _shorten_url(self, text): '''Shorten a URL and make sure to not cut of html entities.''' if len(text) > self._max_url_length and self._max_url_length != -1: text = text[0:self._max_url_length - 3] amp = text.rfind('&') close = text.rfind(';') if amp !...
python
def _shorten_url(self, text): '''Shorten a URL and make sure to not cut of html entities.''' if len(text) > self._max_url_length and self._max_url_length != -1: text = text[0:self._max_url_length - 3] amp = text.rfind('&') close = text.rfind(';') if amp !...
[ "def", "_shorten_url", "(", "self", ",", "text", ")", ":", "if", "len", "(", "text", ")", ">", "self", ".", "_max_url_length", "and", "self", ".", "_max_url_length", "!=", "-", "1", ":", "text", "=", "text", "[", "0", ":", "self", ".", "_max_url_leng...
Shorten a URL and make sure to not cut of html entities.
[ "Shorten", "a", "URL", "and", "make", "sure", "to", "not", "cut", "of", "html", "entities", "." ]
2a23ced35bfd34c4bc4b7148afd85771e9eb8669
https://github.com/edmondburnett/twitter-text-python/blob/2a23ced35bfd34c4bc4b7148afd85771e9eb8669/ttp/ttp.py#L255-L268
train
edmondburnett/twitter-text-python
ttp/ttp.py
Parser.format_list
def format_list(self, at_char, user, list_name): '''Return formatted HTML for a list.''' return '<a href="https://twitter.com/%s/lists/%s">%s%s/%s</a>' \ % (user, list_name, at_char, user, list_name)
python
def format_list(self, at_char, user, list_name): '''Return formatted HTML for a list.''' return '<a href="https://twitter.com/%s/lists/%s">%s%s/%s</a>' \ % (user, list_name, at_char, user, list_name)
[ "def", "format_list", "(", "self", ",", "at_char", ",", "user", ",", "list_name", ")", ":", "return", "'<a href=\"https://twitter.com/%s/lists/%s\">%s%s/%s</a>'", "%", "(", "user", ",", "list_name", ",", "at_char", ",", "user", ",", "list_name", ")" ]
Return formatted HTML for a list.
[ "Return", "formatted", "HTML", "for", "a", "list", "." ]
2a23ced35bfd34c4bc4b7148afd85771e9eb8669
https://github.com/edmondburnett/twitter-text-python/blob/2a23ced35bfd34c4bc4b7148afd85771e9eb8669/ttp/ttp.py#L281-L284
train
edmondburnett/twitter-text-python
ttp/utils.py
follow_shortlinks
def follow_shortlinks(shortlinks): """Follow redirects in list of shortlinks, return dict of resulting URLs""" links_followed = {} for shortlink in shortlinks: url = shortlink request_result = requests.get(url) redirect_history = request_result.history # history might look li...
python
def follow_shortlinks(shortlinks): """Follow redirects in list of shortlinks, return dict of resulting URLs""" links_followed = {} for shortlink in shortlinks: url = shortlink request_result = requests.get(url) redirect_history = request_result.history # history might look li...
[ "def", "follow_shortlinks", "(", "shortlinks", ")", ":", "links_followed", "=", "{", "}", "for", "shortlink", "in", "shortlinks", ":", "url", "=", "shortlink", "request_result", "=", "requests", ".", "get", "(", "url", ")", "redirect_history", "=", "request_re...
Follow redirects in list of shortlinks, return dict of resulting URLs
[ "Follow", "redirects", "in", "list", "of", "shortlinks", "return", "dict", "of", "resulting", "URLs" ]
2a23ced35bfd34c4bc4b7148afd85771e9eb8669
https://github.com/edmondburnett/twitter-text-python/blob/2a23ced35bfd34c4bc4b7148afd85771e9eb8669/ttp/utils.py#L8-L24
train
cloudendpoints/endpoints-python
endpoints/resource_container.py
_GetFieldAttributes
def _GetFieldAttributes(field): """Decomposes field into the needed arguments to pass to the constructor. This can be used to create copies of the field or to compare if two fields are "equal" (since __eq__ is not implemented on messages.Field). Args: field: A ProtoRPC message field (potentially to be cop...
python
def _GetFieldAttributes(field): """Decomposes field into the needed arguments to pass to the constructor. This can be used to create copies of the field or to compare if two fields are "equal" (since __eq__ is not implemented on messages.Field). Args: field: A ProtoRPC message field (potentially to be cop...
[ "def", "_GetFieldAttributes", "(", "field", ")", ":", "if", "not", "isinstance", "(", "field", ",", "messages", ".", "Field", ")", ":", "raise", "TypeError", "(", "'Field %r to be copied not a ProtoRPC field.'", "%", "(", "field", ",", ")", ")", "positional_args...
Decomposes field into the needed arguments to pass to the constructor. This can be used to create copies of the field or to compare if two fields are "equal" (since __eq__ is not implemented on messages.Field). Args: field: A ProtoRPC message field (potentially to be copied). Raises: TypeError: If th...
[ "Decomposes", "field", "into", "the", "needed", "arguments", "to", "pass", "to", "the", "constructor", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/resource_container.py#L142-L178
train
cloudendpoints/endpoints-python
endpoints/resource_container.py
_CompareFields
def _CompareFields(field, other_field): """Checks if two ProtoRPC fields are "equal". Compares the arguments, rather than the id of the elements (which is the default __eq__ behavior) as well as the class of the fields. Args: field: A ProtoRPC message field to be compared. other_field: A ProtoRPC mess...
python
def _CompareFields(field, other_field): """Checks if two ProtoRPC fields are "equal". Compares the arguments, rather than the id of the elements (which is the default __eq__ behavior) as well as the class of the fields. Args: field: A ProtoRPC message field to be compared. other_field: A ProtoRPC mess...
[ "def", "_CompareFields", "(", "field", ",", "other_field", ")", ":", "field_attrs", "=", "_GetFieldAttributes", "(", "field", ")", "other_field_attrs", "=", "_GetFieldAttributes", "(", "other_field", ")", "if", "field_attrs", "!=", "other_field_attrs", ":", "return"...
Checks if two ProtoRPC fields are "equal". Compares the arguments, rather than the id of the elements (which is the default __eq__ behavior) as well as the class of the fields. Args: field: A ProtoRPC message field to be compared. other_field: A ProtoRPC message field to be compared. Returns: Boo...
[ "Checks", "if", "two", "ProtoRPC", "fields", "are", "equal", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/resource_container.py#L181-L198
train
cloudendpoints/endpoints-python
endpoints/resource_container.py
ResourceContainer.combined_message_class
def combined_message_class(self): """A ProtoRPC message class with both request and parameters fields. Caches the result in a local private variable. Uses _CopyField to create copies of the fields from the existing request and parameters classes since those fields are "owned" by the message classes. ...
python
def combined_message_class(self): """A ProtoRPC message class with both request and parameters fields. Caches the result in a local private variable. Uses _CopyField to create copies of the fields from the existing request and parameters classes since those fields are "owned" by the message classes. ...
[ "def", "combined_message_class", "(", "self", ")", ":", "if", "self", ".", "__combined_message_class", "is", "not", "None", ":", "return", "self", ".", "__combined_message_class", "fields", "=", "{", "}", "field_number", "=", "1", "for", "field", "in", "self",...
A ProtoRPC message class with both request and parameters fields. Caches the result in a local private variable. Uses _CopyField to create copies of the fields from the existing request and parameters classes since those fields are "owned" by the message classes. Raises: TypeError: If a field na...
[ "A", "ProtoRPC", "message", "class", "with", "both", "request", "and", "parameters", "fields", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/resource_container.py#L58-L100
train
cloudendpoints/endpoints-python
endpoints/resource_container.py
ResourceContainer.add_to_cache
def add_to_cache(cls, remote_info, container): # pylint: disable=g-bad-name """Adds a ResourceContainer to a cache tying it to a protorpc method. Args: remote_info: Instance of protorpc.remote._RemoteMethodInfo corresponding to a method. container: An instance of ResourceContainer. ...
python
def add_to_cache(cls, remote_info, container): # pylint: disable=g-bad-name """Adds a ResourceContainer to a cache tying it to a protorpc method. Args: remote_info: Instance of protorpc.remote._RemoteMethodInfo corresponding to a method. container: An instance of ResourceContainer. ...
[ "def", "add_to_cache", "(", "cls", ",", "remote_info", ",", "container", ")", ":", "if", "not", "isinstance", "(", "container", ",", "cls", ")", ":", "raise", "TypeError", "(", "'%r not an instance of %r, could not be added to cache.'", "%", "(", "container", ",",...
Adds a ResourceContainer to a cache tying it to a protorpc method. Args: remote_info: Instance of protorpc.remote._RemoteMethodInfo corresponding to a method. container: An instance of ResourceContainer. Raises: TypeError: if the container is not an instance of cls. KeyError:...
[ "Adds", "a", "ResourceContainer", "to", "a", "cache", "tying", "it", "to", "a", "protorpc", "method", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/resource_container.py#L103-L122
train
cloudendpoints/endpoints-python
endpoints/resource_container.py
ResourceContainer.get_request_message
def get_request_message(cls, remote_info): # pylint: disable=g-bad-name """Gets request message or container from remote info. Args: remote_info: Instance of protorpc.remote._RemoteMethodInfo corresponding to a method. Returns: Either an instance of the request type from the remote ...
python
def get_request_message(cls, remote_info): # pylint: disable=g-bad-name """Gets request message or container from remote info. Args: remote_info: Instance of protorpc.remote._RemoteMethodInfo corresponding to a method. Returns: Either an instance of the request type from the remote ...
[ "def", "get_request_message", "(", "cls", ",", "remote_info", ")", ":", "if", "remote_info", "in", "cls", ".", "__remote_info_cache", ":", "return", "cls", ".", "__remote_info_cache", "[", "remote_info", "]", "else", ":", "return", "remote_info", ".", "request_t...
Gets request message or container from remote info. Args: remote_info: Instance of protorpc.remote._RemoteMethodInfo corresponding to a method. Returns: Either an instance of the request type from the remote or the ResourceContainer that was cached with the remote method.
[ "Gets", "request", "message", "or", "container", "from", "remote", "info", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/resource_container.py#L125-L139
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_is_auth_info_available
def _is_auth_info_available(): """Check if user auth info has been set in environment variables.""" return (_ENDPOINTS_USER_INFO in os.environ or (_ENV_AUTH_EMAIL in os.environ and _ENV_AUTH_DOMAIN in os.environ) or _ENV_USE_OAUTH_SCOPE in os.environ)
python
def _is_auth_info_available(): """Check if user auth info has been set in environment variables.""" return (_ENDPOINTS_USER_INFO in os.environ or (_ENV_AUTH_EMAIL in os.environ and _ENV_AUTH_DOMAIN in os.environ) or _ENV_USE_OAUTH_SCOPE in os.environ)
[ "def", "_is_auth_info_available", "(", ")", ":", "return", "(", "_ENDPOINTS_USER_INFO", "in", "os", ".", "environ", "or", "(", "_ENV_AUTH_EMAIL", "in", "os", ".", "environ", "and", "_ENV_AUTH_DOMAIN", "in", "os", ".", "environ", ")", "or", "_ENV_USE_OAUTH_SCOPE"...
Check if user auth info has been set in environment variables.
[ "Check", "if", "user", "auth", "info", "has", "been", "set", "in", "environment", "variables", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L151-L155
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_get_token
def _get_token( request=None, allowed_auth_schemes=('OAuth', 'Bearer'), allowed_query_keys=('bearer_token', 'access_token')): """Get the auth token for this request. Auth token may be specified in either the Authorization header or as a query param (either access_token or bearer_token). We'll check in ...
python
def _get_token( request=None, allowed_auth_schemes=('OAuth', 'Bearer'), allowed_query_keys=('bearer_token', 'access_token')): """Get the auth token for this request. Auth token may be specified in either the Authorization header or as a query param (either access_token or bearer_token). We'll check in ...
[ "def", "_get_token", "(", "request", "=", "None", ",", "allowed_auth_schemes", "=", "(", "'OAuth'", ",", "'Bearer'", ")", ",", "allowed_query_keys", "=", "(", "'bearer_token'", ",", "'access_token'", ")", ")", ":", "allowed_auth_schemes", "=", "_listlike_guard", ...
Get the auth token for this request. Auth token may be specified in either the Authorization header or as a query param (either access_token or bearer_token). We'll check in this order: 1. Authorization header. 2. bearer_token query param. 3. access_token query param. Args: request: The curre...
[ "Get", "the", "auth", "token", "for", "this", "request", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L248-L285
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_get_id_token_user
def _get_id_token_user(token, issuers, audiences, allowed_client_ids, time_now, cache): """Get a User for the given id token, if the token is valid. Args: token: The id_token to check. issuers: dict of Issuers audiences: List of audiences that are acceptable. allowed_client_ids: List of client IDs ...
python
def _get_id_token_user(token, issuers, audiences, allowed_client_ids, time_now, cache): """Get a User for the given id token, if the token is valid. Args: token: The id_token to check. issuers: dict of Issuers audiences: List of audiences that are acceptable. allowed_client_ids: List of client IDs ...
[ "def", "_get_id_token_user", "(", "token", ",", "issuers", ",", "audiences", ",", "allowed_client_ids", ",", "time_now", ",", "cache", ")", ":", "for", "issuer_key", ",", "issuer", "in", "issuers", ".", "items", "(", ")", ":", "issuer_cert_uri", "=", "conver...
Get a User for the given id token, if the token is valid. Args: token: The id_token to check. issuers: dict of Issuers audiences: List of audiences that are acceptable. allowed_client_ids: List of client IDs that are acceptable. time_now: The current time as a long (eg. long(time.time())). ca...
[ "Get", "a", "User", "for", "the", "given", "id", "token", "if", "the", "token", "is", "valid", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L288-L330
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_process_scopes
def _process_scopes(scopes): """Parse a scopes list into a set of all scopes and a set of sufficient scope sets. scopes: A list of strings, each of which is a space-separated list of scopes. Examples: ['scope1'] ['scope1', 'scope2'] ['scope1', 'scope2 scope3'] Retu...
python
def _process_scopes(scopes): """Parse a scopes list into a set of all scopes and a set of sufficient scope sets. scopes: A list of strings, each of which is a space-separated list of scopes. Examples: ['scope1'] ['scope1', 'scope2'] ['scope1', 'scope2 scope3'] Retu...
[ "def", "_process_scopes", "(", "scopes", ")", ":", "all_scopes", "=", "set", "(", ")", "sufficient_scopes", "=", "set", "(", ")", "for", "scope_set", "in", "scopes", ":", "scope_set_scopes", "=", "frozenset", "(", "scope_set", ".", "split", "(", ")", ")", ...
Parse a scopes list into a set of all scopes and a set of sufficient scope sets. scopes: A list of strings, each of which is a space-separated list of scopes. Examples: ['scope1'] ['scope1', 'scope2'] ['scope1', 'scope2 scope3'] Returns: all_scopes: a set of s...
[ "Parse", "a", "scopes", "list", "into", "a", "set", "of", "all", "scopes", "and", "a", "set", "of", "sufficient", "scope", "sets", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L342-L362
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_are_scopes_sufficient
def _are_scopes_sufficient(authorized_scopes, sufficient_scopes): """Check if a list of authorized scopes satisfies any set of sufficient scopes. Args: authorized_scopes: a list of strings, return value from oauth.get_authorized_scopes sufficient_scopes: a set of sets of strings, return value from...
python
def _are_scopes_sufficient(authorized_scopes, sufficient_scopes): """Check if a list of authorized scopes satisfies any set of sufficient scopes. Args: authorized_scopes: a list of strings, return value from oauth.get_authorized_scopes sufficient_scopes: a set of sets of strings, return value from...
[ "def", "_are_scopes_sufficient", "(", "authorized_scopes", ",", "sufficient_scopes", ")", ":", "for", "sufficient_scope_set", "in", "sufficient_scopes", ":", "if", "sufficient_scope_set", ".", "issubset", "(", "authorized_scopes", ")", ":", "return", "True", "return", ...
Check if a list of authorized scopes satisfies any set of sufficient scopes. Args: authorized_scopes: a list of strings, return value from oauth.get_authorized_scopes sufficient_scopes: a set of sets of strings, return value from _process_scopes
[ "Check", "if", "a", "list", "of", "authorized", "scopes", "satisfies", "any", "set", "of", "sufficient", "scopes", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L365-L375
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_set_bearer_user_vars
def _set_bearer_user_vars(allowed_client_ids, scopes): """Validate the oauth bearer token and set endpoints auth user variables. If the bearer token is valid, this sets ENDPOINTS_USE_OAUTH_SCOPE. This provides enough information that our endpoints.get_current_user() function can get the user. Args: all...
python
def _set_bearer_user_vars(allowed_client_ids, scopes): """Validate the oauth bearer token and set endpoints auth user variables. If the bearer token is valid, this sets ENDPOINTS_USE_OAUTH_SCOPE. This provides enough information that our endpoints.get_current_user() function can get the user. Args: all...
[ "def", "_set_bearer_user_vars", "(", "allowed_client_ids", ",", "scopes", ")", ":", "all_scopes", ",", "sufficient_scopes", "=", "_process_scopes", "(", "scopes", ")", "try", ":", "authorized_scopes", "=", "oauth", ".", "get_authorized_scopes", "(", "sorted", "(", ...
Validate the oauth bearer token and set endpoints auth user variables. If the bearer token is valid, this sets ENDPOINTS_USE_OAUTH_SCOPE. This provides enough information that our endpoints.get_current_user() function can get the user. Args: allowed_client_ids: List of client IDs that are acceptable. ...
[ "Validate", "the", "oauth", "bearer", "token", "and", "set", "endpoints", "auth", "user", "variables", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L379-L410
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_set_bearer_user_vars_local
def _set_bearer_user_vars_local(token, allowed_client_ids, scopes): """Validate the oauth bearer token on the dev server. Since the functions in the oauth module return only example results in local development, this hits the tokeninfo endpoint and attempts to validate the token. If it's valid, we'll set _ENV...
python
def _set_bearer_user_vars_local(token, allowed_client_ids, scopes): """Validate the oauth bearer token on the dev server. Since the functions in the oauth module return only example results in local development, this hits the tokeninfo endpoint and attempts to validate the token. If it's valid, we'll set _ENV...
[ "def", "_set_bearer_user_vars_local", "(", "token", ",", "allowed_client_ids", ",", "scopes", ")", ":", "result", "=", "urlfetch", ".", "fetch", "(", "'%s?%s'", "%", "(", "_TOKENINFO_URL", ",", "urllib", ".", "urlencode", "(", "{", "'access_token'", ":", "toke...
Validate the oauth bearer token on the dev server. Since the functions in the oauth module return only example results in local development, this hits the tokeninfo endpoint and attempts to validate the token. If it's valid, we'll set _ENV_AUTH_EMAIL and _ENV_AUTH_DOMAIN so we can get the user from the token....
[ "Validate", "the", "oauth", "bearer", "token", "on", "the", "dev", "server", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L413-L463
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_verify_parsed_token
def _verify_parsed_token(parsed_token, issuers, audiences, allowed_client_ids, is_legacy_google_auth=True): """Verify a parsed user ID token. Args: parsed_token: The parsed token information. issuers: A list of allowed issuers audiences: The allowed audiences. allowed_client_ids: The allowed client...
python
def _verify_parsed_token(parsed_token, issuers, audiences, allowed_client_ids, is_legacy_google_auth=True): """Verify a parsed user ID token. Args: parsed_token: The parsed token information. issuers: A list of allowed issuers audiences: The allowed audiences. allowed_client_ids: The allowed client...
[ "def", "_verify_parsed_token", "(", "parsed_token", ",", "issuers", ",", "audiences", ",", "allowed_client_ids", ",", "is_legacy_google_auth", "=", "True", ")", ":", "if", "parsed_token", ".", "get", "(", "'iss'", ")", "not", "in", "issuers", ":", "_logger", "...
Verify a parsed user ID token. Args: parsed_token: The parsed token information. issuers: A list of allowed issuers audiences: The allowed audiences. allowed_client_ids: The allowed client IDs. Returns: True if the token is verified, False otherwise.
[ "Verify", "a", "parsed", "user", "ID", "token", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L470-L514
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_get_cert_expiration_time
def _get_cert_expiration_time(headers): """Get the expiration time for a cert, given the response headers. Get expiration time from the headers in the result. If we can't get a time from the headers, this returns 0, indicating that the cert shouldn't be cached. Args: headers: A dict containing the resp...
python
def _get_cert_expiration_time(headers): """Get the expiration time for a cert, given the response headers. Get expiration time from the headers in the result. If we can't get a time from the headers, this returns 0, indicating that the cert shouldn't be cached. Args: headers: A dict containing the resp...
[ "def", "_get_cert_expiration_time", "(", "headers", ")", ":", "cache_control", "=", "headers", ".", "get", "(", "'Cache-Control'", ",", "''", ")", "for", "entry", "in", "cache_control", ".", "split", "(", "','", ")", ":", "match", "=", "_MAX_AGE_REGEX", ".",...
Get the expiration time for a cert, given the response headers. Get expiration time from the headers in the result. If we can't get a time from the headers, this returns 0, indicating that the cert shouldn't be cached. Args: headers: A dict containing the response headers from the request to get ce...
[ "Get", "the", "expiration", "time", "for", "a", "cert", "given", "the", "response", "headers", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L524-L561
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_get_cached_certs
def _get_cached_certs(cert_uri, cache): """Get certs from cache if present; otherwise, gets from URI and caches them. Args: cert_uri: URI from which to retrieve certs if cache is stale or empty. cache: Cache of pre-fetched certs. Returns: The retrieved certs. """ certs = cache.get(cert_uri, name...
python
def _get_cached_certs(cert_uri, cache): """Get certs from cache if present; otherwise, gets from URI and caches them. Args: cert_uri: URI from which to retrieve certs if cache is stale or empty. cache: Cache of pre-fetched certs. Returns: The retrieved certs. """ certs = cache.get(cert_uri, name...
[ "def", "_get_cached_certs", "(", "cert_uri", ",", "cache", ")", ":", "certs", "=", "cache", ".", "get", "(", "cert_uri", ",", "namespace", "=", "_CERT_NAMESPACE", ")", "if", "certs", "is", "None", ":", "_logger", ".", "debug", "(", "'Cert cache miss for %s'"...
Get certs from cache if present; otherwise, gets from URI and caches them. Args: cert_uri: URI from which to retrieve certs if cache is stale or empty. cache: Cache of pre-fetched certs. Returns: The retrieved certs.
[ "Get", "certs", "from", "cache", "if", "present", ";", "otherwise", "gets", "from", "URI", "and", "caches", "them", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L564-L593
train
cloudendpoints/endpoints-python
endpoints/users_id_token.py
_verify_signed_jwt_with_certs
def _verify_signed_jwt_with_certs( jwt, time_now, cache, cert_uri=_DEFAULT_CERT_URI): """Verify a JWT against public certs. See http://self-issued.info/docs/draft-jones-json-web-token.html. The PyCrypto library included with Google App Engine is severely limited and so you have to use it very carefull...
python
def _verify_signed_jwt_with_certs( jwt, time_now, cache, cert_uri=_DEFAULT_CERT_URI): """Verify a JWT against public certs. See http://self-issued.info/docs/draft-jones-json-web-token.html. The PyCrypto library included with Google App Engine is severely limited and so you have to use it very carefull...
[ "def", "_verify_signed_jwt_with_certs", "(", "jwt", ",", "time_now", ",", "cache", ",", "cert_uri", "=", "_DEFAULT_CERT_URI", ")", ":", "segments", "=", "jwt", ".", "split", "(", "'.'", ")", "if", "len", "(", "segments", ")", "!=", "3", ":", "raise", "_A...
Verify a JWT against public certs. See http://self-issued.info/docs/draft-jones-json-web-token.html. The PyCrypto library included with Google App Engine is severely limited and so you have to use it very carefully to verify JWT signatures. The first issue is that the library can't read X.509 files, so we mak...
[ "Verify", "a", "JWT", "against", "public", "certs", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L603-L732
train