repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
bitlabstudio/django-libs | django_libs/utils/converter.py | HTML2PlainParser.handle_endtag | def handle_endtag(self, tag):
"""Handles every end tag like e.g. </p>."""
if tag in self.stroke_after_elements:
if self.text.endswith(self.stroke_text):
# Only add a stroke if there isn't already a stroke posted
# In this case, there was no content between the... | python | def handle_endtag(self, tag):
"""Handles every end tag like e.g. </p>."""
if tag in self.stroke_after_elements:
if self.text.endswith(self.stroke_text):
# Only add a stroke if there isn't already a stroke posted
# In this case, there was no content between the... | [
"def",
"handle_endtag",
"(",
"self",
",",
"tag",
")",
":",
"if",
"tag",
"in",
"self",
".",
"stroke_after_elements",
":",
"if",
"self",
".",
"text",
".",
"endswith",
"(",
"self",
".",
"stroke_text",
")",
":",
"# Only add a stroke if there isn't already a stroke p... | Handles every end tag like e.g. </p>. | [
"Handles",
"every",
"end",
"tag",
"like",
"e",
".",
"g",
".",
"<",
"/",
"p",
">",
"."
] | 2c5376cda084bf16edea540e0f6999f1d844afd0 | https://github.com/bitlabstudio/django-libs/blob/2c5376cda084bf16edea540e0f6999f1d844afd0/django_libs/utils/converter.py#L86-L109 | train | Handles every end tag like e. g. </p >. |
flavio/scsgate | scsgate/reactor.py | Reactor.run | def run(self):
""" Starts the thread """
task = None
monitor_task = MonitorTask(
notification_endpoint=self._handle_message)
while True:
if self._terminate:
self._logger.info("scsgate.Reactor exiting")
self._connection.close()
... | python | def run(self):
""" Starts the thread """
task = None
monitor_task = MonitorTask(
notification_endpoint=self._handle_message)
while True:
if self._terminate:
self._logger.info("scsgate.Reactor exiting")
self._connection.close()
... | [
"def",
"run",
"(",
"self",
")",
":",
"task",
"=",
"None",
"monitor_task",
"=",
"MonitorTask",
"(",
"notification_endpoint",
"=",
"self",
".",
"_handle_message",
")",
"while",
"True",
":",
"if",
"self",
".",
"_terminate",
":",
"self",
".",
"_logger",
".",
... | Starts the thread | [
"Starts",
"the",
"thread"
] | aad1d181eef4714ab475f4ff7fcfac4a6425fbb4 | https://github.com/flavio/scsgate/blob/aad1d181eef4714ab475f4ff7fcfac4a6425fbb4/scsgate/reactor.py#L31-L52 | train | Starts the thread. |
gsi-upm/soil | examples/custom_generator/mymodule.py | mygenerator | def mygenerator(n=5, n_edges=5):
'''
Just a simple generator that creates a network with n nodes and
n_edges edges. Edges are assigned randomly, only avoiding self loops.
'''
G = nx.Graph()
for i in range(n):
G.add_node(i)
for i in range(n_edges):
nodes = list(G.nodes)
... | python | def mygenerator(n=5, n_edges=5):
'''
Just a simple generator that creates a network with n nodes and
n_edges edges. Edges are assigned randomly, only avoiding self loops.
'''
G = nx.Graph()
for i in range(n):
G.add_node(i)
for i in range(n_edges):
nodes = list(G.nodes)
... | [
"def",
"mygenerator",
"(",
"n",
"=",
"5",
",",
"n_edges",
"=",
"5",
")",
":",
"G",
"=",
"nx",
".",
"Graph",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"n",
")",
":",
"G",
".",
"add_node",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"n_edg... | Just a simple generator that creates a network with n nodes and
n_edges edges. Edges are assigned randomly, only avoiding self loops. | [
"Just",
"a",
"simple",
"generator",
"that",
"creates",
"a",
"network",
"with",
"n",
"nodes",
"and",
"n_edges",
"edges",
".",
"Edges",
"are",
"assigned",
"randomly",
"only",
"avoiding",
"self",
"loops",
"."
] | a3ea434f237f039c3cadbc2e0a83ae626d77b818 | https://github.com/gsi-upm/soil/blob/a3ea434f237f039c3cadbc2e0a83ae626d77b818/examples/custom_generator/mymodule.py#L5-L21 | train | A simple generator that creates a network with n nodes and n_edges edges. |
dbarsam/python-vsgen | vsgen/project.py | VSGProject._import | def _import(self, datadict):
"""
Internal method to import instance variables data from a dictionary
:param dict datadict: The dictionary containing variables values.
"""
self.GUID = datadict.get("GUID", uuid.uuid1())
self.FileName = datadict.get("FileName", "")
... | python | def _import(self, datadict):
"""
Internal method to import instance variables data from a dictionary
:param dict datadict: The dictionary containing variables values.
"""
self.GUID = datadict.get("GUID", uuid.uuid1())
self.FileName = datadict.get("FileName", "")
... | [
"def",
"_import",
"(",
"self",
",",
"datadict",
")",
":",
"self",
".",
"GUID",
"=",
"datadict",
".",
"get",
"(",
"\"GUID\"",
",",
"uuid",
".",
"uuid1",
"(",
")",
")",
"self",
".",
"FileName",
"=",
"datadict",
".",
"get",
"(",
"\"FileName\"",
",",
"... | Internal method to import instance variables data from a dictionary
:param dict datadict: The dictionary containing variables values. | [
"Internal",
"method",
"to",
"import",
"instance",
"variables",
"data",
"from",
"a",
"dictionary"
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/project.py#L46-L69 | train | Internal method to import instance variables data from a dictionary containing variables values. |
dbarsam/python-vsgen | vsgen/project.py | VSGProject.from_section | def from_section(cls, config, section, **kwargs):
"""
Creates a :class:`~vsgen.project.VSGProject` from a :class:`~configparser.ConfigParser` section.
:param ConfigParser config: A :class:`~configparser.ConfigParser` instance.
:param str section: A :class:`~configparser.Conf... | python | def from_section(cls, config, section, **kwargs):
"""
Creates a :class:`~vsgen.project.VSGProject` from a :class:`~configparser.ConfigParser` section.
:param ConfigParser config: A :class:`~configparser.ConfigParser` instance.
:param str section: A :class:`~configparser.Conf... | [
"def",
"from_section",
"(",
"cls",
",",
"config",
",",
"section",
",",
"*",
"*",
"kwargs",
")",
":",
"p",
"=",
"cls",
"(",
"*",
"*",
"kwargs",
")",
"p",
".",
"Name",
"=",
"config",
".",
"get",
"(",
"section",
",",
"'name'",
",",
"fallback",
"=",
... | Creates a :class:`~vsgen.project.VSGProject` from a :class:`~configparser.ConfigParser` section.
:param ConfigParser config: A :class:`~configparser.ConfigParser` instance.
:param str section: A :class:`~configparser.ConfigParser` section key.
:param kwargs: List of a... | [
"Creates",
"a",
":",
"class",
":",
"~vsgen",
".",
"project",
".",
"VSGProject",
"from",
"a",
":",
"class",
":",
"~configparser",
".",
"ConfigParser",
"section",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/project.py#L72-L103 | train | Creates a new instance of a VSGProject from a section. |
dbarsam/python-vsgen | vsgen/project.py | VSGProject.ProjectHomeRelative | def ProjectHomeRelative(self):
"""
Returns the :attr:`ProjectHome` relative to :attr:`FileName` directory.
"""
return os.path.relpath(self.ProjectHome, os.path.dirname(self.FileName)) | python | def ProjectHomeRelative(self):
"""
Returns the :attr:`ProjectHome` relative to :attr:`FileName` directory.
"""
return os.path.relpath(self.ProjectHome, os.path.dirname(self.FileName)) | [
"def",
"ProjectHomeRelative",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"relpath",
"(",
"self",
".",
"ProjectHome",
",",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"FileName",
")",
")"
] | Returns the :attr:`ProjectHome` relative to :attr:`FileName` directory. | [
"Returns",
"the",
":",
"attr",
":",
"ProjectHome",
"relative",
"to",
":",
"attr",
":",
"FileName",
"directory",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/project.py#L106-L110 | train | Returns the ProjectHome relative to the FileName directory. |
dbarsam/python-vsgen | vsgen/project.py | VSGProject.StartupFileRelative | def StartupFileRelative(self):
"""
Returns the :attr:`StartupFile` relative to :attr:`ProjectHome` directory.
"""
return os.path.relpath(self.StartupFile, self.ProjectHome) if self.StartupFile else self.StartupFile | python | def StartupFileRelative(self):
"""
Returns the :attr:`StartupFile` relative to :attr:`ProjectHome` directory.
"""
return os.path.relpath(self.StartupFile, self.ProjectHome) if self.StartupFile else self.StartupFile | [
"def",
"StartupFileRelative",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"relpath",
"(",
"self",
".",
"StartupFile",
",",
"self",
".",
"ProjectHome",
")",
"if",
"self",
".",
"StartupFile",
"else",
"self",
".",
"StartupFile"
] | Returns the :attr:`StartupFile` relative to :attr:`ProjectHome` directory. | [
"Returns",
"the",
":",
"attr",
":",
"StartupFile",
"relative",
"to",
":",
"attr",
":",
"ProjectHome",
"directory",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/project.py#L113-L117 | train | Returns the StartupFile relative to the ProjectHome directory. |
dbarsam/python-vsgen | vsgen/project.py | VSGProject.ContentFilesRelative | def ContentFilesRelative(self):
"""
Returns a generator iterating over the each file in :attr:`ContentFiles` relative to :attr:`ProjectHome` directory.
"""
return (os.path.relpath(path, self.ProjectHome) for path in sorted(self.ContentFiles, key=self.lower)) | python | def ContentFilesRelative(self):
"""
Returns a generator iterating over the each file in :attr:`ContentFiles` relative to :attr:`ProjectHome` directory.
"""
return (os.path.relpath(path, self.ProjectHome) for path in sorted(self.ContentFiles, key=self.lower)) | [
"def",
"ContentFilesRelative",
"(",
"self",
")",
":",
"return",
"(",
"os",
".",
"path",
".",
"relpath",
"(",
"path",
",",
"self",
".",
"ProjectHome",
")",
"for",
"path",
"in",
"sorted",
"(",
"self",
".",
"ContentFiles",
",",
"key",
"=",
"self",
".",
... | Returns a generator iterating over the each file in :attr:`ContentFiles` relative to :attr:`ProjectHome` directory. | [
"Returns",
"a",
"generator",
"iterating",
"over",
"the",
"each",
"file",
"in",
":",
"attr",
":",
"ContentFiles",
"relative",
"to",
":",
"attr",
":",
"ProjectHome",
"directory",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/project.py#L134-L138 | train | Returns a generator iterating over the content files in the current directory. |
dbarsam/python-vsgen | vsgen/project.py | VSGProject.CompileFilesRelative | def CompileFilesRelative(self):
"""
Returns a generator iterating over the each file in :attr:`ContentFiles` relative to :attr:`ProjectHome` directory.
"""
return (os.path.relpath(path, self.ProjectHome) for path in sorted(self.CompileFiles, key=self.lower)) | python | def CompileFilesRelative(self):
"""
Returns a generator iterating over the each file in :attr:`ContentFiles` relative to :attr:`ProjectHome` directory.
"""
return (os.path.relpath(path, self.ProjectHome) for path in sorted(self.CompileFiles, key=self.lower)) | [
"def",
"CompileFilesRelative",
"(",
"self",
")",
":",
"return",
"(",
"os",
".",
"path",
".",
"relpath",
"(",
"path",
",",
"self",
".",
"ProjectHome",
")",
"for",
"path",
"in",
"sorted",
"(",
"self",
".",
"CompileFiles",
",",
"key",
"=",
"self",
".",
... | Returns a generator iterating over the each file in :attr:`ContentFiles` relative to :attr:`ProjectHome` directory. | [
"Returns",
"a",
"generator",
"iterating",
"over",
"the",
"each",
"file",
"in",
":",
"attr",
":",
"ContentFiles",
"relative",
"to",
":",
"attr",
":",
"ProjectHome",
"directory",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/project.py#L141-L145 | train | Returns a generator iterating over the files in CompileFiles relative to ProjectHome directory. |
dbarsam/python-vsgen | vsgen/project.py | VSGProject.DirectoriesRelative | def DirectoriesRelative(self):
"""
Returns a generator iterating over the each directory referenced by the project, relative to :attr:`ProjectHome` directory.
"""
# Acquire all directories
directories = itertools.chain(self.Directories, (os.path.dirname(f) for f in itertools.chai... | python | def DirectoriesRelative(self):
"""
Returns a generator iterating over the each directory referenced by the project, relative to :attr:`ProjectHome` directory.
"""
# Acquire all directories
directories = itertools.chain(self.Directories, (os.path.dirname(f) for f in itertools.chai... | [
"def",
"DirectoriesRelative",
"(",
"self",
")",
":",
"# Acquire all directories",
"directories",
"=",
"itertools",
".",
"chain",
"(",
"self",
".",
"Directories",
",",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"f",
")",
"for",
"f",
"in",
"itertools",
"."... | Returns a generator iterating over the each directory referenced by the project, relative to :attr:`ProjectHome` directory. | [
"Returns",
"a",
"generator",
"iterating",
"over",
"the",
"each",
"directory",
"referenced",
"by",
"the",
"project",
"relative",
"to",
":",
"attr",
":",
"ProjectHome",
"directory",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/project.py#L148-L163 | train | Returns an iterator over the directories referenced by the project relative to the ProjectHome directory. |
dbarsam/python-vsgen | vsgen/project.py | VSGProject.insert_files | def insert_files(self, rootpath, directoryInFilter=None, directoryExFilter=None, compileInFilter=None, compileExFilter=None, contentInFilter=None, contentExFilter=None):
"""
Inserts files by recursive traversing the rootpath and inserting files according the addition filter parameters.
:param s... | python | def insert_files(self, rootpath, directoryInFilter=None, directoryExFilter=None, compileInFilter=None, compileExFilter=None, contentInFilter=None, contentExFilter=None):
"""
Inserts files by recursive traversing the rootpath and inserting files according the addition filter parameters.
:param s... | [
"def",
"insert_files",
"(",
"self",
",",
"rootpath",
",",
"directoryInFilter",
"=",
"None",
",",
"directoryExFilter",
"=",
"None",
",",
"compileInFilter",
"=",
"None",
",",
"compileExFilter",
"=",
"None",
",",
"contentInFilter",
"=",
"None",
",",
"contentExFilte... | Inserts files by recursive traversing the rootpath and inserting files according the addition filter parameters.
:param str rootpath: The absolute path to the root directory.
:param list directoryInFilter: A list of fnmatch expressions to match directories to be included. A `None` value wi... | [
"Inserts",
"files",
"by",
"recursive",
"traversing",
"the",
"rootpath",
"and",
"inserting",
"files",
"according",
"the",
"addition",
"filter",
"parameters",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/project.py#L165-L209 | train | Inserts files in the current directory by recursive traversing the rootpath and inserting them according the addition filter parameters. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_codec.py | encode_caveat | def encode_caveat(condition, root_key, third_party_info, key, ns):
'''Encrypt a third-party caveat.
The third_party_info key holds information about the
third party we're encrypting the caveat for; the key is the
public/private key pair of the party that's adding the caveat.
The caveat will be enc... | python | def encode_caveat(condition, root_key, third_party_info, key, ns):
'''Encrypt a third-party caveat.
The third_party_info key holds information about the
third party we're encrypting the caveat for; the key is the
public/private key pair of the party that's adding the caveat.
The caveat will be enc... | [
"def",
"encode_caveat",
"(",
"condition",
",",
"root_key",
",",
"third_party_info",
",",
"key",
",",
"ns",
")",
":",
"if",
"third_party_info",
".",
"version",
"==",
"VERSION_1",
":",
"return",
"_encode_caveat_v1",
"(",
"condition",
",",
"root_key",
",",
"third... | Encrypt a third-party caveat.
The third_party_info key holds information about the
third party we're encrypting the caveat for; the key is the
public/private key pair of the party that's adding the caveat.
The caveat will be encoded according to the version information
found in third_party_info.
... | [
"Encrypt",
"a",
"third",
"-",
"party",
"caveat",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_codec.py#L21-L46 | train | Encode a third - party caveat. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_codec.py | _encode_caveat_v1 | def _encode_caveat_v1(condition, root_key, third_party_pub_key, key):
'''Create a JSON-encoded third-party caveat.
The third_party_pub_key key represents the PublicKey of the third party
we're encrypting the caveat for; the key is the public/private key pair of
the party that's adding the caveat.
... | python | def _encode_caveat_v1(condition, root_key, third_party_pub_key, key):
'''Create a JSON-encoded third-party caveat.
The third_party_pub_key key represents the PublicKey of the third party
we're encrypting the caveat for; the key is the public/private key pair of
the party that's adding the caveat.
... | [
"def",
"_encode_caveat_v1",
"(",
"condition",
",",
"root_key",
",",
"third_party_pub_key",
",",
"key",
")",
":",
"plain_data",
"=",
"json",
".",
"dumps",
"(",
"{",
"'RootKey'",
":",
"base64",
".",
"b64encode",
"(",
"root_key",
")",
".",
"decode",
"(",
"'as... | Create a JSON-encoded third-party caveat.
The third_party_pub_key key represents the PublicKey of the third party
we're encrypting the caveat for; the key is the public/private key pair of
the party that's adding the caveat.
@param condition string
@param root_key bytes
@param third_party_pub_... | [
"Create",
"a",
"JSON",
"-",
"encoded",
"third",
"-",
"party",
"caveat",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_codec.py#L49-L76 | train | Create a JSON - encoded third - party caveat. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_codec.py | _encode_caveat_v2_v3 | def _encode_caveat_v2_v3(version, condition, root_key, third_party_pub_key,
key, ns):
'''Create a version 2 or version 3 third-party caveat.
The format has the following packed binary fields (note
that all fields up to and including the nonce are the same
as the v2 format):
... | python | def _encode_caveat_v2_v3(version, condition, root_key, third_party_pub_key,
key, ns):
'''Create a version 2 or version 3 third-party caveat.
The format has the following packed binary fields (note
that all fields up to and including the nonce are the same
as the v2 format):
... | [
"def",
"_encode_caveat_v2_v3",
"(",
"version",
",",
"condition",
",",
"root_key",
",",
"third_party_pub_key",
",",
"key",
",",
"ns",
")",
":",
"ns_data",
"=",
"bytearray",
"(",
")",
"if",
"version",
">=",
"VERSION_3",
":",
"ns_data",
"=",
"ns",
".",
"seria... | Create a version 2 or version 3 third-party caveat.
The format has the following packed binary fields (note
that all fields up to and including the nonce are the same
as the v2 format):
version 2 or 3 [1 byte]
first 4 bytes of third-party Curve25519 public key [4 bytes]
first-party... | [
"Create",
"a",
"version",
"2",
"or",
"version",
"3",
"third",
"-",
"party",
"caveat",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_codec.py#L79-L117 | train | Encode a version 2 or version 3 third - party caveat. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_codec.py | _encode_secret_part_v2_v3 | def _encode_secret_part_v2_v3(version, condition, root_key, ns):
'''Creates a version 2 or version 3 secret part of the third party
caveat. The returned data is not encrypted.
The format has the following packed binary fields:
version 2 or 3 [1 byte]
root key length [n: uvarint]
root key [n byt... | python | def _encode_secret_part_v2_v3(version, condition, root_key, ns):
'''Creates a version 2 or version 3 secret part of the third party
caveat. The returned data is not encrypted.
The format has the following packed binary fields:
version 2 or 3 [1 byte]
root key length [n: uvarint]
root key [n byt... | [
"def",
"_encode_secret_part_v2_v3",
"(",
"version",
",",
"condition",
",",
"root_key",
",",
"ns",
")",
":",
"data",
"=",
"bytearray",
"(",
")",
"data",
".",
"append",
"(",
"version",
")",
"encode_uvarint",
"(",
"len",
"(",
"root_key",
")",
",",
"data",
"... | Creates a version 2 or version 3 secret part of the third party
caveat. The returned data is not encrypted.
The format has the following packed binary fields:
version 2 or 3 [1 byte]
root key length [n: uvarint]
root key [n bytes]
namespace length [n: uvarint] (v3 only)
namespace [n bytes] ... | [
"Creates",
"a",
"version",
"2",
"or",
"version",
"3",
"secret",
"part",
"of",
"the",
"third",
"party",
"caveat",
".",
"The",
"returned",
"data",
"is",
"not",
"encrypted",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_codec.py#L120-L140 | train | Encodes a version 2 or version 3 secret part of the third party
caveat. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_codec.py | decode_caveat | def decode_caveat(key, caveat):
'''Decode caveat by decrypting the encrypted part using key.
@param key the nacl private key to decode.
@param caveat bytes.
@return ThirdPartyCaveatInfo
'''
if len(caveat) == 0:
raise VerificationError('empty third party caveat')
first = caveat[:1]
... | python | def decode_caveat(key, caveat):
'''Decode caveat by decrypting the encrypted part using key.
@param key the nacl private key to decode.
@param caveat bytes.
@return ThirdPartyCaveatInfo
'''
if len(caveat) == 0:
raise VerificationError('empty third party caveat')
first = caveat[:1]
... | [
"def",
"decode_caveat",
"(",
"key",
",",
"caveat",
")",
":",
"if",
"len",
"(",
"caveat",
")",
"==",
"0",
":",
"raise",
"VerificationError",
"(",
"'empty third party caveat'",
")",
"first",
"=",
"caveat",
"[",
":",
"1",
"]",
"if",
"first",
"==",
"b'e'",
... | Decode caveat by decrypting the encrypted part using key.
@param key the nacl private key to decode.
@param caveat bytes.
@return ThirdPartyCaveatInfo | [
"Decode",
"caveat",
"by",
"decrypting",
"the",
"encrypted",
"part",
"using",
"key",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_codec.py#L143-L169 | train | Decode a third party caveat by decrypting the encrypted part using key. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_codec.py | _decode_caveat_v1 | def _decode_caveat_v1(key, caveat):
'''Decode a base64 encoded JSON id.
@param key the nacl private key to decode.
@param caveat a base64 encoded JSON string.
'''
data = base64.b64decode(caveat).decode('utf-8')
wrapper = json.loads(data)
tp_public_key = nacl.public.PublicKey(
base6... | python | def _decode_caveat_v1(key, caveat):
'''Decode a base64 encoded JSON id.
@param key the nacl private key to decode.
@param caveat a base64 encoded JSON string.
'''
data = base64.b64decode(caveat).decode('utf-8')
wrapper = json.loads(data)
tp_public_key = nacl.public.PublicKey(
base6... | [
"def",
"_decode_caveat_v1",
"(",
"key",
",",
"caveat",
")",
":",
"data",
"=",
"base64",
".",
"b64decode",
"(",
"caveat",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"wrapper",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"tp_public_key",
"=",
"nacl",
".",... | Decode a base64 encoded JSON id.
@param key the nacl private key to decode.
@param caveat a base64 encoded JSON string. | [
"Decode",
"a",
"base64",
"encoded",
"JSON",
"id",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_codec.py#L172-L210 | train | Decode a base64 encoded JSON string. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_codec.py | _decode_caveat_v2_v3 | def _decode_caveat_v2_v3(version, key, caveat):
'''Decodes a version 2 or version 3 caveat.
'''
if (len(caveat) < 1 + _PUBLIC_KEY_PREFIX_LEN +
_KEY_LEN + nacl.public.Box.NONCE_SIZE + 16):
raise VerificationError('caveat id too short')
original_caveat = caveat
caveat = caveat[1:] ... | python | def _decode_caveat_v2_v3(version, key, caveat):
'''Decodes a version 2 or version 3 caveat.
'''
if (len(caveat) < 1 + _PUBLIC_KEY_PREFIX_LEN +
_KEY_LEN + nacl.public.Box.NONCE_SIZE + 16):
raise VerificationError('caveat id too short')
original_caveat = caveat
caveat = caveat[1:] ... | [
"def",
"_decode_caveat_v2_v3",
"(",
"version",
",",
"key",
",",
"caveat",
")",
":",
"if",
"(",
"len",
"(",
"caveat",
")",
"<",
"1",
"+",
"_PUBLIC_KEY_PREFIX_LEN",
"+",
"_KEY_LEN",
"+",
"nacl",
".",
"public",
".",
"Box",
".",
"NONCE_SIZE",
"+",
"16",
")... | Decodes a version 2 or version 3 caveat. | [
"Decodes",
"a",
"version",
"2",
"or",
"version",
"3",
"caveat",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_codec.py#L213-L244 | train | Decodes a version 2 or version 3 caveat. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_codec.py | encode_uvarint | def encode_uvarint(n, data):
'''encodes integer into variable-length format into data.'''
if n < 0:
raise ValueError('only support positive integer')
while True:
this_byte = n & 127
n >>= 7
if n == 0:
data.append(this_byte)
break
data.append(th... | python | def encode_uvarint(n, data):
'''encodes integer into variable-length format into data.'''
if n < 0:
raise ValueError('only support positive integer')
while True:
this_byte = n & 127
n >>= 7
if n == 0:
data.append(this_byte)
break
data.append(th... | [
"def",
"encode_uvarint",
"(",
"n",
",",
"data",
")",
":",
"if",
"n",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'only support positive integer'",
")",
"while",
"True",
":",
"this_byte",
"=",
"n",
"&",
"127",
"n",
">>=",
"7",
"if",
"n",
"==",
"0",
":... | encodes integer into variable-length format into data. | [
"encodes",
"integer",
"into",
"variable",
"-",
"length",
"format",
"into",
"data",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_codec.py#L271-L281 | train | encodes integer into variable - length format into data. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_codec.py | decode_uvarint | def decode_uvarint(data):
'''Decode a variable-length integer.
Reads a sequence of unsigned integer byte and decodes them into an integer
in variable-length format and returns it and the length read.
'''
n = 0
shift = 0
length = 0
for b in data:
if not isinstance(b, int):
... | python | def decode_uvarint(data):
'''Decode a variable-length integer.
Reads a sequence of unsigned integer byte and decodes them into an integer
in variable-length format and returns it and the length read.
'''
n = 0
shift = 0
length = 0
for b in data:
if not isinstance(b, int):
... | [
"def",
"decode_uvarint",
"(",
"data",
")",
":",
"n",
"=",
"0",
"shift",
"=",
"0",
"length",
"=",
"0",
"for",
"b",
"in",
"data",
":",
"if",
"not",
"isinstance",
"(",
"b",
",",
"int",
")",
":",
"b",
"=",
"six",
".",
"byte2int",
"(",
"b",
")",
"... | Decode a variable-length integer.
Reads a sequence of unsigned integer byte and decodes them into an integer
in variable-length format and returns it and the length read. | [
"Decode",
"a",
"variable",
"-",
"length",
"integer",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_codec.py#L284-L301 | train | Decode a variable - length integer. |
jenisys/parse_type | parse_type/builder.py | build_type_dict | def build_type_dict(converters):
"""
Builds type dictionary for user-defined type converters,
used by :mod:`parse` module.
This requires that each type converter has a "name" attribute.
:param converters: List of type converters (parse_types)
:return: Type converter dictionary
"""
more_... | python | def build_type_dict(converters):
"""
Builds type dictionary for user-defined type converters,
used by :mod:`parse` module.
This requires that each type converter has a "name" attribute.
:param converters: List of type converters (parse_types)
:return: Type converter dictionary
"""
more_... | [
"def",
"build_type_dict",
"(",
"converters",
")",
":",
"more_types",
"=",
"{",
"}",
"for",
"converter",
"in",
"converters",
":",
"assert",
"callable",
"(",
"converter",
")",
"more_types",
"[",
"converter",
".",
"name",
"]",
"=",
"converter",
"return",
"more_... | Builds type dictionary for user-defined type converters,
used by :mod:`parse` module.
This requires that each type converter has a "name" attribute.
:param converters: List of type converters (parse_types)
:return: Type converter dictionary | [
"Builds",
"type",
"dictionary",
"for",
"user",
"-",
"defined",
"type",
"converters",
"used",
"by",
":",
"mod",
":",
"parse",
"module",
".",
"This",
"requires",
"that",
"each",
"type",
"converter",
"has",
"a",
"name",
"attribute",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/builder.py#L259-L272 | train | Builds type dictionary for user - defined type converters. |
jenisys/parse_type | parse_type/builder.py | TypeBuilder.make_list | def make_list(cls, item_converter=None, listsep=','):
"""
Create a type converter for a list of items (many := 1..*).
The parser accepts anything and the converter needs to fail on errors.
:param item_converter: Type converter for an item.
:param listsep: List separator to use... | python | def make_list(cls, item_converter=None, listsep=','):
"""
Create a type converter for a list of items (many := 1..*).
The parser accepts anything and the converter needs to fail on errors.
:param item_converter: Type converter for an item.
:param listsep: List separator to use... | [
"def",
"make_list",
"(",
"cls",
",",
"item_converter",
"=",
"None",
",",
"listsep",
"=",
"','",
")",
":",
"if",
"not",
"item_converter",
":",
"item_converter",
"=",
"parse_anything",
"return",
"cls",
".",
"with_cardinality",
"(",
"Cardinality",
".",
"many",
... | Create a type converter for a list of items (many := 1..*).
The parser accepts anything and the converter needs to fail on errors.
:param item_converter: Type converter for an item.
:param listsep: List separator to use (as string).
:return: Type converter function object for the list... | [
"Create",
"a",
"type",
"converter",
"for",
"a",
"list",
"of",
"items",
"(",
"many",
":",
"=",
"1",
"..",
"*",
")",
".",
"The",
"parser",
"accepts",
"anything",
"and",
"the",
"converter",
"needs",
"to",
"fail",
"on",
"errors",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/builder.py#L83-L95 | train | Create a type converter for a list of items. |
jenisys/parse_type | parse_type/builder.py | TypeBuilder.make_enum | def make_enum(enum_mappings):
"""
Creates a type converter for an enumeration or text-to-value mapping.
:param enum_mappings: Defines enumeration names and values.
:return: Type converter function object for the enum/mapping.
"""
if (inspect.isclass(enum_mappings) and
... | python | def make_enum(enum_mappings):
"""
Creates a type converter for an enumeration or text-to-value mapping.
:param enum_mappings: Defines enumeration names and values.
:return: Type converter function object for the enum/mapping.
"""
if (inspect.isclass(enum_mappings) and
... | [
"def",
"make_enum",
"(",
"enum_mappings",
")",
":",
"if",
"(",
"inspect",
".",
"isclass",
"(",
"enum_mappings",
")",
"and",
"issubclass",
"(",
"enum_mappings",
",",
"enum",
".",
"Enum",
")",
")",
":",
"enum_class",
"=",
"enum_mappings",
"enum_mappings",
"=",... | Creates a type converter for an enumeration or text-to-value mapping.
:param enum_mappings: Defines enumeration names and values.
:return: Type converter function object for the enum/mapping. | [
"Creates",
"a",
"type",
"converter",
"for",
"an",
"enumeration",
"or",
"text",
"-",
"to",
"-",
"value",
"mapping",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/builder.py#L98-L116 | train | Creates a type converter function for an enumeration or text - to - value mapping. |
jenisys/parse_type | parse_type/builder.py | TypeBuilder.make_choice | def make_choice(cls, choices, transform=None, strict=None):
"""
Creates a type-converter function to select one from a list of strings.
The type-converter function returns the selected choice_text.
The :param:`transform()` function is applied in the type converter.
It can be used... | python | def make_choice(cls, choices, transform=None, strict=None):
"""
Creates a type-converter function to select one from a list of strings.
The type-converter function returns the selected choice_text.
The :param:`transform()` function is applied in the type converter.
It can be used... | [
"def",
"make_choice",
"(",
"cls",
",",
"choices",
",",
"transform",
"=",
"None",
",",
"strict",
"=",
"None",
")",
":",
"# -- NOTE: Parser uses re.IGNORECASE flag",
"# => transform may enforce case.",
"choices",
"=",
"cls",
".",
"_normalize_choices",
"(",
"choices",... | Creates a type-converter function to select one from a list of strings.
The type-converter function returns the selected choice_text.
The :param:`transform()` function is applied in the type converter.
It can be used to enforce the case (because parser uses re.IGNORECASE).
:param choice... | [
"Creates",
"a",
"type",
"-",
"converter",
"function",
"to",
"select",
"one",
"from",
"a",
"list",
"of",
"strings",
".",
"The",
"type",
"-",
"converter",
"function",
"returns",
"the",
"selected",
"choice_text",
".",
"The",
":",
"param",
":",
"transform",
"(... | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/builder.py#L128-L154 | train | Creates a type converter function to select one from a list of strings. |
jenisys/parse_type | parse_type/builder.py | TypeBuilder.make_choice2 | def make_choice2(cls, choices, transform=None, strict=None):
"""
Creates a type converter to select one item from a list of strings.
The type converter function returns a tuple (index, choice_text).
:param choices: List of strings as choice.
:param transform: Optional, initial t... | python | def make_choice2(cls, choices, transform=None, strict=None):
"""
Creates a type converter to select one item from a list of strings.
The type converter function returns a tuple (index, choice_text).
:param choices: List of strings as choice.
:param transform: Optional, initial t... | [
"def",
"make_choice2",
"(",
"cls",
",",
"choices",
",",
"transform",
"=",
"None",
",",
"strict",
"=",
"None",
")",
":",
"choices",
"=",
"cls",
".",
"_normalize_choices",
"(",
"choices",
",",
"transform",
")",
"if",
"strict",
"is",
"None",
":",
"strict",
... | Creates a type converter to select one item from a list of strings.
The type converter function returns a tuple (index, choice_text).
:param choices: List of strings as choice.
:param transform: Optional, initial transform function for parsed text.
:return: Type converter function objec... | [
"Creates",
"a",
"type",
"converter",
"to",
"select",
"one",
"item",
"from",
"a",
"list",
"of",
"strings",
".",
"The",
"type",
"converter",
"function",
"returns",
"a",
"tuple",
"(",
"index",
"choice_text",
")",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/builder.py#L157-L180 | train | Creates a type converter function to select one item from a list of strings. |
jenisys/parse_type | parse_type/builder.py | TypeBuilder.make_variant | def make_variant(cls, converters, re_opts=None, compiled=False, strict=True):
"""
Creates a type converter for a number of type converter alternatives.
The first matching type converter is used.
REQUIRES: type_converter.pattern attribute
:param converters: List of type converte... | python | def make_variant(cls, converters, re_opts=None, compiled=False, strict=True):
"""
Creates a type converter for a number of type converter alternatives.
The first matching type converter is used.
REQUIRES: type_converter.pattern attribute
:param converters: List of type converte... | [
"def",
"make_variant",
"(",
"cls",
",",
"converters",
",",
"re_opts",
"=",
"None",
",",
"compiled",
"=",
"False",
",",
"strict",
"=",
"True",
")",
":",
"# -- NOTE: Uses double-dispatch with regex pattern rematch because",
"# match is not passed through to primary t... | Creates a type converter for a number of type converter alternatives.
The first matching type converter is used.
REQUIRES: type_converter.pattern attribute
:param converters: List of type converters as alternatives.
:param re_opts: Regular expression options zu use (=default_re_opts).... | [
"Creates",
"a",
"type",
"converter",
"for",
"a",
"number",
"of",
"type",
"converter",
"alternatives",
".",
"The",
"first",
"matching",
"type",
"converter",
"is",
"used",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/builder.py#L183-L227 | train | Creates a type converter function object for a number of type converters. |
crm416/semantic | semantic/units.py | ConversionService.parseUnits | def parseUnits(self, inp):
"""Carries out a conversion (represented as a string) and returns the
result as a human-readable string.
Args:
inp (str): Text representing a unit conversion, which should
include a magnitude, a description of the initial units,
... | python | def parseUnits(self, inp):
"""Carries out a conversion (represented as a string) and returns the
result as a human-readable string.
Args:
inp (str): Text representing a unit conversion, which should
include a magnitude, a description of the initial units,
... | [
"def",
"parseUnits",
"(",
"self",
",",
"inp",
")",
":",
"quantity",
"=",
"self",
".",
"convert",
"(",
"inp",
")",
"units",
"=",
"' '",
".",
"join",
"(",
"str",
"(",
"quantity",
".",
"units",
")",
".",
"split",
"(",
"' '",
")",
"[",
"1",
":",
"]... | Carries out a conversion (represented as a string) and returns the
result as a human-readable string.
Args:
inp (str): Text representing a unit conversion, which should
include a magnitude, a description of the initial units,
and a description of the target u... | [
"Carries",
"out",
"a",
"conversion",
"(",
"represented",
"as",
"a",
"string",
")",
"and",
"returns",
"the",
"result",
"as",
"a",
"human",
"-",
"readable",
"string",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/units.py#L55-L71 | train | Carries out a conversion and returns the converted quantity and its new
units. |
crm416/semantic | semantic/units.py | ConversionService.isValidUnit | def isValidUnit(self, w):
"""Checks if a string represents a valid quantities unit.
Args:
w (str): A string to be tested against the set of valid
quantities units.
Returns:
True if the string can be used as a unit in the quantities
module.
... | python | def isValidUnit(self, w):
"""Checks if a string represents a valid quantities unit.
Args:
w (str): A string to be tested against the set of valid
quantities units.
Returns:
True if the string can be used as a unit in the quantities
module.
... | [
"def",
"isValidUnit",
"(",
"self",
",",
"w",
")",
":",
"bad",
"=",
"set",
"(",
"[",
"'point'",
",",
"'a'",
"]",
")",
"if",
"w",
"in",
"bad",
":",
"return",
"False",
"try",
":",
"pq",
".",
"Quantity",
"(",
"0.0",
",",
"w",
")",
"return",
"True",... | Checks if a string represents a valid quantities unit.
Args:
w (str): A string to be tested against the set of valid
quantities units.
Returns:
True if the string can be used as a unit in the quantities
module. | [
"Checks",
"if",
"a",
"string",
"represents",
"a",
"valid",
"quantities",
"unit",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/units.py#L73-L92 | train | Checks if a string represents a valid quantities unit. |
crm416/semantic | semantic/units.py | ConversionService.extractUnits | def extractUnits(self, inp):
"""Collects all the valid units from an inp string. Works by
appending consecutive words from the string and cross-referncing
them with a set of valid units.
Args:
inp (str): Some text which hopefully contains descriptions
of diff... | python | def extractUnits(self, inp):
"""Collects all the valid units from an inp string. Works by
appending consecutive words from the string and cross-referncing
them with a set of valid units.
Args:
inp (str): Some text which hopefully contains descriptions
of diff... | [
"def",
"extractUnits",
"(",
"self",
",",
"inp",
")",
":",
"inp",
"=",
"self",
".",
"_preprocess",
"(",
"inp",
")",
"units",
"=",
"[",
"]",
"description",
"=",
"\"\"",
"for",
"w",
"in",
"inp",
".",
"split",
"(",
"' '",
")",
":",
"if",
"self",
".",... | Collects all the valid units from an inp string. Works by
appending consecutive words from the string and cross-referncing
them with a set of valid units.
Args:
inp (str): Some text which hopefully contains descriptions
of different units.
Returns:
... | [
"Collects",
"all",
"the",
"valid",
"units",
"from",
"an",
"inp",
"string",
".",
"Works",
"by",
"appending",
"consecutive",
"words",
"from",
"the",
"string",
"and",
"cross",
"-",
"referncing",
"them",
"with",
"a",
"set",
"of",
"valid",
"units",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/units.py#L94-L123 | train | Extracts all the valid units from an inp string and returns a list of strings each entry in which is a valid quantities
unit. |
crm416/semantic | semantic/units.py | ConversionService.convert | def convert(self, inp):
"""Converts a string representation of some quantity of units into a
quantities object.
Args:
inp (str): A textual representation of some quantity of units,
e.g., "fifty kilograms".
Returns:
A quantities object representin... | python | def convert(self, inp):
"""Converts a string representation of some quantity of units into a
quantities object.
Args:
inp (str): A textual representation of some quantity of units,
e.g., "fifty kilograms".
Returns:
A quantities object representin... | [
"def",
"convert",
"(",
"self",
",",
"inp",
")",
":",
"inp",
"=",
"self",
".",
"_preprocess",
"(",
"inp",
")",
"n",
"=",
"NumberService",
"(",
")",
".",
"longestNumber",
"(",
"inp",
")",
"units",
"=",
"self",
".",
"extractUnits",
"(",
"inp",
")",
"#... | Converts a string representation of some quantity of units into a
quantities object.
Args:
inp (str): A textual representation of some quantity of units,
e.g., "fifty kilograms".
Returns:
A quantities object representing the described quantity and its
... | [
"Converts",
"a",
"string",
"representation",
"of",
"some",
"quantity",
"of",
"units",
"into",
"a",
"quantities",
"object",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/units.py#L125-L146 | train | Converts a string representation of some quantity of units into a
quantity object. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_identity.py | SimpleIdentity.allow | def allow(self, ctx, acls):
'''Allow access to any ACL members that was equal to the user name.
That is, some user u is considered a member of group u and no other.
'''
for acl in acls:
if self._identity == acl:
return True
return False | python | def allow(self, ctx, acls):
'''Allow access to any ACL members that was equal to the user name.
That is, some user u is considered a member of group u and no other.
'''
for acl in acls:
if self._identity == acl:
return True
return False | [
"def",
"allow",
"(",
"self",
",",
"ctx",
",",
"acls",
")",
":",
"for",
"acl",
"in",
"acls",
":",
"if",
"self",
".",
"_identity",
"==",
"acl",
":",
"return",
"True",
"return",
"False"
] | Allow access to any ACL members that was equal to the user name.
That is, some user u is considered a member of group u and no other. | [
"Allow",
"access",
"to",
"any",
"ACL",
"members",
"that",
"was",
"equal",
"to",
"the",
"user",
"name",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_identity.py#L68-L76 | train | Allow access to any ACL members that were equal to the user name. |
eonpatapon/contrail-api-cli | contrail_api_cli/command.py | expand_paths | def expand_paths(paths=None, predicate=None, filters=None, parent_uuid=None):
"""Return an unique list of resources or collections from a list of paths.
Supports fq_name and wilcards resolution.
>>> expand_paths(['virtual-network',
'floating-ip/2a0a54b4-a420-485e-8372-42f70a627ec9'])
... | python | def expand_paths(paths=None, predicate=None, filters=None, parent_uuid=None):
"""Return an unique list of resources or collections from a list of paths.
Supports fq_name and wilcards resolution.
>>> expand_paths(['virtual-network',
'floating-ip/2a0a54b4-a420-485e-8372-42f70a627ec9'])
... | [
"def",
"expand_paths",
"(",
"paths",
"=",
"None",
",",
"predicate",
"=",
"None",
",",
"filters",
"=",
"None",
",",
"parent_uuid",
"=",
"None",
")",
":",
"if",
"not",
"paths",
":",
"paths",
"=",
"[",
"Context",
"(",
")",
".",
"shell",
".",
"current_pa... | Return an unique list of resources or collections from a list of paths.
Supports fq_name and wilcards resolution.
>>> expand_paths(['virtual-network',
'floating-ip/2a0a54b4-a420-485e-8372-42f70a627ec9'])
[Collection('virtual-network'),
Resource('floating-ip', uuid='2a0a54b4-a420-... | [
"Return",
"an",
"unique",
"list",
"of",
"resources",
"or",
"collections",
"from",
"a",
"list",
"of",
"paths",
".",
"Supports",
"fq_name",
"and",
"wilcards",
"resolution",
"."
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/command.py#L136-L174 | train | Expand a list of paths into a list of resources or collections. |
dbarsam/python-vsgen | vsgen/writer.py | VSGJinjaRenderer.render | def render(self, template, filename, context={}, filters={}):
"""
Renders a Jinja2 template to text.
"""
filename = os.path.normpath(filename)
path, file = os.path.split(filename)
try:
os.makedirs(path)
except OSError as exception:
if excep... | python | def render(self, template, filename, context={}, filters={}):
"""
Renders a Jinja2 template to text.
"""
filename = os.path.normpath(filename)
path, file = os.path.split(filename)
try:
os.makedirs(path)
except OSError as exception:
if excep... | [
"def",
"render",
"(",
"self",
",",
"template",
",",
"filename",
",",
"context",
"=",
"{",
"}",
",",
"filters",
"=",
"{",
"}",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"filename",
")",
"path",
",",
"file",
"=",
"os",
"."... | Renders a Jinja2 template to text. | [
"Renders",
"a",
"Jinja2",
"template",
"to",
"text",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/writer.py#L19-L38 | train | Renders a Jinja2 template to text. |
dbarsam/python-vsgen | vsgen/writer.py | VSGWriteCommand.execute | def execute(self):
"""
Executes the command.
"""
from vsgen.util.logger import VSGLogger
VSGLogger.info(self._logname, self._message)
start = time.clock()
VSGWriter.write(self._writables, self._parallel)
end = time.clock()
VSGLogger.info(self._log... | python | def execute(self):
"""
Executes the command.
"""
from vsgen.util.logger import VSGLogger
VSGLogger.info(self._logname, self._message)
start = time.clock()
VSGWriter.write(self._writables, self._parallel)
end = time.clock()
VSGLogger.info(self._log... | [
"def",
"execute",
"(",
"self",
")",
":",
"from",
"vsgen",
".",
"util",
".",
"logger",
"import",
"VSGLogger",
"VSGLogger",
".",
"info",
"(",
"self",
".",
"_logname",
",",
"self",
".",
"_message",
")",
"start",
"=",
"time",
".",
"clock",
"(",
")",
"VSG... | Executes the command. | [
"Executes",
"the",
"command",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/writer.py#L118-L128 | train | Executes the command. |
dbarsam/python-vsgen | vsgen/writer.py | VSGWriter.write | def write(pylist, parallel=True):
"""
Utility method to spawn a VSGWriter for each element in a collection.
:param list pylist: A list of VSG objects (PrProjects, VSGSolutions, etc)
:param bool parallel: Flag to enable asynchronous writing.
"""
threads = [VSGWriter(o) ... | python | def write(pylist, parallel=True):
"""
Utility method to spawn a VSGWriter for each element in a collection.
:param list pylist: A list of VSG objects (PrProjects, VSGSolutions, etc)
:param bool parallel: Flag to enable asynchronous writing.
"""
threads = [VSGWriter(o) ... | [
"def",
"write",
"(",
"pylist",
",",
"parallel",
"=",
"True",
")",
":",
"threads",
"=",
"[",
"VSGWriter",
"(",
"o",
")",
"for",
"o",
"in",
"pylist",
"]",
"if",
"parallel",
":",
"for",
"t",
"in",
"threads",
":",
"t",
".",
"start",
"(",
")",
"for",
... | Utility method to spawn a VSGWriter for each element in a collection.
:param list pylist: A list of VSG objects (PrProjects, VSGSolutions, etc)
:param bool parallel: Flag to enable asynchronous writing. | [
"Utility",
"method",
"to",
"spawn",
"a",
"VSGWriter",
"for",
"each",
"element",
"in",
"a",
"collection",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/writer.py#L156-L171 | train | Utility method to spawn a VSGWriter for each element in a collection. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_browser.py | WebBrowserInteractor.interact | def interact(self, ctx, location, ir_err):
'''Implement Interactor.interact by opening the browser window
and waiting for the discharge token'''
p = ir_err.interaction_method(self.kind(), WebBrowserInteractionInfo)
if not location.endswith('/'):
location += '/'
visit_... | python | def interact(self, ctx, location, ir_err):
'''Implement Interactor.interact by opening the browser window
and waiting for the discharge token'''
p = ir_err.interaction_method(self.kind(), WebBrowserInteractionInfo)
if not location.endswith('/'):
location += '/'
visit_... | [
"def",
"interact",
"(",
"self",
",",
"ctx",
",",
"location",
",",
"ir_err",
")",
":",
"p",
"=",
"ir_err",
".",
"interaction_method",
"(",
"self",
".",
"kind",
"(",
")",
",",
"WebBrowserInteractionInfo",
")",
"if",
"not",
"location",
".",
"endswith",
"(",... | Implement Interactor.interact by opening the browser window
and waiting for the discharge token | [
"Implement",
"Interactor",
".",
"interact",
"by",
"opening",
"the",
"browser",
"window",
"and",
"waiting",
"for",
"the",
"discharge",
"token"
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_browser.py#L38-L47 | train | Implement Interactor. interact by opening the browser window
and waiting for the discharge token. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_browser.py | WebBrowserInteractor._wait_for_token | def _wait_for_token(self, ctx, wait_token_url):
''' Returns a token from a the wait token URL
@param wait_token_url URL to wait for (string)
:return DischargeToken
'''
resp = requests.get(wait_token_url)
if resp.status_code != 200:
raise InteractionError('cann... | python | def _wait_for_token(self, ctx, wait_token_url):
''' Returns a token from a the wait token URL
@param wait_token_url URL to wait for (string)
:return DischargeToken
'''
resp = requests.get(wait_token_url)
if resp.status_code != 200:
raise InteractionError('cann... | [
"def",
"_wait_for_token",
"(",
"self",
",",
"ctx",
",",
"wait_token_url",
")",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"wait_token_url",
")",
"if",
"resp",
".",
"status_code",
"!=",
"200",
":",
"raise",
"InteractionError",
"(",
"'cannot get {}'",
".",... | Returns a token from a the wait token URL
@param wait_token_url URL to wait for (string)
:return DischargeToken | [
"Returns",
"a",
"token",
"from",
"a",
"the",
"wait",
"token",
"URL"
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_browser.py#L49-L69 | train | Returns a DischargeToken from a wait token URL |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_browser.py | WebBrowserInteractionInfo.from_dict | def from_dict(cls, info_dict):
'''Create a new instance of WebBrowserInteractionInfo, as expected
by the Error.interaction_method method.
@param info_dict The deserialized JSON object
@return a new WebBrowserInteractionInfo object.
'''
return WebBrowserInteractionInfo(
... | python | def from_dict(cls, info_dict):
'''Create a new instance of WebBrowserInteractionInfo, as expected
by the Error.interaction_method method.
@param info_dict The deserialized JSON object
@return a new WebBrowserInteractionInfo object.
'''
return WebBrowserInteractionInfo(
... | [
"def",
"from_dict",
"(",
"cls",
",",
"info_dict",
")",
":",
"return",
"WebBrowserInteractionInfo",
"(",
"visit_url",
"=",
"info_dict",
".",
"get",
"(",
"'VisitURL'",
")",
",",
"wait_token_url",
"=",
"info_dict",
".",
"get",
"(",
"'WaitTokenURL'",
")",
")"
] | Create a new instance of WebBrowserInteractionInfo, as expected
by the Error.interaction_method method.
@param info_dict The deserialized JSON object
@return a new WebBrowserInteractionInfo object. | [
"Create",
"a",
"new",
"instance",
"of",
"WebBrowserInteractionInfo",
"as",
"expected",
"by",
"the",
"Error",
".",
"interaction_method",
"method",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_browser.py#L82-L90 | train | Create a new instance of WebBrowserInteractionInfo as expected
by the Error. interaction_method method. |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/sds.py | Sds.get | def get(self):
"""
Returns a `list` of all the `System` objects to the cluster. Updates every time - no caching.
:return: a `list` of all the `System` objects known to the cluster.
:rtype: list
"""
self.conn.connection._check_login()
response = self.conn.connecti... | python | def get(self):
"""
Returns a `list` of all the `System` objects to the cluster. Updates every time - no caching.
:return: a `list` of all the `System` objects known to the cluster.
:rtype: list
"""
self.conn.connection._check_login()
response = self.conn.connecti... | [
"def",
"get",
"(",
"self",
")",
":",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"conn",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"conn",
".",
"conn... | Returns a `list` of all the `System` objects to the cluster. Updates every time - no caching.
:return: a `list` of all the `System` objects known to the cluster.
:rtype: list | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"System",
"objects",
"to",
"the",
"cluster",
".",
"Updates",
"every",
"time",
"-",
"no",
"caching",
".",
":",
"return",
":",
"a",
"list",
"of",
"all",
"the",
"System",
"objects",
"known",
"to",
"the",
"cluste... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/sds.py#L20-L31 | train | Returns a list of all the System objects known to the cluster. |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/sds.py | Sds.set_sds_name | def set_sds_name(self, name, sdsObj):
"""
Set name for SDS
:param name: Name of SDS
:param sdsObj: ScaleIO SDS object
:return: POST request response
:rtype: Requests POST response object
"""
# TODO:
# Check if object parameters are the correct type... | python | def set_sds_name(self, name, sdsObj):
"""
Set name for SDS
:param name: Name of SDS
:param sdsObj: ScaleIO SDS object
:return: POST request response
:rtype: Requests POST response object
"""
# TODO:
# Check if object parameters are the correct type... | [
"def",
"set_sds_name",
"(",
"self",
",",
"name",
",",
"sdsObj",
")",
":",
"# TODO:",
"# Check if object parameters are the correct type, otherwise throw error",
"# UNSURE IF THIS IS CORRECT WAY TO SET SDS NAME",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"("... | Set name for SDS
:param name: Name of SDS
:param sdsObj: ScaleIO SDS object
:return: POST request response
:rtype: Requests POST response object | [
"Set",
"name",
"for",
"SDS",
":",
"param",
"name",
":",
"Name",
"of",
"SDS",
":",
"param",
"sdsObj",
":",
"ScaleIO",
"SDS",
"object",
":",
"return",
":",
"POST",
"request",
"response",
":",
"rtype",
":",
"Requests",
"POST",
"response",
"object"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/sds.py#L33-L47 | train | Set the name of the SDS object for the specified name. |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/sds.py | Sds.unregisterSds | def unregisterSds(self, sdsObj):
"""
Unregister SDS from MDM/SIO Cluster
:param sdsObj: ScaleIO SDS objecty
:return: POST request response
:rtype: Requests POST response object
"""
self.conn.connection._check_login()
response = self.conn.connection._do_pos... | python | def unregisterSds(self, sdsObj):
"""
Unregister SDS from MDM/SIO Cluster
:param sdsObj: ScaleIO SDS objecty
:return: POST request response
:rtype: Requests POST response object
"""
self.conn.connection._check_login()
response = self.conn.connection._do_pos... | [
"def",
"unregisterSds",
"(",
"self",
",",
"sdsObj",
")",
":",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"conn",
".",
"connection",
".",
"_do_post",
"(",
"\"{}/{}{}/{}\"",
".",
"format",
"(",
"sel... | Unregister SDS from MDM/SIO Cluster
:param sdsObj: ScaleIO SDS objecty
:return: POST request response
:rtype: Requests POST response object | [
"Unregister",
"SDS",
"from",
"MDM",
"/",
"SIO",
"Cluster",
":",
"param",
"sdsObj",
":",
"ScaleIO",
"SDS",
"objecty",
":",
"return",
":",
"POST",
"request",
"response",
":",
"rtype",
":",
"Requests",
"POST",
"response",
"object"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/sds.py#L50-L59 | train | Unregisters an SDS from MDM or SIO Cluster |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/sds.py | Sds.registerSds | def registerSds(self, sdsObj, **kwargs):
"""
Register SDS with MDM/SIO Cluster
:param sdsObj: ScaleIO SDS object
:return: POST request response
:rtype: Requests POST response object
"""
# Register existing SDS running SDS binary (need to be installed manually but ... | python | def registerSds(self, sdsObj, **kwargs):
"""
Register SDS with MDM/SIO Cluster
:param sdsObj: ScaleIO SDS object
:return: POST request response
:rtype: Requests POST response object
"""
# Register existing SDS running SDS binary (need to be installed manually but ... | [
"def",
"registerSds",
"(",
"self",
",",
"sdsObj",
",",
"*",
"*",
"kwargs",
")",
":",
"# Register existing SDS running SDS binary (need to be installed manually but not added to MDM)",
"# ",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"(",
")",
"response... | Register SDS with MDM/SIO Cluster
:param sdsObj: ScaleIO SDS object
:return: POST request response
:rtype: Requests POST response object | [
"Register",
"SDS",
"with",
"MDM",
"/",
"SIO",
"Cluster",
":",
"param",
"sdsObj",
":",
"ScaleIO",
"SDS",
"object",
":",
"return",
":",
"POST",
"request",
"response",
":",
"rtype",
":",
"Requests",
"POST",
"response",
"object"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/sds.py#L62-L74 | train | Register SDS with MDM |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/sds.py | Sds.get_sds_in_faultset | def get_sds_in_faultset(self, faultSetObj):
"""
Get list of SDS objects attached to a specific ScaleIO Faultset
:param faultSetObj: ScaleIO Faultset object
:rtype: list of SDS in specified Faultset
"""
self.conn.connection._check_login()
response = self.conn.conne... | python | def get_sds_in_faultset(self, faultSetObj):
"""
Get list of SDS objects attached to a specific ScaleIO Faultset
:param faultSetObj: ScaleIO Faultset object
:rtype: list of SDS in specified Faultset
"""
self.conn.connection._check_login()
response = self.conn.conne... | [
"def",
"get_sds_in_faultset",
"(",
"self",
",",
"faultSetObj",
")",
":",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"conn",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}{}/{}\"",
".",
"format",
"... | Get list of SDS objects attached to a specific ScaleIO Faultset
:param faultSetObj: ScaleIO Faultset object
:rtype: list of SDS in specified Faultset | [
"Get",
"list",
"of",
"SDS",
"objects",
"attached",
"to",
"a",
"specific",
"ScaleIO",
"Faultset",
":",
"param",
"faultSetObj",
":",
"ScaleIO",
"Faultset",
"object",
":",
"rtype",
":",
"list",
"of",
"SDS",
"in",
"specified",
"Faultset"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/sds.py#L76-L89 | train | Get list of SDS objects attached to a specific ScaleIO Faultset. |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/sds.py | Sds.get_sds_by_name | def get_sds_by_name(self,name):
"""
Get ScaleIO SDS object by its name
:param name: Name of SDS
:return: ScaleIO SDS object
:raise KeyError: No SDS with specified name found
:rtype: SDS object
"""
for sds in self.sds:
if sds.name == name:
... | python | def get_sds_by_name(self,name):
"""
Get ScaleIO SDS object by its name
:param name: Name of SDS
:return: ScaleIO SDS object
:raise KeyError: No SDS with specified name found
:rtype: SDS object
"""
for sds in self.sds:
if sds.name == name:
... | [
"def",
"get_sds_by_name",
"(",
"self",
",",
"name",
")",
":",
"for",
"sds",
"in",
"self",
".",
"sds",
":",
"if",
"sds",
".",
"name",
"==",
"name",
":",
"return",
"sds",
"raise",
"KeyError",
"(",
"\"SDS of that name not found\"",
")"
] | Get ScaleIO SDS object by its name
:param name: Name of SDS
:return: ScaleIO SDS object
:raise KeyError: No SDS with specified name found
:rtype: SDS object | [
"Get",
"ScaleIO",
"SDS",
"object",
"by",
"its",
"name",
":",
"param",
"name",
":",
"Name",
"of",
"SDS",
":",
"return",
":",
"ScaleIO",
"SDS",
"object",
":",
"raise",
"KeyError",
":",
"No",
"SDS",
"with",
"specified",
"name",
"found",
":",
"rtype",
":",... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/sds.py#L91-L102 | train | Get ScaleIO SDS object by its name. |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/sds.py | Sds.get_sds_by_ip | def get_sds_by_ip(self,ip):
"""
Get ScaleIO SDS object by its ip address
:param name: IP address of SDS
:return: ScaleIO SDS object
:raise KeyError: No SDS with specified ip found
:rtype: SDS object
"""
if self.conn.is_ip_addr(ip):
for sds in s... | python | def get_sds_by_ip(self,ip):
"""
Get ScaleIO SDS object by its ip address
:param name: IP address of SDS
:return: ScaleIO SDS object
:raise KeyError: No SDS with specified ip found
:rtype: SDS object
"""
if self.conn.is_ip_addr(ip):
for sds in s... | [
"def",
"get_sds_by_ip",
"(",
"self",
",",
"ip",
")",
":",
"if",
"self",
".",
"conn",
".",
"is_ip_addr",
"(",
"ip",
")",
":",
"for",
"sds",
"in",
"self",
".",
"sds",
":",
"for",
"sdsIp",
"in",
"sds",
".",
"ipList",
":",
"if",
"sdsIp",
"==",
"ip",
... | Get ScaleIO SDS object by its ip address
:param name: IP address of SDS
:return: ScaleIO SDS object
:raise KeyError: No SDS with specified ip found
:rtype: SDS object | [
"Get",
"ScaleIO",
"SDS",
"object",
"by",
"its",
"ip",
"address",
":",
"param",
"name",
":",
"IP",
"address",
"of",
"SDS",
":",
"return",
":",
"ScaleIO",
"SDS",
"object",
":",
"raise",
"KeyError",
":",
"No",
"SDS",
"with",
"specified",
"ip",
"found",
":... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/sds.py#L104-L119 | train | Get ScaleIO SDS object by its ip address |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/sds.py | Sds.get_sds_by_id | def get_sds_by_id(self,id):
"""
Get ScaleIO SDS object by its id
:param name: ID of SDS
:return: ScaleIO SDS object
:raise KeyError: No SDS with specified id found
:rtype: SDS object
"""
for sds in self.sds:
if sds.id == id:
ret... | python | def get_sds_by_id(self,id):
"""
Get ScaleIO SDS object by its id
:param name: ID of SDS
:return: ScaleIO SDS object
:raise KeyError: No SDS with specified id found
:rtype: SDS object
"""
for sds in self.sds:
if sds.id == id:
ret... | [
"def",
"get_sds_by_id",
"(",
"self",
",",
"id",
")",
":",
"for",
"sds",
"in",
"self",
".",
"sds",
":",
"if",
"sds",
".",
"id",
"==",
"id",
":",
"return",
"sds",
"raise",
"KeyError",
"(",
"\"SDS with that ID not found\"",
")"
] | Get ScaleIO SDS object by its id
:param name: ID of SDS
:return: ScaleIO SDS object
:raise KeyError: No SDS with specified id found
:rtype: SDS object | [
"Get",
"ScaleIO",
"SDS",
"object",
"by",
"its",
"id",
":",
"param",
"name",
":",
"ID",
"of",
"SDS",
":",
"return",
":",
"ScaleIO",
"SDS",
"object",
":",
"raise",
"KeyError",
":",
"No",
"SDS",
"with",
"specified",
"id",
"found",
":",
"rtype",
":",
"SD... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/sds.py#L121-L132 | train | Get ScaleIO SDS object by its id |
useblocks/groundwork | groundwork/configuration/config.py | Config.set | def set(self, name, value, overwrite=False):
"""
Sets a new value for a given configuration parameter.
If it already exists, an Exception is thrown.
To overwrite an existing value, set overwrite to True.
:param name: Unique name of the parameter
:param value: Value of t... | python | def set(self, name, value, overwrite=False):
"""
Sets a new value for a given configuration parameter.
If it already exists, an Exception is thrown.
To overwrite an existing value, set overwrite to True.
:param name: Unique name of the parameter
:param value: Value of t... | [
"def",
"set",
"(",
"self",
",",
"name",
",",
"value",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"name",
")",
":",
"if",
"overwrite",
":",
"setattr",
"(",
"self",
",",
"name",
",",
"value",
")",
"else",
":",
"sel... | Sets a new value for a given configuration parameter.
If it already exists, an Exception is thrown.
To overwrite an existing value, set overwrite to True.
:param name: Unique name of the parameter
:param value: Value of the configuration parameter
:param overwrite: If true, an ... | [
"Sets",
"a",
"new",
"value",
"for",
"a",
"given",
"configuration",
"parameter",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/configuration/config.py#L30-L50 | train | Sets a new value for a given configuration parameter. |
jenisys/parse_type | parse_type/cfparse.py | Parser.create_missing_types | def create_missing_types(cls, schema, type_dict, type_builder=None):
"""Creates missing types for fields with a CardinalityField part.
It is assumed that the primary type converter for cardinality=1
is registered in the type dictionary.
:param schema: Parse schema (or format) for parse... | python | def create_missing_types(cls, schema, type_dict, type_builder=None):
"""Creates missing types for fields with a CardinalityField part.
It is assumed that the primary type converter for cardinality=1
is registered in the type dictionary.
:param schema: Parse schema (or format) for parse... | [
"def",
"create_missing_types",
"(",
"cls",
",",
"schema",
",",
"type_dict",
",",
"type_builder",
"=",
"None",
")",
":",
"if",
"not",
"type_builder",
":",
"type_builder",
"=",
"cls",
".",
"type_builder",
"missing",
"=",
"cls",
".",
"extract_missing_special_type_n... | Creates missing types for fields with a CardinalityField part.
It is assumed that the primary type converter for cardinality=1
is registered in the type dictionary.
:param schema: Parse schema (or format) for parser (as string).
:param type_dict: Type dictionary with type converters.
... | [
"Creates",
"missing",
"types",
"for",
"fields",
"with",
"a",
"CardinalityField",
"part",
".",
"It",
"is",
"assumed",
"that",
"the",
"primary",
"type",
"converter",
"for",
"cardinality",
"=",
"1",
"is",
"registered",
"in",
"the",
"type",
"dictionary",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cfparse.py#L56-L72 | train | Creates missing types for fields with a CardinalityField part. |
jenisys/parse_type | parse_type/cfparse.py | Parser.extract_missing_special_type_names | def extract_missing_special_type_names(schema, type_dict):
"""Extract the type names for fields with CardinalityField part.
Selects only the missing type names that are not in the type dictionary.
:param schema: Parse schema to use (as string).
:param type_dict: Type dictionary wit... | python | def extract_missing_special_type_names(schema, type_dict):
"""Extract the type names for fields with CardinalityField part.
Selects only the missing type names that are not in the type dictionary.
:param schema: Parse schema to use (as string).
:param type_dict: Type dictionary wit... | [
"def",
"extract_missing_special_type_names",
"(",
"schema",
",",
"type_dict",
")",
":",
"for",
"name",
"in",
"FieldParser",
".",
"extract_types",
"(",
"schema",
")",
":",
"if",
"CardinalityField",
".",
"matches_type",
"(",
"name",
")",
"and",
"(",
"name",
"not... | Extract the type names for fields with CardinalityField part.
Selects only the missing type names that are not in the type dictionary.
:param schema: Parse schema to use (as string).
:param type_dict: Type dictionary with type converters.
:return: Generator with missing type names ... | [
"Extract",
"the",
"type",
"names",
"for",
"fields",
"with",
"CardinalityField",
"part",
".",
"Selects",
"only",
"the",
"missing",
"type",
"names",
"that",
"are",
"not",
"in",
"the",
"type",
"dictionary",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cfparse.py#L75-L85 | train | Extract the type names for fields with CardinalityField part. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/checkers/_checkers.py | _check_operations | def _check_operations(ctx, need_ops, arg):
''' Checks an allow or a deny caveat. The need_ops parameter specifies
whether we require all the operations in the caveat to be declared in
the context.
'''
ctx_ops = ctx.get(OP_KEY, [])
if len(ctx_ops) == 0:
if need_ops:
f = arg.sp... | python | def _check_operations(ctx, need_ops, arg):
''' Checks an allow or a deny caveat. The need_ops parameter specifies
whether we require all the operations in the caveat to be declared in
the context.
'''
ctx_ops = ctx.get(OP_KEY, [])
if len(ctx_ops) == 0:
if need_ops:
f = arg.sp... | [
"def",
"_check_operations",
"(",
"ctx",
",",
"need_ops",
",",
"arg",
")",
":",
"ctx_ops",
"=",
"ctx",
".",
"get",
"(",
"OP_KEY",
",",
"[",
"]",
")",
"if",
"len",
"(",
"ctx_ops",
")",
"==",
"0",
":",
"if",
"need_ops",
":",
"f",
"=",
"arg",
".",
... | Checks an allow or a deny caveat. The need_ops parameter specifies
whether we require all the operations in the caveat to be declared in
the context. | [
"Checks",
"an",
"allow",
"or",
"a",
"deny",
"caveat",
".",
"The",
"need_ops",
"parameter",
"specifies",
"whether",
"we",
"require",
"all",
"the",
"operations",
"in",
"the",
"caveat",
"to",
"be",
"declared",
"in",
"the",
"context",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_checkers.py#L210-L229 | train | Checks an allow or deny caveat. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/checkers/_checkers.py | Checker.check_first_party_caveat | def check_first_party_caveat(self, ctx, cav):
''' Checks the caveat against all registered caveat conditions.
:return: error message string if any or None
'''
try:
cond, arg = parse_caveat(cav)
except ValueError as ex:
# If we can't parse it, perhaps it's ... | python | def check_first_party_caveat(self, ctx, cav):
''' Checks the caveat against all registered caveat conditions.
:return: error message string if any or None
'''
try:
cond, arg = parse_caveat(cav)
except ValueError as ex:
# If we can't parse it, perhaps it's ... | [
"def",
"check_first_party_caveat",
"(",
"self",
",",
"ctx",
",",
"cav",
")",
":",
"try",
":",
"cond",
",",
"arg",
"=",
"parse_caveat",
"(",
"cav",
")",
"except",
"ValueError",
"as",
"ex",
":",
"# If we can't parse it, perhaps it's in some other format,",
"# return... | Checks the caveat against all registered caveat conditions.
:return: error message string if any or None | [
"Checks",
"the",
"caveat",
"against",
"all",
"registered",
"caveat",
"conditions",
".",
":",
"return",
":",
"error",
"message",
"string",
"if",
"any",
"or",
"None"
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_checkers.py#L67-L83 | train | Checks the caveat against all registered caveat conditions. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/checkers/_checkers.py | Checker.info | def info(self):
''' Returns information on all the registered checkers.
Sorted by namespace and then name
:returns a list of CheckerInfo
'''
return sorted(self._checkers.values(), key=lambda x: (x.ns, x.name)) | python | def info(self):
''' Returns information on all the registered checkers.
Sorted by namespace and then name
:returns a list of CheckerInfo
'''
return sorted(self._checkers.values(), key=lambda x: (x.ns, x.name)) | [
"def",
"info",
"(",
"self",
")",
":",
"return",
"sorted",
"(",
"self",
".",
"_checkers",
".",
"values",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"(",
"x",
".",
"ns",
",",
"x",
".",
"name",
")",
")"
] | Returns information on all the registered checkers.
Sorted by namespace and then name
:returns a list of CheckerInfo | [
"Returns",
"information",
"on",
"all",
"the",
"registered",
"checkers",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_checkers.py#L90-L96 | train | Returns a list of CheckerInfo objects sorted by namespace and then name |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/checkers/_checkers.py | Checker.register | def register(self, cond, uri, check):
''' Registers the given condition(string) in the given namespace
uri (string) to be checked with the given check function.
The check function checks a caveat by passing an auth context, a cond
parameter(string) that holds the caveat condition includi... | python | def register(self, cond, uri, check):
''' Registers the given condition(string) in the given namespace
uri (string) to be checked with the given check function.
The check function checks a caveat by passing an auth context, a cond
parameter(string) that holds the caveat condition includi... | [
"def",
"register",
"(",
"self",
",",
"cond",
",",
"uri",
",",
"check",
")",
":",
"if",
"check",
"is",
"None",
":",
"raise",
"RegisterError",
"(",
"'no check function registered for namespace {} when '",
"'registering condition {}'",
".",
"format",
"(",
"uri",
",",... | Registers the given condition(string) in the given namespace
uri (string) to be checked with the given check function.
The check function checks a caveat by passing an auth context, a cond
parameter(string) that holds the caveat condition including any
namespace prefix and an arg paramet... | [
"Registers",
"the",
"given",
"condition",
"(",
"string",
")",
"in",
"the",
"given",
"namespace",
"uri",
"(",
"string",
")",
"to",
"be",
"checked",
"with",
"the",
"given",
"check",
"function",
".",
"The",
"check",
"function",
"checks",
"a",
"caveat",
"by",
... | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_checkers.py#L98-L135 | train | Registers the given condition in the given namespace
uri with the given check function. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/checkers/_checkers.py | Checker.register_std | def register_std(self):
''' Registers all the standard checkers in the given checker.
If not present already, the standard checkers schema (STD_NAMESPACE) is
added to the checker's namespace with an empty prefix.
'''
self._namespace.register(STD_NAMESPACE, '')
for cond i... | python | def register_std(self):
''' Registers all the standard checkers in the given checker.
If not present already, the standard checkers schema (STD_NAMESPACE) is
added to the checker's namespace with an empty prefix.
'''
self._namespace.register(STD_NAMESPACE, '')
for cond i... | [
"def",
"register_std",
"(",
"self",
")",
":",
"self",
".",
"_namespace",
".",
"register",
"(",
"STD_NAMESPACE",
",",
"''",
")",
"for",
"cond",
"in",
"_ALL_CHECKERS",
":",
"self",
".",
"register",
"(",
"cond",
",",
"STD_NAMESPACE",
",",
"_ALL_CHECKERS",
"["... | Registers all the standard checkers in the given checker.
If not present already, the standard checkers schema (STD_NAMESPACE) is
added to the checker's namespace with an empty prefix. | [
"Registers",
"all",
"the",
"standard",
"checkers",
"in",
"the",
"given",
"checker",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_checkers.py#L137-L145 | train | Registers all the standard checkers in the given checker. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_authorizer.py | AuthorizerFunc.authorize | def authorize(self, ctx, identity, ops):
'''Implements Authorizer.authorize by calling f with the given identity
for each operation.
'''
allowed = []
caveats = []
for op in ops:
ok, fcaveats = self._f(ctx, identity, op)
allowed.append(ok)
... | python | def authorize(self, ctx, identity, ops):
'''Implements Authorizer.authorize by calling f with the given identity
for each operation.
'''
allowed = []
caveats = []
for op in ops:
ok, fcaveats = self._f(ctx, identity, op)
allowed.append(ok)
... | [
"def",
"authorize",
"(",
"self",
",",
"ctx",
",",
"identity",
",",
"ops",
")",
":",
"allowed",
"=",
"[",
"]",
"caveats",
"=",
"[",
"]",
"for",
"op",
"in",
"ops",
":",
"ok",
",",
"fcaveats",
"=",
"self",
".",
"_f",
"(",
"ctx",
",",
"identity",
"... | Implements Authorizer.authorize by calling f with the given identity
for each operation. | [
"Implements",
"Authorizer",
".",
"authorize",
"by",
"calling",
"f",
"with",
"the",
"given",
"identity",
"for",
"each",
"operation",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_authorizer.py#L50-L61 | train | Implements Authorizer. authorize by calling f with the given identity
for each operation. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_authorizer.py | ACLAuthorizer.authorize | def authorize(self, ctx, identity, ops):
'''Implements Authorizer.authorize by calling identity.allow to
determine whether the identity is a member of the ACLs associated with
the given operations.
'''
if len(ops) == 0:
# Anyone is allowed to do nothing.
r... | python | def authorize(self, ctx, identity, ops):
'''Implements Authorizer.authorize by calling identity.allow to
determine whether the identity is a member of the ACLs associated with
the given operations.
'''
if len(ops) == 0:
# Anyone is allowed to do nothing.
r... | [
"def",
"authorize",
"(",
"self",
",",
"ctx",
",",
"identity",
",",
"ops",
")",
":",
"if",
"len",
"(",
"ops",
")",
"==",
"0",
":",
"# Anyone is allowed to do nothing.",
"return",
"[",
"]",
",",
"[",
"]",
"allowed",
"=",
"[",
"False",
"]",
"*",
"len",
... | Implements Authorizer.authorize by calling identity.allow to
determine whether the identity is a member of the ACLs associated with
the given operations. | [
"Implements",
"Authorizer",
".",
"authorize",
"by",
"calling",
"identity",
".",
"allow",
"to",
"determine",
"whether",
"the",
"identity",
"is",
"a",
"member",
"of",
"the",
"ACLs",
"associated",
"with",
"the",
"given",
"operations",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_authorizer.py#L83-L99 | train | Implements Authorizer. authorize by calling identity. allow to determine whether the identity is a member of the ACLs associated with the given operations. |
cocoakekeyu/cancan | cancan/rule.py | Rule.is_relevant | def is_relevant(self, action, subject):
"""
Matches both the subject and action, not necessarily the conditions.
"""
return self.matches_action(action) and self.matches_subject(subject) | python | def is_relevant(self, action, subject):
"""
Matches both the subject and action, not necessarily the conditions.
"""
return self.matches_action(action) and self.matches_subject(subject) | [
"def",
"is_relevant",
"(",
"self",
",",
"action",
",",
"subject",
")",
":",
"return",
"self",
".",
"matches_action",
"(",
"action",
")",
"and",
"self",
".",
"matches_subject",
"(",
"subject",
")"
] | Matches both the subject and action, not necessarily the conditions. | [
"Matches",
"both",
"the",
"subject",
"and",
"action",
"not",
"necessarily",
"the",
"conditions",
"."
] | f198d560e6e008e6c5580ba55581a939a5d544ed | https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/rule.py#L42-L46 | train | Returns True if the action and subject match the conditions. |
Phyks/libbmc | libbmc/repositories/hal.py | is_valid | def is_valid(hal_id):
"""
Check that a given HAL id is a valid one.
:param hal_id: The HAL id to be checked.
:returns: Boolean indicating whether the HAL id is valid or not.
>>> is_valid("hal-01258754, version 1")
True
>>> is_valid("hal-01258754")
True
>>> is_valid("hal-01258754v... | python | def is_valid(hal_id):
"""
Check that a given HAL id is a valid one.
:param hal_id: The HAL id to be checked.
:returns: Boolean indicating whether the HAL id is valid or not.
>>> is_valid("hal-01258754, version 1")
True
>>> is_valid("hal-01258754")
True
>>> is_valid("hal-01258754v... | [
"def",
"is_valid",
"(",
"hal_id",
")",
":",
"match",
"=",
"REGEX",
".",
"match",
"(",
"hal_id",
")",
"return",
"(",
"match",
"is",
"not",
"None",
")",
"and",
"(",
"match",
".",
"group",
"(",
"0",
")",
"==",
"hal_id",
")"
] | Check that a given HAL id is a valid one.
:param hal_id: The HAL id to be checked.
:returns: Boolean indicating whether the HAL id is valid or not.
>>> is_valid("hal-01258754, version 1")
True
>>> is_valid("hal-01258754")
True
>>> is_valid("hal-01258754v2")
True
>>> is_valid("fo... | [
"Check",
"that",
"a",
"given",
"HAL",
"id",
"is",
"a",
"valid",
"one",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/repositories/hal.py#L16-L36 | train | Checks that a given HAL id is a valid one. |
Phyks/libbmc | libbmc/repositories/hal.py | extract_from_text | def extract_from_text(text):
"""
Extract HAL ids from a text.
:param text: The text to extract HAL ids from.
:returns: A list of matching HAL ids.
>>> sorted(extract_from_text("hal-01258754 hal-01258754v2 foobar"))
['hal-01258754', 'hal-01258754v2']
"""
return tools.remove_duplicates([... | python | def extract_from_text(text):
"""
Extract HAL ids from a text.
:param text: The text to extract HAL ids from.
:returns: A list of matching HAL ids.
>>> sorted(extract_from_text("hal-01258754 hal-01258754v2 foobar"))
['hal-01258754', 'hal-01258754v2']
"""
return tools.remove_duplicates([... | [
"def",
"extract_from_text",
"(",
"text",
")",
":",
"return",
"tools",
".",
"remove_duplicates",
"(",
"[",
"i",
"[",
"0",
"]",
"for",
"i",
"in",
"REGEX",
".",
"findall",
"(",
"text",
")",
"if",
"i",
"!=",
"''",
"]",
")"
] | Extract HAL ids from a text.
:param text: The text to extract HAL ids from.
:returns: A list of matching HAL ids.
>>> sorted(extract_from_text("hal-01258754 hal-01258754v2 foobar"))
['hal-01258754', 'hal-01258754v2'] | [
"Extract",
"HAL",
"ids",
"from",
"a",
"text",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/repositories/hal.py#L39-L50 | train | Extract HAL ids from a text. |
dbarsam/python-vsgen | vsgen/suite.py | VSGSuite._getsolution | def _getsolution(self, config, section, **kwargs):
"""
Creates a VSG solution from a configparser instance.
:param object config: The instance of the configparser class
:param str section: The section name to read.
:param kwargs: List of additional keyworded arguments to be pas... | python | def _getsolution(self, config, section, **kwargs):
"""
Creates a VSG solution from a configparser instance.
:param object config: The instance of the configparser class
:param str section: The section name to read.
:param kwargs: List of additional keyworded arguments to be pas... | [
"def",
"_getsolution",
"(",
"self",
",",
"config",
",",
"section",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"section",
"not",
"in",
"config",
":",
"raise",
"ValueError",
"(",
"'Section [{}] not found in [{}]'",
".",
"format",
"(",
"section",
",",
"', '",
"... | Creates a VSG solution from a configparser instance.
:param object config: The instance of the configparser class
:param str section: The section name to read.
:param kwargs: List of additional keyworded arguments to be passed into the VSGSolution.
:return: A valid VSGSolution instance... | [
"Creates",
"a",
"VSG",
"solution",
"from",
"a",
"configparser",
"instance",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/suite.py#L43-L68 | train | Creates a VSG solution from a configparser instance. |
dbarsam/python-vsgen | vsgen/suite.py | VSGSuite._getproject | def _getproject(self, config, section, **kwargs):
"""
Creates a VSG project from a configparser instance.
:param object config: The instance of the configparser class
:param str section: The section name to read.
:param kwargs: List of additional keyworded arguments to be passe... | python | def _getproject(self, config, section, **kwargs):
"""
Creates a VSG project from a configparser instance.
:param object config: The instance of the configparser class
:param str section: The section name to read.
:param kwargs: List of additional keyworded arguments to be passe... | [
"def",
"_getproject",
"(",
"self",
",",
"config",
",",
"section",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"section",
"not",
"in",
"config",
":",
"raise",
"ValueError",
"(",
"'Section [{}] not found in [{}]'",
".",
"format",
"(",
"section",
",",
"', '",
".... | Creates a VSG project from a configparser instance.
:param object config: The instance of the configparser class
:param str section: The section name to read.
:param kwargs: List of additional keyworded arguments to be passed into the VSGProject.
:return: A valid VSGProject instance if... | [
"Creates",
"a",
"VSG",
"project",
"from",
"a",
"configparser",
"instance",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/suite.py#L70-L87 | train | Creates a VSG project from a configparser instance. |
dbarsam/python-vsgen | vsgen/suite.py | VSGSuite.from_file | def from_file(cls, filename):
"""
Creates an VSGSuite instance from a filename.
:param str filename: The fully qualified path to the VSG configuration file.
"""
# Read the configuration file
config = VSGConfigParser()
if filename not in config.read([filename]):
... | python | def from_file(cls, filename):
"""
Creates an VSGSuite instance from a filename.
:param str filename: The fully qualified path to the VSG configuration file.
"""
# Read the configuration file
config = VSGConfigParser()
if filename not in config.read([filename]):
... | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
")",
":",
"# Read the configuration file",
"config",
"=",
"VSGConfigParser",
"(",
")",
"if",
"filename",
"not",
"in",
"config",
".",
"read",
"(",
"[",
"filename",
"]",
")",
":",
"raise",
"ValueError",
"(",
"... | Creates an VSGSuite instance from a filename.
:param str filename: The fully qualified path to the VSG configuration file. | [
"Creates",
"an",
"VSGSuite",
"instance",
"from",
"a",
"filename",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/suite.py#L90-L106 | train | Creates an instance of the class VSGSuite from a file. |
dbarsam/python-vsgen | vsgen/suite.py | VSGSuite.make_parser | def make_parser(cls, **kwargs):
"""
Creates a :class:`~argparse.ArgumentParser` instances to work with VSGSuite classes.
:param kwargs: List of additional keyworded arguments to be passed into the :class:`~argparse.ArgumentParser`.
:return: A :class:`~argparse.ArgumentParser` instance... | python | def make_parser(cls, **kwargs):
"""
Creates a :class:`~argparse.ArgumentParser` instances to work with VSGSuite classes.
:param kwargs: List of additional keyworded arguments to be passed into the :class:`~argparse.ArgumentParser`.
:return: A :class:`~argparse.ArgumentParser` instance... | [
"def",
"make_parser",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"# Build a parent parser",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"*",
"*",
"kwargs",
")",
"# Add multiple sub-commands:",
"subparsers",
"=",
"parser",
".",
"add_subparsers",
"(... | Creates a :class:`~argparse.ArgumentParser` instances to work with VSGSuite classes.
:param kwargs: List of additional keyworded arguments to be passed into the :class:`~argparse.ArgumentParser`.
:return: A :class:`~argparse.ArgumentParser` instance. | [
"Creates",
"a",
":",
"class",
":",
"~argparse",
".",
"ArgumentParser",
"instances",
"to",
"work",
"with",
"VSGSuite",
"classes",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/suite.py#L109-L134 | train | Creates a parser for the VSGSuite classes. |
dbarsam/python-vsgen | vsgen/suite.py | VSGSuite.from_args | def from_args(cls, **kwargs):
"""
Generates one or more VSGSuite instances from command line arguments.
:param kwargs: List of additional keyworded arguments to be passed into the VSGSuite defined in the :meth:`~VSGSuite.make_parser` method.
"""
# Create a VSGSuite for each fil... | python | def from_args(cls, **kwargs):
"""
Generates one or more VSGSuite instances from command line arguments.
:param kwargs: List of additional keyworded arguments to be passed into the VSGSuite defined in the :meth:`~VSGSuite.make_parser` method.
"""
# Create a VSGSuite for each fil... | [
"def",
"from_args",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"# Create a VSGSuite for each filename on the command line.",
"if",
"kwargs",
".",
"get",
"(",
"'suite_commands'",
",",
"None",
")",
"==",
"'generate'",
":",
"filenames",
"=",
"kwargs",
".",
"pop... | Generates one or more VSGSuite instances from command line arguments.
:param kwargs: List of additional keyworded arguments to be passed into the VSGSuite defined in the :meth:`~VSGSuite.make_parser` method. | [
"Generates",
"one",
"or",
"more",
"VSGSuite",
"instances",
"from",
"command",
"line",
"arguments",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/suite.py#L137-L154 | train | Generates one or more VSGSuite instances from command line arguments. |
dbarsam/python-vsgen | vsgen/suite.py | VSGSuite.from_directory | def from_directory(cls, directory, type, **kwargs):
"""
Creates an VSGSuite instance from a filename.
:param str filename: The fully qualified path to the VSG configuration file.
:param str type: The configuration type to generate.
:param kwargs: List of additional keyworded ... | python | def from_directory(cls, directory, type, **kwargs):
"""
Creates an VSGSuite instance from a filename.
:param str filename: The fully qualified path to the VSG configuration file.
:param str type: The configuration type to generate.
:param kwargs: List of additional keyworded ... | [
"def",
"from_directory",
"(",
"cls",
",",
"directory",
",",
"type",
",",
"*",
"*",
"kwargs",
")",
":",
"# Resolve the suite class from the type",
"suite_class",
"=",
"entrypoint",
"(",
"'vsgen.suites'",
",",
"type",
")",
"# Merge the default and any additional, maybe ov... | Creates an VSGSuite instance from a filename.
:param str filename: The fully qualified path to the VSG configuration file.
:param str type: The configuration type to generate.
:param kwargs: List of additional keyworded arguments to be passed into the VSGSuite. | [
"Creates",
"an",
"VSGSuite",
"instance",
"from",
"a",
"filename",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/suite.py#L157-L174 | train | Creates an instance of the class specified by the type and the directory. |
dbarsam/python-vsgen | vsgen/suite.py | VSGSuite.write | def write(self, parallel=True):
"""
Writes the configuration to disk.
"""
# Write the Solution files
solutions = sorted(self._solutions, key=lambda x: x.Name)
with VSGWriteCommand('Writing VSG Solution', solutions, parallel) as command:
command.execute()
... | python | def write(self, parallel=True):
"""
Writes the configuration to disk.
"""
# Write the Solution files
solutions = sorted(self._solutions, key=lambda x: x.Name)
with VSGWriteCommand('Writing VSG Solution', solutions, parallel) as command:
command.execute()
... | [
"def",
"write",
"(",
"self",
",",
"parallel",
"=",
"True",
")",
":",
"# Write the Solution files",
"solutions",
"=",
"sorted",
"(",
"self",
".",
"_solutions",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"Name",
")",
"with",
"VSGWriteCommand",
"(",
"'W... | Writes the configuration to disk. | [
"Writes",
"the",
"configuration",
"to",
"disk",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/suite.py#L176-L193 | train | Writes the configuration to disk. |
Phyks/libbmc | libbmc/citations/bbl.py | bibitem_as_plaintext | def bibitem_as_plaintext(bibitem):
"""
Return a plaintext representation of a bibitem from the ``.bbl`` file.
.. note::
This plaintext representation can be super ugly, contain URLs and so \
on.
.. note::
You need to have ``delatex`` installed system-wide, or to build it in \... | python | def bibitem_as_plaintext(bibitem):
"""
Return a plaintext representation of a bibitem from the ``.bbl`` file.
.. note::
This plaintext representation can be super ugly, contain URLs and so \
on.
.. note::
You need to have ``delatex`` installed system-wide, or to build it in \... | [
"def",
"bibitem_as_plaintext",
"(",
"bibitem",
")",
":",
"try",
":",
"output",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"delatex\"",
",",
"\"-s\"",
"]",
",",
"input",
"=",
"bibitem",
".",
"encode",
"(",
"\"utf-8\"",
")",
")",
"except",
"FileNotF... | Return a plaintext representation of a bibitem from the ``.bbl`` file.
.. note::
This plaintext representation can be super ugly, contain URLs and so \
on.
.. note::
You need to have ``delatex`` installed system-wide, or to build it in \
this repo, according to the ``... | [
"Return",
"a",
"plaintext",
"representation",
"of",
"a",
"bibitem",
"from",
"the",
".",
"bbl",
"file",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/bbl.py#L19-L49 | train | Returns a plaintext representation of a bibitem. |
Phyks/libbmc | libbmc/citations/bbl.py | get_plaintext_citations | def get_plaintext_citations(bbl):
"""
Parse a ``*.bbl`` file to get a clean list of plaintext citations.
:param bbl: Either the path to the .bbl file or the content of a ``.bbl`` \
file.
:returns: A list of cleaned plaintext citations.
"""
# Handle path or content
if os.path.is... | python | def get_plaintext_citations(bbl):
"""
Parse a ``*.bbl`` file to get a clean list of plaintext citations.
:param bbl: Either the path to the .bbl file or the content of a ``.bbl`` \
file.
:returns: A list of cleaned plaintext citations.
"""
# Handle path or content
if os.path.is... | [
"def",
"get_plaintext_citations",
"(",
"bbl",
")",
":",
"# Handle path or content",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"bbl",
")",
":",
"with",
"open",
"(",
"bbl",
",",
"'r'",
")",
"as",
"fh",
":",
"bbl_content",
"=",
"fh",
".",
"read",
"(",
... | Parse a ``*.bbl`` file to get a clean list of plaintext citations.
:param bbl: Either the path to the .bbl file or the content of a ``.bbl`` \
file.
:returns: A list of cleaned plaintext citations. | [
"Parse",
"a",
"*",
".",
"bbl",
"file",
"to",
"get",
"a",
"clean",
"list",
"of",
"plaintext",
"citations",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/bbl.py#L52-L73 | train | Parse a. bbl file to get a list of plaintext citations. |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/protectiondomain.py | ProtectionDomain.get_pd_by_name | def get_pd_by_name(self, name):
"""
Get ScaleIO ProtectionDomain object by its name
:param name: Name of ProtectionDomain
:return: ScaleIO ProtectionDomain object
:raise KeyError: No ProtetionDomain with specified name found
:rtype: ProtectionDomain object
"""
... | python | def get_pd_by_name(self, name):
"""
Get ScaleIO ProtectionDomain object by its name
:param name: Name of ProtectionDomain
:return: ScaleIO ProtectionDomain object
:raise KeyError: No ProtetionDomain with specified name found
:rtype: ProtectionDomain object
"""
... | [
"def",
"get_pd_by_name",
"(",
"self",
",",
"name",
")",
":",
"for",
"pd",
"in",
"self",
".",
"conn",
".",
"protection_domains",
":",
"if",
"pd",
".",
"name",
"==",
"name",
":",
"return",
"pd",
"raise",
"KeyError",
"(",
"\"Protection Domain NAME \"",
"+",
... | Get ScaleIO ProtectionDomain object by its name
:param name: Name of ProtectionDomain
:return: ScaleIO ProtectionDomain object
:raise KeyError: No ProtetionDomain with specified name found
:rtype: ProtectionDomain object | [
"Get",
"ScaleIO",
"ProtectionDomain",
"object",
"by",
"its",
"name",
":",
"param",
"name",
":",
"Name",
"of",
"ProtectionDomain",
":",
"return",
":",
"ScaleIO",
"ProtectionDomain",
"object",
":",
"raise",
"KeyError",
":",
"No",
"ProtetionDomain",
"with",
"specif... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/protectiondomain.py#L33-L44 | train | Get a ProtetionDomain object by its name |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/protectiondomain.py | ProtectionDomain.get_pd_by_id | def get_pd_by_id(self, id):
"""
Get ScaleIO ProtectionDomain object by its id
:param name: ID of ProtectionDomain
:return: ScaleIO ProctectionDomain object
:raise KeyError: No ProtectionDomain with specified name found
:rtype: ProtectionDomain object
"""
f... | python | def get_pd_by_id(self, id):
"""
Get ScaleIO ProtectionDomain object by its id
:param name: ID of ProtectionDomain
:return: ScaleIO ProctectionDomain object
:raise KeyError: No ProtectionDomain with specified name found
:rtype: ProtectionDomain object
"""
f... | [
"def",
"get_pd_by_id",
"(",
"self",
",",
"id",
")",
":",
"for",
"pd",
"in",
"self",
".",
"conn",
".",
"protection_domains",
":",
"if",
"pd",
".",
"id",
"==",
"id",
":",
"return",
"pd",
"raise",
"KeyError",
"(",
"\"Protection Domain with ID \"",
"+",
"id"... | Get ScaleIO ProtectionDomain object by its id
:param name: ID of ProtectionDomain
:return: ScaleIO ProctectionDomain object
:raise KeyError: No ProtectionDomain with specified name found
:rtype: ProtectionDomain object | [
"Get",
"ScaleIO",
"ProtectionDomain",
"object",
"by",
"its",
"id",
":",
"param",
"name",
":",
"ID",
"of",
"ProtectionDomain",
":",
"return",
":",
"ScaleIO",
"ProctectionDomain",
"object",
":",
"raise",
"KeyError",
":",
"No",
"ProtectionDomain",
"with",
"specifie... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/protectiondomain.py#L46-L57 | train | Get a ProtectionDomain object by its id |
swevm/scaleio-py | scaleiopy/api/scaleio/cluster/protectiondomain.py | ProtectionDomain.delete_potection_domain | def delete_potection_domain(self, pdObj):
"""
:param pdObj: ID of ProtectionDomain
type: POST
Required:
Protection Domain Object
Return:
"""
self.conn.connection._check_login()
response = self.conn.connection._do_post("{}/{}{}/{}".form... | python | def delete_potection_domain(self, pdObj):
"""
:param pdObj: ID of ProtectionDomain
type: POST
Required:
Protection Domain Object
Return:
"""
self.conn.connection._check_login()
response = self.conn.connection._do_post("{}/{}{}/{}".form... | [
"def",
"delete_potection_domain",
"(",
"self",
",",
"pdObj",
")",
":",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"conn",
".",
"connection",
".",
"_do_post",
"(",
"\"{}/{}{}/{}\"",
".",
"format",
"(... | :param pdObj: ID of ProtectionDomain
type: POST
Required:
Protection Domain Object
Return: | [
":",
"param",
"pdObj",
":",
"ID",
"of",
"ProtectionDomain",
"type",
":",
"POST",
"Required",
":",
"Protection",
"Domain",
"Object",
"Return",
":"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/protectiondomain.py#L66-L77 | train | Delete a potential domain from the Protection Domain |
jenisys/parse_type | parse_type/cardinality_field.py | CardinalityField.split_type | def split_type(cls, type_name):
"""Split type of a type name with CardinalityField suffix into its parts.
:param type_name: Type name (as string).
:return: Tuple (type_basename, cardinality)
"""
if cls.matches_type(type_name):
basename = type_name[:-1]
c... | python | def split_type(cls, type_name):
"""Split type of a type name with CardinalityField suffix into its parts.
:param type_name: Type name (as string).
:return: Tuple (type_basename, cardinality)
"""
if cls.matches_type(type_name):
basename = type_name[:-1]
c... | [
"def",
"split_type",
"(",
"cls",
",",
"type_name",
")",
":",
"if",
"cls",
".",
"matches_type",
"(",
"type_name",
")",
":",
"basename",
"=",
"type_name",
"[",
":",
"-",
"1",
"]",
"cardinality",
"=",
"cls",
".",
"from_char_map",
"[",
"type_name",
"[",
"-... | Split type of a type name with CardinalityField suffix into its parts.
:param type_name: Type name (as string).
:return: Tuple (type_basename, cardinality) | [
"Split",
"type",
"of",
"a",
"type",
"name",
"with",
"CardinalityField",
"suffix",
"into",
"its",
"parts",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality_field.py#L48-L61 | train | Split a type name with CardinalityField suffix into its parts. |
jenisys/parse_type | parse_type/cardinality_field.py | CardinalityField.make_type | def make_type(cls, basename, cardinality):
"""Build new type name according to CardinalityField naming scheme.
:param basename: Type basename of primary type (as string).
:param cardinality: Cardinality of the new type (as Cardinality item).
:return: Type name with CardinalityField suf... | python | def make_type(cls, basename, cardinality):
"""Build new type name according to CardinalityField naming scheme.
:param basename: Type basename of primary type (as string).
:param cardinality: Cardinality of the new type (as Cardinality item).
:return: Type name with CardinalityField suf... | [
"def",
"make_type",
"(",
"cls",
",",
"basename",
",",
"cardinality",
")",
":",
"if",
"cardinality",
"is",
"Cardinality",
".",
"one",
":",
"# -- POSTCONDITION: assert not cls.make_type(type_name)",
"return",
"basename",
"# -- NORMAL CASE: type with CardinalityField suffix.",
... | Build new type name according to CardinalityField naming scheme.
:param basename: Type basename of primary type (as string).
:param cardinality: Cardinality of the new type (as Cardinality item).
:return: Type name with CardinalityField suffix (if needed) | [
"Build",
"new",
"type",
"name",
"according",
"to",
"CardinalityField",
"naming",
"scheme",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality_field.py#L64-L77 | train | Build a new type name according to CardinalityField naming scheme. |
jenisys/parse_type | parse_type/cardinality_field.py | CardinalityFieldTypeBuilder.create_type_variant | def create_type_variant(cls, type_name, type_converter):
"""
Create type variants for types with a cardinality field.
The new type converters are based on the type converter with
cardinality=1.
.. code-block:: python
import parse
@parse.with_pattern(r'\... | python | def create_type_variant(cls, type_name, type_converter):
"""
Create type variants for types with a cardinality field.
The new type converters are based on the type converter with
cardinality=1.
.. code-block:: python
import parse
@parse.with_pattern(r'\... | [
"def",
"create_type_variant",
"(",
"cls",
",",
"type_name",
",",
"type_converter",
")",
":",
"assert",
"isinstance",
"(",
"type_name",
",",
"six",
".",
"string_types",
")",
"if",
"not",
"CardinalityField",
".",
"matches_type",
"(",
"type_name",
")",
":",
"mess... | Create type variants for types with a cardinality field.
The new type converters are based on the type converter with
cardinality=1.
.. code-block:: python
import parse
@parse.with_pattern(r'\d+')
def parse_number(text):
return int(text)
... | [
"Create",
"type",
"variants",
"for",
"types",
"with",
"a",
"cardinality",
"field",
".",
"The",
"new",
"type",
"converters",
"are",
"based",
"on",
"the",
"type",
"converter",
"with",
"cardinality",
"=",
"1",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality_field.py#L93-L134 | train | Create a type variant for a specific type. |
jenisys/parse_type | parse_type/cardinality_field.py | CardinalityFieldTypeBuilder.create_type_variants | def create_type_variants(cls, type_names, type_dict):
"""
Create type variants for types with a cardinality field.
The new type converters are based on the type converter with
cardinality=1.
.. code-block:: python
# -- USE: parse_number() type converter function.
... | python | def create_type_variants(cls, type_names, type_dict):
"""
Create type variants for types with a cardinality field.
The new type converters are based on the type converter with
cardinality=1.
.. code-block:: python
# -- USE: parse_number() type converter function.
... | [
"def",
"create_type_variants",
"(",
"cls",
",",
"type_names",
",",
"type_dict",
")",
":",
"type_variant_dict",
"=",
"{",
"}",
"for",
"type_name",
"in",
"type_names",
":",
"type_variant",
"=",
"cls",
".",
"create_type_variant",
"(",
"type_name",
",",
"type_dict",... | Create type variants for types with a cardinality field.
The new type converters are based on the type converter with
cardinality=1.
.. code-block:: python
# -- USE: parse_number() type converter function.
new_types = CardinalityFieldTypeBuilder.create_type_variants(
... | [
"Create",
"type",
"variants",
"for",
"types",
"with",
"a",
"cardinality",
"field",
".",
"The",
"new",
"type",
"converters",
"are",
"based",
"on",
"the",
"type",
"converter",
"with",
"cardinality",
"=",
"1",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality_field.py#L138-L158 | train | Create type variants for types with a cardinality field suffix. |
jenisys/parse_type | parse_type/cardinality_field.py | CardinalityFieldTypeBuilder.create_missing_type_variants | def create_missing_type_variants(cls, type_names, type_dict):
"""
Create missing type variants for types with a cardinality field.
:param type_names: List of type names with cardinality field suffix.
:param type_dict: Type dictionary with named type converters.
:return: Type di... | python | def create_missing_type_variants(cls, type_names, type_dict):
"""
Create missing type variants for types with a cardinality field.
:param type_names: List of type names with cardinality field suffix.
:param type_dict: Type dictionary with named type converters.
:return: Type di... | [
"def",
"create_missing_type_variants",
"(",
"cls",
",",
"type_names",
",",
"type_dict",
")",
":",
"missing_type_names",
"=",
"[",
"name",
"for",
"name",
"in",
"type_names",
"if",
"name",
"not",
"in",
"type_dict",
"]",
"return",
"cls",
".",
"create_type_variants"... | Create missing type variants for types with a cardinality field.
:param type_names: List of type names with cardinality field suffix.
:param type_dict: Type dictionary with named type converters.
:return: Type dictionary with missing type converter variants. | [
"Create",
"missing",
"type",
"variants",
"for",
"types",
"with",
"a",
"cardinality",
"field",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality_field.py#L162-L172 | train | Create missing type variants for types with cardinality field suffix. |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO._get_log_level | def _get_log_level(level):
"""
small static method to get logging level
:param str level: string of the level e.g. "INFO"
:returns logging.<LEVEL>: appropriate debug level
"""
# default to DEBUG
if level is None or level == "DEBUG":
return logging.DEBU... | python | def _get_log_level(level):
"""
small static method to get logging level
:param str level: string of the level e.g. "INFO"
:returns logging.<LEVEL>: appropriate debug level
"""
# default to DEBUG
if level is None or level == "DEBUG":
return logging.DEBU... | [
"def",
"_get_log_level",
"(",
"level",
")",
":",
"# default to DEBUG",
"if",
"level",
"is",
"None",
"or",
"level",
"==",
"\"DEBUG\"",
":",
"return",
"logging",
".",
"DEBUG",
"level",
"=",
"level",
".",
"upper",
"(",
")",
"# Make debugging configurable",
"if",
... | small static method to get logging level
:param str level: string of the level e.g. "INFO"
:returns logging.<LEVEL>: appropriate debug level | [
"small",
"static",
"method",
"to",
"get",
"logging",
"level",
":",
"param",
"str",
"level",
":",
"string",
"of",
"the",
"level",
"e",
".",
"g",
".",
"INFO",
":",
"returns",
"logging",
".",
"<LEVEL",
">",
":",
"appropriate",
"debug",
"level"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L103-L126 | train | small static method to get logging level |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO.system | def system(self):
"""
Returns a `list` of all the `System` objects to the cluster. Updates every time - no caching.
:return: a `list` of all the `System` objects known to the cluster.
:rtype: list
"""
self.connection._check_login()
response = self.connection._do_... | python | def system(self):
"""
Returns a `list` of all the `System` objects to the cluster. Updates every time - no caching.
:return: a `list` of all the `System` objects known to the cluster.
:rtype: list
"""
self.connection._check_login()
response = self.connection._do_... | [
"def",
"system",
"(",
"self",
")",
":",
"self",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"connection",
".",
"_api_url",
",",
"\"types/... | Returns a `list` of all the `System` objects to the cluster. Updates every time - no caching.
:return: a `list` of all the `System` objects known to the cluster.
:rtype: list | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"System",
"objects",
"to",
"the",
"cluster",
".",
"Updates",
"every",
"time",
"-",
"no",
"caching",
".",
":",
"return",
":",
"a",
"list",
"of",
"all",
"the",
"System",
"objects",
"known",
"to",
"the",
"cluste... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L130-L141 | train | Returns a list of all the System objects known to the cluster. |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO.storage_pools | def storage_pools(self):
"""
Returns a `list` of all the `System` objects to the cluster. Updates every time - no caching.
:return: a `list` of all the `System` objects known to the cluster.
:rtype: list
"""
self.connection._check_login()
response = self.connecti... | python | def storage_pools(self):
"""
Returns a `list` of all the `System` objects to the cluster. Updates every time - no caching.
:return: a `list` of all the `System` objects known to the cluster.
:rtype: list
"""
self.connection._check_login()
response = self.connecti... | [
"def",
"storage_pools",
"(",
"self",
")",
":",
"self",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"connection",
".",
"_api_url",
",",
"\... | Returns a `list` of all the `System` objects to the cluster. Updates every time - no caching.
:return: a `list` of all the `System` objects known to the cluster.
:rtype: list | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"System",
"objects",
"to",
"the",
"cluster",
".",
"Updates",
"every",
"time",
"-",
"no",
"caching",
".",
":",
"return",
":",
"a",
"list",
"of",
"all",
"the",
"System",
"objects",
"known",
"to",
"the",
"cluste... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L144-L155 | train | Returns a list of all the System objects known to the cluster. Updates every time - no caching. |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO.sdc | def sdc(self):
"""
Returns a `list` of all the `ScaleIO_SDC` known to the cluster. Updates every time - no caching.
:return: a `list` of all the `ScaleIO_SDC` known to the cluster.
:rtype: list
"""
self.connection._check_login()
response = self.connection._do_get... | python | def sdc(self):
"""
Returns a `list` of all the `ScaleIO_SDC` known to the cluster. Updates every time - no caching.
:return: a `list` of all the `ScaleIO_SDC` known to the cluster.
:rtype: list
"""
self.connection._check_login()
response = self.connection._do_get... | [
"def",
"sdc",
"(",
"self",
")",
":",
"self",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"connection",
".",
"_api_url",
",",
"\"types/Sdc... | Returns a `list` of all the `ScaleIO_SDC` known to the cluster. Updates every time - no caching.
:return: a `list` of all the `ScaleIO_SDC` known to the cluster.
:rtype: list | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"ScaleIO_SDC",
"known",
"to",
"the",
"cluster",
".",
"Updates",
"every",
"time",
"-",
"no",
"caching",
".",
":",
"return",
":",
"a",
"list",
"of",
"all",
"the",
"ScaleIO_SDC",
"known",
"to",
"the",
"cluster",
... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L158-L171 | train | Returns a list of all the SDC known to the cluster. Updates every time - no caching. |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO.sds | def sds(self):
"""
Returns a `list` of all the `ScaleIO_SDS` known to the cluster. Updates every time - no caching.
:return: a `list` of all the `ScaleIO_SDS` known to the cluster.
:rtype: list
"""
self.connection._check_login()
response = self.connection._do_get... | python | def sds(self):
"""
Returns a `list` of all the `ScaleIO_SDS` known to the cluster. Updates every time - no caching.
:return: a `list` of all the `ScaleIO_SDS` known to the cluster.
:rtype: list
"""
self.connection._check_login()
response = self.connection._do_get... | [
"def",
"sds",
"(",
"self",
")",
":",
"self",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"connection",
".",
"_api_url",
",",
"\"types/Sds... | Returns a `list` of all the `ScaleIO_SDS` known to the cluster. Updates every time - no caching.
:return: a `list` of all the `ScaleIO_SDS` known to the cluster.
:rtype: list | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"ScaleIO_SDS",
"known",
"to",
"the",
"cluster",
".",
"Updates",
"every",
"time",
"-",
"no",
"caching",
".",
":",
"return",
":",
"a",
"list",
"of",
"all",
"the",
"ScaleIO_SDS",
"known",
"to",
"the",
"cluster",
... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L174-L187 | train | Returns a list of all the SIO_SDS known to the cluster. Updates every time - no caching. |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO.volumes | def volumes(self):
"""
Returns a `list` of all the `Volume` known to the cluster. Updates every time - no caching.
:return: a `list` of all the `Volume` known to the cluster.
:rtype: list
"""
self.connection._check_login()
response = self.connection._do_get("{}/{... | python | def volumes(self):
"""
Returns a `list` of all the `Volume` known to the cluster. Updates every time - no caching.
:return: a `list` of all the `Volume` known to the cluster.
:rtype: list
"""
self.connection._check_login()
response = self.connection._do_get("{}/{... | [
"def",
"volumes",
"(",
"self",
")",
":",
"self",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"connection",
".",
"_api_url",
",",
"\"types... | Returns a `list` of all the `Volume` known to the cluster. Updates every time - no caching.
:return: a `list` of all the `Volume` known to the cluster.
:rtype: list | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"Volume",
"known",
"to",
"the",
"cluster",
".",
"Updates",
"every",
"time",
"-",
"no",
"caching",
".",
":",
"return",
":",
"a",
"list",
"of",
"all",
"the",
"Volume",
"known",
"to",
"the",
"cluster",
".",
":... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L190-L203 | train | Returns a list of all the SIO_Volume objects known to the cluster. Updates every time - no caching. |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO.snapshots | def snapshots(self):
"""
Get all Volumes of type Snapshot. Updates every time - no caching.
:return: a `list` of all the `ScaleIO_Volume` that have a are of type Snapshot.
:rtype: list
"""
self.connection._check_login()
response = self.connection._do_get("{}/{}".... | python | def snapshots(self):
"""
Get all Volumes of type Snapshot. Updates every time - no caching.
:return: a `list` of all the `ScaleIO_Volume` that have a are of type Snapshot.
:rtype: list
"""
self.connection._check_login()
response = self.connection._do_get("{}/{}".... | [
"def",
"snapshots",
"(",
"self",
")",
":",
"self",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"connection",
".",
"_api_url",
",",
"\"typ... | Get all Volumes of type Snapshot. Updates every time - no caching.
:return: a `list` of all the `ScaleIO_Volume` that have a are of type Snapshot.
:rtype: list | [
"Get",
"all",
"Volumes",
"of",
"type",
"Snapshot",
".",
"Updates",
"every",
"time",
"-",
"no",
"caching",
".",
":",
"return",
":",
"a",
"list",
"of",
"all",
"the",
"ScaleIO_Volume",
"that",
"have",
"a",
"are",
"of",
"type",
"Snapshot",
".",
":",
"rtype... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L206-L220 | train | Get all the Volumes of type Snapshot. Updates every time - no caching. |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO.protection_domains | def protection_domains(self):
"""
:rtype: list of Protection Domains
"""
self.connection._check_login()
response = self.connection._do_get("{}/{}".format(self.connection._api_url, "types/ProtectionDomain/instances")).json()
all_pds = []
for pd in response:
... | python | def protection_domains(self):
"""
:rtype: list of Protection Domains
"""
self.connection._check_login()
response = self.connection._do_get("{}/{}".format(self.connection._api_url, "types/ProtectionDomain/instances")).json()
all_pds = []
for pd in response:
... | [
"def",
"protection_domains",
"(",
"self",
")",
":",
"self",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"connection",
".",
"_api_url",
",",... | :rtype: list of Protection Domains | [
":",
"rtype",
":",
"list",
"of",
"Protection",
"Domains"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L223-L234 | train | returns a list of all the Protection Domains in this API |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO.fault_sets | def fault_sets(self):
"""
You can only create and configure Fault Sets before adding SDSs to the system, and configuring them incorrectly
may prevent the creation of volumes. An SDS can only be added to a Fault Set during the creation of the SDS.
:rtype: list of Faultset objects
... | python | def fault_sets(self):
"""
You can only create and configure Fault Sets before adding SDSs to the system, and configuring them incorrectly
may prevent the creation of volumes. An SDS can only be added to a Fault Set during the creation of the SDS.
:rtype: list of Faultset objects
... | [
"def",
"fault_sets",
"(",
"self",
")",
":",
"self",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"connection",
".",
"_api_url",
",",
"\"ty... | You can only create and configure Fault Sets before adding SDSs to the system, and configuring them incorrectly
may prevent the creation of volumes. An SDS can only be added to a Fault Set during the creation of the SDS.
:rtype: list of Faultset objects | [
"You",
"can",
"only",
"create",
"and",
"configure",
"Fault",
"Sets",
"before",
"adding",
"SDSs",
"to",
"the",
"system",
"and",
"configuring",
"them",
"incorrectly",
"may",
"prevent",
"the",
"creation",
"of",
"volumes",
".",
"An",
"SDS",
"can",
"only",
"be",
... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L237-L250 | train | returns a list of all fault sets in the system |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO.vtrees | def vtrees(self):
"""
Get list of VTrees from ScaleIO cluster
:return: List of VTree objects - Can be empty of no VTrees exist
:rtype: VTree object
"""
self.connection._check_login()
response = self.connection._do_get("{}/{}".format(self.connection._api_url, "type... | python | def vtrees(self):
"""
Get list of VTrees from ScaleIO cluster
:return: List of VTree objects - Can be empty of no VTrees exist
:rtype: VTree object
"""
self.connection._check_login()
response = self.connection._do_get("{}/{}".format(self.connection._api_url, "type... | [
"def",
"vtrees",
"(",
"self",
")",
":",
"self",
".",
"connection",
".",
"_check_login",
"(",
")",
"response",
"=",
"self",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"connection",
".",
"_api_url",
",",
"\"types/... | Get list of VTrees from ScaleIO cluster
:return: List of VTree objects - Can be empty of no VTrees exist
:rtype: VTree object | [
"Get",
"list",
"of",
"VTrees",
"from",
"ScaleIO",
"cluster",
":",
"return",
":",
"List",
"of",
"VTree",
"objects",
"-",
"Can",
"be",
"empty",
"of",
"no",
"VTrees",
"exist",
":",
"rtype",
":",
"VTree",
"object"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L253-L266 | train | Get list of VTrees from ScaleIO cluster |
swevm/scaleio-py | scaleiopy/scaleio.py | ScaleIO.is_ip_addr | def is_ip_addr(self, ipstr):
"""
Convenience method to verify if string is an IP addr?
:param ipstr: Stinrg containing IP address
:rtype True if string is a valid IP address
"""
ipstr_chunks = ipstr.split('.')
if len(ipstr_chunks) != 4:
return False
... | python | def is_ip_addr(self, ipstr):
"""
Convenience method to verify if string is an IP addr?
:param ipstr: Stinrg containing IP address
:rtype True if string is a valid IP address
"""
ipstr_chunks = ipstr.split('.')
if len(ipstr_chunks) != 4:
return False
... | [
"def",
"is_ip_addr",
"(",
"self",
",",
"ipstr",
")",
":",
"ipstr_chunks",
"=",
"ipstr",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"ipstr_chunks",
")",
"!=",
"4",
":",
"return",
"False",
"for",
"ipstr_chunk",
"in",
"ipstr_chunks",
":",
"if",
"not... | Convenience method to verify if string is an IP addr?
:param ipstr: Stinrg containing IP address
:rtype True if string is a valid IP address | [
"Convenience",
"method",
"to",
"verify",
"if",
"string",
"is",
"an",
"IP",
"addr?",
":",
"param",
"ipstr",
":",
"Stinrg",
"containing",
"IP",
"address",
":",
"rtype",
"True",
"if",
"string",
"is",
"a",
"valid",
"IP",
"address"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/scaleio.py#L276-L291 | train | Helper method to verify if string is an IP addr? |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_store.py | MemoryOpsStore.put_ops | def put_ops(self, key, time, ops):
''' Put an ops only if not already there, otherwise it's a no op.
'''
if self._store.get(key) is None:
self._store[key] = ops | python | def put_ops(self, key, time, ops):
''' Put an ops only if not already there, otherwise it's a no op.
'''
if self._store.get(key) is None:
self._store[key] = ops | [
"def",
"put_ops",
"(",
"self",
",",
"key",
",",
"time",
",",
"ops",
")",
":",
"if",
"self",
".",
"_store",
".",
"get",
"(",
"key",
")",
"is",
"None",
":",
"self",
".",
"_store",
"[",
"key",
"]",
"=",
"ops"
] | Put an ops only if not already there, otherwise it's a no op. | [
"Put",
"an",
"ops",
"only",
"if",
"not",
"already",
"there",
"otherwise",
"it",
"s",
"a",
"no",
"op",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_store.py#L13-L17 | train | Put an ops only if not already there. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_store.py | MemoryOpsStore.get_ops | def get_ops(self, key):
''' Returns ops from the key if found otherwise raises a KeyError.
'''
ops = self._store.get(key)
if ops is None:
raise KeyError(
'cannot get operations for {}'.format(key))
return ops | python | def get_ops(self, key):
''' Returns ops from the key if found otherwise raises a KeyError.
'''
ops = self._store.get(key)
if ops is None:
raise KeyError(
'cannot get operations for {}'.format(key))
return ops | [
"def",
"get_ops",
"(",
"self",
",",
"key",
")",
":",
"ops",
"=",
"self",
".",
"_store",
".",
"get",
"(",
"key",
")",
"if",
"ops",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"'cannot get operations for {}'",
".",
"format",
"(",
"key",
")",
")",
"ret... | Returns ops from the key if found otherwise raises a KeyError. | [
"Returns",
"ops",
"from",
"the",
"key",
"if",
"found",
"otherwise",
"raises",
"a",
"KeyError",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_store.py#L19-L26 | train | Returns the list of operations for the given key if found otherwise raises a KeyError. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_macaroon.py | _parse_local_location | def _parse_local_location(loc):
'''Parse a local caveat location as generated by LocalThirdPartyCaveat.
This is of the form:
local <version> <pubkey>
where <version> is the bakery version of the client that we're
adding the local caveat for.
It returns None if the location does not repre... | python | def _parse_local_location(loc):
'''Parse a local caveat location as generated by LocalThirdPartyCaveat.
This is of the form:
local <version> <pubkey>
where <version> is the bakery version of the client that we're
adding the local caveat for.
It returns None if the location does not repre... | [
"def",
"_parse_local_location",
"(",
"loc",
")",
":",
"if",
"not",
"(",
"loc",
".",
"startswith",
"(",
"'local '",
")",
")",
":",
"return",
"None",
"v",
"=",
"VERSION_1",
"fields",
"=",
"loc",
".",
"split",
"(",
")",
"fields",
"=",
"fields",
"[",
"1"... | Parse a local caveat location as generated by LocalThirdPartyCaveat.
This is of the form:
local <version> <pubkey>
where <version> is the bakery version of the client that we're
adding the local caveat for.
It returns None if the location does not represent a local
caveat location.
@... | [
"Parse",
"a",
"local",
"caveat",
"location",
"as",
"generated",
"by",
"LocalThirdPartyCaveat",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_macaroon.py#L372-L400 | train | Parse a local caveat location as generated by LocalThirdPartyCaveat. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_macaroon.py | Macaroon.add_caveat | def add_caveat(self, cav, key=None, loc=None):
'''Add a caveat to the macaroon.
It encrypts it using the given key pair
and by looking up the location using the given locator.
As a special case, if the caveat's Location field has the prefix
"local " the caveat is added as a clie... | python | def add_caveat(self, cav, key=None, loc=None):
'''Add a caveat to the macaroon.
It encrypts it using the given key pair
and by looking up the location using the given locator.
As a special case, if the caveat's Location field has the prefix
"local " the caveat is added as a clie... | [
"def",
"add_caveat",
"(",
"self",
",",
"cav",
",",
"key",
"=",
"None",
",",
"loc",
"=",
"None",
")",
":",
"if",
"cav",
".",
"location",
"is",
"None",
":",
"self",
".",
"_macaroon",
".",
"add_first_party_caveat",
"(",
"self",
".",
"namespace",
".",
"r... | Add a caveat to the macaroon.
It encrypts it using the given key pair
and by looking up the location using the given locator.
As a special case, if the caveat's Location field has the prefix
"local " the caveat is added as a client self-discharge caveat using
the public key base... | [
"Add",
"a",
"caveat",
"to",
"the",
"macaroon",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_macaroon.py#L90-L150 | train | Add a caveat to the macaroon. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_macaroon.py | Macaroon.add_caveats | def add_caveats(self, cavs, key, loc):
'''Add an array of caveats to the macaroon.
This method does not mutate the current object.
@param cavs arrary of caveats.
@param key the PublicKey to encrypt third party caveat.
@param loc locator to find the location object that has a met... | python | def add_caveats(self, cavs, key, loc):
'''Add an array of caveats to the macaroon.
This method does not mutate the current object.
@param cavs arrary of caveats.
@param key the PublicKey to encrypt third party caveat.
@param loc locator to find the location object that has a met... | [
"def",
"add_caveats",
"(",
"self",
",",
"cavs",
",",
"key",
",",
"loc",
")",
":",
"if",
"cavs",
"is",
"None",
":",
"return",
"for",
"cav",
"in",
"cavs",
":",
"self",
".",
"add_caveat",
"(",
"cav",
",",
"key",
",",
"loc",
")"
] | Add an array of caveats to the macaroon.
This method does not mutate the current object.
@param cavs arrary of caveats.
@param key the PublicKey to encrypt third party caveat.
@param loc locator to find the location object that has a method
third_party_info. | [
"Add",
"an",
"array",
"of",
"caveats",
"to",
"the",
"macaroon",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_macaroon.py#L152-L164 | train | Add an array of caveats to the macaroon. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_macaroon.py | Macaroon.to_dict | def to_dict(self):
'''Return a dict representation of the macaroon data in JSON format.
@return a dict
'''
if self.version < VERSION_3:
if len(self._caveat_data) > 0:
raise ValueError('cannot serialize pre-version3 macaroon with '
... | python | def to_dict(self):
'''Return a dict representation of the macaroon data in JSON format.
@return a dict
'''
if self.version < VERSION_3:
if len(self._caveat_data) > 0:
raise ValueError('cannot serialize pre-version3 macaroon with '
... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"if",
"self",
".",
"version",
"<",
"VERSION_3",
":",
"if",
"len",
"(",
"self",
".",
"_caveat_data",
")",
">",
"0",
":",
"raise",
"ValueError",
"(",
"'cannot serialize pre-version3 macaroon with '",
"'external caveat data'... | Return a dict representation of the macaroon data in JSON format.
@return a dict | [
"Return",
"a",
"dict",
"representation",
"of",
"the",
"macaroon",
"data",
"in",
"JSON",
"format",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_macaroon.py#L172-L196 | train | Return a dict representation of the macaroon data in JSON format. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_macaroon.py | Macaroon.from_dict | def from_dict(cls, json_dict):
'''Return a macaroon obtained from the given dictionary as
deserialized from JSON.
@param json_dict The deserialized JSON object.
'''
json_macaroon = json_dict.get('m')
if json_macaroon is None:
# Try the v1 format if we don't ha... | python | def from_dict(cls, json_dict):
'''Return a macaroon obtained from the given dictionary as
deserialized from JSON.
@param json_dict The deserialized JSON object.
'''
json_macaroon = json_dict.get('m')
if json_macaroon is None:
# Try the v1 format if we don't ha... | [
"def",
"from_dict",
"(",
"cls",
",",
"json_dict",
")",
":",
"json_macaroon",
"=",
"json_dict",
".",
"get",
"(",
"'m'",
")",
"if",
"json_macaroon",
"is",
"None",
":",
"# Try the v1 format if we don't have a macaroon field.",
"m",
"=",
"pymacaroons",
".",
"Macaroon"... | Return a macaroon obtained from the given dictionary as
deserialized from JSON.
@param json_dict The deserialized JSON object. | [
"Return",
"a",
"macaroon",
"obtained",
"from",
"the",
"given",
"dictionary",
"as",
"deserialized",
"from",
"JSON",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_macaroon.py#L199-L239 | train | Return a macaroon obtained from the given dictionary as
deserialized from JSON. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_macaroon.py | Macaroon.deserialize_json | def deserialize_json(cls, serialized_json):
'''Return a macaroon deserialized from a string
@param serialized_json The string to decode {str}
@return {Macaroon}
'''
serialized = json.loads(serialized_json)
return Macaroon.from_dict(serialized) | python | def deserialize_json(cls, serialized_json):
'''Return a macaroon deserialized from a string
@param serialized_json The string to decode {str}
@return {Macaroon}
'''
serialized = json.loads(serialized_json)
return Macaroon.from_dict(serialized) | [
"def",
"deserialize_json",
"(",
"cls",
",",
"serialized_json",
")",
":",
"serialized",
"=",
"json",
".",
"loads",
"(",
"serialized_json",
")",
"return",
"Macaroon",
".",
"from_dict",
"(",
"serialized",
")"
] | Return a macaroon deserialized from a string
@param serialized_json The string to decode {str}
@return {Macaroon} | [
"Return",
"a",
"macaroon",
"deserialized",
"from",
"a",
"string"
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_macaroon.py#L242-L248 | train | Return a macaroon deserialized from a string
|
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_macaroon.py | Macaroon._new_caveat_id | def _new_caveat_id(self, base):
'''Return a third party caveat id
This does not duplicate any third party caveat ids already inside
macaroon. If base is non-empty, it is used as the id prefix.
@param base bytes
@return bytes
'''
id = bytearray()
if len(b... | python | def _new_caveat_id(self, base):
'''Return a third party caveat id
This does not duplicate any third party caveat ids already inside
macaroon. If base is non-empty, it is used as the id prefix.
@param base bytes
@return bytes
'''
id = bytearray()
if len(b... | [
"def",
"_new_caveat_id",
"(",
"self",
",",
"base",
")",
":",
"id",
"=",
"bytearray",
"(",
")",
"if",
"len",
"(",
"base",
")",
">",
"0",
":",
"id",
".",
"extend",
"(",
"base",
")",
"else",
":",
"# Add a version byte to the caveat id. Technically",
"# this i... | Return a third party caveat id
This does not duplicate any third party caveat ids already inside
macaroon. If base is non-empty, it is used as the id prefix.
@param base bytes
@return bytes | [
"Return",
"a",
"third",
"party",
"caveat",
"id"
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_macaroon.py#L250-L293 | train | Return a third party caveat id This does not duplicate any third party caveat ids already inside the macaroon. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_macaroon.py | Macaroon.copy | def copy(self):
''' Returns a copy of the macaroon. Note that the the new
macaroon's namespace still points to the same underlying Namespace -
copying the macaroon does not make a copy of the namespace.
:return a Macaroon
'''
m1 = Macaroon(None, None, version=self._versio... | python | def copy(self):
''' Returns a copy of the macaroon. Note that the the new
macaroon's namespace still points to the same underlying Namespace -
copying the macaroon does not make a copy of the namespace.
:return a Macaroon
'''
m1 = Macaroon(None, None, version=self._versio... | [
"def",
"copy",
"(",
"self",
")",
":",
"m1",
"=",
"Macaroon",
"(",
"None",
",",
"None",
",",
"version",
"=",
"self",
".",
"_version",
",",
"namespace",
"=",
"self",
".",
"_namespace",
")",
"m1",
".",
"_macaroon",
"=",
"self",
".",
"_macaroon",
".",
... | Returns a copy of the macaroon. Note that the the new
macaroon's namespace still points to the same underlying Namespace -
copying the macaroon does not make a copy of the namespace.
:return a Macaroon | [
"Returns",
"a",
"copy",
"of",
"the",
"macaroon",
".",
"Note",
"that",
"the",
"the",
"new",
"macaroon",
"s",
"namespace",
"still",
"points",
"to",
"the",
"same",
"underlying",
"Namespace",
"-",
"copying",
"the",
"macaroon",
"does",
"not",
"make",
"a",
"copy... | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_macaroon.py#L310-L320 | train | Returns a copy of the macaroon. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_client.py | _prepare_discharge_hook | def _prepare_discharge_hook(req, client):
''' Return the hook function (called when the response is received.)
This allows us to intercept the response and do any necessary
macaroon discharge before returning.
'''
class Retry:
# Define a local class so that we can use its class variable as
... | python | def _prepare_discharge_hook(req, client):
''' Return the hook function (called when the response is received.)
This allows us to intercept the response and do any necessary
macaroon discharge before returning.
'''
class Retry:
# Define a local class so that we can use its class variable as
... | [
"def",
"_prepare_discharge_hook",
"(",
"req",
",",
"client",
")",
":",
"class",
"Retry",
":",
"# Define a local class so that we can use its class variable as",
"# mutable state accessed by the closures below.",
"count",
"=",
"0",
"def",
"hook",
"(",
"response",
",",
"*",
... | Return the hook function (called when the response is received.)
This allows us to intercept the response and do any necessary
macaroon discharge before returning. | [
"Return",
"the",
"hook",
"function",
"(",
"called",
"when",
"the",
"response",
"is",
"received",
".",
")"
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_client.py#L259-L299 | train | Prepare the discharge hook function. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_client.py | extract_macaroons | def extract_macaroons(headers_or_request):
''' Returns an array of any macaroons found in the given slice of cookies.
If the argument implements a get_header method, that will be used
instead of the get method to retrieve headers.
@param headers_or_request: dict of headers or a
urllib.request.Reques... | python | def extract_macaroons(headers_or_request):
''' Returns an array of any macaroons found in the given slice of cookies.
If the argument implements a get_header method, that will be used
instead of the get method to retrieve headers.
@param headers_or_request: dict of headers or a
urllib.request.Reques... | [
"def",
"extract_macaroons",
"(",
"headers_or_request",
")",
":",
"def",
"get_header",
"(",
"key",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"return",
"headers_or_request",
".",
"get_header",
"(",
"key",
",",
"default",
")",
"except",
"AttributeError",... | Returns an array of any macaroons found in the given slice of cookies.
If the argument implements a get_header method, that will be used
instead of the get method to retrieve headers.
@param headers_or_request: dict of headers or a
urllib.request.Request-like object.
@return: A list of list of mpy m... | [
"Returns",
"an",
"array",
"of",
"any",
"macaroons",
"found",
"in",
"the",
"given",
"slice",
"of",
"cookies",
".",
"If",
"the",
"argument",
"implements",
"a",
"get_header",
"method",
"that",
"will",
"be",
"used",
"instead",
"of",
"the",
"get",
"method",
"to... | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_client.py#L302-L344 | train | Returns an array of any macaroons found in the given slice of cookies. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_client.py | _add_json_binary_field | def _add_json_binary_field(b, serialized, field):
'''' Set the given field to the given val (bytes) in the serialized
dictionary.
If the value isn't valid utf-8, we base64 encode it and use field+"64"
as the field name.
'''
try:
val = b.decode('utf-8')
serialized[field] = val
... | python | def _add_json_binary_field(b, serialized, field):
'''' Set the given field to the given val (bytes) in the serialized
dictionary.
If the value isn't valid utf-8, we base64 encode it and use field+"64"
as the field name.
'''
try:
val = b.decode('utf-8')
serialized[field] = val
... | [
"def",
"_add_json_binary_field",
"(",
"b",
",",
"serialized",
",",
"field",
")",
":",
"try",
":",
"val",
"=",
"b",
".",
"decode",
"(",
"'utf-8'",
")",
"serialized",
"[",
"field",
"]",
"=",
"val",
"except",
"UnicodeDecodeError",
":",
"val",
"=",
"base64",... | Set the given field to the given val (bytes) in the serialized
dictionary.
If the value isn't valid utf-8, we base64 encode it and use field+"64"
as the field name. | [
"Set",
"the",
"given",
"field",
"to",
"the",
"given",
"val",
"(",
"bytes",
")",
"in",
"the",
"serialized",
"dictionary",
".",
"If",
"the",
"value",
"isn",
"t",
"valid",
"utf",
"-",
"8",
"we",
"base64",
"encode",
"it",
"and",
"use",
"field",
"+",
"64"... | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_client.py#L347-L358 | train | Add a field to the serialized dictionary. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.