repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
galaxyproject/pulsar | pulsar/client/job_directory.py | RemoteJobDirectory.calculate_path | def calculate_path(self, remote_relative_path, input_type):
""" Only for used by Pulsar client, should override for managers to
enforce security and make the directory if needed.
"""
directory, allow_nested_files = self._directory_for_file_type(input_type)
return self.path_helper... | python | def calculate_path(self, remote_relative_path, input_type):
""" Only for used by Pulsar client, should override for managers to
enforce security and make the directory if needed.
"""
directory, allow_nested_files = self._directory_for_file_type(input_type)
return self.path_helper... | [
"def",
"calculate_path",
"(",
"self",
",",
"remote_relative_path",
",",
"input_type",
")",
":",
"directory",
",",
"allow_nested_files",
"=",
"self",
".",
"_directory_for_file_type",
"(",
"input_type",
")",
"return",
"self",
".",
"path_helper",
".",
"remote_join",
... | Only for used by Pulsar client, should override for managers to
enforce security and make the directory if needed. | [
"Only",
"for",
"used",
"by",
"Pulsar",
"client",
"should",
"override",
"for",
"managers",
"to",
"enforce",
"security",
"and",
"make",
"the",
"directory",
"if",
"needed",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/job_directory.py#L71-L76 |
galaxyproject/pulsar | pulsar/managers/stateful.py | StatefulManagerProxy.get_status | def get_status(self, job_id):
""" Compute status used proxied manager and handle state transitions
and track additional state information needed.
"""
job_directory = self._proxied_manager.job_directory(job_id)
with job_directory.lock("status"):
proxy_status, state_cha... | python | def get_status(self, job_id):
""" Compute status used proxied manager and handle state transitions
and track additional state information needed.
"""
job_directory = self._proxied_manager.job_directory(job_id)
with job_directory.lock("status"):
proxy_status, state_cha... | [
"def",
"get_status",
"(",
"self",
",",
"job_id",
")",
":",
"job_directory",
"=",
"self",
".",
"_proxied_manager",
".",
"job_directory",
"(",
"job_id",
")",
"with",
"job_directory",
".",
"lock",
"(",
"\"status\"",
")",
":",
"proxy_status",
",",
"state_change",
... | Compute status used proxied manager and handle state transitions
and track additional state information needed. | [
"Compute",
"status",
"used",
"proxied",
"manager",
"and",
"handle",
"state",
"transitions",
"and",
"track",
"additional",
"state",
"information",
"needed",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/stateful.py#L137-L150 |
galaxyproject/pulsar | pulsar/managers/stateful.py | StatefulManagerProxy.__proxy_status | def __proxy_status(self, job_directory, job_id):
""" Determine state with proxied job manager and if this job needs
to be marked as deactivated (this occurs when job first returns a
complete status from proxy.
"""
state_change = None
if job_directory.has_metadata(JOB_FILE... | python | def __proxy_status(self, job_directory, job_id):
""" Determine state with proxied job manager and if this job needs
to be marked as deactivated (this occurs when job first returns a
complete status from proxy.
"""
state_change = None
if job_directory.has_metadata(JOB_FILE... | [
"def",
"__proxy_status",
"(",
"self",
",",
"job_directory",
",",
"job_id",
")",
":",
"state_change",
"=",
"None",
"if",
"job_directory",
".",
"has_metadata",
"(",
"JOB_FILE_PREPROCESSING_FAILED",
")",
":",
"proxy_status",
"=",
"status",
".",
"FAILED",
"job_directo... | Determine state with proxied job manager and if this job needs
to be marked as deactivated (this occurs when job first returns a
complete status from proxy. | [
"Determine",
"state",
"with",
"proxied",
"job",
"manager",
"and",
"if",
"this",
"job",
"needs",
"to",
"be",
"marked",
"as",
"deactivated",
"(",
"this",
"occurs",
"when",
"job",
"first",
"returns",
"a",
"complete",
"status",
"from",
"proxy",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/stateful.py#L152-L175 |
galaxyproject/pulsar | pulsar/managers/stateful.py | StatefulManagerProxy.__status | def __status(self, job_directory, proxy_status):
""" Use proxied manager's status to compute the real
(stateful) status of job.
"""
if proxy_status == status.COMPLETE:
if not job_directory.has_metadata(JOB_FILE_POSTPROCESSED):
job_status = status.POSTPROCESSIN... | python | def __status(self, job_directory, proxy_status):
""" Use proxied manager's status to compute the real
(stateful) status of job.
"""
if proxy_status == status.COMPLETE:
if not job_directory.has_metadata(JOB_FILE_POSTPROCESSED):
job_status = status.POSTPROCESSIN... | [
"def",
"__status",
"(",
"self",
",",
"job_directory",
",",
"proxy_status",
")",
":",
"if",
"proxy_status",
"==",
"status",
".",
"COMPLETE",
":",
"if",
"not",
"job_directory",
".",
"has_metadata",
"(",
"JOB_FILE_POSTPROCESSED",
")",
":",
"job_status",
"=",
"sta... | Use proxied manager's status to compute the real
(stateful) status of job. | [
"Use",
"proxied",
"manager",
"s",
"status",
"to",
"compute",
"the",
"real",
"(",
"stateful",
")",
"status",
"of",
"job",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/stateful.py#L177-L188 |
galaxyproject/pulsar | pulsar/client/staging/__init__.py | PulsarOutputs.output_extras | def output_extras(self, output_file):
"""
Returns dict mapping local path to remote name.
"""
output_directory = dirname(output_file)
def local_path(name):
return join(output_directory, self.path_helper.local_name(name))
files_directory = "%s_files%s" % (bas... | python | def output_extras(self, output_file):
"""
Returns dict mapping local path to remote name.
"""
output_directory = dirname(output_file)
def local_path(name):
return join(output_directory, self.path_helper.local_name(name))
files_directory = "%s_files%s" % (bas... | [
"def",
"output_extras",
"(",
"self",
",",
"output_file",
")",
":",
"output_directory",
"=",
"dirname",
"(",
"output_file",
")",
"def",
"local_path",
"(",
"name",
")",
":",
"return",
"join",
"(",
"output_directory",
",",
"self",
".",
"path_helper",
".",
"loca... | Returns dict mapping local path to remote name. | [
"Returns",
"dict",
"mapping",
"local",
"path",
"to",
"remote",
"name",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/staging/__init__.py#L185-L196 |
galaxyproject/pulsar | pulsar/managers/util/sudo.py | sudo_popen | def sudo_popen(*args, **kwargs):
"""
Helper method for building and executing Popen command. This is potentially
sensetive code so should probably be centralized.
"""
user = kwargs.get("user", None)
full_command = [SUDO_PATH, SUDO_PRESERVE_ENVIRONMENT_ARG]
if user:
full_command.exten... | python | def sudo_popen(*args, **kwargs):
"""
Helper method for building and executing Popen command. This is potentially
sensetive code so should probably be centralized.
"""
user = kwargs.get("user", None)
full_command = [SUDO_PATH, SUDO_PRESERVE_ENVIRONMENT_ARG]
if user:
full_command.exten... | [
"def",
"sudo_popen",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"user",
"=",
"kwargs",
".",
"get",
"(",
"\"user\"",
",",
"None",
")",
"full_command",
"=",
"[",
"SUDO_PATH",
",",
"SUDO_PRESERVE_ENVIRONMENT_ARG",
"]",
"if",
"user",
":",
"full_com... | Helper method for building and executing Popen command. This is potentially
sensetive code so should probably be centralized. | [
"Helper",
"method",
"for",
"building",
"and",
"executing",
"Popen",
"command",
".",
"This",
"is",
"potentially",
"sensetive",
"code",
"so",
"should",
"probably",
"be",
"centralized",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/util/sudo.py#L14-L26 |
bitprophet/releases | releases/line_manager.py | LineManager.add_family | def add_family(self, major_number):
"""
Expand to a new release line with given ``major_number``.
This will flesh out mandatory buckets like ``unreleased_bugfix`` and do
other necessary bookkeeping.
"""
# Normally, we have separate buckets for bugfixes vs features
... | python | def add_family(self, major_number):
"""
Expand to a new release line with given ``major_number``.
This will flesh out mandatory buckets like ``unreleased_bugfix`` and do
other necessary bookkeeping.
"""
# Normally, we have separate buckets for bugfixes vs features
... | [
"def",
"add_family",
"(",
"self",
",",
"major_number",
")",
":",
"# Normally, we have separate buckets for bugfixes vs features",
"keys",
"=",
"[",
"'unreleased_bugfix'",
",",
"'unreleased_feature'",
"]",
"# But unstable prehistorical releases roll all up into just",
"# 'unreleased... | Expand to a new release line with given ``major_number``.
This will flesh out mandatory buckets like ``unreleased_bugfix`` and do
other necessary bookkeeping. | [
"Expand",
"to",
"a",
"new",
"release",
"line",
"with",
"given",
"major_number",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/line_manager.py#L23-L37 |
bitprophet/releases | releases/line_manager.py | LineManager.has_stable_releases | def has_stable_releases(self):
"""
Returns whether stable (post-0.x) releases seem to exist.
"""
nonzeroes = self.stable_families
# Nothing but 0.x releases -> yup we're prehistory
if not nonzeroes:
return False
# Presumably, if there's >1 major family... | python | def has_stable_releases(self):
"""
Returns whether stable (post-0.x) releases seem to exist.
"""
nonzeroes = self.stable_families
# Nothing but 0.x releases -> yup we're prehistory
if not nonzeroes:
return False
# Presumably, if there's >1 major family... | [
"def",
"has_stable_releases",
"(",
"self",
")",
":",
"nonzeroes",
"=",
"self",
".",
"stable_families",
"# Nothing but 0.x releases -> yup we're prehistory",
"if",
"not",
"nonzeroes",
":",
"return",
"False",
"# Presumably, if there's >1 major family besides 0.x, we're at least",
... | Returns whether stable (post-0.x) releases seem to exist. | [
"Returns",
"whether",
"stable",
"(",
"post",
"-",
"0",
".",
"x",
")",
"releases",
"seem",
"to",
"exist",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/line_manager.py#L59-L75 |
bitprophet/releases | releases/util.py | parse_changelog | def parse_changelog(path, **kwargs):
"""
Load and parse changelog file from ``path``, returning data structures.
This function does not alter any files on disk; it is solely for
introspecting a Releases ``changelog.rst`` and programmatically answering
questions like "are there any unreleased bugfix... | python | def parse_changelog(path, **kwargs):
"""
Load and parse changelog file from ``path``, returning data structures.
This function does not alter any files on disk; it is solely for
introspecting a Releases ``changelog.rst`` and programmatically answering
questions like "are there any unreleased bugfix... | [
"def",
"parse_changelog",
"(",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"app",
",",
"doctree",
"=",
"get_doctree",
"(",
"path",
",",
"*",
"*",
"kwargs",
")",
"# Have to semi-reproduce the 'find first bullet list' bit from main code,",
"# which is unfortunately side-ef... | Load and parse changelog file from ``path``, returning data structures.
This function does not alter any files on disk; it is solely for
introspecting a Releases ``changelog.rst`` and programmatically answering
questions like "are there any unreleased bugfixes for the 2.3 line?" or
"what was included i... | [
"Load",
"and",
"parse",
"changelog",
"file",
"from",
"path",
"returning",
"data",
"structures",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/util.py#L37-L106 |
bitprophet/releases | releases/util.py | get_doctree | def get_doctree(path, **kwargs):
"""
Obtain a Sphinx doctree from the RST file at ``path``.
Performs no Releases-specific processing; this code would, ideally, be in
Sphinx itself, but things there are pretty tightly coupled. So we wrote
this.
Any additional kwargs are passed unmodified into a... | python | def get_doctree(path, **kwargs):
"""
Obtain a Sphinx doctree from the RST file at ``path``.
Performs no Releases-specific processing; this code would, ideally, be in
Sphinx itself, but things there are pretty tightly coupled. So we wrote
this.
Any additional kwargs are passed unmodified into a... | [
"def",
"get_doctree",
"(",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"root",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"docname",
",",
"_",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"# TODO: this... | Obtain a Sphinx doctree from the RST file at ``path``.
Performs no Releases-specific processing; this code would, ideally, be in
Sphinx itself, but things there are pretty tightly coupled. So we wrote
this.
Any additional kwargs are passed unmodified into an internal `make_app`
call.
:param s... | [
"Obtain",
"a",
"Sphinx",
"doctree",
"from",
"the",
"RST",
"file",
"at",
"path",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/util.py#L109-L194 |
bitprophet/releases | releases/util.py | load_conf | def load_conf(srcdir):
"""
Load ``conf.py`` from given ``srcdir``.
:returns: Dictionary derived from the conf module.
"""
path = os.path.join(srcdir, 'conf.py')
mylocals = {'__file__': path}
with open(path) as fd:
exec(fd.read(), mylocals)
return mylocals | python | def load_conf(srcdir):
"""
Load ``conf.py`` from given ``srcdir``.
:returns: Dictionary derived from the conf module.
"""
path = os.path.join(srcdir, 'conf.py')
mylocals = {'__file__': path}
with open(path) as fd:
exec(fd.read(), mylocals)
return mylocals | [
"def",
"load_conf",
"(",
"srcdir",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"srcdir",
",",
"'conf.py'",
")",
"mylocals",
"=",
"{",
"'__file__'",
":",
"path",
"}",
"with",
"open",
"(",
"path",
")",
"as",
"fd",
":",
"exec",
"(",
... | Load ``conf.py`` from given ``srcdir``.
:returns: Dictionary derived from the conf module. | [
"Load",
"conf",
".",
"py",
"from",
"given",
"srcdir",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/util.py#L197-L207 |
bitprophet/releases | releases/util.py | make_app | def make_app(**kwargs):
"""
Create a dummy Sphinx app, filling in various hardcoded assumptions.
For example, Sphinx assumes the existence of various source/dest
directories, even if you're only calling internals that never generate (or
sometimes, even read!) on-disk files. This function creates sa... | python | def make_app(**kwargs):
"""
Create a dummy Sphinx app, filling in various hardcoded assumptions.
For example, Sphinx assumes the existence of various source/dest
directories, even if you're only calling internals that never generate (or
sometimes, even read!) on-disk files. This function creates sa... | [
"def",
"make_app",
"(",
"*",
"*",
"kwargs",
")",
":",
"srcdir",
"=",
"kwargs",
".",
"pop",
"(",
"'srcdir'",
",",
"mkdtemp",
"(",
")",
")",
"dstdir",
"=",
"kwargs",
".",
"pop",
"(",
"'dstdir'",
",",
"mkdtemp",
"(",
")",
")",
"doctreedir",
"=",
"kwar... | Create a dummy Sphinx app, filling in various hardcoded assumptions.
For example, Sphinx assumes the existence of various source/dest
directories, even if you're only calling internals that never generate (or
sometimes, even read!) on-disk files. This function creates safe temp
directories for these in... | [
"Create",
"a",
"dummy",
"Sphinx",
"app",
"filling",
"in",
"various",
"hardcoded",
"assumptions",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/util.py#L210-L318 |
bitprophet/releases | releases/__init__.py | _log | def _log(txt, config):
"""
Log debug output if debug setting is on.
Intended to be partial'd w/ config at top of functions. Meh.
"""
if config.releases_debug:
sys.stderr.write(str(txt) + "\n")
sys.stderr.flush() | python | def _log(txt, config):
"""
Log debug output if debug setting is on.
Intended to be partial'd w/ config at top of functions. Meh.
"""
if config.releases_debug:
sys.stderr.write(str(txt) + "\n")
sys.stderr.flush() | [
"def",
"_log",
"(",
"txt",
",",
"config",
")",
":",
"if",
"config",
".",
"releases_debug",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"str",
"(",
"txt",
")",
"+",
"\"\\n\"",
")",
"sys",
".",
"stderr",
".",
"flush",
"(",
")"
] | Log debug output if debug setting is on.
Intended to be partial'd w/ config at top of functions. Meh. | [
"Log",
"debug",
"output",
"if",
"debug",
"setting",
"is",
"on",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/__init__.py#L15-L23 |
bitprophet/releases | releases/__init__.py | scan_for_spec | def scan_for_spec(keyword):
"""
Attempt to return some sort of Spec from given keyword value.
Returns None if one could not be derived.
"""
# Both 'spec' formats are wrapped in parens, discard
keyword = keyword.lstrip('(').rstrip(')')
# First, test for intermediate '1.2+' style
matches ... | python | def scan_for_spec(keyword):
"""
Attempt to return some sort of Spec from given keyword value.
Returns None if one could not be derived.
"""
# Both 'spec' formats are wrapped in parens, discard
keyword = keyword.lstrip('(').rstrip(')')
# First, test for intermediate '1.2+' style
matches ... | [
"def",
"scan_for_spec",
"(",
"keyword",
")",
":",
"# Both 'spec' formats are wrapped in parens, discard",
"keyword",
"=",
"keyword",
".",
"lstrip",
"(",
"'('",
")",
".",
"rstrip",
"(",
"')'",
")",
"# First, test for intermediate '1.2+' style",
"matches",
"=",
"release_l... | Attempt to return some sort of Spec from given keyword value.
Returns None if one could not be derived. | [
"Attempt",
"to",
"return",
"some",
"sort",
"of",
"Spec",
"from",
"given",
"keyword",
"value",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/__init__.py#L38-L55 |
bitprophet/releases | releases/__init__.py | issues_role | def issues_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""
Use: :issue|bug|feature|support:`ticket_number`
When invoked as :issue:, turns into just a "#NN" hyperlink to
`releases_issue_uri`.
When invoked otherwise, turns into "[Type] <#NN hyperlink>: ".
Spaces present ... | python | def issues_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""
Use: :issue|bug|feature|support:`ticket_number`
When invoked as :issue:, turns into just a "#NN" hyperlink to
`releases_issue_uri`.
When invoked otherwise, turns into "[Type] <#NN hyperlink>: ".
Spaces present ... | [
"def",
"issues_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"{",
"}",
",",
"content",
"=",
"[",
"]",
")",
":",
"parts",
"=",
"utils",
".",
"unescape",
"(",
"text",
")",
".",
"split",
"(",
")... | Use: :issue|bug|feature|support:`ticket_number`
When invoked as :issue:, turns into just a "#NN" hyperlink to
`releases_issue_uri`.
When invoked otherwise, turns into "[Type] <#NN hyperlink>: ".
Spaces present in the "ticket number" are used as fields for keywords
(major, backported) and/or specs... | [
"Use",
":",
":",
"issue|bug|feature|support",
":",
"ticket_number"
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/__init__.py#L58-L128 |
bitprophet/releases | releases/__init__.py | release_role | def release_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""
Invoked as :release:`N.N.N <YYYY-MM-DD>`.
Turns into useful release header + link to GH tree for the tag.
"""
# Make sure year has been specified
match = year_arg_re.match(text)
if not match:
msg = i... | python | def release_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""
Invoked as :release:`N.N.N <YYYY-MM-DD>`.
Turns into useful release header + link to GH tree for the tag.
"""
# Make sure year has been specified
match = year_arg_re.match(text)
if not match:
msg = i... | [
"def",
"release_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"{",
"}",
",",
"content",
"=",
"[",
"]",
")",
":",
"# Make sure year has been specified",
"match",
"=",
"year_arg_re",
".",
"match",
"(",
... | Invoked as :release:`N.N.N <YYYY-MM-DD>`.
Turns into useful release header + link to GH tree for the tag. | [
"Invoked",
"as",
":",
"release",
":",
"N",
".",
"N",
".",
"N",
"<YYYY",
"-",
"MM",
"-",
"DD",
">",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/__init__.py#L164-L181 |
bitprophet/releases | releases/__init__.py | append_unreleased_entries | def append_unreleased_entries(app, manager, releases):
"""
Generate new abstract 'releases' for unreleased issues.
There's one for each combination of bug-vs-feature & major release line.
When only one major release line exists, that dimension is ignored.
"""
for family, lines in six.iteritems... | python | def append_unreleased_entries(app, manager, releases):
"""
Generate new abstract 'releases' for unreleased issues.
There's one for each combination of bug-vs-feature & major release line.
When only one major release line exists, that dimension is ignored.
"""
for family, lines in six.iteritems... | [
"def",
"append_unreleased_entries",
"(",
"app",
",",
"manager",
",",
"releases",
")",
":",
"for",
"family",
",",
"lines",
"in",
"six",
".",
"iteritems",
"(",
"manager",
")",
":",
"for",
"type_",
"in",
"(",
"'bugfix'",
",",
"'feature'",
")",
":",
"bucket"... | Generate new abstract 'releases' for unreleased issues.
There's one for each combination of bug-vs-feature & major release line.
When only one major release line exists, that dimension is ignored. | [
"Generate",
"new",
"abstract",
"releases",
"for",
"unreleased",
"issues",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/__init__.py#L202-L221 |
bitprophet/releases | releases/__init__.py | reorder_release_entries | def reorder_release_entries(releases):
"""
Mutate ``releases`` so the entrylist in each is ordered by feature/bug/etc.
"""
order = {'feature': 0, 'bug': 1, 'support': 2}
for release in releases:
entries = release['entries'][:]
release['entries'] = sorted(entries, key=lambda x: order[... | python | def reorder_release_entries(releases):
"""
Mutate ``releases`` so the entrylist in each is ordered by feature/bug/etc.
"""
order = {'feature': 0, 'bug': 1, 'support': 2}
for release in releases:
entries = release['entries'][:]
release['entries'] = sorted(entries, key=lambda x: order[... | [
"def",
"reorder_release_entries",
"(",
"releases",
")",
":",
"order",
"=",
"{",
"'feature'",
":",
"0",
",",
"'bug'",
":",
"1",
",",
"'support'",
":",
"2",
"}",
"for",
"release",
"in",
"releases",
":",
"entries",
"=",
"release",
"[",
"'entries'",
"]",
"... | Mutate ``releases`` so the entrylist in each is ordered by feature/bug/etc. | [
"Mutate",
"releases",
"so",
"the",
"entrylist",
"in",
"each",
"is",
"ordered",
"by",
"feature",
"/",
"bug",
"/",
"etc",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/__init__.py#L224-L231 |
bitprophet/releases | releases/__init__.py | construct_entry_with_release | def construct_entry_with_release(focus, issues, manager, log, releases, rest):
"""
Releases 'eat' the entries in their line's list and get added to the
final data structure. They also inform new release-line 'buffers'.
Release lines, once the release obj is removed, should be empty or a
comma-separa... | python | def construct_entry_with_release(focus, issues, manager, log, releases, rest):
"""
Releases 'eat' the entries in their line's list and get added to the
final data structure. They also inform new release-line 'buffers'.
Release lines, once the release obj is removed, should be empty or a
comma-separa... | [
"def",
"construct_entry_with_release",
"(",
"focus",
",",
"issues",
",",
"manager",
",",
"log",
",",
"releases",
",",
"rest",
")",
":",
"log",
"(",
"\"release for line %r\"",
"%",
"focus",
".",
"minor",
")",
"# Check for explicitly listed issues first",
"explicit",
... | Releases 'eat' the entries in their line's list and get added to the
final data structure. They also inform new release-line 'buffers'.
Release lines, once the release obj is removed, should be empty or a
comma-separated list of issue numbers. | [
"Releases",
"eat",
"the",
"entries",
"in",
"their",
"line",
"s",
"list",
"and",
"get",
"added",
"to",
"the",
"final",
"data",
"structure",
".",
"They",
"also",
"inform",
"new",
"release",
"-",
"line",
"buffers",
".",
"Release",
"lines",
"once",
"the",
"r... | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/__init__.py#L234-L352 |
bitprophet/releases | releases/__init__.py | handle_first_release_line | def handle_first_release_line(entries, manager):
"""
Set up initial line-manager entry for first encountered release line.
To be called at start of overall process; afterwards, subsequent major
lines are generated by `handle_upcoming_major_release`.
"""
# It's remotely possible the changelog is... | python | def handle_first_release_line(entries, manager):
"""
Set up initial line-manager entry for first encountered release line.
To be called at start of overall process; afterwards, subsequent major
lines are generated by `handle_upcoming_major_release`.
"""
# It's remotely possible the changelog is... | [
"def",
"handle_first_release_line",
"(",
"entries",
",",
"manager",
")",
":",
"# It's remotely possible the changelog is totally empty...",
"if",
"not",
"entries",
":",
"return",
"# Obtain (short-circuiting) first Release obj.",
"first_release",
"=",
"None",
"for",
"obj",
"in... | Set up initial line-manager entry for first encountered release line.
To be called at start of overall process; afterwards, subsequent major
lines are generated by `handle_upcoming_major_release`. | [
"Set",
"up",
"initial",
"line",
"-",
"manager",
"entry",
"for",
"first",
"encountered",
"release",
"line",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/__init__.py#L434-L455 |
bitprophet/releases | releases/models.py | Issue.minor_releases | def minor_releases(self, manager):
"""
Return all minor release line labels found in ``manager``.
"""
# TODO: yea deffo need a real object for 'manager', heh. E.g. we do a
# very similar test for "do you have any actual releases yet?"
# elsewhere. (This may be fodder for ... | python | def minor_releases(self, manager):
"""
Return all minor release line labels found in ``manager``.
"""
# TODO: yea deffo need a real object for 'manager', heh. E.g. we do a
# very similar test for "do you have any actual releases yet?"
# elsewhere. (This may be fodder for ... | [
"def",
"minor_releases",
"(",
"self",
",",
"manager",
")",
":",
"# TODO: yea deffo need a real object for 'manager', heh. E.g. we do a",
"# very similar test for \"do you have any actual releases yet?\"",
"# elsewhere. (This may be fodder for changing how we roll up",
"# pre-major-release feat... | Return all minor release line labels found in ``manager``. | [
"Return",
"all",
"minor",
"release",
"line",
"labels",
"found",
"in",
"manager",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/models.py#L69-L80 |
bitprophet/releases | releases/models.py | Issue.default_spec | def default_spec(self, manager):
"""
Given the current release-lines structure, return a default Spec.
Specifics:
* For feature-like issues, only the highest major release is used, so
given a ``manager`` with top level keys of ``[1, 2]``, this would
return ``Spec(">... | python | def default_spec(self, manager):
"""
Given the current release-lines structure, return a default Spec.
Specifics:
* For feature-like issues, only the highest major release is used, so
given a ``manager`` with top level keys of ``[1, 2]``, this would
return ``Spec(">... | [
"def",
"default_spec",
"(",
"self",
",",
"manager",
")",
":",
"# TODO: I feel like this + the surrounding bits in add_to_manager()",
"# could be consolidated & simplified...",
"specstr",
"=",
"\"\"",
"# Make sure truly-default spec skips 0.x if prehistory was unstable.",
"stable_families... | Given the current release-lines structure, return a default Spec.
Specifics:
* For feature-like issues, only the highest major release is used, so
given a ``manager`` with top level keys of ``[1, 2]``, this would
return ``Spec(">=2")``.
* When ``releases_always_forward... | [
"Given",
"the",
"current",
"release",
"-",
"lines",
"structure",
"return",
"a",
"default",
"Spec",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/models.py#L82-L125 |
bitprophet/releases | releases/models.py | Issue.add_to_manager | def add_to_manager(self, manager):
"""
Given a 'manager' structure, add self to one or more of its 'buckets'.
"""
# Derive version spec allowing us to filter against major/minor buckets
spec = self.spec or self.default_spec(manager)
# Only look in appropriate major versio... | python | def add_to_manager(self, manager):
"""
Given a 'manager' structure, add self to one or more of its 'buckets'.
"""
# Derive version spec allowing us to filter against major/minor buckets
spec = self.spec or self.default_spec(manager)
# Only look in appropriate major versio... | [
"def",
"add_to_manager",
"(",
"self",
",",
"manager",
")",
":",
"# Derive version spec allowing us to filter against major/minor buckets",
"spec",
"=",
"self",
".",
"spec",
"or",
"self",
".",
"default_spec",
"(",
"manager",
")",
"# Only look in appropriate major version/fam... | Given a 'manager' structure, add self to one or more of its 'buckets'. | [
"Given",
"a",
"manager",
"structure",
"add",
"self",
"to",
"one",
"or",
"more",
"of",
"its",
"buckets",
"."
] | train | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/models.py#L127-L170 |
brendonh/pyth | pyth/plugins/rtf15/reader.py | Rtf15Reader.read | def read(self, source, errors='strict', clean_paragraphs=True):
"""
source: A list of P objects.
"""
reader = Rtf15Reader(source, errors, clean_paragraphs)
return reader.go() | python | def read(self, source, errors='strict', clean_paragraphs=True):
"""
source: A list of P objects.
"""
reader = Rtf15Reader(source, errors, clean_paragraphs)
return reader.go() | [
"def",
"read",
"(",
"self",
",",
"source",
",",
"errors",
"=",
"'strict'",
",",
"clean_paragraphs",
"=",
"True",
")",
":",
"reader",
"=",
"Rtf15Reader",
"(",
"source",
",",
"errors",
",",
"clean_paragraphs",
")",
"return",
"reader",
".",
"go",
"(",
")"
] | source: A list of P objects. | [
"source",
":",
"A",
"list",
"of",
"P",
"objects",
"."
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/rtf15/reader.py#L80-L86 |
brendonh/pyth | pyth/plugins/rtf15/reader.py | DocBuilder.cleanParagraph | def cleanParagraph(self):
"""
Compress text runs, remove whitespace at start and end,
skip empty blocks, etc
"""
runs = self.block.content
if not runs:
self.block = None
return
if not self.clean_paragraphs:
return
jo... | python | def cleanParagraph(self):
"""
Compress text runs, remove whitespace at start and end,
skip empty blocks, etc
"""
runs = self.block.content
if not runs:
self.block = None
return
if not self.clean_paragraphs:
return
jo... | [
"def",
"cleanParagraph",
"(",
"self",
")",
":",
"runs",
"=",
"self",
".",
"block",
".",
"content",
"if",
"not",
"runs",
":",
"self",
".",
"block",
"=",
"None",
"return",
"if",
"not",
"self",
".",
"clean_paragraphs",
":",
"return",
"joinedRuns",
"=",
"[... | Compress text runs, remove whitespace at start and end,
skip empty blocks, etc | [
"Compress",
"text",
"runs",
"remove",
"whitespace",
"at",
"start",
"and",
"end",
"skip",
"empty",
"blocks",
"etc"
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/rtf15/reader.py#L241-L284 |
brendonh/pyth | pyth/plugins/xhtml/css.py | CSS.parse_css | def parse_css(self, css):
"""
Parse a css style sheet into the CSS object.
For the moment this will only work for very simple css
documents. It works by using regular expression matching css
syntax. This is not bullet proof.
"""
rulesets = self.ruleset_re.finda... | python | def parse_css(self, css):
"""
Parse a css style sheet into the CSS object.
For the moment this will only work for very simple css
documents. It works by using regular expression matching css
syntax. This is not bullet proof.
"""
rulesets = self.ruleset_re.finda... | [
"def",
"parse_css",
"(",
"self",
",",
"css",
")",
":",
"rulesets",
"=",
"self",
".",
"ruleset_re",
".",
"findall",
"(",
"css",
")",
"for",
"(",
"selector",
",",
"declarations",
")",
"in",
"rulesets",
":",
"rule",
"=",
"Rule",
"(",
"self",
".",
"parse... | Parse a css style sheet into the CSS object.
For the moment this will only work for very simple css
documents. It works by using regular expression matching css
syntax. This is not bullet proof. | [
"Parse",
"a",
"css",
"style",
"sheet",
"into",
"the",
"CSS",
"object",
"."
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/xhtml/css.py#L73-L85 |
brendonh/pyth | pyth/plugins/xhtml/css.py | CSS.parse_declarations | def parse_declarations(self, declarations):
"""
parse a css declaration list
"""
declarations = self.declaration_re.findall(declarations)
return dict(declarations) | python | def parse_declarations(self, declarations):
"""
parse a css declaration list
"""
declarations = self.declaration_re.findall(declarations)
return dict(declarations) | [
"def",
"parse_declarations",
"(",
"self",
",",
"declarations",
")",
":",
"declarations",
"=",
"self",
".",
"declaration_re",
".",
"findall",
"(",
"declarations",
")",
"return",
"dict",
"(",
"declarations",
")"
] | parse a css declaration list | [
"parse",
"a",
"css",
"declaration",
"list"
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/xhtml/css.py#L87-L92 |
brendonh/pyth | pyth/plugins/xhtml/css.py | CSS.parse_selector | def parse_selector(self, selector):
"""
parse a css selector
"""
tag, klass = self.selector_re.match(selector).groups()
return Selector(tag, klass) | python | def parse_selector(self, selector):
"""
parse a css selector
"""
tag, klass = self.selector_re.match(selector).groups()
return Selector(tag, klass) | [
"def",
"parse_selector",
"(",
"self",
",",
"selector",
")",
":",
"tag",
",",
"klass",
"=",
"self",
".",
"selector_re",
".",
"match",
"(",
"selector",
")",
".",
"groups",
"(",
")",
"return",
"Selector",
"(",
"tag",
",",
"klass",
")"
] | parse a css selector | [
"parse",
"a",
"css",
"selector"
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/xhtml/css.py#L94-L99 |
brendonh/pyth | pyth/plugins/xhtml/css.py | CSS.get_properties | def get_properties(self, node):
"""
return a dict of all the properties of a given BeautifulSoup
node found by applying the css style.
"""
ret = {}
# Try all the rules one by one
for rule in self.rules:
if rule.selector(node):
ret.updat... | python | def get_properties(self, node):
"""
return a dict of all the properties of a given BeautifulSoup
node found by applying the css style.
"""
ret = {}
# Try all the rules one by one
for rule in self.rules:
if rule.selector(node):
ret.updat... | [
"def",
"get_properties",
"(",
"self",
",",
"node",
")",
":",
"ret",
"=",
"{",
"}",
"# Try all the rules one by one",
"for",
"rule",
"in",
"self",
".",
"rules",
":",
"if",
"rule",
".",
"selector",
"(",
"node",
")",
":",
"ret",
".",
"update",
"(",
"rule"... | return a dict of all the properties of a given BeautifulSoup
node found by applying the css style. | [
"return",
"a",
"dict",
"of",
"all",
"the",
"properties",
"of",
"a",
"given",
"BeautifulSoup",
"node",
"found",
"by",
"applying",
"the",
"css",
"style",
"."
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/xhtml/css.py#L101-L116 |
brendonh/pyth | pyth/__init__.py | namedModule | def namedModule(name):
"""Return a module given its name."""
topLevel = __import__(name)
packages = name.split(".")[1:]
m = topLevel
for p in packages:
m = getattr(m, p)
return m | python | def namedModule(name):
"""Return a module given its name."""
topLevel = __import__(name)
packages = name.split(".")[1:]
m = topLevel
for p in packages:
m = getattr(m, p)
return m | [
"def",
"namedModule",
"(",
"name",
")",
":",
"topLevel",
"=",
"__import__",
"(",
"name",
")",
"packages",
"=",
"name",
".",
"split",
"(",
"\".\"",
")",
"[",
"1",
":",
"]",
"m",
"=",
"topLevel",
"for",
"p",
"in",
"packages",
":",
"m",
"=",
"getattr"... | Return a module given its name. | [
"Return",
"a",
"module",
"given",
"its",
"name",
"."
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/__init__.py#L37-L44 |
brendonh/pyth | pyth/__init__.py | namedObject | def namedObject(name):
"""Get a fully named module-global object.
"""
classSplit = name.split('.')
module = namedModule('.'.join(classSplit[:-1]))
return getattr(module, classSplit[-1]) | python | def namedObject(name):
"""Get a fully named module-global object.
"""
classSplit = name.split('.')
module = namedModule('.'.join(classSplit[:-1]))
return getattr(module, classSplit[-1]) | [
"def",
"namedObject",
"(",
"name",
")",
":",
"classSplit",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"module",
"=",
"namedModule",
"(",
"'.'",
".",
"join",
"(",
"classSplit",
"[",
":",
"-",
"1",
"]",
")",
")",
"return",
"getattr",
"(",
"module",
... | Get a fully named module-global object. | [
"Get",
"a",
"fully",
"named",
"module",
"-",
"global",
"object",
"."
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/__init__.py#L47-L52 |
brendonh/pyth | pyth/plugins/rst/writer.py | RSTWriter.text | def text(self, text):
"""
process a pyth text and return the formatted string
"""
ret = u"".join(text.content)
if 'url' in text.properties:
return u"`%s`_" % ret
if 'bold' in text.properties:
return u"**%s**" % ret
if 'italic' in text.prope... | python | def text(self, text):
"""
process a pyth text and return the formatted string
"""
ret = u"".join(text.content)
if 'url' in text.properties:
return u"`%s`_" % ret
if 'bold' in text.properties:
return u"**%s**" % ret
if 'italic' in text.prope... | [
"def",
"text",
"(",
"self",
",",
"text",
")",
":",
"ret",
"=",
"u\"\"",
".",
"join",
"(",
"text",
".",
"content",
")",
"if",
"'url'",
"in",
"text",
".",
"properties",
":",
"return",
"u\"`%s`_\"",
"%",
"ret",
"if",
"'bold'",
"in",
"text",
".",
"prop... | process a pyth text and return the formatted string | [
"process",
"a",
"pyth",
"text",
"and",
"return",
"the",
"formatted",
"string"
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/rst/writer.py#L40-L55 |
brendonh/pyth | pyth/plugins/rst/writer.py | RSTWriter.paragraph | def paragraph(self, paragraph, prefix=""):
"""
process a pyth paragraph into the target
"""
content = []
for text in paragraph.content:
content.append(self.text(text))
content = u"".join(content).encode("utf-8")
for line in content.split("\n"):
... | python | def paragraph(self, paragraph, prefix=""):
"""
process a pyth paragraph into the target
"""
content = []
for text in paragraph.content:
content.append(self.text(text))
content = u"".join(content).encode("utf-8")
for line in content.split("\n"):
... | [
"def",
"paragraph",
"(",
"self",
",",
"paragraph",
",",
"prefix",
"=",
"\"\"",
")",
":",
"content",
"=",
"[",
"]",
"for",
"text",
"in",
"paragraph",
".",
"content",
":",
"content",
".",
"append",
"(",
"self",
".",
"text",
"(",
"text",
")",
")",
"co... | process a pyth paragraph into the target | [
"process",
"a",
"pyth",
"paragraph",
"into",
"the",
"target"
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/rst/writer.py#L57-L81 |
brendonh/pyth | pyth/plugins/rst/writer.py | RSTWriter.list | def list(self, list, prefix=None):
"""
Process a pyth list into the target
"""
self.indent += 1
for (i, entry) in enumerate(list.content):
for (j, paragraph) in enumerate(entry.content):
prefix = "- " if j == 0 else " "
handler = self.... | python | def list(self, list, prefix=None):
"""
Process a pyth list into the target
"""
self.indent += 1
for (i, entry) in enumerate(list.content):
for (j, paragraph) in enumerate(entry.content):
prefix = "- " if j == 0 else " "
handler = self.... | [
"def",
"list",
"(",
"self",
",",
"list",
",",
"prefix",
"=",
"None",
")",
":",
"self",
".",
"indent",
"+=",
"1",
"for",
"(",
"i",
",",
"entry",
")",
"in",
"enumerate",
"(",
"list",
".",
"content",
")",
":",
"for",
"(",
"j",
",",
"paragraph",
")... | Process a pyth list into the target | [
"Process",
"a",
"pyth",
"list",
"into",
"the",
"target"
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/rst/writer.py#L83-L94 |
brendonh/pyth | pyth/plugins/xhtml/reader.py | XHTMLReader.format | def format(self, soup):
"""format a BeautifulSoup document
This will transform the block elements content from
multi-lines text into single line.
This allow us to avoid having to deal with further text
rendering once this step has been done.
"""
# Remove all the... | python | def format(self, soup):
"""format a BeautifulSoup document
This will transform the block elements content from
multi-lines text into single line.
This allow us to avoid having to deal with further text
rendering once this step has been done.
"""
# Remove all the... | [
"def",
"format",
"(",
"self",
",",
"soup",
")",
":",
"# Remove all the newline characters before a closing tag.",
"for",
"node",
"in",
"soup",
".",
"findAll",
"(",
"text",
"=",
"True",
")",
":",
"if",
"node",
".",
"rstrip",
"(",
"\" \"",
")",
".",
"endswith"... | format a BeautifulSoup document
This will transform the block elements content from
multi-lines text into single line.
This allow us to avoid having to deal with further text
rendering once this step has been done. | [
"format",
"a",
"BeautifulSoup",
"document"
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/xhtml/reader.py#L40-L65 |
brendonh/pyth | pyth/plugins/xhtml/reader.py | XHTMLReader.url | def url(self, node):
"""
return the url of a BeautifulSoup node or None if there is no
url.
"""
a_node = node.findParent('a')
if not a_node:
return None
if self.link_callback is None:
return a_node.get('href')
else:
ret... | python | def url(self, node):
"""
return the url of a BeautifulSoup node or None if there is no
url.
"""
a_node = node.findParent('a')
if not a_node:
return None
if self.link_callback is None:
return a_node.get('href')
else:
ret... | [
"def",
"url",
"(",
"self",
",",
"node",
")",
":",
"a_node",
"=",
"node",
".",
"findParent",
"(",
"'a'",
")",
"if",
"not",
"a_node",
":",
"return",
"None",
"if",
"self",
".",
"link_callback",
"is",
"None",
":",
"return",
"a_node",
".",
"get",
"(",
"... | return the url of a BeautifulSoup node or None if there is no
url. | [
"return",
"the",
"url",
"of",
"a",
"BeautifulSoup",
"node",
"or",
"None",
"if",
"there",
"is",
"no",
"url",
"."
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/xhtml/reader.py#L99-L111 |
brendonh/pyth | pyth/plugins/xhtml/reader.py | XHTMLReader.process_text | def process_text(self, node):
"""
Return a pyth Text object from a BeautifulSoup node or None if
the text is empty.
"""
text = node.string.strip()
if not text:
return
# Set all the properties
properties=dict()
if self.is_bold(node):
... | python | def process_text(self, node):
"""
Return a pyth Text object from a BeautifulSoup node or None if
the text is empty.
"""
text = node.string.strip()
if not text:
return
# Set all the properties
properties=dict()
if self.is_bold(node):
... | [
"def",
"process_text",
"(",
"self",
",",
"node",
")",
":",
"text",
"=",
"node",
".",
"string",
".",
"strip",
"(",
")",
"if",
"not",
"text",
":",
"return",
"# Set all the properties",
"properties",
"=",
"dict",
"(",
")",
"if",
"self",
".",
"is_bold",
"(... | Return a pyth Text object from a BeautifulSoup node or None if
the text is empty. | [
"Return",
"a",
"pyth",
"Text",
"object",
"from",
"a",
"BeautifulSoup",
"node",
"or",
"None",
"if",
"the",
"text",
"is",
"empty",
"."
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/xhtml/reader.py#L113-L137 |
brendonh/pyth | pyth/plugins/xhtml/reader.py | XHTMLReader.process_into | def process_into(self, node, obj):
"""
Process a BeautifulSoup node and fill its elements into a pyth
base object.
"""
if isinstance(node, BeautifulSoup.NavigableString):
text = self.process_text(node)
if text:
obj.append(text)
... | python | def process_into(self, node, obj):
"""
Process a BeautifulSoup node and fill its elements into a pyth
base object.
"""
if isinstance(node, BeautifulSoup.NavigableString):
text = self.process_text(node)
if text:
obj.append(text)
... | [
"def",
"process_into",
"(",
"self",
",",
"node",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"BeautifulSoup",
".",
"NavigableString",
")",
":",
"text",
"=",
"self",
".",
"process_text",
"(",
"node",
")",
"if",
"text",
":",
"obj",
".",
... | Process a BeautifulSoup node and fill its elements into a pyth
base object. | [
"Process",
"a",
"BeautifulSoup",
"node",
"and",
"fill",
"its",
"elements",
"into",
"a",
"pyth",
"base",
"object",
"."
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/xhtml/reader.py#L139-L165 |
brendonh/pyth | pyth/document.py | _PythBase.append | def append(self, item):
"""
Try to add an item to this element.
If the item is of the wrong type, and if this element has a sub-type,
then try to create such a sub-type and insert the item into that, instead.
This happens recursively, so (in python-markup):
L ... | python | def append(self, item):
"""
Try to add an item to this element.
If the item is of the wrong type, and if this element has a sub-type,
then try to create such a sub-type and insert the item into that, instead.
This happens recursively, so (in python-markup):
L ... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"okay",
"=",
"True",
"if",
"not",
"isinstance",
"(",
"item",
",",
"self",
".",
"contentType",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"contentType",
",",
"'contentType'",
")",
":",
"try",
":",... | Try to add an item to this element.
If the item is of the wrong type, and if this element has a sub-type,
then try to create such a sub-type and insert the item into that, instead.
This happens recursively, so (in python-markup):
L [ u'Foo' ]
actually creates:
... | [
"Try",
"to",
"add",
"an",
"item",
"to",
"this",
"element",
"."
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/document.py#L30-L59 |
brendonh/pyth | pyth/plugins/python/reader.py | _MetaPythonBase | def _MetaPythonBase():
"""
Return a metaclass which implements __getitem__,
allowing e.g. P[...] instead of P()[...]
"""
class MagicGetItem(type):
def __new__(mcs, name, bases, dict):
klass = type.__new__(mcs, name, bases, dict)
mcs.__getitem__ = lambda _, k: kla... | python | def _MetaPythonBase():
"""
Return a metaclass which implements __getitem__,
allowing e.g. P[...] instead of P()[...]
"""
class MagicGetItem(type):
def __new__(mcs, name, bases, dict):
klass = type.__new__(mcs, name, bases, dict)
mcs.__getitem__ = lambda _, k: kla... | [
"def",
"_MetaPythonBase",
"(",
")",
":",
"class",
"MagicGetItem",
"(",
"type",
")",
":",
"def",
"__new__",
"(",
"mcs",
",",
"name",
",",
"bases",
",",
"dict",
")",
":",
"klass",
"=",
"type",
".",
"__new__",
"(",
"mcs",
",",
"name",
",",
"bases",
",... | Return a metaclass which implements __getitem__,
allowing e.g. P[...] instead of P()[...] | [
"Return",
"a",
"metaclass",
"which",
"implements",
"__getitem__",
"allowing",
"e",
".",
"g",
".",
"P",
"[",
"...",
"]",
"instead",
"of",
"P",
"()",
"[",
"...",
"]"
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/python/reader.py#L40-L52 |
brendonh/pyth | pyth/plugins/latex/writer.py | LatexWriter.write | def write(klass, document, target=None, stylesheet=""):
"""
convert a pyth document to a latex document
we can specify a stylesheet as a latex document fragment that
will be inserted after the headers. This way we can override
the default style.
"""
writer = Lat... | python | def write(klass, document, target=None, stylesheet=""):
"""
convert a pyth document to a latex document
we can specify a stylesheet as a latex document fragment that
will be inserted after the headers. This way we can override
the default style.
"""
writer = Lat... | [
"def",
"write",
"(",
"klass",
",",
"document",
",",
"target",
"=",
"None",
",",
"stylesheet",
"=",
"\"\"",
")",
":",
"writer",
"=",
"LatexWriter",
"(",
"document",
",",
"target",
",",
"stylesheet",
")",
"return",
"writer",
".",
"go",
"(",
")"
] | convert a pyth document to a latex document
we can specify a stylesheet as a latex document fragment that
will be inserted after the headers. This way we can override
the default style. | [
"convert",
"a",
"pyth",
"document",
"to",
"a",
"latex",
"document"
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/latex/writer.py#L19-L28 |
brendonh/pyth | pyth/plugins/latex/writer.py | LatexWriter.full_stylesheet | def full_stylesheet(self):
"""
Return the style sheet that will ultimately be inserted into
the latex document.
This is the user given style sheet plus some additional parts
to add the meta data.
"""
latex_fragment = r"""
\usepackage[colorlinks=true,linkc... | python | def full_stylesheet(self):
"""
Return the style sheet that will ultimately be inserted into
the latex document.
This is the user given style sheet plus some additional parts
to add the meta data.
"""
latex_fragment = r"""
\usepackage[colorlinks=true,linkc... | [
"def",
"full_stylesheet",
"(",
"self",
")",
":",
"latex_fragment",
"=",
"r\"\"\"\n \\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}\n \\hypersetup{\n pdftitle={%s},\n pdfauthor={%s},\n pdfsubject={%s}\n }\n \"\"\"",
"%",... | Return the style sheet that will ultimately be inserted into
the latex document.
This is the user given style sheet plus some additional parts
to add the meta data. | [
"Return",
"the",
"style",
"sheet",
"that",
"will",
"ultimately",
"be",
"inserted",
"into",
"the",
"latex",
"document",
"."
] | train | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/latex/writer.py#L42-L60 |
opentok/Opentok-Python-SDK | opentok/endpoints.py | Endpoints.get_stream_url | def get_stream_url(self, session_id, stream_id=None):
""" this method returns the url to get streams information """
url = self.api_url + '/v2/project/' + self.api_key + '/session/' + session_id + '/stream'
if stream_id:
url = url + '/' + stream_id
return url | python | def get_stream_url(self, session_id, stream_id=None):
""" this method returns the url to get streams information """
url = self.api_url + '/v2/project/' + self.api_key + '/session/' + session_id + '/stream'
if stream_id:
url = url + '/' + stream_id
return url | [
"def",
"get_stream_url",
"(",
"self",
",",
"session_id",
",",
"stream_id",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"api_url",
"+",
"'/v2/project/'",
"+",
"self",
".",
"api_key",
"+",
"'/session/'",
"+",
"session_id",
"+",
"'/stream'",
"if",
"stream... | this method returns the url to get streams information | [
"this",
"method",
"returns",
"the",
"url",
"to",
"get",
"streams",
"information"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/endpoints.py#L29-L34 |
opentok/Opentok-Python-SDK | opentok/endpoints.py | Endpoints.force_disconnect_url | def force_disconnect_url(self, session_id, connection_id):
""" this method returns the force disconnect url endpoint """
url = (
self.api_url + '/v2/project/' + self.api_key + '/session/' +
session_id + '/connection/' + connection_id
)
return url | python | def force_disconnect_url(self, session_id, connection_id):
""" this method returns the force disconnect url endpoint """
url = (
self.api_url + '/v2/project/' + self.api_key + '/session/' +
session_id + '/connection/' + connection_id
)
return url | [
"def",
"force_disconnect_url",
"(",
"self",
",",
"session_id",
",",
"connection_id",
")",
":",
"url",
"=",
"(",
"self",
".",
"api_url",
"+",
"'/v2/project/'",
"+",
"self",
".",
"api_key",
"+",
"'/session/'",
"+",
"session_id",
"+",
"'/connection/'",
"+",
"co... | this method returns the force disconnect url endpoint | [
"this",
"method",
"returns",
"the",
"force",
"disconnect",
"url",
"endpoint"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/endpoints.py#L36-L42 |
opentok/Opentok-Python-SDK | opentok/endpoints.py | Endpoints.set_archive_layout_url | def set_archive_layout_url(self, archive_id):
""" this method returns the url to set the archive layout """
url = self.api_url + '/v2/project/' + self.api_key + '/archive/' + archive_id + '/layout'
return url | python | def set_archive_layout_url(self, archive_id):
""" this method returns the url to set the archive layout """
url = self.api_url + '/v2/project/' + self.api_key + '/archive/' + archive_id + '/layout'
return url | [
"def",
"set_archive_layout_url",
"(",
"self",
",",
"archive_id",
")",
":",
"url",
"=",
"self",
".",
"api_url",
"+",
"'/v2/project/'",
"+",
"self",
".",
"api_key",
"+",
"'/archive/'",
"+",
"archive_id",
"+",
"'/layout'",
"return",
"url"
] | this method returns the url to set the archive layout | [
"this",
"method",
"returns",
"the",
"url",
"to",
"set",
"the",
"archive",
"layout"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/endpoints.py#L44-L47 |
opentok/Opentok-Python-SDK | opentok/endpoints.py | Endpoints.set_stream_class_lists_url | def set_stream_class_lists_url(self, session_id):
""" this method returns the url to set the stream class list """
url = self.api_url + '/v2/project/' + self.api_key + '/session/' + session_id + '/stream'
return url | python | def set_stream_class_lists_url(self, session_id):
""" this method returns the url to set the stream class list """
url = self.api_url + '/v2/project/' + self.api_key + '/session/' + session_id + '/stream'
return url | [
"def",
"set_stream_class_lists_url",
"(",
"self",
",",
"session_id",
")",
":",
"url",
"=",
"self",
".",
"api_url",
"+",
"'/v2/project/'",
"+",
"self",
".",
"api_key",
"+",
"'/session/'",
"+",
"session_id",
"+",
"'/stream'",
"return",
"url"
] | this method returns the url to set the stream class list | [
"this",
"method",
"returns",
"the",
"url",
"to",
"set",
"the",
"stream",
"class",
"list"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/endpoints.py#L54-L57 |
opentok/Opentok-Python-SDK | opentok/endpoints.py | Endpoints.broadcast_url | def broadcast_url(self, broadcast_id=None, stop=False, layout=False):
""" this method returns urls for working with broadcast """
url = self.api_url + '/v2/project/' + self.api_key + '/broadcast'
if broadcast_id:
url = url + '/' + broadcast_id
if stop:
url = url ... | python | def broadcast_url(self, broadcast_id=None, stop=False, layout=False):
""" this method returns urls for working with broadcast """
url = self.api_url + '/v2/project/' + self.api_key + '/broadcast'
if broadcast_id:
url = url + '/' + broadcast_id
if stop:
url = url ... | [
"def",
"broadcast_url",
"(",
"self",
",",
"broadcast_id",
"=",
"None",
",",
"stop",
"=",
"False",
",",
"layout",
"=",
"False",
")",
":",
"url",
"=",
"self",
".",
"api_url",
"+",
"'/v2/project/'",
"+",
"self",
".",
"api_key",
"+",
"'/broadcast'",
"if",
... | this method returns urls for working with broadcast | [
"this",
"method",
"returns",
"urls",
"for",
"working",
"with",
"broadcast"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/endpoints.py#L59-L69 |
opentok/Opentok-Python-SDK | opentok/archives.py | Archive.stop | def stop(self):
"""
Stops an OpenTok archive that is being recorded.
Archives automatically stop recording after 120 minutes or when all clients have
disconnected from the session being archived.
"""
temp_archive = self.sdk.stop_archive(self.id)
for k,v in iterit... | python | def stop(self):
"""
Stops an OpenTok archive that is being recorded.
Archives automatically stop recording after 120 minutes or when all clients have
disconnected from the session being archived.
"""
temp_archive = self.sdk.stop_archive(self.id)
for k,v in iterit... | [
"def",
"stop",
"(",
"self",
")",
":",
"temp_archive",
"=",
"self",
".",
"sdk",
".",
"stop_archive",
"(",
"self",
".",
"id",
")",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"temp_archive",
".",
"attrs",
"(",
")",
")",
":",
"setattr",
"(",
"self",... | Stops an OpenTok archive that is being recorded.
Archives automatically stop recording after 120 minutes or when all clients have
disconnected from the session being archived. | [
"Stops",
"an",
"OpenTok",
"archive",
"that",
"is",
"being",
"recorded",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/archives.py#L107-L116 |
opentok/Opentok-Python-SDK | opentok/archives.py | Archive.attrs | def attrs(self):
"""
Returns a dictionary of the archive's attributes.
"""
return dict((k, v) for k, v in iteritems(self.__dict__) if k is not "sdk") | python | def attrs(self):
"""
Returns a dictionary of the archive's attributes.
"""
return dict((k, v) for k, v in iteritems(self.__dict__) if k is not "sdk") | [
"def",
"attrs",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"self",
".",
"__dict__",
")",
"if",
"k",
"is",
"not",
"\"sdk\"",
")"
] | Returns a dictionary of the archive's attributes. | [
"Returns",
"a",
"dictionary",
"of",
"the",
"archive",
"s",
"attributes",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/archives.py#L129-L133 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.generate_token | def generate_token(self, session_id, role=Roles.publisher, expire_time=None, data=None,
initial_layout_class_list=[]):
"""
Generates a token for a given session.
:param String session_id: The session ID of the session to be accessed by the client using
the token.
:par... | python | def generate_token(self, session_id, role=Roles.publisher, expire_time=None, data=None,
initial_layout_class_list=[]):
"""
Generates a token for a given session.
:param String session_id: The session ID of the session to be accessed by the client using
the token.
:par... | [
"def",
"generate_token",
"(",
"self",
",",
"session_id",
",",
"role",
"=",
"Roles",
".",
"publisher",
",",
"expire_time",
"=",
"None",
",",
"data",
"=",
"None",
",",
"initial_layout_class_list",
"=",
"[",
"]",
")",
":",
"# normalize",
"# expire_time can be an ... | Generates a token for a given session.
:param String session_id: The session ID of the session to be accessed by the client using
the token.
:param String role: The role for the token. Valid values are defined in the Role
class:
* `Roles.subscriber` -- A subscriber can o... | [
"Generates",
"a",
"token",
"for",
"a",
"given",
"session",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L94-L202 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.create_session | def create_session(self, location=None, media_mode=MediaModes.relayed, archive_mode=ArchiveModes.manual):
"""
Creates a new OpenTok session and returns the session ID, which uniquely identifies
the session.
For example, when using the OpenTok JavaScript library, use the session ID when ... | python | def create_session(self, location=None, media_mode=MediaModes.relayed, archive_mode=ArchiveModes.manual):
"""
Creates a new OpenTok session and returns the session ID, which uniquely identifies
the session.
For example, when using the OpenTok JavaScript library, use the session ID when ... | [
"def",
"create_session",
"(",
"self",
",",
"location",
"=",
"None",
",",
"media_mode",
"=",
"MediaModes",
".",
"relayed",
",",
"archive_mode",
"=",
"ArchiveModes",
".",
"manual",
")",
":",
"# build options",
"options",
"=",
"{",
"}",
"if",
"not",
"isinstance... | Creates a new OpenTok session and returns the session ID, which uniquely identifies
the session.
For example, when using the OpenTok JavaScript library, use the session ID when calling the
OT.initSession() method (to initialize an OpenTok session).
OpenTok sessions do not expire. Howev... | [
"Creates",
"a",
"new",
"OpenTok",
"session",
"and",
"returns",
"the",
"session",
"ID",
"which",
"uniquely",
"identifies",
"the",
"session",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L204-L304 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.start_archive | def start_archive(self, session_id, has_audio=True, has_video=True, name=None, output_mode=OutputModes.composed, resolution=None):
"""
Starts archiving an OpenTok session.
Clients must be actively connected to the OpenTok session for you to successfully start
recording an archive.
... | python | def start_archive(self, session_id, has_audio=True, has_video=True, name=None, output_mode=OutputModes.composed, resolution=None):
"""
Starts archiving an OpenTok session.
Clients must be actively connected to the OpenTok session for you to successfully start
recording an archive.
... | [
"def",
"start_archive",
"(",
"self",
",",
"session_id",
",",
"has_audio",
"=",
"True",
",",
"has_video",
"=",
"True",
",",
"name",
"=",
"None",
",",
"output_mode",
"=",
"OutputModes",
".",
"composed",
",",
"resolution",
"=",
"None",
")",
":",
"if",
"not"... | Starts archiving an OpenTok session.
Clients must be actively connected to the OpenTok session for you to successfully start
recording an archive.
You can only record one archive at a time for a given session. You can only record archives
of sessions that use the OpenTok Media Router (... | [
"Starts",
"archiving",
"an",
"OpenTok",
"session",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L319-L389 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.stop_archive | def stop_archive(self, archive_id):
"""
Stops an OpenTok archive that is being recorded.
Archives automatically stop recording after 90 minutes or when all clients have disconnected
from the session being archived.
@param [String] archive_id The archive ID of the archive you wa... | python | def stop_archive(self, archive_id):
"""
Stops an OpenTok archive that is being recorded.
Archives automatically stop recording after 90 minutes or when all clients have disconnected
from the session being archived.
@param [String] archive_id The archive ID of the archive you wa... | [
"def",
"stop_archive",
"(",
"self",
",",
"archive_id",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"self",
".",
"endpoints",
".",
"archive_url",
"(",
"archive_id",
")",
"+",
"'/stop'",
",",
"headers",
"=",
"self",
".",
"json_headers",
"(",
"... | Stops an OpenTok archive that is being recorded.
Archives automatically stop recording after 90 minutes or when all clients have disconnected
from the session being archived.
@param [String] archive_id The archive ID of the archive you want to stop recording.
:rtype: The Archive objec... | [
"Stops",
"an",
"OpenTok",
"archive",
"that",
"is",
"being",
"recorded",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L391-L413 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.delete_archive | def delete_archive(self, archive_id):
"""
Deletes an OpenTok archive.
You can only delete an archive which has a status of "available" or "uploaded". Deleting an
archive removes its record from the list of archives. For an "available" archive, it also
removes the archive file, m... | python | def delete_archive(self, archive_id):
"""
Deletes an OpenTok archive.
You can only delete an archive which has a status of "available" or "uploaded". Deleting an
archive removes its record from the list of archives. For an "available" archive, it also
removes the archive file, m... | [
"def",
"delete_archive",
"(",
"self",
",",
"archive_id",
")",
":",
"response",
"=",
"requests",
".",
"delete",
"(",
"self",
".",
"endpoints",
".",
"archive_url",
"(",
"archive_id",
")",
",",
"headers",
"=",
"self",
".",
"json_headers",
"(",
")",
",",
"pr... | Deletes an OpenTok archive.
You can only delete an archive which has a status of "available" or "uploaded". Deleting an
archive removes its record from the list of archives. For an "available" archive, it also
removes the archive file, making it unavailable for download.
:param String ... | [
"Deletes",
"an",
"OpenTok",
"archive",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L415-L434 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.get_archive | def get_archive(self, archive_id):
"""Gets an Archive object for the given archive ID.
:param String archive_id: The archive ID.
:rtype: The Archive object.
"""
response = requests.get(self.endpoints.archive_url(archive_id), headers=self.json_headers(), proxies=self.proxies, ti... | python | def get_archive(self, archive_id):
"""Gets an Archive object for the given archive ID.
:param String archive_id: The archive ID.
:rtype: The Archive object.
"""
response = requests.get(self.endpoints.archive_url(archive_id), headers=self.json_headers(), proxies=self.proxies, ti... | [
"def",
"get_archive",
"(",
"self",
",",
"archive_id",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"endpoints",
".",
"archive_url",
"(",
"archive_id",
")",
",",
"headers",
"=",
"self",
".",
"json_headers",
"(",
")",
",",
"proxies"... | Gets an Archive object for the given archive ID.
:param String archive_id: The archive ID.
:rtype: The Archive object. | [
"Gets",
"an",
"Archive",
"object",
"for",
"the",
"given",
"archive",
"ID",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L436-L452 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.get_archives | def get_archives(self, offset=None, count=None, session_id=None):
"""Returns an ArchiveList, which is an array of archives that are completed and in-progress,
for your API key.
:param int: offset Optional. The index offset of the first archive. 0 is offset
of the most recently started... | python | def get_archives(self, offset=None, count=None, session_id=None):
"""Returns an ArchiveList, which is an array of archives that are completed and in-progress,
for your API key.
:param int: offset Optional. The index offset of the first archive. 0 is offset
of the most recently started... | [
"def",
"get_archives",
"(",
"self",
",",
"offset",
"=",
"None",
",",
"count",
"=",
"None",
",",
"session_id",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"offset",
"is",
"not",
"None",
":",
"params",
"[",
"'offset'",
"]",
"=",
"offset",
"... | Returns an ArchiveList, which is an array of archives that are completed and in-progress,
for your API key.
:param int: offset Optional. The index offset of the first archive. 0 is offset
of the most recently started archive. 1 is the offset of the archive that started prior to
the ... | [
"Returns",
"an",
"ArchiveList",
"which",
"is",
"an",
"array",
"of",
"archives",
"that",
"are",
"completed",
"and",
"in",
"-",
"progress",
"for",
"your",
"API",
"key",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L454-L488 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.list_archives | def list_archives(self, offset=None, count=None, session_id=None):
"""
New method to get archive list, it's alternative to 'get_archives()',
both methods exist to have backwards compatible
"""
return self.get_archives(offset, count, session_id) | python | def list_archives(self, offset=None, count=None, session_id=None):
"""
New method to get archive list, it's alternative to 'get_archives()',
both methods exist to have backwards compatible
"""
return self.get_archives(offset, count, session_id) | [
"def",
"list_archives",
"(",
"self",
",",
"offset",
"=",
"None",
",",
"count",
"=",
"None",
",",
"session_id",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_archives",
"(",
"offset",
",",
"count",
",",
"session_id",
")"
] | New method to get archive list, it's alternative to 'get_archives()',
both methods exist to have backwards compatible | [
"New",
"method",
"to",
"get",
"archive",
"list",
"it",
"s",
"alternative",
"to",
"get_archives",
"()",
"both",
"methods",
"exist",
"to",
"have",
"backwards",
"compatible"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L490-L495 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.signal | def signal(self, session_id, payload, connection_id=None):
"""
Send signals to all participants in an active OpenTok session or to a specific client
connected to that session.
:param String session_id: The session ID of the OpenTok session that receives the signal
:param Dictio... | python | def signal(self, session_id, payload, connection_id=None):
"""
Send signals to all participants in an active OpenTok session or to a specific client
connected to that session.
:param String session_id: The session ID of the OpenTok session that receives the signal
:param Dictio... | [
"def",
"signal",
"(",
"self",
",",
"session_id",
",",
"payload",
",",
"connection_id",
"=",
"None",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"self",
".",
"endpoints",
".",
"signaling_url",
"(",
"session_id",
",",
"connection_id",
")",
",",
... | Send signals to all participants in an active OpenTok session or to a specific client
connected to that session.
:param String session_id: The session ID of the OpenTok session that receives the signal
:param Dictionary payload: Structure that contains both the type and data fields. These
... | [
"Send",
"signals",
"to",
"all",
"participants",
"in",
"an",
"active",
"OpenTok",
"session",
"or",
"to",
"a",
"specific",
"client",
"connected",
"to",
"that",
"session",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L497-L531 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.get_stream | def get_stream(self, session_id, stream_id):
"""
Returns an Stream object that contains information of an OpenTok stream:
-id: The stream ID
-videoType: "camera" or "screen"
-name: The stream name (if one was set when the client published the stream)
-layoutClassList: It... | python | def get_stream(self, session_id, stream_id):
"""
Returns an Stream object that contains information of an OpenTok stream:
-id: The stream ID
-videoType: "camera" or "screen"
-name: The stream name (if one was set when the client published the stream)
-layoutClassList: It... | [
"def",
"get_stream",
"(",
"self",
",",
"session_id",
",",
"stream_id",
")",
":",
"endpoint",
"=",
"self",
".",
"endpoints",
".",
"get_stream_url",
"(",
"session_id",
",",
"stream_id",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"endpoint",
",",
"hea... | Returns an Stream object that contains information of an OpenTok stream:
-id: The stream ID
-videoType: "camera" or "screen"
-name: The stream name (if one was set when the client published the stream)
-layoutClassList: It's an array of the layout classes for the stream | [
"Returns",
"an",
"Stream",
"object",
"that",
"contains",
"information",
"of",
"an",
"OpenTok",
"stream",
":"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L533-L556 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.list_streams | def list_streams(self, session_id):
"""
Returns a list of Stream objects that contains information of all
the streams in a OpenTok session, with the following attributes:
-count: An integer that indicates the number of streams in the session
-items: List of the Stream objects
... | python | def list_streams(self, session_id):
"""
Returns a list of Stream objects that contains information of all
the streams in a OpenTok session, with the following attributes:
-count: An integer that indicates the number of streams in the session
-items: List of the Stream objects
... | [
"def",
"list_streams",
"(",
"self",
",",
"session_id",
")",
":",
"endpoint",
"=",
"self",
".",
"endpoints",
".",
"get_stream_url",
"(",
"session_id",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"endpoint",
",",
"headers",
"=",
"self",
".",
"json_hea... | Returns a list of Stream objects that contains information of all
the streams in a OpenTok session, with the following attributes:
-count: An integer that indicates the number of streams in the session
-items: List of the Stream objects | [
"Returns",
"a",
"list",
"of",
"Stream",
"objects",
"that",
"contains",
"information",
"of",
"all",
"the",
"streams",
"in",
"a",
"OpenTok",
"session",
"with",
"the",
"following",
"attributes",
":"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L558-L579 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.force_disconnect | def force_disconnect(self, session_id, connection_id):
"""
Sends a request to disconnect a client from an OpenTok session
:param String session_id: The session ID of the OpenTok session from which the
client will be disconnected
:param String connection_id: The connection ID of... | python | def force_disconnect(self, session_id, connection_id):
"""
Sends a request to disconnect a client from an OpenTok session
:param String session_id: The session ID of the OpenTok session from which the
client will be disconnected
:param String connection_id: The connection ID of... | [
"def",
"force_disconnect",
"(",
"self",
",",
"session_id",
",",
"connection_id",
")",
":",
"endpoint",
"=",
"self",
".",
"endpoints",
".",
"force_disconnect_url",
"(",
"session_id",
",",
"connection_id",
")",
"response",
"=",
"requests",
".",
"delete",
"(",
"e... | Sends a request to disconnect a client from an OpenTok session
:param String session_id: The session ID of the OpenTok session from which the
client will be disconnected
:param String connection_id: The connection ID of the client that will be disconnected | [
"Sends",
"a",
"request",
"to",
"disconnect",
"a",
"client",
"from",
"an",
"OpenTok",
"session"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L581-L604 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.set_archive_layout | def set_archive_layout(self, archive_id, layout_type, stylesheet=None):
"""
Use this method to change the layout of videos in an OpenTok archive
:param String archive_id: The ID of the archive that will be updated
:param String layout_type: The layout type for the archive. Valid values... | python | def set_archive_layout(self, archive_id, layout_type, stylesheet=None):
"""
Use this method to change the layout of videos in an OpenTok archive
:param String archive_id: The ID of the archive that will be updated
:param String layout_type: The layout type for the archive. Valid values... | [
"def",
"set_archive_layout",
"(",
"self",
",",
"archive_id",
",",
"layout_type",
",",
"stylesheet",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"'type'",
":",
"layout_type",
",",
"}",
"if",
"layout_type",
"==",
"'custom'",
":",
"if",
"stylesheet",
"is",
"n... | Use this method to change the layout of videos in an OpenTok archive
:param String archive_id: The ID of the archive that will be updated
:param String layout_type: The layout type for the archive. Valid values are:
'bestFit', 'custom', 'horizontalPresentation', 'pip' and 'verticalPresentation... | [
"Use",
"this",
"method",
"to",
"change",
"the",
"layout",
"of",
"videos",
"in",
"an",
"OpenTok",
"archive"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L606-L642 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.dial | def dial(self, session_id, token, sip_uri, options=[]):
"""
Use this method to connect a SIP platform to an OpenTok session. The audio from the end
of the SIP call is added to the OpenTok session as an audio-only stream. The OpenTok Media
Router mixes audio from other streams in the sess... | python | def dial(self, session_id, token, sip_uri, options=[]):
"""
Use this method to connect a SIP platform to an OpenTok session. The audio from the end
of the SIP call is added to the OpenTok session as an audio-only stream. The OpenTok Media
Router mixes audio from other streams in the sess... | [
"def",
"dial",
"(",
"self",
",",
"session_id",
",",
"token",
",",
"sip_uri",
",",
"options",
"=",
"[",
"]",
")",
":",
"payload",
"=",
"{",
"'sessionId'",
":",
"session_id",
",",
"'token'",
":",
"token",
",",
"'sip'",
":",
"{",
"'uri'",
":",
"sip_uri"... | Use this method to connect a SIP platform to an OpenTok session. The audio from the end
of the SIP call is added to the OpenTok session as an audio-only stream. The OpenTok Media
Router mixes audio from other streams in the session and sends the mixed audio to the SIP
endpoint
:param St... | [
"Use",
"this",
"method",
"to",
"connect",
"a",
"SIP",
"platform",
"to",
"an",
"OpenTok",
"session",
".",
"The",
"audio",
"from",
"the",
"end",
"of",
"the",
"SIP",
"call",
"is",
"added",
"to",
"the",
"OpenTok",
"session",
"as",
"an",
"audio",
"-",
"only... | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L644-L723 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.set_stream_class_lists | def set_stream_class_lists(self, session_id, payload):
"""
Use this method to change layout classes for OpenTok streams. The layout classes
define how the streams are displayed in the layout of a composed OpenTok archive
:param String session_id: The ID of the session of the streams tha... | python | def set_stream_class_lists(self, session_id, payload):
"""
Use this method to change layout classes for OpenTok streams. The layout classes
define how the streams are displayed in the layout of a composed OpenTok archive
:param String session_id: The ID of the session of the streams tha... | [
"def",
"set_stream_class_lists",
"(",
"self",
",",
"session_id",
",",
"payload",
")",
":",
"items_payload",
"=",
"{",
"'items'",
":",
"payload",
"}",
"endpoint",
"=",
"self",
".",
"endpoints",
".",
"set_stream_class_lists_url",
"(",
"session_id",
")",
"response"... | Use this method to change layout classes for OpenTok streams. The layout classes
define how the streams are displayed in the layout of a composed OpenTok archive
:param String session_id: The ID of the session of the streams that will be updated
:param List payload: A list defining the class l... | [
"Use",
"this",
"method",
"to",
"change",
"layout",
"classes",
"for",
"OpenTok",
"streams",
".",
"The",
"layout",
"classes",
"define",
"how",
"the",
"streams",
"are",
"displayed",
"in",
"the",
"layout",
"of",
"a",
"composed",
"OpenTok",
"archive"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L725-L764 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.start_broadcast | def start_broadcast(self, session_id, options):
"""
Use this method to start a live streaming for an OpenTok session. This broadcasts the
session to an HLS (HTTP live streaming) or to RTMP streams. To successfully start
broadcasting a session, at least one client must be connected to the... | python | def start_broadcast(self, session_id, options):
"""
Use this method to start a live streaming for an OpenTok session. This broadcasts the
session to an HLS (HTTP live streaming) or to RTMP streams. To successfully start
broadcasting a session, at least one client must be connected to the... | [
"def",
"start_broadcast",
"(",
"self",
",",
"session_id",
",",
"options",
")",
":",
"payload",
"=",
"{",
"'sessionId'",
":",
"session_id",
"}",
"payload",
".",
"update",
"(",
"options",
")",
"endpoint",
"=",
"self",
".",
"endpoints",
".",
"broadcast_url",
... | Use this method to start a live streaming for an OpenTok session. This broadcasts the
session to an HLS (HTTP live streaming) or to RTMP streams. To successfully start
broadcasting a session, at least one client must be connected to the session. You can only
start live streaming for sessions tha... | [
"Use",
"this",
"method",
"to",
"start",
"a",
"live",
"streaming",
"for",
"an",
"OpenTok",
"session",
".",
"This",
"broadcasts",
"the",
"session",
"to",
"an",
"HLS",
"(",
"HTTP",
"live",
"streaming",
")",
"or",
"to",
"RTMP",
"streams",
".",
"To",
"success... | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L766-L832 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.stop_broadcast | def stop_broadcast(self, broadcast_id):
"""
Use this method to stop a live broadcast of an OpenTok session
:param String broadcast_id: The ID of the broadcast you want to stop
:rtype A Broadcast object, which contains information of the broadcast: id, sessionId
projectId, creat... | python | def stop_broadcast(self, broadcast_id):
"""
Use this method to stop a live broadcast of an OpenTok session
:param String broadcast_id: The ID of the broadcast you want to stop
:rtype A Broadcast object, which contains information of the broadcast: id, sessionId
projectId, creat... | [
"def",
"stop_broadcast",
"(",
"self",
",",
"broadcast_id",
")",
":",
"endpoint",
"=",
"self",
".",
"endpoints",
".",
"broadcast_url",
"(",
"broadcast_id",
",",
"stop",
"=",
"True",
")",
"response",
"=",
"requests",
".",
"post",
"(",
"endpoint",
",",
"heade... | Use this method to stop a live broadcast of an OpenTok session
:param String broadcast_id: The ID of the broadcast you want to stop
:rtype A Broadcast object, which contains information of the broadcast: id, sessionId
projectId, createdAt, updatedAt and resolution | [
"Use",
"this",
"method",
"to",
"stop",
"a",
"live",
"broadcast",
"of",
"an",
"OpenTok",
"session"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L834-L864 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.get_broadcast | def get_broadcast(self, broadcast_id):
"""
Use this method to get details on a broadcast that is in-progress.
:param String broadcast_id: The ID of the broadcast you want to stop
:rtype A Broadcast object, which contains information of the broadcast: id, sessionId
projectId, cr... | python | def get_broadcast(self, broadcast_id):
"""
Use this method to get details on a broadcast that is in-progress.
:param String broadcast_id: The ID of the broadcast you want to stop
:rtype A Broadcast object, which contains information of the broadcast: id, sessionId
projectId, cr... | [
"def",
"get_broadcast",
"(",
"self",
",",
"broadcast_id",
")",
":",
"endpoint",
"=",
"self",
".",
"endpoints",
".",
"broadcast_url",
"(",
"broadcast_id",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"endpoint",
",",
"headers",
"=",
"self",
".",
"json... | Use this method to get details on a broadcast that is in-progress.
:param String broadcast_id: The ID of the broadcast you want to stop
:rtype A Broadcast object, which contains information of the broadcast: id, sessionId
projectId, createdAt, updatedAt, resolution, broadcastUrls and status | [
"Use",
"this",
"method",
"to",
"get",
"details",
"on",
"a",
"broadcast",
"that",
"is",
"in",
"-",
"progress",
"."
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L866-L894 |
opentok/Opentok-Python-SDK | opentok/opentok.py | OpenTok.set_broadcast_layout | def set_broadcast_layout(self, broadcast_id, layout_type, stylesheet=None):
"""
Use this method to change the layout type of a live streaming broadcast
:param String broadcast_id: The ID of the broadcast that will be updated
:param String layout_type: The layout type for the broadcast.... | python | def set_broadcast_layout(self, broadcast_id, layout_type, stylesheet=None):
"""
Use this method to change the layout type of a live streaming broadcast
:param String broadcast_id: The ID of the broadcast that will be updated
:param String layout_type: The layout type for the broadcast.... | [
"def",
"set_broadcast_layout",
"(",
"self",
",",
"broadcast_id",
",",
"layout_type",
",",
"stylesheet",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"'type'",
":",
"layout_type",
",",
"}",
"if",
"layout_type",
"==",
"'custom'",
":",
"if",
"stylesheet",
"is",
... | Use this method to change the layout type of a live streaming broadcast
:param String broadcast_id: The ID of the broadcast that will be updated
:param String layout_type: The layout type for the broadcast. Valid values are:
'bestFit', 'custom', 'horizontalPresentation', 'pip' and 'verticalPre... | [
"Use",
"this",
"method",
"to",
"change",
"the",
"layout",
"type",
"of",
"a",
"live",
"streaming",
"broadcast"
] | train | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L896-L934 |
mdorn/pyinstapaper | pyinstapaper/instapaper.py | Instapaper.login | def login(self, username, password):
'''Authenticate using XAuth variant of OAuth.
:param str username: Username or email address for the relevant account
:param str password: Password for the account
'''
response = self.request(
ACCESS_TOKEN,
{
... | python | def login(self, username, password):
'''Authenticate using XAuth variant of OAuth.
:param str username: Username or email address for the relevant account
:param str password: Password for the account
'''
response = self.request(
ACCESS_TOKEN,
{
... | [
"def",
"login",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"response",
"=",
"self",
".",
"request",
"(",
"ACCESS_TOKEN",
",",
"{",
"'x_auth_mode'",
":",
"'client_auth'",
",",
"'x_auth_username'",
":",
"username",
",",
"'x_auth_password'",
":",
... | Authenticate using XAuth variant of OAuth.
:param str username: Username or email address for the relevant account
:param str password: Password for the account | [
"Authenticate",
"using",
"XAuth",
"variant",
"of",
"OAuth",
"."
] | train | https://github.com/mdorn/pyinstapaper/blob/94f5f61ccd07079ba3967f788c555aea1a81cca5/pyinstapaper/instapaper.py#L34-L52 |
mdorn/pyinstapaper | pyinstapaper/instapaper.py | Instapaper.request | def request(self, path, params=None, returns_json=True,
method='POST', api_version=API_VERSION):
'''Process a request using the OAuth client's request method.
:param str path: Path fragment to the API endpoint, e.g. "resource/ID"
:param dict params: Parameters to pass to request... | python | def request(self, path, params=None, returns_json=True,
method='POST', api_version=API_VERSION):
'''Process a request using the OAuth client's request method.
:param str path: Path fragment to the API endpoint, e.g. "resource/ID"
:param dict params: Parameters to pass to request... | [
"def",
"request",
"(",
"self",
",",
"path",
",",
"params",
"=",
"None",
",",
"returns_json",
"=",
"True",
",",
"method",
"=",
"'POST'",
",",
"api_version",
"=",
"API_VERSION",
")",
":",
"time",
".",
"sleep",
"(",
"REQUEST_DELAY_SECS",
")",
"full_path",
"... | Process a request using the OAuth client's request method.
:param str path: Path fragment to the API endpoint, e.g. "resource/ID"
:param dict params: Parameters to pass to request
:param str method: Optional HTTP method, normally POST for Instapaper
:param str api_version: Optional alte... | [
"Process",
"a",
"request",
"using",
"the",
"OAuth",
"client",
"s",
"request",
"method",
"."
] | train | https://github.com/mdorn/pyinstapaper/blob/94f5f61ccd07079ba3967f788c555aea1a81cca5/pyinstapaper/instapaper.py#L54-L96 |
mdorn/pyinstapaper | pyinstapaper/instapaper.py | Instapaper.get_bookmarks | def get_bookmarks(self, folder='unread', limit=25, have=None):
"""Return list of user's bookmarks.
:param str folder: Optional. Possible values are unread (default),
starred, archive, or a folder_id value.
:param int limit: Optional. A number between 1 and 500, default 25.
:... | python | def get_bookmarks(self, folder='unread', limit=25, have=None):
"""Return list of user's bookmarks.
:param str folder: Optional. Possible values are unread (default),
starred, archive, or a folder_id value.
:param int limit: Optional. A number between 1 and 500, default 25.
:... | [
"def",
"get_bookmarks",
"(",
"self",
",",
"folder",
"=",
"'unread'",
",",
"limit",
"=",
"25",
",",
"have",
"=",
"None",
")",
":",
"path",
"=",
"'bookmarks/list'",
"params",
"=",
"{",
"'folder_id'",
":",
"folder",
",",
"'limit'",
":",
"limit",
"}",
"if"... | Return list of user's bookmarks.
:param str folder: Optional. Possible values are unread (default),
starred, archive, or a folder_id value.
:param int limit: Optional. A number between 1 and 500, default 25.
:param list have: Optional. A list of IDs to exclude from results
:... | [
"Return",
"list",
"of",
"user",
"s",
"bookmarks",
"."
] | train | https://github.com/mdorn/pyinstapaper/blob/94f5f61ccd07079ba3967f788c555aea1a81cca5/pyinstapaper/instapaper.py#L98-L121 |
mdorn/pyinstapaper | pyinstapaper/instapaper.py | Instapaper.get_folders | def get_folders(self):
"""Return list of user's folders.
:rtype: list
"""
path = 'folders/list'
response = self.request(path)
items = response['data']
folders = []
for item in items:
if item.get('type') == 'error':
raise Except... | python | def get_folders(self):
"""Return list of user's folders.
:rtype: list
"""
path = 'folders/list'
response = self.request(path)
items = response['data']
folders = []
for item in items:
if item.get('type') == 'error':
raise Except... | [
"def",
"get_folders",
"(",
"self",
")",
":",
"path",
"=",
"'folders/list'",
"response",
"=",
"self",
".",
"request",
"(",
"path",
")",
"items",
"=",
"response",
"[",
"'data'",
"]",
"folders",
"=",
"[",
"]",
"for",
"item",
"in",
"items",
":",
"if",
"i... | Return list of user's folders.
:rtype: list | [
"Return",
"list",
"of",
"user",
"s",
"folders",
"."
] | train | https://github.com/mdorn/pyinstapaper/blob/94f5f61ccd07079ba3967f788c555aea1a81cca5/pyinstapaper/instapaper.py#L123-L137 |
mdorn/pyinstapaper | pyinstapaper/instapaper.py | InstapaperObject.add | def add(self):
'''Save an object to Instapaper after instantiating it.
Example::
folder = Folder(instapaper, title='stuff')
result = folder.add()
'''
# TODO validation per object type
submit_attribs = {}
for attrib in self.ATTRIBUTES:
... | python | def add(self):
'''Save an object to Instapaper after instantiating it.
Example::
folder = Folder(instapaper, title='stuff')
result = folder.add()
'''
# TODO validation per object type
submit_attribs = {}
for attrib in self.ATTRIBUTES:
... | [
"def",
"add",
"(",
"self",
")",
":",
"# TODO validation per object type",
"submit_attribs",
"=",
"{",
"}",
"for",
"attrib",
"in",
"self",
".",
"ATTRIBUTES",
":",
"val",
"=",
"getattr",
"(",
"self",
",",
"attrib",
",",
"None",
")",
"if",
"val",
":",
"subm... | Save an object to Instapaper after instantiating it.
Example::
folder = Folder(instapaper, title='stuff')
result = folder.add() | [
"Save",
"an",
"object",
"to",
"Instapaper",
"after",
"instantiating",
"it",
"."
] | train | https://github.com/mdorn/pyinstapaper/blob/94f5f61ccd07079ba3967f788c555aea1a81cca5/pyinstapaper/instapaper.py#L173-L189 |
mdorn/pyinstapaper | pyinstapaper/instapaper.py | InstapaperObject._simple_action | def _simple_action(self, action=None):
'''Issue a request for an API method whose only param is the obj ID.
:param str action: The name of the action for the resource
:returns: Response from the API
:rtype: dict
'''
if not action:
raise Exception('No simple a... | python | def _simple_action(self, action=None):
'''Issue a request for an API method whose only param is the obj ID.
:param str action: The name of the action for the resource
:returns: Response from the API
:rtype: dict
'''
if not action:
raise Exception('No simple a... | [
"def",
"_simple_action",
"(",
"self",
",",
"action",
"=",
"None",
")",
":",
"if",
"not",
"action",
":",
"raise",
"Exception",
"(",
"'No simple action defined'",
")",
"path",
"=",
"\"/\"",
".",
"join",
"(",
"[",
"self",
".",
"RESOURCE",
",",
"action",
"]"... | Issue a request for an API method whose only param is the obj ID.
:param str action: The name of the action for the resource
:returns: Response from the API
:rtype: dict | [
"Issue",
"a",
"request",
"for",
"an",
"API",
"method",
"whose",
"only",
"param",
"is",
"the",
"obj",
"ID",
"."
] | train | https://github.com/mdorn/pyinstapaper/blob/94f5f61ccd07079ba3967f788c555aea1a81cca5/pyinstapaper/instapaper.py#L191-L204 |
mdorn/pyinstapaper | pyinstapaper/instapaper.py | Bookmark.get_highlights | def get_highlights(self):
'''Get highlights for Bookmark instance.
:return: list of ``Highlight`` objects
:rtype: list
'''
# NOTE: all Instapaper API methods use POST except this one!
path = '/'.join([self.RESOURCE, str(self.object_id), 'highlights'])
response = ... | python | def get_highlights(self):
'''Get highlights for Bookmark instance.
:return: list of ``Highlight`` objects
:rtype: list
'''
# NOTE: all Instapaper API methods use POST except this one!
path = '/'.join([self.RESOURCE, str(self.object_id), 'highlights'])
response = ... | [
"def",
"get_highlights",
"(",
"self",
")",
":",
"# NOTE: all Instapaper API methods use POST except this one!",
"path",
"=",
"'/'",
".",
"join",
"(",
"[",
"self",
".",
"RESOURCE",
",",
"str",
"(",
"self",
".",
"object_id",
")",
",",
"'highlights'",
"]",
")",
"... | Get highlights for Bookmark instance.
:return: list of ``Highlight`` objects
:rtype: list | [
"Get",
"highlights",
"for",
"Bookmark",
"instance",
"."
] | train | https://github.com/mdorn/pyinstapaper/blob/94f5f61ccd07079ba3967f788c555aea1a81cca5/pyinstapaper/instapaper.py#L242-L258 |
Jetsetter/graphyte | graphyte.py | Sender.stop | def stop(self):
"""Tell the sender thread to finish and wait for it to stop sending
(should be at most "timeout" seconds).
"""
if self.interval is not None:
self._queue.put_nowait(None)
self._thread.join()
self.interval = None | python | def stop(self):
"""Tell the sender thread to finish and wait for it to stop sending
(should be at most "timeout" seconds).
"""
if self.interval is not None:
self._queue.put_nowait(None)
self._thread.join()
self.interval = None | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"interval",
"is",
"not",
"None",
":",
"self",
".",
"_queue",
".",
"put_nowait",
"(",
"None",
")",
"self",
".",
"_thread",
".",
"join",
"(",
")",
"self",
".",
"interval",
"=",
"None"
] | Tell the sender thread to finish and wait for it to stop sending
(should be at most "timeout" seconds). | [
"Tell",
"the",
"sender",
"thread",
"to",
"finish",
"and",
"wait",
"for",
"it",
"to",
"stop",
"sending",
"(",
"should",
"be",
"at",
"most",
"timeout",
"seconds",
")",
"."
] | train | https://github.com/Jetsetter/graphyte/blob/200781c5105140df32b8e18bbec497cc0be5d40e/graphyte.py#L58-L65 |
Jetsetter/graphyte | graphyte.py | Sender.build_message | def build_message(self, metric, value, timestamp, tags={}):
"""Build a Graphite message to send and return it as a byte string."""
if not metric or metric.split(None, 1)[0] != metric:
raise ValueError('"metric" must not have whitespace in it')
if not isinstance(value, (int, float)):
... | python | def build_message(self, metric, value, timestamp, tags={}):
"""Build a Graphite message to send and return it as a byte string."""
if not metric or metric.split(None, 1)[0] != metric:
raise ValueError('"metric" must not have whitespace in it')
if not isinstance(value, (int, float)):
... | [
"def",
"build_message",
"(",
"self",
",",
"metric",
",",
"value",
",",
"timestamp",
",",
"tags",
"=",
"{",
"}",
")",
":",
"if",
"not",
"metric",
"or",
"metric",
".",
"split",
"(",
"None",
",",
"1",
")",
"[",
"0",
"]",
"!=",
"metric",
":",
"raise"... | Build a Graphite message to send and return it as a byte string. | [
"Build",
"a",
"Graphite",
"message",
"to",
"send",
"and",
"return",
"it",
"as",
"a",
"byte",
"string",
"."
] | train | https://github.com/Jetsetter/graphyte/blob/200781c5105140df32b8e18bbec497cc0be5d40e/graphyte.py#L67-L85 |
Jetsetter/graphyte | graphyte.py | Sender.send | def send(self, metric, value, timestamp=None, tags={}):
"""Send given metric and (int or float) value to Graphite host.
Performs send on background thread if "interval" was specified when
creating this Sender.
If a "tags" dict is specified, send the tags to the Graphite host along with ... | python | def send(self, metric, value, timestamp=None, tags={}):
"""Send given metric and (int or float) value to Graphite host.
Performs send on background thread if "interval" was specified when
creating this Sender.
If a "tags" dict is specified, send the tags to the Graphite host along with ... | [
"def",
"send",
"(",
"self",
",",
"metric",
",",
"value",
",",
"timestamp",
"=",
"None",
",",
"tags",
"=",
"{",
"}",
")",
":",
"if",
"timestamp",
"is",
"None",
":",
"timestamp",
"=",
"time",
".",
"time",
"(",
")",
"message",
"=",
"self",
".",
"bui... | Send given metric and (int or float) value to Graphite host.
Performs send on background thread if "interval" was specified when
creating this Sender.
If a "tags" dict is specified, send the tags to the Graphite host along with the metric. | [
"Send",
"given",
"metric",
"and",
"(",
"int",
"or",
"float",
")",
"value",
"to",
"Graphite",
"host",
".",
"Performs",
"send",
"on",
"background",
"thread",
"if",
"interval",
"was",
"specified",
"when",
"creating",
"this",
"Sender",
"."
] | train | https://github.com/Jetsetter/graphyte/blob/200781c5105140df32b8e18bbec497cc0be5d40e/graphyte.py#L87-L104 |
Jetsetter/graphyte | graphyte.py | Sender.send_socket | def send_socket(self, message):
"""Low-level function to send message bytes to this Sender's socket.
You should usually call send() instead of this function (unless you're
subclassing or writing unit tests).
"""
if self.log_sends:
start_time = time.time()
try:... | python | def send_socket(self, message):
"""Low-level function to send message bytes to this Sender's socket.
You should usually call send() instead of this function (unless you're
subclassing or writing unit tests).
"""
if self.log_sends:
start_time = time.time()
try:... | [
"def",
"send_socket",
"(",
"self",
",",
"message",
")",
":",
"if",
"self",
".",
"log_sends",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"try",
":",
"self",
".",
"send_message",
"(",
"message",
")",
"except",
"Exception",
"as",
"error",
":",... | Low-level function to send message bytes to this Sender's socket.
You should usually call send() instead of this function (unless you're
subclassing or writing unit tests). | [
"Low",
"-",
"level",
"function",
"to",
"send",
"message",
"bytes",
"to",
"this",
"Sender",
"s",
"socket",
".",
"You",
"should",
"usually",
"call",
"send",
"()",
"instead",
"of",
"this",
"function",
"(",
"unless",
"you",
"re",
"subclassing",
"or",
"writing"... | train | https://github.com/Jetsetter/graphyte/blob/200781c5105140df32b8e18bbec497cc0be5d40e/graphyte.py#L123-L138 |
Jetsetter/graphyte | graphyte.py | Sender._thread_loop | def _thread_loop(self):
"""Background thread used when Sender is in asynchronous/interval mode."""
last_check_time = time.time()
messages = []
while True:
# Get first message from queue, blocking until the next time we
# should be sending
time_since_la... | python | def _thread_loop(self):
"""Background thread used when Sender is in asynchronous/interval mode."""
last_check_time = time.time()
messages = []
while True:
# Get first message from queue, blocking until the next time we
# should be sending
time_since_la... | [
"def",
"_thread_loop",
"(",
"self",
")",
":",
"last_check_time",
"=",
"time",
".",
"time",
"(",
")",
"messages",
"=",
"[",
"]",
"while",
"True",
":",
"# Get first message from queue, blocking until the next time we",
"# should be sending",
"time_since_last_check",
"=",
... | Background thread used when Sender is in asynchronous/interval mode. | [
"Background",
"thread",
"used",
"when",
"Sender",
"is",
"in",
"asynchronous",
"/",
"interval",
"mode",
"."
] | train | https://github.com/Jetsetter/graphyte/blob/200781c5105140df32b8e18bbec497cc0be5d40e/graphyte.py#L140-L186 |
gbowerman/azurerm | examples/get_vmss_rolling_upgrade.py | main | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument(
'--vmssname', '-n', required=True, action='store', help='VMSS Name')
arg_parser.add_argument('--rgname', '-g', required=True, action='store',
... | python | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument(
'--vmssname', '-n', required=True, action='store', help='VMSS Name')
arg_parser.add_argument('--rgname', '-g', required=True, action='store',
... | [
"def",
"main",
"(",
")",
":",
"# validate command line arguments",
"arg_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"arg_parser",
".",
"add_argument",
"(",
"'--vmssname'",
",",
"'-n'",
",",
"required",
"=",
"True",
",",
"action",
"=",
"'store'",
... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/get_vmss_rolling_upgrade.py#L9-L50 |
gbowerman/azurerm | examples/get_vmss.py | main | def main():
'''Main routine.'''
# process arguments
if len(sys.argv) < 3:
usage()
rgname = sys.argv[1]
vmss_name = sys.argv[2]
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotF... | python | def main():
'''Main routine.'''
# process arguments
if len(sys.argv) < 3:
usage()
rgname = sys.argv[1]
vmss_name = sys.argv[2]
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotF... | [
"def",
"main",
"(",
")",
":",
"# process arguments",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"<",
"3",
":",
"usage",
"(",
")",
"rgname",
"=",
"sys",
".",
"argv",
"[",
"1",
"]",
"vmss_name",
"=",
"sys",
".",
"argv",
"[",
"2",
"]",
"# Load Azure... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/get_vmss.py#L13-L63 |
gbowerman/azurerm | examples/list_vmss_nics.py | get_rg_from_id | def get_rg_from_id(vmss_id):
'''get a resource group name from a VMSS ID string'''
rgname = re.search('Groups/(.+?)/providers', vmss_id).group(1)
print('Resource group: ' + rgname)
return rgname | python | def get_rg_from_id(vmss_id):
'''get a resource group name from a VMSS ID string'''
rgname = re.search('Groups/(.+?)/providers', vmss_id).group(1)
print('Resource group: ' + rgname)
return rgname | [
"def",
"get_rg_from_id",
"(",
"vmss_id",
")",
":",
"rgname",
"=",
"re",
".",
"search",
"(",
"'Groups/(.+?)/providers'",
",",
"vmss_id",
")",
".",
"group",
"(",
"1",
")",
"print",
"(",
"'Resource group: '",
"+",
"rgname",
")",
"return",
"rgname"
] | get a resource group name from a VMSS ID string | [
"get",
"a",
"resource",
"group",
"name",
"from",
"a",
"VMSS",
"ID",
"string"
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_vmss_nics.py#L9-L13 |
gbowerman/azurerm | examples/list_vmss_nics.py | main | def main():
'''main routine'''
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotFoundError:
sys.exit('Error: Expecting azurermconfig.json in current folder')
tenant_id = config_data['tenantI... | python | def main():
'''main routine'''
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotFoundError:
sys.exit('Error: Expecting azurermconfig.json in current folder')
tenant_id = config_data['tenantI... | [
"def",
"main",
"(",
")",
":",
"# Load Azure app defaults",
"try",
":",
"with",
"open",
"(",
"'azurermconfig.json'",
")",
"as",
"config_file",
":",
"config_data",
"=",
"json",
".",
"load",
"(",
"config_file",
")",
"except",
"FileNotFoundError",
":",
"sys",
".",... | main routine | [
"main",
"routine"
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_vmss_nics.py#L16-L56 |
gbowerman/azurerm | azurerm/restfns.py | get_user_agent | def get_user_agent():
'''User-Agent Header. Sends library identification to Azure endpoint.
'''
version = pkg_resources.require("azurerm")[0].version
user_agent = "python/{} ({}) requests/{} azurerm/{}".format(
platform.python_version(),
platform.platform(),
requests.__version__,... | python | def get_user_agent():
'''User-Agent Header. Sends library identification to Azure endpoint.
'''
version = pkg_resources.require("azurerm")[0].version
user_agent = "python/{} ({}) requests/{} azurerm/{}".format(
platform.python_version(),
platform.platform(),
requests.__version__,... | [
"def",
"get_user_agent",
"(",
")",
":",
"version",
"=",
"pkg_resources",
".",
"require",
"(",
"\"azurerm\"",
")",
"[",
"0",
"]",
".",
"version",
"user_agent",
"=",
"\"python/{} ({}) requests/{} azurerm/{}\"",
".",
"format",
"(",
"platform",
".",
"python_version",
... | User-Agent Header. Sends library identification to Azure endpoint. | [
"User",
"-",
"Agent",
"Header",
".",
"Sends",
"library",
"identification",
"to",
"Azure",
"endpoint",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L9-L18 |
gbowerman/azurerm | azurerm/restfns.py | do_get | def do_get(endpoint, access_token):
'''Do an HTTP GET request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body.
'''
headers = {"Authorization": 'Beare... | python | def do_get(endpoint, access_token):
'''Do an HTTP GET request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body.
'''
headers = {"Authorization": 'Beare... | [
"def",
"do_get",
"(",
"endpoint",
",",
"access_token",
")",
":",
"headers",
"=",
"{",
"\"Authorization\"",
":",
"'Bearer '",
"+",
"access_token",
"}",
"headers",
"[",
"'User-Agent'",
"]",
"=",
"get_user_agent",
"(",
")",
"return",
"requests",
".",
"get",
"("... | Do an HTTP GET request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body. | [
"Do",
"an",
"HTTP",
"GET",
"request",
"and",
"return",
"JSON",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L20-L32 |
gbowerman/azurerm | azurerm/restfns.py | do_get_next | def do_get_next(endpoint, access_token):
'''Do an HTTP GET request, follow the nextLink chain and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body.
'''
he... | python | def do_get_next(endpoint, access_token):
'''Do an HTTP GET request, follow the nextLink chain and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body.
'''
he... | [
"def",
"do_get_next",
"(",
"endpoint",
",",
"access_token",
")",
":",
"headers",
"=",
"{",
"\"Authorization\"",
":",
"'Bearer '",
"+",
"access_token",
"}",
"headers",
"[",
"'User-Agent'",
"]",
"=",
"get_user_agent",
"(",
")",
"looping",
"=",
"True",
"value_lis... | Do an HTTP GET request, follow the nextLink chain and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body. | [
"Do",
"an",
"HTTP",
"GET",
"request",
"follow",
"the",
"nextLink",
"chain",
"and",
"return",
"JSON",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L35-L60 |
gbowerman/azurerm | azurerm/restfns.py | do_delete | def do_delete(endpoint, access_token):
'''Do an HTTP GET request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response.
'''
headers = {"Authorization": 'Bearer ' + ac... | python | def do_delete(endpoint, access_token):
'''Do an HTTP GET request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response.
'''
headers = {"Authorization": 'Bearer ' + ac... | [
"def",
"do_delete",
"(",
"endpoint",
",",
"access_token",
")",
":",
"headers",
"=",
"{",
"\"Authorization\"",
":",
"'Bearer '",
"+",
"access_token",
"}",
"headers",
"[",
"'User-Agent'",
"]",
"=",
"get_user_agent",
"(",
")",
"return",
"requests",
".",
"delete",... | Do an HTTP GET request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. | [
"Do",
"an",
"HTTP",
"GET",
"request",
"and",
"return",
"JSON",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L63-L75 |
gbowerman/azurerm | azurerm/restfns.py | do_patch | def do_patch(endpoint, body, access_token):
'''Do an HTTP PATCH request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to patch.
access_token (str): A valid Azure authentication token.
Returns:
HTTP re... | python | def do_patch(endpoint, body, access_token):
'''Do an HTTP PATCH request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to patch.
access_token (str): A valid Azure authentication token.
Returns:
HTTP re... | [
"def",
"do_patch",
"(",
"endpoint",
",",
"body",
",",
"access_token",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
",",
"\"Authorization\"",
":",
"'Bearer '",
"+",
"access_token",
"}",
"headers",
"[",
"'User-Agent'",
"]",
"=",
... | Do an HTTP PATCH request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to patch.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body. | [
"Do",
"an",
"HTTP",
"PATCH",
"request",
"and",
"return",
"JSON",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L78-L91 |
gbowerman/azurerm | azurerm/restfns.py | do_post | def do_post(endpoint, body, access_token):
'''Do an HTTP POST request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to post.
access_token (str): A valid Azure authentication token.
Returns:
HTTP respo... | python | def do_post(endpoint, body, access_token):
'''Do an HTTP POST request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to post.
access_token (str): A valid Azure authentication token.
Returns:
HTTP respo... | [
"def",
"do_post",
"(",
"endpoint",
",",
"body",
",",
"access_token",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
",",
"\"Authorization\"",
":",
"'Bearer '",
"+",
"access_token",
"}",
"headers",
"[",
"'User-Agent'",
"]",
"=",
... | Do an HTTP POST request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to post.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body. | [
"Do",
"an",
"HTTP",
"POST",
"request",
"and",
"return",
"JSON",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L94-L107 |
gbowerman/azurerm | azurerm/restfns.py | do_put | def do_put(endpoint, body, access_token):
'''Do an HTTP PUT request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to put.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response... | python | def do_put(endpoint, body, access_token):
'''Do an HTTP PUT request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to put.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response... | [
"def",
"do_put",
"(",
"endpoint",
",",
"body",
",",
"access_token",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
",",
"\"Authorization\"",
":",
"'Bearer '",
"+",
"access_token",
"}",
"headers",
"[",
"'User-Agent'",
"]",
"=",
... | Do an HTTP PUT request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to put.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body. | [
"Do",
"an",
"HTTP",
"PUT",
"request",
"and",
"return",
"JSON",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L110-L123 |
gbowerman/azurerm | azurerm/restfns.py | get_url | def get_url(access_token, endpoint=ams_rest_endpoint, flag=True):
'''Get Media Services Final Endpoint URL.
Args:
access_token (str): A valid Azure authentication token.
endpoint (str): Azure Media Services Initial Endpoint.
flag (bol): flag.
Returns:
HTTP response. JSON bod... | python | def get_url(access_token, endpoint=ams_rest_endpoint, flag=True):
'''Get Media Services Final Endpoint URL.
Args:
access_token (str): A valid Azure authentication token.
endpoint (str): Azure Media Services Initial Endpoint.
flag (bol): flag.
Returns:
HTTP response. JSON bod... | [
"def",
"get_url",
"(",
"access_token",
",",
"endpoint",
"=",
"ams_rest_endpoint",
",",
"flag",
"=",
"True",
")",
":",
"return",
"do_ams_get_url",
"(",
"endpoint",
",",
"access_token",
",",
"flag",
")"
] | Get Media Services Final Endpoint URL.
Args:
access_token (str): A valid Azure authentication token.
endpoint (str): Azure Media Services Initial Endpoint.
flag (bol): flag.
Returns:
HTTP response. JSON body. | [
"Get",
"Media",
"Services",
"Final",
"Endpoint",
"URL",
".",
"Args",
":",
"access_token",
"(",
"str",
")",
":",
"A",
"valid",
"Azure",
"authentication",
"token",
".",
"endpoint",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Initial",
"Endpoint",
".... | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L126-L136 |
gbowerman/azurerm | azurerm/restfns.py | do_ams_auth | def do_ams_auth(endpoint, body):
'''Acquire Media Services Authentication Token.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
body (str): A Content Body.
Returns:
HTTP response. JSON body.
'''
headers = {"content-type": "application/x-www-form-urlencoded",
... | python | def do_ams_auth(endpoint, body):
'''Acquire Media Services Authentication Token.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
body (str): A Content Body.
Returns:
HTTP response. JSON body.
'''
headers = {"content-type": "application/x-www-form-urlencoded",
... | [
"def",
"do_ams_auth",
"(",
"endpoint",
",",
"body",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/x-www-form-urlencoded\"",
",",
"\"Accept\"",
":",
"json_acceptformat",
"}",
"return",
"requests",
".",
"post",
"(",
"endpoint",
",",
"data",
... | Acquire Media Services Authentication Token.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
body (str): A Content Body.
Returns:
HTTP response. JSON body. | [
"Acquire",
"Media",
"Services",
"Authentication",
"Token",
".",
"Args",
":",
"endpoint",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Initial",
"Endpoint",
".",
"body",
"(",
"str",
")",
":",
"A",
"Content",
"Body",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L139-L150 |
gbowerman/azurerm | azurerm/restfns.py | do_ams_put | def do_ams_put(endpoint, path, body, access_token, rformat="json", ds_min_version="3.0;NetFx"):
'''Do a AMS HTTP PUT request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
body (str): Azure Media Services Con... | python | def do_ams_put(endpoint, path, body, access_token, rformat="json", ds_min_version="3.0;NetFx"):
'''Do a AMS HTTP PUT request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
body (str): Azure Media Services Con... | [
"def",
"do_ams_put",
"(",
"endpoint",
",",
"path",
",",
"body",
",",
"access_token",
",",
"rformat",
"=",
"\"json\"",
",",
"ds_min_version",
"=",
"\"3.0;NetFx\"",
")",
":",
"min_ds",
"=",
"dsversion_min",
"content_acceptformat",
"=",
"json_acceptformat",
"if",
"... | Do a AMS HTTP PUT request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
body (str): Azure Media Services Content Body.
access_token (str): A valid Azure authentication token.
rformat (str): A req... | [
"Do",
"a",
"AMS",
"HTTP",
"PUT",
"request",
"and",
"return",
"JSON",
".",
"Args",
":",
"endpoint",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Initial",
"Endpoint",
".",
"path",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Endpoint",
"... | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L180-L211 |
gbowerman/azurerm | azurerm/restfns.py | do_ams_post | def do_ams_post(endpoint, path, body, access_token, rformat="json", ds_min_version="3.0;NetFx"):
'''Do a AMS HTTP POST request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
body (str): Azure Media Services C... | python | def do_ams_post(endpoint, path, body, access_token, rformat="json", ds_min_version="3.0;NetFx"):
'''Do a AMS HTTP POST request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
body (str): Azure Media Services C... | [
"def",
"do_ams_post",
"(",
"endpoint",
",",
"path",
",",
"body",
",",
"access_token",
",",
"rformat",
"=",
"\"json\"",
",",
"ds_min_version",
"=",
"\"3.0;NetFx\"",
")",
":",
"min_ds",
"=",
"dsversion_min",
"content_acceptformat",
"=",
"json_acceptformat",
"acceptf... | Do a AMS HTTP POST request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
body (str): Azure Media Services Content Body.
access_token (str): A valid Azure authentication token.
rformat (str): A re... | [
"Do",
"a",
"AMS",
"HTTP",
"POST",
"request",
"and",
"return",
"JSON",
".",
"Args",
":",
"endpoint",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Initial",
"Endpoint",
".",
"path",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Endpoint",
... | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L214-L249 |
gbowerman/azurerm | azurerm/restfns.py | do_ams_patch | def do_ams_patch(endpoint, path, body, access_token):
'''Do a AMS PATCH request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
body (str): Azure Media Services Content Body.
access_token (str): A vali... | python | def do_ams_patch(endpoint, path, body, access_token):
'''Do a AMS PATCH request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
body (str): Azure Media Services Content Body.
access_token (str): A vali... | [
"def",
"do_ams_patch",
"(",
"endpoint",
",",
"path",
",",
"body",
",",
"access_token",
")",
":",
"headers",
"=",
"{",
"\"Content-Type\"",
":",
"json_acceptformat",
",",
"\"DataServiceVersion\"",
":",
"dsversion_min",
",",
"\"MaxDataServiceVersion\"",
":",
"dsversion... | Do a AMS PATCH request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
body (str): Azure Media Services Content Body.
access_token (str): A valid Azure authentication token.
Returns:
HTTP resp... | [
"Do",
"a",
"AMS",
"PATCH",
"request",
"and",
"return",
"JSON",
".",
"Args",
":",
"endpoint",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Initial",
"Endpoint",
".",
"path",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Endpoint",
"Path",
... | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L252-L276 |
gbowerman/azurerm | azurerm/restfns.py | do_ams_delete | def do_ams_delete(endpoint, path, access_token):
'''Do a AMS DELETE request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
access_token (str): A valid Azure authentication token.
Returns:
HTTP res... | python | def do_ams_delete(endpoint, path, access_token):
'''Do a AMS DELETE request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
access_token (str): A valid Azure authentication token.
Returns:
HTTP res... | [
"def",
"do_ams_delete",
"(",
"endpoint",
",",
"path",
",",
"access_token",
")",
":",
"headers",
"=",
"{",
"\"DataServiceVersion\"",
":",
"dsversion_min",
",",
"\"MaxDataServiceVersion\"",
":",
"dsversion_max",
",",
"\"Accept\"",
":",
"json_acceptformat",
",",
"\"Acc... | Do a AMS DELETE request and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
path (str): Azure Media Services Endpoint Path.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body. | [
"Do",
"a",
"AMS",
"DELETE",
"request",
"and",
"return",
"JSON",
".",
"Args",
":",
"endpoint",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Initial",
"Endpoint",
".",
"path",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Endpoint",
"Path",
... | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L279-L301 |
gbowerman/azurerm | azurerm/restfns.py | do_ams_sto_put | def do_ams_sto_put(endpoint, body, content_length):
'''Do a PUT request to the Azure Storage API and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
body (str): Azure Media Services Content Body.
content_length (str): Content_length.
Returns:
HTTP ... | python | def do_ams_sto_put(endpoint, body, content_length):
'''Do a PUT request to the Azure Storage API and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
body (str): Azure Media Services Content Body.
content_length (str): Content_length.
Returns:
HTTP ... | [
"def",
"do_ams_sto_put",
"(",
"endpoint",
",",
"body",
",",
"content_length",
")",
":",
"headers",
"=",
"{",
"\"Accept\"",
":",
"json_acceptformat",
",",
"\"Accept-Charset\"",
":",
"charset",
",",
"\"x-ms-blob-type\"",
":",
"\"BlockBlob\"",
",",
"\"x-ms-meta-m1\"",
... | Do a PUT request to the Azure Storage API and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
body (str): Azure Media Services Content Body.
content_length (str): Content_length.
Returns:
HTTP response. JSON body. | [
"Do",
"a",
"PUT",
"request",
"to",
"the",
"Azure",
"Storage",
"API",
"and",
"return",
"JSON",
".",
"Args",
":",
"endpoint",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Initial",
"Endpoint",
".",
"body",
"(",
"str",
")",
":",
"Azure",
"Media",
... | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L304-L321 |
gbowerman/azurerm | azurerm/restfns.py | do_ams_get_url | def do_ams_get_url(endpoint, access_token, flag=True):
'''Do an AMS GET request to retrieve the Final AMS Endpoint and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
access_token (str): A valid Azure authentication token.
flag (str): A Flag to follow the redir... | python | def do_ams_get_url(endpoint, access_token, flag=True):
'''Do an AMS GET request to retrieve the Final AMS Endpoint and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
access_token (str): A valid Azure authentication token.
flag (str): A Flag to follow the redir... | [
"def",
"do_ams_get_url",
"(",
"endpoint",
",",
"access_token",
",",
"flag",
"=",
"True",
")",
":",
"headers",
"=",
"{",
"\"Content-Type\"",
":",
"json_acceptformat",
",",
"\"DataServiceVersion\"",
":",
"dsversion_min",
",",
"\"MaxDataServiceVersion\"",
":",
"dsversi... | Do an AMS GET request to retrieve the Final AMS Endpoint and return JSON.
Args:
endpoint (str): Azure Media Services Initial Endpoint.
access_token (str): A valid Azure authentication token.
flag (str): A Flag to follow the redirect or not.
Returns:
HTTP response. JSON body. | [
"Do",
"an",
"AMS",
"GET",
"request",
"to",
"retrieve",
"the",
"Final",
"AMS",
"Endpoint",
"and",
"return",
"JSON",
".",
"Args",
":",
"endpoint",
"(",
"str",
")",
":",
"Azure",
"Media",
"Services",
"Initial",
"Endpoint",
".",
"access_token",
"(",
"str",
"... | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L324-L346 |
gbowerman/azurerm | examples/vip_swap.py | handle_bad_update | def handle_bad_update(operation, ret):
'''report error for bad update'''
print("Error " + operation)
sys.exit('Return code: ' + str(ret.status_code) + ' Error: ' + ret.text) | python | def handle_bad_update(operation, ret):
'''report error for bad update'''
print("Error " + operation)
sys.exit('Return code: ' + str(ret.status_code) + ' Error: ' + ret.text) | [
"def",
"handle_bad_update",
"(",
"operation",
",",
"ret",
")",
":",
"print",
"(",
"\"Error \"",
"+",
"operation",
")",
"sys",
".",
"exit",
"(",
"'Return code: '",
"+",
"str",
"(",
"ret",
".",
"status_code",
")",
"+",
"' Error: '",
"+",
"ret",
".",
"text"... | report error for bad update | [
"report",
"error",
"for",
"bad",
"update"
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/vip_swap.py#L12-L15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.