repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
fdChasm/txCarbonClient
src/txCarbonClient/carbon_client_service.py
CarbonClientService.publish_metric
def publish_metric(self, metric_name, metric_value, epoch_seconds=None): '''Record a single hit on a given metric. Args: metric_name: The name of the metric to record with Carbon. metric_value: The value to record with Carbon. epoch_seconds: Optionally specify the ti...
python
def publish_metric(self, metric_name, metric_value, epoch_seconds=None): '''Record a single hit on a given metric. Args: metric_name: The name of the metric to record with Carbon. metric_value: The value to record with Carbon. epoch_seconds: Optionally specify the ti...
[ "def", "publish_metric", "(", "self", ",", "metric_name", ",", "metric_value", ",", "epoch_seconds", "=", "None", ")", ":", "if", "epoch_seconds", "is", "None", ":", "epoch_seconds", "=", "self", ".", "_reactor", ".", "seconds", "(", ")", "self", ".", "_cl...
Record a single hit on a given metric. Args: metric_name: The name of the metric to record with Carbon. metric_value: The value to record with Carbon. epoch_seconds: Optionally specify the time for the metric hit. Returns: None
[ "Record", "a", "single", "hit", "on", "a", "given", "metric", "." ]
train
https://github.com/fdChasm/txCarbonClient/blob/c342eff1957d281cba3c83fc578f08c4bf9fcd03/src/txCarbonClient/carbon_client_service.py#L30-L44
fdChasm/txCarbonClient
src/txCarbonClient/carbon_client_service.py
CarbonClientService.register_repeating_metric
def register_repeating_metric(self, metric_name, frequency, getter): '''Record hits to a metric at a specified interval. Args: metric_name: The name of the metric to record with Carbon. frequency: The frequency with which to poll the getter and record the value with Carbon. ...
python
def register_repeating_metric(self, metric_name, frequency, getter): '''Record hits to a metric at a specified interval. Args: metric_name: The name of the metric to record with Carbon. frequency: The frequency with which to poll the getter and record the value with Carbon. ...
[ "def", "register_repeating_metric", "(", "self", ",", "metric_name", ",", "frequency", ",", "getter", ")", ":", "l", "=", "task", ".", "LoopingCall", "(", "self", ".", "_publish_repeating_metric", ",", "metric_name", ",", "getter", ")", "repeating_metric_handle", ...
Record hits to a metric at a specified interval. Args: metric_name: The name of the metric to record with Carbon. frequency: The frequency with which to poll the getter and record the value with Carbon. getter: A function which takes no arguments and returns the value to rec...
[ "Record", "hits", "to", "a", "metric", "at", "a", "specified", "interval", "." ]
train
https://github.com/fdChasm/txCarbonClient/blob/c342eff1957d281cba3c83fc578f08c4bf9fcd03/src/txCarbonClient/carbon_client_service.py#L46-L63
pyblish/pyblish-nuke
pyblish_nuke/lib.py
setup
def setup(console=False, port=None, menu=True): """Setup integration Registers Pyblish for Maya plug-ins and appends an item to the File-menu Arguments: console (bool): Display console with GUI port (int, optional): Port from which to start looking for an available port to conn...
python
def setup(console=False, port=None, menu=True): """Setup integration Registers Pyblish for Maya plug-ins and appends an item to the File-menu Arguments: console (bool): Display console with GUI port (int, optional): Port from which to start looking for an available port to conn...
[ "def", "setup", "(", "console", "=", "False", ",", "port", "=", "None", ",", "menu", "=", "True", ")", ":", "if", "self", ".", "_has_been_setup", ":", "teardown", "(", ")", "register_plugins", "(", ")", "register_host", "(", ")", "if", "menu", ":", "...
Setup integration Registers Pyblish for Maya plug-ins and appends an item to the File-menu Arguments: console (bool): Display console with GUI port (int, optional): Port from which to start looking for an available port to connect with Pyblish QML, default provided by P...
[ "Setup", "integration" ]
train
https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L28-L52
pyblish/pyblish-nuke
pyblish_nuke/lib.py
show
def show(): """Try showing the most desirable GUI This function cycles through the currently registered graphical user interfaces, if any, and presents it to the user. """ parent = None current = QtWidgets.QApplication.activeWindow() while current: parent = current cur...
python
def show(): """Try showing the most desirable GUI This function cycles through the currently registered graphical user interfaces, if any, and presents it to the user. """ parent = None current = QtWidgets.QApplication.activeWindow() while current: parent = current cur...
[ "def", "show", "(", ")", ":", "parent", "=", "None", "current", "=", "QtWidgets", ".", "QApplication", ".", "activeWindow", "(", ")", "while", "current", ":", "parent", "=", "current", "current", "=", "parent", ".", "parent", "(", ")", "window", "=", "...
Try showing the most desirable GUI This function cycles through the currently registered graphical user interfaces, if any, and presents it to the user.
[ "Try", "showing", "the", "most", "desirable", "GUI" ]
train
https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L55-L72
pyblish/pyblish-nuke
pyblish_nuke/lib.py
_nuke_set_zero_margins
def _nuke_set_zero_margins(widget_object): """Remove Nuke margins when docked UI .. _More info: https://gist.github.com/maty974/4739917 """ parentApp = QtWidgets.QApplication.allWidgets() parentWidgetList = [] for parent in parentApp: for child in parent.children(): i...
python
def _nuke_set_zero_margins(widget_object): """Remove Nuke margins when docked UI .. _More info: https://gist.github.com/maty974/4739917 """ parentApp = QtWidgets.QApplication.allWidgets() parentWidgetList = [] for parent in parentApp: for child in parent.children(): i...
[ "def", "_nuke_set_zero_margins", "(", "widget_object", ")", ":", "parentApp", "=", "QtWidgets", ".", "QApplication", ".", "allWidgets", "(", ")", "parentWidgetList", "=", "[", "]", "for", "parent", "in", "parentApp", ":", "for", "child", "in", "parent", ".", ...
Remove Nuke margins when docked UI .. _More info: https://gist.github.com/maty974/4739917
[ "Remove", "Nuke", "margins", "when", "docked", "UI", "..", "_More", "info", ":", "https", ":", "//", "gist", ".", "github", ".", "com", "/", "maty974", "/", "4739917" ]
train
https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L303-L325
pyblish/pyblish-nuke
pyblish_nuke/lib.py
dock
def dock(window): """ Expecting a window to parent into a Nuke panel, that is dockable. """ # Deleting existing dock # There is a bug where existing docks are kept in-memory when closed via UI if self._dock: print("Deleting existing dock...") parent = self._dock dialog = None ...
python
def dock(window): """ Expecting a window to parent into a Nuke panel, that is dockable. """ # Deleting existing dock # There is a bug where existing docks are kept in-memory when closed via UI if self._dock: print("Deleting existing dock...") parent = self._dock dialog = None ...
[ "def", "dock", "(", "window", ")", ":", "# Deleting existing dock", "# There is a bug where existing docks are kept in-memory when closed via UI", "if", "self", ".", "_dock", ":", "print", "(", "\"Deleting existing dock...\"", ")", "parent", "=", "self", ".", "_dock", "di...
Expecting a window to parent into a Nuke panel, that is dockable.
[ "Expecting", "a", "window", "to", "parent", "into", "a", "Nuke", "panel", "that", "is", "dockable", "." ]
train
https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L335-L379
EUDAT-B2SAFE/B2HANDLE
b2handle/utilhandle.py
remove_index_from_handle
def remove_index_from_handle(handle_with_index): ''' Returns index and handle separately, in a tuple. :handle_with_index: The handle string with an index (e.g. 500:prefix/suffix) :return: index and handle as a tuple. ''' split = handle_with_index.split(':') if len(split) == 2: ...
python
def remove_index_from_handle(handle_with_index): ''' Returns index and handle separately, in a tuple. :handle_with_index: The handle string with an index (e.g. 500:prefix/suffix) :return: index and handle as a tuple. ''' split = handle_with_index.split(':') if len(split) == 2: ...
[ "def", "remove_index_from_handle", "(", "handle_with_index", ")", ":", "split", "=", "handle_with_index", ".", "split", "(", "':'", ")", "if", "len", "(", "split", ")", "==", "2", ":", "split", "[", "0", "]", "=", "int", "(", "split", "[", "0", "]", ...
Returns index and handle separately, in a tuple. :handle_with_index: The handle string with an index (e.g. 500:prefix/suffix) :return: index and handle as a tuple.
[ "Returns", "index", "and", "handle", "separately", "in", "a", "tuple", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L14-L33
EUDAT-B2SAFE/B2HANDLE
b2handle/utilhandle.py
check_handle_syntax
def check_handle_syntax(string): ''' Checks the syntax of a handle without an index (are prefix and suffix there, are there too many slashes?). :string: The handle without index, as string prefix/suffix. :raise: :exc:`~b2handle.handleexceptions.handleexceptions.HandleSyntaxError` :return: True....
python
def check_handle_syntax(string): ''' Checks the syntax of a handle without an index (are prefix and suffix there, are there too many slashes?). :string: The handle without index, as string prefix/suffix. :raise: :exc:`~b2handle.handleexceptions.handleexceptions.HandleSyntaxError` :return: True....
[ "def", "check_handle_syntax", "(", "string", ")", ":", "expected", "=", "'prefix/suffix'", "try", ":", "arr", "=", "string", ".", "split", "(", "'/'", ")", "except", "AttributeError", ":", "raise", "handleexceptions", ".", "HandleSyntaxError", "(", "msg", "=",...
Checks the syntax of a handle without an index (are prefix and suffix there, are there too many slashes?). :string: The handle without index, as string prefix/suffix. :raise: :exc:`~b2handle.handleexceptions.handleexceptions.HandleSyntaxError` :return: True. If it's not ok, exceptions are raised.
[ "Checks", "the", "syntax", "of", "a", "handle", "without", "an", "index", "(", "are", "prefix", "and", "suffix", "there", "are", "there", "too", "many", "slashes?", ")", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L35-L68
EUDAT-B2SAFE/B2HANDLE
b2handle/utilhandle.py
create_authentication_string
def create_authentication_string(username, password): ''' Creates an authentication string from the username and password. :username: Username. :password: Password. :return: The encoded string. ''' username_utf8 = username.encode('utf-8') userpw_utf8 = password.encode('utf-8') user...
python
def create_authentication_string(username, password): ''' Creates an authentication string from the username and password. :username: Username. :password: Password. :return: The encoded string. ''' username_utf8 = username.encode('utf-8') userpw_utf8 = password.encode('utf-8') user...
[ "def", "create_authentication_string", "(", "username", ",", "password", ")", ":", "username_utf8", "=", "username", ".", "encode", "(", "'utf-8'", ")", "userpw_utf8", "=", "password", ".", "encode", "(", "'utf-8'", ")", "username_perc", "=", "quote", "(", "us...
Creates an authentication string from the username and password. :username: Username. :password: Password. :return: The encoded string.
[ "Creates", "an", "authentication", "string", "from", "the", "username", "and", "password", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L102-L118
EUDAT-B2SAFE/B2HANDLE
b2handle/utilhandle.py
make_request_log_message
def make_request_log_message(**args): ''' Creates a string containing all relevant information about a request made to the Handle System, for logging purposes. :handle: The handle that the request is about. :url: The url the request is sent to. :headers: The headers sent along with the requ...
python
def make_request_log_message(**args): ''' Creates a string containing all relevant information about a request made to the Handle System, for logging purposes. :handle: The handle that the request is about. :url: The url the request is sent to. :headers: The headers sent along with the requ...
[ "def", "make_request_log_message", "(", "*", "*", "args", ")", ":", "mandatory_args", "=", "[", "'op'", ",", "'handle'", ",", "'url'", ",", "'headers'", ",", "'verify'", ",", "'resp'", "]", "optional_args", "=", "[", "'payload'", "]", "util", ".", "check_p...
Creates a string containing all relevant information about a request made to the Handle System, for logging purposes. :handle: The handle that the request is about. :url: The url the request is sent to. :headers: The headers sent along with the request. :verify: Boolean parameter passed to the ...
[ "Creates", "a", "string", "containing", "all", "relevant", "information", "about", "a", "request", "made", "to", "the", "Handle", "System", "for", "logging", "purposes", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L120-L154
ioos/thredds_crawler
thredds_crawler/crawl.py
request_xml
def request_xml(url, auth=None): ''' Returns an etree.XMLRoot object loaded from the url :param str url: URL for the resource to load as an XML ''' try: r = requests.get(url, auth=auth, verify=False) return r.text.encode('utf-8') except BaseException: logger.error("Skippi...
python
def request_xml(url, auth=None): ''' Returns an etree.XMLRoot object loaded from the url :param str url: URL for the resource to load as an XML ''' try: r = requests.get(url, auth=auth, verify=False) return r.text.encode('utf-8') except BaseException: logger.error("Skippi...
[ "def", "request_xml", "(", "url", ",", "auth", "=", "None", ")", ":", "try", ":", "r", "=", "requests", ".", "get", "(", "url", ",", "auth", "=", "auth", ",", "verify", "=", "False", ")", "return", "r", ".", "text", ".", "encode", "(", "'utf-8'",...
Returns an etree.XMLRoot object loaded from the url :param str url: URL for the resource to load as an XML
[ "Returns", "an", "etree", ".", "XMLRoot", "object", "loaded", "from", "the", "url", ":", "param", "str", "url", ":", "URL", "for", "the", "resource", "to", "load", "as", "an", "XML" ]
train
https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L35-L45
ioos/thredds_crawler
thredds_crawler/crawl.py
Crawl._get_catalog_url
def _get_catalog_url(self, url): ''' Returns the appropriate catalog URL by replacing html with xml in some cases :param str url: URL to the catalog ''' u = urlparse.urlsplit(url) name, ext = os.path.splitext(u.path) if ext == ".html": u = urlp...
python
def _get_catalog_url(self, url): ''' Returns the appropriate catalog URL by replacing html with xml in some cases :param str url: URL to the catalog ''' u = urlparse.urlsplit(url) name, ext = os.path.splitext(u.path) if ext == ".html": u = urlp...
[ "def", "_get_catalog_url", "(", "self", ",", "url", ")", ":", "u", "=", "urlparse", ".", "urlsplit", "(", "url", ")", "name", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "u", ".", "path", ")", "if", "ext", "==", "\".html\"", ":", "u...
Returns the appropriate catalog URL by replacing html with xml in some cases :param str url: URL to the catalog
[ "Returns", "the", "appropriate", "catalog", "URL", "by", "replacing", "html", "with", "xml", "in", "some", "cases", ":", "param", "str", "url", ":", "URL", "to", "the", "catalog" ]
train
https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L133-L144
ioos/thredds_crawler
thredds_crawler/crawl.py
Crawl._yield_leaves
def _yield_leaves(self, url, tree): ''' Yields a URL corresponding to a leaf dataset for each dataset described by the catalog :param str url: URL for the current catalog :param lxml.etree.Eleemnt tree: Current XML Tree ''' for leaf in tree.findall('.//{%s}dataset[@urlPat...
python
def _yield_leaves(self, url, tree): ''' Yields a URL corresponding to a leaf dataset for each dataset described by the catalog :param str url: URL for the current catalog :param lxml.etree.Eleemnt tree: Current XML Tree ''' for leaf in tree.findall('.//{%s}dataset[@urlPat...
[ "def", "_yield_leaves", "(", "self", ",", "url", ",", "tree", ")", ":", "for", "leaf", "in", "tree", ".", "findall", "(", "'.//{%s}dataset[@urlPath]'", "%", "INV_NS", ")", ":", "# Subset by the skips", "name", "=", "leaf", ".", "get", "(", "\"name\"", ")",...
Yields a URL corresponding to a leaf dataset for each dataset described by the catalog :param str url: URL for the current catalog :param lxml.etree.Eleemnt tree: Current XML Tree
[ "Yields", "a", "URL", "corresponding", "to", "a", "leaf", "dataset", "for", "each", "dataset", "described", "by", "the", "catalog", ":", "param", "str", "url", ":", "URL", "for", "the", "current", "catalog", ":", "param", "lxml", ".", "etree", ".", "Elee...
train
https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L146-L185
ioos/thredds_crawler
thredds_crawler/crawl.py
Crawl._compile_references
def _compile_references(self, url, tree): ''' Returns a list of catalog reference URLs for the current catalog :param str url: URL for the current catalog :param lxml.etree.Eleemnt tree: Current XML Tree ''' references = [] for ref in tree.findall('.//{%s}catalogR...
python
def _compile_references(self, url, tree): ''' Returns a list of catalog reference URLs for the current catalog :param str url: URL for the current catalog :param lxml.etree.Eleemnt tree: Current XML Tree ''' references = [] for ref in tree.findall('.//{%s}catalogR...
[ "def", "_compile_references", "(", "self", ",", "url", ",", "tree", ")", ":", "references", "=", "[", "]", "for", "ref", "in", "tree", ".", "findall", "(", "'.//{%s}catalogRef'", "%", "INV_NS", ")", ":", "# Check skips", "title", "=", "ref", ".", "get", ...
Returns a list of catalog reference URLs for the current catalog :param str url: URL for the current catalog :param lxml.etree.Eleemnt tree: Current XML Tree
[ "Returns", "a", "list", "of", "catalog", "reference", "URLs", "for", "the", "current", "catalog", ":", "param", "str", "url", ":", "URL", "for", "the", "current", "catalog", ":", "param", "lxml", ".", "etree", ".", "Eleemnt", "tree", ":", "Current", "XML...
train
https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L187-L201
ioos/thredds_crawler
thredds_crawler/crawl.py
Crawl._run
def _run(self, url, auth): ''' Performs a multiprocess depth-first-search of the catalog references and yields a URL for each leaf dataset found :param str url: URL for the current catalog :param requests.auth.AuthBase auth: requets auth object to use ''' if url i...
python
def _run(self, url, auth): ''' Performs a multiprocess depth-first-search of the catalog references and yields a URL for each leaf dataset found :param str url: URL for the current catalog :param requests.auth.AuthBase auth: requets auth object to use ''' if url i...
[ "def", "_run", "(", "self", ",", "url", ",", "auth", ")", ":", "if", "url", "in", "self", ".", "visited", ":", "logger", ".", "debug", "(", "\"Skipping %s (already crawled)\"", "%", "url", ")", "return", "self", ".", "visited", ".", "append", "(", "url...
Performs a multiprocess depth-first-search of the catalog references and yields a URL for each leaf dataset found :param str url: URL for the current catalog :param requests.auth.AuthBase auth: requets auth object to use
[ "Performs", "a", "multiprocess", "depth", "-", "first", "-", "search", "of", "the", "catalog", "references", "and", "yields", "a", "URL", "for", "each", "leaf", "dataset", "found", ":", "param", "str", "url", ":", "URL", "for", "the", "current", "catalog",...
train
https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L203-L221
ioos/thredds_crawler
thredds_crawler/crawl.py
Crawl._build_catalog
def _build_catalog(self, url, xml_content): ''' Recursive function to perform the DFS and yield the leaf datasets :param str url: URL for the current catalog :param str xml_content: XML Body returned from HTTP Request ''' try: tree = etree.XML(xml_content) ...
python
def _build_catalog(self, url, xml_content): ''' Recursive function to perform the DFS and yield the leaf datasets :param str url: URL for the current catalog :param str xml_content: XML Body returned from HTTP Request ''' try: tree = etree.XML(xml_content) ...
[ "def", "_build_catalog", "(", "self", ",", "url", ",", "xml_content", ")", ":", "try", ":", "tree", "=", "etree", ".", "XML", "(", "xml_content", ")", "except", "BaseException", ":", "return", "# Get a list of URLs", "references", "=", "self", ".", "_compile...
Recursive function to perform the DFS and yield the leaf datasets :param str url: URL for the current catalog :param str xml_content: XML Body returned from HTTP Request
[ "Recursive", "function", "to", "perform", "the", "DFS", "and", "yield", "the", "leaf", "datasets", ":", "param", "str", "url", ":", "URL", "for", "the", "current", "catalog", ":", "param", "str", "xml_content", ":", "XML", "Body", "returned", "from", "HTTP...
train
https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L223-L247
roman-neuhauser/py-impala
impala/__init__.py
Finder.find_module
def find_module(fdr, fqname, path = None): '''Find a loader for module or package `fqname`. This method will be called with the fully qualified name of the module. If the finder is installed on `sys.meta_path`, it will receive a second argument, which is `None` for a top-level module, ...
python
def find_module(fdr, fqname, path = None): '''Find a loader for module or package `fqname`. This method will be called with the fully qualified name of the module. If the finder is installed on `sys.meta_path`, it will receive a second argument, which is `None` for a top-level module, ...
[ "def", "find_module", "(", "fdr", ",", "fqname", ",", "path", "=", "None", ")", ":", "if", "fqname", "in", "fdr", ".", "aliases", ":", "return", "Loader", "(", "fqname", ",", "fdr", ".", "aliases", "[", "fqname", "]", ")", "return", "None" ]
Find a loader for module or package `fqname`. This method will be called with the fully qualified name of the module. If the finder is installed on `sys.meta_path`, it will receive a second argument, which is `None` for a top-level module, or `package.__path__` for submodules or sub...
[ "Find", "a", "loader", "for", "module", "or", "package", "fqname", "." ]
train
https://github.com/roman-neuhauser/py-impala/blob/8a22def2744460d20c620beb24c00332e77125d5/impala/__init__.py#L60-L80
roman-neuhauser/py-impala
impala/__init__.py
Loader.load_module
def load_module(ldr, fqname): '''Load `fqname` from under `ldr.fspath`. The `fqname` argument is the fully qualified module name, eg. "spam.eggs.ham". As explained above, when :: finder.find_module("spam.eggs.ham") is called, "spam.eggs" has already been imported and added t...
python
def load_module(ldr, fqname): '''Load `fqname` from under `ldr.fspath`. The `fqname` argument is the fully qualified module name, eg. "spam.eggs.ham". As explained above, when :: finder.find_module("spam.eggs.ham") is called, "spam.eggs" has already been imported and added t...
[ "def", "load_module", "(", "ldr", ",", "fqname", ")", ":", "scope", "=", "ldr", ".", "scope", ".", "split", "(", "'.'", ")", "modpath", "=", "fqname", ".", "split", "(", "'.'", ")", "if", "scope", "!=", "modpath", "[", "0", ":", "len", "(", "scop...
Load `fqname` from under `ldr.fspath`. The `fqname` argument is the fully qualified module name, eg. "spam.eggs.ham". As explained above, when :: finder.find_module("spam.eggs.ham") is called, "spam.eggs" has already been imported and added to `sys.modules`. However, the `find_...
[ "Load", "fqname", "from", "under", "ldr", ".", "fspath", "." ]
train
https://github.com/roman-neuhauser/py-impala/blob/8a22def2744460d20c620beb24c00332e77125d5/impala/__init__.py#L119-L216
csirtgadgets/bearded-avenger-sdk-py
cifsdk/utils/zhelper.py
zthread_fork
def zthread_fork(ctx, func, *args, **kwargs): """ Create an attached thread. An attached thread gets a ctx and a PAIR pipe back to its parent. It must monitor its pipe, and exit if the pipe becomes unreadable. Returns pipe, or NULL if there was an error. """ a = ctx.socket(zmq.PAIR) a.setsoc...
python
def zthread_fork(ctx, func, *args, **kwargs): """ Create an attached thread. An attached thread gets a ctx and a PAIR pipe back to its parent. It must monitor its pipe, and exit if the pipe becomes unreadable. Returns pipe, or NULL if there was an error. """ a = ctx.socket(zmq.PAIR) a.setsoc...
[ "def", "zthread_fork", "(", "ctx", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "a", "=", "ctx", ".", "socket", "(", "zmq", ".", "PAIR", ")", "a", ".", "setsockopt", "(", "zmq", ".", "LINGER", ",", "0", ")", "a", ".", "se...
Create an attached thread. An attached thread gets a ctx and a PAIR pipe back to its parent. It must monitor its pipe, and exit if the pipe becomes unreadable. Returns pipe, or NULL if there was an error.
[ "Create", "an", "attached", "thread", ".", "An", "attached", "thread", "gets", "a", "ctx", "and", "a", "PAIR", "pipe", "back", "to", "its", "parent", ".", "It", "must", "monitor", "its", "pipe", "and", "exit", "if", "the", "pipe", "becomes", "unreadable"...
train
https://github.com/csirtgadgets/bearded-avenger-sdk-py/blob/2b3e96cb2e7703ee0402811096da8265a740f378/cifsdk/utils/zhelper.py#L44-L70
pyblish/pyblish-nuke
pyblish_nuke/vendor/Qt.py
_remap
def _remap(object, name, value, safe=True): """Prevent accidental assignment of existing members Arguments: object (object): Parent of new attribute name (str): Name of new attribute value (object): Value of new attribute safe (bool): Whether or not to guarantee that ...
python
def _remap(object, name, value, safe=True): """Prevent accidental assignment of existing members Arguments: object (object): Parent of new attribute name (str): Name of new attribute value (object): Value of new attribute safe (bool): Whether or not to guarantee that ...
[ "def", "_remap", "(", "object", ",", "name", ",", "value", ",", "safe", "=", "True", ")", ":", "if", "os", ".", "getenv", "(", "\"QT_TESTING\"", ")", "is", "not", "None", "and", "safe", ":", "# Cannot alter original binding.", "if", "hasattr", "(", "obje...
Prevent accidental assignment of existing members Arguments: object (object): Parent of new attribute name (str): Name of new attribute value (object): Value of new attribute safe (bool): Whether or not to guarantee that the new attribute was not overwritten. ...
[ "Prevent", "accidental", "assignment", "of", "existing", "members" ]
train
https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/vendor/Qt.py#L77-L108
pyblish/pyblish-nuke
pyblish_nuke/vendor/Qt.py
init
def init(): """Try loading each binding in turn Please note: the entire Qt module is replaced with this code: sys.modules["Qt"] = binding() This means no functions or variables can be called after this has executed. For debugging and testing, this module may be accessed through `Qt.__...
python
def init(): """Try loading each binding in turn Please note: the entire Qt module is replaced with this code: sys.modules["Qt"] = binding() This means no functions or variables can be called after this has executed. For debugging and testing, this module may be accessed through `Qt.__...
[ "def", "init", "(", ")", ":", "preferred", "=", "os", ".", "getenv", "(", "\"QT_PREFERRED_BINDING\"", ")", "verbose", "=", "os", ".", "getenv", "(", "\"QT_VERBOSE\"", ")", "is", "not", "None", "bindings", "=", "(", "_pyside2", ",", "_pyqt5", ",", "_pysid...
Try loading each binding in turn Please note: the entire Qt module is replaced with this code: sys.modules["Qt"] = binding() This means no functions or variables can be called after this has executed. For debugging and testing, this module may be accessed through `Qt.__shim__`.
[ "Try", "loading", "each", "binding", "in", "turn" ]
train
https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/vendor/Qt.py#L299-L365
EUDAT-B2SAFE/B2HANDLE
b2handle/util/logutils.py
log_instantiation
def log_instantiation(LOGGER, classname, args, forbidden, with_date=False): ''' Log the instantiation of an object to the given logger. :LOGGER: A logger to log to. Please see module "logging". :classname: The name of the class that is being instantiated. :args: A dictionary of arguments pa...
python
def log_instantiation(LOGGER, classname, args, forbidden, with_date=False): ''' Log the instantiation of an object to the given logger. :LOGGER: A logger to log to. Please see module "logging". :classname: The name of the class that is being instantiated. :args: A dictionary of arguments pa...
[ "def", "log_instantiation", "(", "LOGGER", ",", "classname", ",", "args", ",", "forbidden", ",", "with_date", "=", "False", ")", ":", "# Info:", "if", "with_date", ":", "LOGGER", ".", "info", "(", "'Instantiating '", "+", "classname", "+", "' at '", "+", "...
Log the instantiation of an object to the given logger. :LOGGER: A logger to log to. Please see module "logging". :classname: The name of the class that is being instantiated. :args: A dictionary of arguments passed to the instantiation, which will be logged on debug level. :forbidden: ...
[ "Log", "the", "instantiation", "of", "an", "object", "to", "the", "given", "logger", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/logutils.py#L31-L58
nooperpudd/weibopy
weibopy/weibo.py
filter_params
def filter_params(params): """ convert dict value if value is bool type, False -> "false" True -> "true" """ if params is not None: new_params = copy.deepcopy(params) new_params = dict((k, v) for k, v in new_params.items() if v is not None) for key, value in new_params.it...
python
def filter_params(params): """ convert dict value if value is bool type, False -> "false" True -> "true" """ if params is not None: new_params = copy.deepcopy(params) new_params = dict((k, v) for k, v in new_params.items() if v is not None) for key, value in new_params.it...
[ "def", "filter_params", "(", "params", ")", ":", "if", "params", "is", "not", "None", ":", "new_params", "=", "copy", ".", "deepcopy", "(", "params", ")", "new_params", "=", "dict", "(", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "new_par...
convert dict value if value is bool type, False -> "false" True -> "true"
[ "convert", "dict", "value", "if", "value", "is", "bool", "type", "False", "-", ">", "false", "True", "-", ">", "true" ]
train
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L9-L21
nooperpudd/weibopy
weibopy/weibo.py
WeiboClient._handler_response
def _handler_response(self, response, data=None): """ error code response: { "request": "/statuses/home_timeline.json", "error_code": "20502", "error": "Need you follow uid." } :param response: :return: """ if response.s...
python
def _handler_response(self, response, data=None): """ error code response: { "request": "/statuses/home_timeline.json", "error_code": "20502", "error": "Need you follow uid." } :param response: :return: """ if response.s...
[ "def", "_handler_response", "(", "self", ",", "response", ",", "data", "=", "None", ")", ":", "if", "response", ".", "status_code", "==", "200", ":", "data", "=", "response", ".", "json", "(", ")", "if", "isinstance", "(", "data", ",", "dict", ")", "...
error code response: { "request": "/statuses/home_timeline.json", "error_code": "20502", "error": "Need you follow uid." } :param response: :return:
[ "error", "code", "response", ":", "{", "request", ":", "/", "statuses", "/", "home_timeline", ".", "json", "error_code", ":", "20502", "error", ":", "Need", "you", "follow", "uid", ".", "}", ":", "param", "response", ":", ":", "return", ":" ]
train
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L37-L64
nooperpudd/weibopy
weibopy/weibo.py
WeiboClient.get
def get(self, suffix, params=None): """ request weibo api :param suffix: str, :param params: dict, url query parameters :return: """ url = self.base + suffix params = filter_params(params) response = self.session.get(url=url, params=params) ...
python
def get(self, suffix, params=None): """ request weibo api :param suffix: str, :param params: dict, url query parameters :return: """ url = self.base + suffix params = filter_params(params) response = self.session.get(url=url, params=params) ...
[ "def", "get", "(", "self", ",", "suffix", ",", "params", "=", "None", ")", ":", "url", "=", "self", ".", "base", "+", "suffix", "params", "=", "filter_params", "(", "params", ")", "response", "=", "self", ".", "session", ".", "get", "(", "url", "="...
request weibo api :param suffix: str, :param params: dict, url query parameters :return:
[ "request", "weibo", "api", ":", "param", "suffix", ":", "str", ":", "param", "params", ":", "dict", "url", "query", "parameters", ":", "return", ":" ]
train
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L66-L80
nooperpudd/weibopy
weibopy/weibo.py
WeiboClient.post
def post(self, suffix, params=None, data=None, files=None): """ :return: """ url = self.base + suffix params = filter_params(params) response = self.session.post(url=url, params=params, data=data, files=files) return self._handler_response(response, data=data)
python
def post(self, suffix, params=None, data=None, files=None): """ :return: """ url = self.base + suffix params = filter_params(params) response = self.session.post(url=url, params=params, data=data, files=files) return self._handler_response(response, data=data)
[ "def", "post", "(", "self", ",", "suffix", ",", "params", "=", "None", ",", "data", "=", "None", ",", "files", "=", "None", ")", ":", "url", "=", "self", ".", "base", "+", "suffix", "params", "=", "filter_params", "(", "params", ")", "response", "=...
:return:
[ ":", "return", ":" ]
train
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L82-L92
EUDAT-B2SAFE/B2HANDLE
b2handle/searcher.py
Searcher.search_handle
def search_handle(self, **args): ''' Search for handles containing the specified key with the specified value. The search terms are passed on to the reverse lookup servlet as-is. The servlet is supposed to be case-insensitive, but if it isn't, the wrong case will cause a :exc:`~b...
python
def search_handle(self, **args): ''' Search for handles containing the specified key with the specified value. The search terms are passed on to the reverse lookup servlet as-is. The servlet is supposed to be case-insensitive, but if it isn't, the wrong case will cause a :exc:`~b...
[ "def", "search_handle", "(", "self", ",", "*", "*", "args", ")", ":", "LOGGER", ".", "debug", "(", "'search_handle...'", ")", "if", "self", ".", "__has_search_access", ":", "return", "self", ".", "__search_handle", "(", "*", "*", "args", ")", "else", ":"...
Search for handles containing the specified key with the specified value. The search terms are passed on to the reverse lookup servlet as-is. The servlet is supposed to be case-insensitive, but if it isn't, the wrong case will cause a :exc:`~b2handle.handleexceptions.ReverseLookupException`. ...
[ "Search", "for", "handles", "containing", "the", "specified", "key", "with", "the", "specified", "value", ".", "The", "search", "terms", "are", "passed", "on", "to", "the", "reverse", "lookup", "servlet", "as", "-", "is", ".", "The", "servlet", "is", "supp...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/searcher.py#L210-L250
EUDAT-B2SAFE/B2HANDLE
b2handle/searcher.py
Searcher.create_revlookup_query
def create_revlookup_query(self, *fulltext_searchterms, **keyvalue_searchterms): ''' Create the part of the solr request that comes after the question mark, e.g. ?URL=*dkrz*&CHECKSUM=*abc*. If allowed search keys are configured, only these are used. If no'allowed search keys are ...
python
def create_revlookup_query(self, *fulltext_searchterms, **keyvalue_searchterms): ''' Create the part of the solr request that comes after the question mark, e.g. ?URL=*dkrz*&CHECKSUM=*abc*. If allowed search keys are configured, only these are used. If no'allowed search keys are ...
[ "def", "create_revlookup_query", "(", "self", ",", "*", "fulltext_searchterms", ",", "*", "*", "keyvalue_searchterms", ")", ":", "LOGGER", ".", "debug", "(", "'create_revlookup_query...'", ")", "allowed_search_keys", "=", "self", ".", "__allowed_search_keys", "only_se...
Create the part of the solr request that comes after the question mark, e.g. ?URL=*dkrz*&CHECKSUM=*abc*. If allowed search keys are configured, only these are used. If no'allowed search keys are specified, all key-value pairs are passed on to the reverse lookup servlet. :param f...
[ "Create", "the", "part", "of", "the", "solr", "request", "that", "comes", "after", "the", "question", "mark", "e", ".", "g", ".", "?URL", "=", "*", "dkrz", "*", "&CHECKSUM", "=", "*", "abc", "*", ".", "If", "allowed", "search", "keys", "are", "config...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/searcher.py#L340-L402
EUDAT-B2SAFE/B2HANDLE
b2handle/searcher.py
Searcher.__set_revlookup_auth_string
def __set_revlookup_auth_string(self, username, password): ''' Creates and sets the authentication string for accessing the reverse lookup servlet. No return, the string is set as an attribute to the client instance. :param username: Username. :param password: Pa...
python
def __set_revlookup_auth_string(self, username, password): ''' Creates and sets the authentication string for accessing the reverse lookup servlet. No return, the string is set as an attribute to the client instance. :param username: Username. :param password: Pa...
[ "def", "__set_revlookup_auth_string", "(", "self", ",", "username", ",", "password", ")", ":", "auth", "=", "b2handle", ".", "utilhandle", ".", "create_authentication_string", "(", "username", ",", "password", ")", "self", ".", "__revlookup_auth_string", "=", "aut...
Creates and sets the authentication string for accessing the reverse lookup servlet. No return, the string is set as an attribute to the client instance. :param username: Username. :param password: Password.
[ "Creates", "and", "sets", "the", "authentication", "string", "for", "accessing", "the", "reverse", "lookup", "servlet", ".", "No", "return", "the", "string", "is", "set", "as", "an", "attribute", "to", "the", "client", "instance", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/searcher.py#L404-L414
EUDAT-B2SAFE/B2HANDLE
b2handle/clientcredentials.py
PIDClientCredentials.load_from_JSON
def load_from_JSON(json_filename): ''' Create a new instance of a PIDClientCredentials with information read from a local JSON file. :param json_filename: The path to the json credentials file. The json file should have the following format: .. code:: json ...
python
def load_from_JSON(json_filename): ''' Create a new instance of a PIDClientCredentials with information read from a local JSON file. :param json_filename: The path to the json credentials file. The json file should have the following format: .. code:: json ...
[ "def", "load_from_JSON", "(", "json_filename", ")", ":", "try", ":", "jsonfilecontent", "=", "json", ".", "loads", "(", "open", "(", "json_filename", ",", "'r'", ")", ".", "read", "(", ")", ")", "except", "ValueError", "as", "exc", ":", "raise", "Credent...
Create a new instance of a PIDClientCredentials with information read from a local JSON file. :param json_filename: The path to the json credentials file. The json file should have the following format: .. code:: json { "handle_s...
[ "Create", "a", "new", "instance", "of", "a", "PIDClientCredentials", "with", "information", "read", "from", "a", "local", "JSON", "file", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/clientcredentials.py#L29-L58
alexhayes/django-migration-fixture
django_migration_fixture/__init__.py
fixture
def fixture(app, fixtures, fixtures_dir='fixtures', raise_does_not_exist=False, reversible=True, models=[]): """ Load fixtures using a data migration. The migration will by default provide a rollback, deleting items by primary key. This is not always what you want ; you may set reversible=F...
python
def fixture(app, fixtures, fixtures_dir='fixtures', raise_does_not_exist=False, reversible=True, models=[]): """ Load fixtures using a data migration. The migration will by default provide a rollback, deleting items by primary key. This is not always what you want ; you may set reversible=F...
[ "def", "fixture", "(", "app", ",", "fixtures", ",", "fixtures_dir", "=", "'fixtures'", ",", "raise_does_not_exist", "=", "False", ",", "reversible", "=", "True", ",", "models", "=", "[", "]", ")", ":", "fixture_path", "=", "os", ".", "path", ".", "join",...
Load fixtures using a data migration. The migration will by default provide a rollback, deleting items by primary key. This is not always what you want ; you may set reversible=False to prevent rolling back. Usage: import myapp import anotherapp operations = [ migrations.RunPytho...
[ "Load", "fixtures", "using", "a", "data", "migration", "." ]
train
https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/__init__.py#L37-L124
wanji/bitmap
src/bitmap.py
BitMap.nonzero
def nonzero(self): """ Get all non-zero bits """ return [i for i in xrange(self.size()) if self.test(i)]
python
def nonzero(self): """ Get all non-zero bits """ return [i for i in xrange(self.size()) if self.test(i)]
[ "def", "nonzero", "(", "self", ")", ":", "return", "[", "i", "for", "i", "in", "xrange", "(", "self", ".", "size", "(", ")", ")", "if", "self", ".", "test", "(", "i", ")", "]" ]
Get all non-zero bits
[ "Get", "all", "non", "-", "zero", "bits" ]
train
https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L95-L99
wanji/bitmap
src/bitmap.py
BitMap.tohexstring
def tohexstring(self): """ Returns a hexadecimal string """ val = self.tostring() st = "{0:0x}".format(int(val, 2)) return st.zfill(len(self.bitmap)*2)
python
def tohexstring(self): """ Returns a hexadecimal string """ val = self.tostring() st = "{0:0x}".format(int(val, 2)) return st.zfill(len(self.bitmap)*2)
[ "def", "tohexstring", "(", "self", ")", ":", "val", "=", "self", ".", "tostring", "(", ")", "st", "=", "\"{0:0x}\"", ".", "format", "(", "int", "(", "val", ",", "2", ")", ")", "return", "st", ".", "zfill", "(", "len", "(", "self", ".", "bitmap", ...
Returns a hexadecimal string
[ "Returns", "a", "hexadecimal", "string" ]
train
https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L131-L137
wanji/bitmap
src/bitmap.py
BitMap.fromhexstring
def fromhexstring(cls, hexstring): """ Construct BitMap from hex string """ bitstring = format(int(hexstring, 16), "0" + str(len(hexstring)/4) + "b") return cls.fromstring(bitstring)
python
def fromhexstring(cls, hexstring): """ Construct BitMap from hex string """ bitstring = format(int(hexstring, 16), "0" + str(len(hexstring)/4) + "b") return cls.fromstring(bitstring)
[ "def", "fromhexstring", "(", "cls", ",", "hexstring", ")", ":", "bitstring", "=", "format", "(", "int", "(", "hexstring", ",", "16", ")", ",", "\"0\"", "+", "str", "(", "len", "(", "hexstring", ")", "/", "4", ")", "+", "\"b\"", ")", "return", "cls"...
Construct BitMap from hex string
[ "Construct", "BitMap", "from", "hex", "string" ]
train
https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L140-L145
wanji/bitmap
src/bitmap.py
BitMap.fromstring
def fromstring(cls, bitstring): """ Construct BitMap from string """ nbits = len(bitstring) bm = cls(nbits) for i in xrange(nbits): if bitstring[-i-1] == '1': bm.set(i) elif bitstring[-i-1] != '0': raise Exception("I...
python
def fromstring(cls, bitstring): """ Construct BitMap from string """ nbits = len(bitstring) bm = cls(nbits) for i in xrange(nbits): if bitstring[-i-1] == '1': bm.set(i) elif bitstring[-i-1] != '0': raise Exception("I...
[ "def", "fromstring", "(", "cls", ",", "bitstring", ")", ":", "nbits", "=", "len", "(", "bitstring", ")", "bm", "=", "cls", "(", "nbits", ")", "for", "i", "in", "xrange", "(", "nbits", ")", ":", "if", "bitstring", "[", "-", "i", "-", "1", "]", "...
Construct BitMap from string
[ "Construct", "BitMap", "from", "string" ]
train
https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L148-L159
csirtgadgets/bearded-avenger-sdk-py
cifsdk/_version.py
get_versions
def get_versions(): """Get version information or return default if unable to do so.""" # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have # __file__, we can work backwards from there to the root. Some # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which #...
python
def get_versions(): """Get version information or return default if unable to do so.""" # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have # __file__, we can work backwards from there to the root. Some # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which #...
[ "def", "get_versions", "(", ")", ":", "# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have", "# __file__, we can work backwards from there to the root. Some", "# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which", "# case we can only use expanded keywords....
Get version information or return default if unable to do so.
[ "Get", "version", "information", "or", "return", "default", "if", "unable", "to", "do", "so", "." ]
train
https://github.com/csirtgadgets/bearded-avenger-sdk-py/blob/2b3e96cb2e7703ee0402811096da8265a740f378/cifsdk/_version.py#L442-L495
EUDAT-B2SAFE/B2HANDLE
b2handle/util/utilconfig.py
get_valid_https_verify
def get_valid_https_verify(value): ''' Get a value that can be the boolean representation of a string or a boolean itself and returns It as a boolean. If this is not the case, It returns a string. :value: The HTTPS_verify input value. A string can be passed as a path to a CA_BUNDLE cert...
python
def get_valid_https_verify(value): ''' Get a value that can be the boolean representation of a string or a boolean itself and returns It as a boolean. If this is not the case, It returns a string. :value: The HTTPS_verify input value. A string can be passed as a path to a CA_BUNDLE cert...
[ "def", "get_valid_https_verify", "(", "value", ")", ":", "http_verify_value", "=", "value", "bool_values", "=", "{", "'false'", ":", "False", ",", "'true'", ":", "True", "}", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "http_verify_value", "=", ...
Get a value that can be the boolean representation of a string or a boolean itself and returns It as a boolean. If this is not the case, It returns a string. :value: The HTTPS_verify input value. A string can be passed as a path to a CA_BUNDLE certificate :returns: True, False or a string.
[ "Get", "a", "value", "that", "can", "be", "the", "boolean", "representation", "of", "a", "string", "or", "a", "boolean", "itself", "and", "returns", "It", "as", "a", "boolean", ".", "If", "this", "is", "not", "the", "case", "It", "returns", "a", "strin...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/utilconfig.py#L6-L24
inveniosoftware/invenio-assets
invenio_assets/filters.py
RequireJSFilter.setup
def setup(self): """Setup filter (only called when filter is actually used).""" super(RequireJSFilter, self).setup() excluded_files = [] for bundle in self.excluded_bundles: excluded_files.extend( map(lambda f: os.path.splitext(f)[0], bund...
python
def setup(self): """Setup filter (only called when filter is actually used).""" super(RequireJSFilter, self).setup() excluded_files = [] for bundle in self.excluded_bundles: excluded_files.extend( map(lambda f: os.path.splitext(f)[0], bund...
[ "def", "setup", "(", "self", ")", ":", "super", "(", "RequireJSFilter", ",", "self", ")", ".", "setup", "(", ")", "excluded_files", "=", "[", "]", "for", "bundle", "in", "self", ".", "excluded_bundles", ":", "excluded_files", ".", "extend", "(", "map", ...
Setup filter (only called when filter is actually used).
[ "Setup", "filter", "(", "only", "called", "when", "filter", "is", "actually", "used", ")", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L45-L59
inveniosoftware/invenio-assets
invenio_assets/filters.py
CleanCSSFilter.setup
def setup(self): """Initialize filter just before it will be used.""" super(CleanCSSFilter, self).setup() self.root = current_app.config.get('COLLECT_STATIC_ROOT')
python
def setup(self): """Initialize filter just before it will be used.""" super(CleanCSSFilter, self).setup() self.root = current_app.config.get('COLLECT_STATIC_ROOT')
[ "def", "setup", "(", "self", ")", ":", "super", "(", "CleanCSSFilter", ",", "self", ")", ".", "setup", "(", ")", "self", ".", "root", "=", "current_app", ".", "config", ".", "get", "(", "'COLLECT_STATIC_ROOT'", ")" ]
Initialize filter just before it will be used.
[ "Initialize", "filter", "just", "before", "it", "will", "be", "used", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L71-L74
inveniosoftware/invenio-assets
invenio_assets/filters.py
CleanCSSFilter.rebase_opt
def rebase_opt(self): """Determine which option name to use.""" if not hasattr(self, '_rebase_opt'): # out = b"MAJOR.MINOR.REVISION" // b"3.4.19" or b"4.0.0" out, err = Popen( ['cleancss', '--version'], stdout=PIPE).communicate() ver = int(out[:out.ind...
python
def rebase_opt(self): """Determine which option name to use.""" if not hasattr(self, '_rebase_opt'): # out = b"MAJOR.MINOR.REVISION" // b"3.4.19" or b"4.0.0" out, err = Popen( ['cleancss', '--version'], stdout=PIPE).communicate() ver = int(out[:out.ind...
[ "def", "rebase_opt", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_rebase_opt'", ")", ":", "# out = b\"MAJOR.MINOR.REVISION\" // b\"3.4.19\" or b\"4.0.0\"", "out", ",", "err", "=", "Popen", "(", "[", "'cleancss'", ",", "'--version'", "]", "...
Determine which option name to use.
[ "Determine", "which", "option", "name", "to", "use", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L77-L85
inveniosoftware/invenio-assets
invenio_assets/filters.py
CleanCSSFilter.input
def input(self, _in, out, **kw): """Input filtering.""" args = [self.binary or 'cleancss'] + self.rebase_opt if self.extra_args: args.extend(self.extra_args) self.subprocess(args, out, _in)
python
def input(self, _in, out, **kw): """Input filtering.""" args = [self.binary or 'cleancss'] + self.rebase_opt if self.extra_args: args.extend(self.extra_args) self.subprocess(args, out, _in)
[ "def", "input", "(", "self", ",", "_in", ",", "out", ",", "*", "*", "kw", ")", ":", "args", "=", "[", "self", ".", "binary", "or", "'cleancss'", "]", "+", "self", ".", "rebase_opt", "if", "self", ".", "extra_args", ":", "args", ".", "extend", "("...
Input filtering.
[ "Input", "filtering", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L87-L92
inveniosoftware/invenio-assets
invenio_assets/filters.py
AngularGettextFilter.output
def output(self, _in, out, **kwargs): """Wrap translation in Angular module.""" out.write( 'angular.module("{0}", ["gettext"]).run(' '["gettextCatalog", function (gettextCatalog) {{'.format( self.catalog_name ) ) out.write(_in.read()) ...
python
def output(self, _in, out, **kwargs): """Wrap translation in Angular module.""" out.write( 'angular.module("{0}", ["gettext"]).run(' '["gettextCatalog", function (gettextCatalog) {{'.format( self.catalog_name ) ) out.write(_in.read()) ...
[ "def", "output", "(", "self", ",", "_in", ",", "out", ",", "*", "*", "kwargs", ")", ":", "out", ".", "write", "(", "'angular.module(\"{0}\", [\"gettext\"]).run('", "'[\"gettextCatalog\", function (gettextCatalog) {{'", ".", "format", "(", "self", ".", "catalog_name"...
Wrap translation in Angular module.
[ "Wrap", "translation", "in", "Angular", "module", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L110-L119
inveniosoftware/invenio-assets
invenio_assets/filters.py
AngularGettextFilter.input
def input(self, _in, out, **kwargs): """Process individual translation file.""" language_code = _re_language_code.search(_in.read()).group( 'language_code' ) _in.seek(0) # move at the begining after matching the language catalog = read_po(_in) out.write('gett...
python
def input(self, _in, out, **kwargs): """Process individual translation file.""" language_code = _re_language_code.search(_in.read()).group( 'language_code' ) _in.seek(0) # move at the begining after matching the language catalog = read_po(_in) out.write('gett...
[ "def", "input", "(", "self", ",", "_in", ",", "out", ",", "*", "*", "kwargs", ")", ":", "language_code", "=", "_re_language_code", ".", "search", "(", "_in", ".", "read", "(", ")", ")", ".", "group", "(", "'language_code'", ")", "_in", ".", "seek", ...
Process individual translation file.
[ "Process", "individual", "translation", "file", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L121-L133
redhat-cip/dci-control-server
dci/auth_mechanism.py
BasicAuthMechanism.get_user_and_check_auth
def get_user_and_check_auth(self, username, password): """Check the combination username/password that is valid on the database. """ constraint = sql.or_( models.USERS.c.name == username, models.USERS.c.email == username ) user = self.identity_fro...
python
def get_user_and_check_auth(self, username, password): """Check the combination username/password that is valid on the database. """ constraint = sql.or_( models.USERS.c.name == username, models.USERS.c.email == username ) user = self.identity_fro...
[ "def", "get_user_and_check_auth", "(", "self", ",", "username", ",", "password", ")", ":", "constraint", "=", "sql", ".", "or_", "(", "models", ".", "USERS", ".", "c", ".", "name", "==", "username", ",", "models", ".", "USERS", ".", "c", ".", "email", ...
Check the combination username/password that is valid on the database.
[ "Check", "the", "combination", "username", "/", "password", "that", "is", "valid", "on", "the", "database", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/auth_mechanism.py#L135-L149
redhat-cip/dci-control-server
dci/trackers/github.py
Github.retrieve_info
def retrieve_info(self): """Query the Github API to retrieve the needed infos.""" path = urlparse(self.url).path path = path.split('/')[1:] sanity_filter = re.compile('[\da-z-_]+', re.IGNORECASE) self.product = sanity_filter.match(path[0]).group(0) self.component = sani...
python
def retrieve_info(self): """Query the Github API to retrieve the needed infos.""" path = urlparse(self.url).path path = path.split('/')[1:] sanity_filter = re.compile('[\da-z-_]+', re.IGNORECASE) self.product = sanity_filter.match(path[0]).group(0) self.component = sani...
[ "def", "retrieve_info", "(", "self", ")", ":", "path", "=", "urlparse", "(", "self", ".", "url", ")", ".", "path", "path", "=", "path", ".", "split", "(", "'/'", ")", "[", "1", ":", "]", "sanity_filter", "=", "re", ".", "compile", "(", "'[\\da-z-_]...
Query the Github API to retrieve the needed infos.
[ "Query", "the", "Github", "API", "to", "retrieve", "the", "needed", "infos", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/trackers/github.py#L32-L62
danijar/sets
sets/core/step.py
Step.disk_cache
def disk_cache(cls, basename, function, *args, method=True, **kwargs): """ Cache the return value in the correct cache directory. Set 'method' to false for static methods. """ @utility.disk_cache(basename, cls.directory(), method=method) def wrapper(*args, **kwargs): ...
python
def disk_cache(cls, basename, function, *args, method=True, **kwargs): """ Cache the return value in the correct cache directory. Set 'method' to false for static methods. """ @utility.disk_cache(basename, cls.directory(), method=method) def wrapper(*args, **kwargs): ...
[ "def", "disk_cache", "(", "cls", ",", "basename", ",", "function", ",", "*", "args", ",", "method", "=", "True", ",", "*", "*", "kwargs", ")", ":", "@", "utility", ".", "disk_cache", "(", "basename", ",", "cls", ".", "directory", "(", ")", ",", "me...
Cache the return value in the correct cache directory. Set 'method' to false for static methods.
[ "Cache", "the", "return", "value", "in", "the", "correct", "cache", "directory", ".", "Set", "method", "to", "false", "for", "static", "methods", "." ]
train
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/core/step.py#L12-L21
danijar/sets
sets/core/step.py
Step.download
def download(cls, url, filename=None): """ Download a file into the correct cache directory. """ return utility.download(url, cls.directory(), filename)
python
def download(cls, url, filename=None): """ Download a file into the correct cache directory. """ return utility.download(url, cls.directory(), filename)
[ "def", "download", "(", "cls", ",", "url", ",", "filename", "=", "None", ")", ":", "return", "utility", ".", "download", "(", "url", ",", "cls", ".", "directory", "(", ")", ",", "filename", ")" ]
Download a file into the correct cache directory.
[ "Download", "a", "file", "into", "the", "correct", "cache", "directory", "." ]
train
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/core/step.py#L24-L28
danijar/sets
sets/core/step.py
Step.directory
def directory(cls, prefix=None): """ Path that should be used for caching. Different for all subclasses. """ prefix = prefix or utility.read_config().directory name = cls.__name__.lower() directory = os.path.expanduser(os.path.join(prefix, name)) utility.ensure_di...
python
def directory(cls, prefix=None): """ Path that should be used for caching. Different for all subclasses. """ prefix = prefix or utility.read_config().directory name = cls.__name__.lower() directory = os.path.expanduser(os.path.join(prefix, name)) utility.ensure_di...
[ "def", "directory", "(", "cls", ",", "prefix", "=", "None", ")", ":", "prefix", "=", "prefix", "or", "utility", ".", "read_config", "(", ")", ".", "directory", "name", "=", "cls", ".", "__name__", ".", "lower", "(", ")", "directory", "=", "os", ".", ...
Path that should be used for caching. Different for all subclasses.
[ "Path", "that", "should", "be", "used", "for", "caching", ".", "Different", "for", "all", "subclasses", "." ]
train
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/core/step.py#L31-L39
redhat-cip/dci-control-server
dci/api/v1/remotecis.py
get_last_rconfiguration_id
def get_last_rconfiguration_id(topic_id, remoteci_id, db_conn=None): """Get the rconfiguration_id of the last job run by the remoteci. :param topic_id: the topic :param remoteci_id: the remoteci id :return: last rconfiguration_id of the remoteci """ db_conn = db_conn or flask.g.db_conn __TA...
python
def get_last_rconfiguration_id(topic_id, remoteci_id, db_conn=None): """Get the rconfiguration_id of the last job run by the remoteci. :param topic_id: the topic :param remoteci_id: the remoteci id :return: last rconfiguration_id of the remoteci """ db_conn = db_conn or flask.g.db_conn __TA...
[ "def", "get_last_rconfiguration_id", "(", "topic_id", ",", "remoteci_id", ",", "db_conn", "=", "None", ")", ":", "db_conn", "=", "db_conn", "or", "flask", ".", "g", ".", "db_conn", "__TABLE", "=", "models", ".", "JOBS", "query", "=", "sql", ".", "select", ...
Get the rconfiguration_id of the last job run by the remoteci. :param topic_id: the topic :param remoteci_id: the remoteci id :return: last rconfiguration_id of the remoteci
[ "Get", "the", "rconfiguration_id", "of", "the", "last", "job", "run", "by", "the", "remoteci", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/remotecis.py#L409-L427
redhat-cip/dci-control-server
dci/api/v1/remotecis.py
get_remoteci_configuration
def get_remoteci_configuration(topic_id, remoteci_id, db_conn=None): """Get a remoteci configuration. This will iterate over each configuration in a round robin manner depending on the last rconfiguration used by the remoteci.""" db_conn = db_conn or flask.g.db_conn last_rconfiguration_id = get_las...
python
def get_remoteci_configuration(topic_id, remoteci_id, db_conn=None): """Get a remoteci configuration. This will iterate over each configuration in a round robin manner depending on the last rconfiguration used by the remoteci.""" db_conn = db_conn or flask.g.db_conn last_rconfiguration_id = get_las...
[ "def", "get_remoteci_configuration", "(", "topic_id", ",", "remoteci_id", ",", "db_conn", "=", "None", ")", ":", "db_conn", "=", "db_conn", "or", "flask", ".", "g", ".", "db_conn", "last_rconfiguration_id", "=", "get_last_rconfiguration_id", "(", "topic_id", ",", ...
Get a remoteci configuration. This will iterate over each configuration in a round robin manner depending on the last rconfiguration used by the remoteci.
[ "Get", "a", "remoteci", "configuration", ".", "This", "will", "iterate", "over", "each", "configuration", "in", "a", "round", "robin", "manner", "depending", "on", "the", "last", "rconfiguration", "used", "by", "the", "remoteci", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/remotecis.py#L430-L457
BrighterCommand/Brightside
brightside/command_processor.py
CommandProcessor.send
def send(self, request: Request) -> None: """ Dispatches a request. Expects one and one only target handler :param request: The request to dispatch :return: None, will throw a ConfigurationException if more than one handler factor is registered for the command """ handle...
python
def send(self, request: Request) -> None: """ Dispatches a request. Expects one and one only target handler :param request: The request to dispatch :return: None, will throw a ConfigurationException if more than one handler factor is registered for the command """ handle...
[ "def", "send", "(", "self", ",", "request", ":", "Request", ")", "->", "None", ":", "handler_factories", "=", "self", ".", "_registry", ".", "lookup", "(", "request", ")", "if", "len", "(", "handler_factories", ")", "!=", "1", ":", "raise", "Configuratio...
Dispatches a request. Expects one and one only target handler :param request: The request to dispatch :return: None, will throw a ConfigurationException if more than one handler factor is registered for the command
[ "Dispatches", "a", "request", ".", "Expects", "one", "and", "one", "only", "target", "handler", ":", "param", "request", ":", "The", "request", "to", "dispatch", ":", "return", ":", "None", "will", "throw", "a", "ConfigurationException", "if", "more", "than"...
train
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/command_processor.py#L54-L65
BrighterCommand/Brightside
brightside/command_processor.py
CommandProcessor.publish
def publish(self, request: Request) -> None: """ Dispatches a request. Expects zero or more target handlers :param request: The request to dispatch :return: None. """ handler_factories = self._registry.lookup(request) for factory in handler_factories: ...
python
def publish(self, request: Request) -> None: """ Dispatches a request. Expects zero or more target handlers :param request: The request to dispatch :return: None. """ handler_factories = self._registry.lookup(request) for factory in handler_factories: ...
[ "def", "publish", "(", "self", ",", "request", ":", "Request", ")", "->", "None", ":", "handler_factories", "=", "self", ".", "_registry", ".", "lookup", "(", "request", ")", "for", "factory", "in", "handler_factories", ":", "handler", "=", "factory", "(",...
Dispatches a request. Expects zero or more target handlers :param request: The request to dispatch :return: None.
[ "Dispatches", "a", "request", ".", "Expects", "zero", "or", "more", "target", "handlers", ":", "param", "request", ":", "The", "request", "to", "dispatch", ":", "return", ":", "None", "." ]
train
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/command_processor.py#L67-L76
BrighterCommand/Brightside
brightside/command_processor.py
CommandProcessor.post
def post(self, request: Request) -> None: """ Dispatches a request over middleware. Returns when message put onto outgoing channel by producer, does not wait for response from a consuming application i.e. is fire-and-forget :param request: The request to dispatch :return: None ...
python
def post(self, request: Request) -> None: """ Dispatches a request over middleware. Returns when message put onto outgoing channel by producer, does not wait for response from a consuming application i.e. is fire-and-forget :param request: The request to dispatch :return: None ...
[ "def", "post", "(", "self", ",", "request", ":", "Request", ")", "->", "None", ":", "if", "self", ".", "_producer", "is", "None", ":", "raise", "ConfigurationException", "(", "\"Command Processor requires a BrightsideProducer to post to a Broker\"", ")", "if", "self...
Dispatches a request over middleware. Returns when message put onto outgoing channel by producer, does not wait for response from a consuming application i.e. is fire-and-forget :param request: The request to dispatch :return: None
[ "Dispatches", "a", "request", "over", "middleware", ".", "Returns", "when", "message", "put", "onto", "outgoing", "channel", "by", "producer", "does", "not", "wait", "for", "response", "from", "a", "consuming", "application", "i", ".", "e", ".", "is", "fire"...
train
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/command_processor.py#L78-L94
jmurty/xml4h
xml4h/impls/interface.py
XmlImplAdapter.ignore_whitespace_text_nodes
def ignore_whitespace_text_nodes(cls, wrapped_node): """ Find and delete any text nodes containing nothing but whitespace in in the given node and its descendents. This is useful for cleaning up excess low-value text nodes in a document DOM after parsing a pretty-printed XML doc...
python
def ignore_whitespace_text_nodes(cls, wrapped_node): """ Find and delete any text nodes containing nothing but whitespace in in the given node and its descendents. This is useful for cleaning up excess low-value text nodes in a document DOM after parsing a pretty-printed XML doc...
[ "def", "ignore_whitespace_text_nodes", "(", "cls", ",", "wrapped_node", ")", ":", "for", "child", "in", "wrapped_node", ".", "children", ":", "if", "child", ".", "is_text", "and", "child", ".", "value", ".", "strip", "(", ")", "==", "''", ":", "child", "...
Find and delete any text nodes containing nothing but whitespace in in the given node and its descendents. This is useful for cleaning up excess low-value text nodes in a document DOM after parsing a pretty-printed XML document.
[ "Find", "and", "delete", "any", "text", "nodes", "containing", "nothing", "but", "whitespace", "in", "in", "the", "given", "node", "and", "its", "descendents", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/interface.py#L32-L44
jmurty/xml4h
xml4h/impls/interface.py
XmlImplAdapter.get_ns_info_from_node_name
def get_ns_info_from_node_name(self, name, impl_node): """ Return a three-element tuple with the prefix, local name, and namespace URI for the given element/attribute name (in the context of the given node's hierarchy). If the name has no associated prefix or namespace informatio...
python
def get_ns_info_from_node_name(self, name, impl_node): """ Return a three-element tuple with the prefix, local name, and namespace URI for the given element/attribute name (in the context of the given node's hierarchy). If the name has no associated prefix or namespace informatio...
[ "def", "get_ns_info_from_node_name", "(", "self", ",", "name", ",", "impl_node", ")", ":", "if", "'}'", "in", "name", ":", "ns_uri", ",", "name", "=", "name", ".", "split", "(", "'}'", ")", "ns_uri", "=", "ns_uri", "[", "1", ":", "]", "prefix", "=", ...
Return a three-element tuple with the prefix, local name, and namespace URI for the given element/attribute name (in the context of the given node's hierarchy). If the name has no associated prefix or namespace information, None is return for those tuple members.
[ "Return", "a", "three", "-", "element", "tuple", "with", "the", "prefix", "local", "name", "and", "namespace", "URI", "for", "the", "given", "element", "/", "attribute", "name", "(", "in", "the", "context", "of", "the", "given", "node", "s", "hierarchy", ...
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/interface.py#L141-L161
jmurty/xml4h
xml4h/builder.py
Builder.up
def up(self, count=1, to_name=None): """ :return: a builder representing an ancestor of the current element, by default the parent element. :param count: return the n'th ancestor element; defaults to 1 which means the immediate parent. If *count* is greater than the...
python
def up(self, count=1, to_name=None): """ :return: a builder representing an ancestor of the current element, by default the parent element. :param count: return the n'th ancestor element; defaults to 1 which means the immediate parent. If *count* is greater than the...
[ "def", "up", "(", "self", ",", "count", "=", "1", ",", "to_name", "=", "None", ")", ":", "elem", "=", "self", ".", "_element", "up_count", "=", "0", "while", "True", ":", "# Don't go up beyond the document root", "if", "elem", ".", "is_root", "or", "elem...
:return: a builder representing an ancestor of the current element, by default the parent element. :param count: return the n'th ancestor element; defaults to 1 which means the immediate parent. If *count* is greater than the number of number of ancestors return the doc...
[ ":", "return", ":", "a", "builder", "representing", "an", "ancestor", "of", "the", "current", "element", "by", "default", "the", "parent", "element", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L103-L131
jmurty/xml4h
xml4h/builder.py
Builder.element
def element(self, *args, **kwargs): """ Add a child element to the :class:`xml4h.nodes.Element` node represented by this Builder. :return: a new Builder that represents the child element. Delegates to :meth:`xml4h.nodes.Element.add_element`. """ child_element = ...
python
def element(self, *args, **kwargs): """ Add a child element to the :class:`xml4h.nodes.Element` node represented by this Builder. :return: a new Builder that represents the child element. Delegates to :meth:`xml4h.nodes.Element.add_element`. """ child_element = ...
[ "def", "element", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "child_element", "=", "self", ".", "_element", ".", "add_element", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "Builder", "(", "child_element", ")" ]
Add a child element to the :class:`xml4h.nodes.Element` node represented by this Builder. :return: a new Builder that represents the child element. Delegates to :meth:`xml4h.nodes.Element.add_element`.
[ "Add", "a", "child", "element", "to", "the", ":", "class", ":", "xml4h", ".", "nodes", ".", "Element", "node", "represented", "by", "this", "Builder", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L159-L169
jmurty/xml4h
xml4h/builder.py
Builder.attributes
def attributes(self, *args, **kwargs): """ Add one or more attributes to the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.set_attributes`. """ self._element.set_attributes(*a...
python
def attributes(self, *args, **kwargs): """ Add one or more attributes to the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.set_attributes`. """ self._element.set_attributes(*a...
[ "def", "attributes", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_element", ".", "set_attributes", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "self" ]
Add one or more attributes to the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.set_attributes`.
[ "Add", "one", "or", "more", "attributes", "to", "the", ":", "class", ":", "xml4h", ".", "nodes", ".", "Element", "node", "represented", "by", "this", "Builder", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L177-L187
jmurty/xml4h
xml4h/builder.py
Builder.processing_instruction
def processing_instruction(self, target, data): """ Add a processing instruction node to the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.add_instruction`. """ self._element....
python
def processing_instruction(self, target, data): """ Add a processing instruction node to the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.add_instruction`. """ self._element....
[ "def", "processing_instruction", "(", "self", ",", "target", ",", "data", ")", ":", "self", ".", "_element", ".", "add_instruction", "(", "target", ",", "data", ")", "return", "self" ]
Add a processing instruction node to the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.add_instruction`.
[ "Add", "a", "processing", "instruction", "node", "to", "the", ":", "class", ":", "xml4h", ".", "nodes", ".", "Element", "node", "represented", "by", "this", "Builder", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L225-L235
jmurty/xml4h
xml4h/builder.py
Builder.ns_prefix
def ns_prefix(self, prefix, ns_uri): """ Set the namespace prefix of the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.set_ns_prefix`. """ self._element.set_ns_prefix(prefix, ...
python
def ns_prefix(self, prefix, ns_uri): """ Set the namespace prefix of the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.set_ns_prefix`. """ self._element.set_ns_prefix(prefix, ...
[ "def", "ns_prefix", "(", "self", ",", "prefix", ",", "ns_uri", ")", ":", "self", ".", "_element", ".", "set_ns_prefix", "(", "prefix", ",", "ns_uri", ")", "return", "self" ]
Set the namespace prefix of the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.set_ns_prefix`.
[ "Set", "the", "namespace", "prefix", "of", "the", ":", "class", ":", "xml4h", ".", "nodes", ".", "Element", "node", "represented", "by", "this", "Builder", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L261-L271
redhat-cip/dci-control-server
dci/api/v1/utils.py
createCertRequest
def createCertRequest(pkey, digest="sha256"): """ Create a certificate request. Arguments: pkey - The key to associate with the request digest - Digestion method to use for signing, default is sha256 **name - The name of the subject of the request, possible ...
python
def createCertRequest(pkey, digest="sha256"): """ Create a certificate request. Arguments: pkey - The key to associate with the request digest - Digestion method to use for signing, default is sha256 **name - The name of the subject of the request, possible ...
[ "def", "createCertRequest", "(", "pkey", ",", "digest", "=", "\"sha256\"", ")", ":", "req", "=", "crypto", ".", "X509Req", "(", ")", "req", ".", "get_subject", "(", ")", ".", "C", "=", "\"FR\"", "req", ".", "get_subject", "(", ")", ".", "ST", "=", ...
Create a certificate request. Arguments: pkey - The key to associate with the request digest - Digestion method to use for signing, default is sha256 **name - The name of the subject of the request, possible arguments are: C - Cou...
[ "Create", "a", "certificate", "request", ".", "Arguments", ":", "pkey", "-", "The", "key", "to", "associate", "with", "the", "request", "digest", "-", "Digestion", "method", "to", "use", "for", "signing", "default", "is", "sha256", "**", "name", "-", "The"...
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L41-L68
redhat-cip/dci-control-server
dci/api/v1/utils.py
verify_existence_and_get
def verify_existence_and_get(id, table, name=None, get_id=False): """Verify the existence of a resource in the database and then return it if it exists, according to the condition, or raise an exception. :param id: id of the resource :param table: the table object :param name: the name of the r...
python
def verify_existence_and_get(id, table, name=None, get_id=False): """Verify the existence of a resource in the database and then return it if it exists, according to the condition, or raise an exception. :param id: id of the resource :param table: the table object :param name: the name of the r...
[ "def", "verify_existence_and_get", "(", "id", ",", "table", ",", "name", "=", "None", ",", "get_id", "=", "False", ")", ":", "where_clause", "=", "table", ".", "c", ".", "id", "==", "id", "if", "name", ":", "where_clause", "=", "table", ".", "c", "."...
Verify the existence of a resource in the database and then return it if it exists, according to the condition, or raise an exception. :param id: id of the resource :param table: the table object :param name: the name of the row to look for :param get_id: if True, return only the ID :return...
[ "Verify", "the", "existence", "of", "a", "resource", "in", "the", "database", "and", "then", "return", "it", "if", "it", "exists", "according", "to", "the", "condition", "or", "raise", "an", "exception", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L91-L118
redhat-cip/dci-control-server
dci/api/v1/utils.py
user_topic_ids
def user_topic_ids(user): """Retrieve the list of topics IDs a user has access to.""" if user.is_super_admin() or user.is_read_only_user(): query = sql.select([models.TOPICS]) else: query = (sql.select([models.JOINS_TOPICS_TEAMS.c.topic_id]) .select_from( ...
python
def user_topic_ids(user): """Retrieve the list of topics IDs a user has access to.""" if user.is_super_admin() or user.is_read_only_user(): query = sql.select([models.TOPICS]) else: query = (sql.select([models.JOINS_TOPICS_TEAMS.c.topic_id]) .select_from( ...
[ "def", "user_topic_ids", "(", "user", ")", ":", "if", "user", ".", "is_super_admin", "(", ")", "or", "user", ".", "is_read_only_user", "(", ")", ":", "query", "=", "sql", ".", "select", "(", "[", "models", ".", "TOPICS", "]", ")", "else", ":", "query...
Retrieve the list of topics IDs a user has access to.
[ "Retrieve", "the", "list", "of", "topics", "IDs", "a", "user", "has", "access", "to", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L121-L137
redhat-cip/dci-control-server
dci/api/v1/utils.py
verify_team_in_topic
def verify_team_in_topic(user, topic_id): """Verify that the user's team does belongs to the given topic. If the user is an admin or read only user then it belongs to all topics. """ if user.is_super_admin() or user.is_read_only_user(): return if str(topic_id) not in user_topic_ids(user): ...
python
def verify_team_in_topic(user, topic_id): """Verify that the user's team does belongs to the given topic. If the user is an admin or read only user then it belongs to all topics. """ if user.is_super_admin() or user.is_read_only_user(): return if str(topic_id) not in user_topic_ids(user): ...
[ "def", "verify_team_in_topic", "(", "user", ",", "topic_id", ")", ":", "if", "user", ".", "is_super_admin", "(", ")", "or", "user", ".", "is_read_only_user", "(", ")", ":", "return", "if", "str", "(", "topic_id", ")", "not", "in", "user_topic_ids", "(", ...
Verify that the user's team does belongs to the given topic. If the user is an admin or read only user then it belongs to all topics.
[ "Verify", "that", "the", "user", "s", "team", "does", "belongs", "to", "the", "given", "topic", ".", "If", "the", "user", "is", "an", "admin", "or", "read", "only", "user", "then", "it", "belongs", "to", "all", "topics", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L140-L147
redhat-cip/dci-control-server
dci/api/v1/utils.py
_format_level_1
def _format_level_1(rows, root_table_name): """ Transform sqlalchemy source: [{'a_id' : 'id1', 'a_name' : 'name1, 'b_id' : 'id2', 'b_name' : 'name2}, {'a_id' : 'id3', 'a_name' : 'name3, 'b_id' : 'id4', 'b_name' : 'name4} ] to [{'id' : 'id1', 'name':...
python
def _format_level_1(rows, root_table_name): """ Transform sqlalchemy source: [{'a_id' : 'id1', 'a_name' : 'name1, 'b_id' : 'id2', 'b_name' : 'name2}, {'a_id' : 'id3', 'a_name' : 'name3, 'b_id' : 'id4', 'b_name' : 'name4} ] to [{'id' : 'id1', 'name':...
[ "def", "_format_level_1", "(", "rows", ",", "root_table_name", ")", ":", "result_rows", "=", "[", "]", "for", "row", "in", "rows", ":", "row", "=", "dict", "(", "row", ")", "result_row", "=", "{", "}", "prefixes_to_remove", "=", "[", "]", "for", "field...
Transform sqlalchemy source: [{'a_id' : 'id1', 'a_name' : 'name1, 'b_id' : 'id2', 'b_name' : 'name2}, {'a_id' : 'id3', 'a_name' : 'name3, 'b_id' : 'id4', 'b_name' : 'name4} ] to [{'id' : 'id1', 'name': 'name2', 'b' : {'id': 'id2', 'name': 'name2'}, ...
[ "Transform", "sqlalchemy", "source", ":", "[", "{", "a_id", ":", "id1", "a_name", ":", "name1", "b_id", ":", "id2", "b_name", ":", "name2", "}", "{", "a_id", ":", "id3", "a_name", ":", "name3", "b_id", ":", "id4", "b_name", ":", "name4", "}", "]", ...
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L417-L463
redhat-cip/dci-control-server
dci/api/v1/utils.py
_format_level_2
def _format_level_2(rows, list_embeds, embed_many): """ From the _format_level_1 function we have a list of rows. Because of using joins, we have as many rows as join result. For example: [{'id' : 'id1', 'name' : 'name1, 'b' : {'id': 'id2, 'name': 'name2'} } {'id'...
python
def _format_level_2(rows, list_embeds, embed_many): """ From the _format_level_1 function we have a list of rows. Because of using joins, we have as many rows as join result. For example: [{'id' : 'id1', 'name' : 'name1, 'b' : {'id': 'id2, 'name': 'name2'} } {'id'...
[ "def", "_format_level_2", "(", "rows", ",", "list_embeds", ",", "embed_many", ")", ":", "def", "_uniqify_list", "(", "list_of_dicts", ")", ":", "# list() for py34", "result", "=", "[", "]", "set_ids", "=", "set", "(", ")", "for", "v", "in", "list_of_dicts", ...
From the _format_level_1 function we have a list of rows. Because of using joins, we have as many rows as join result. For example: [{'id' : 'id1', 'name' : 'name1, 'b' : {'id': 'id2, 'name': 'name2'} } {'id' : 'id1', 'name' : 'name1, 'b' : {'id' : 'id4', ...
[ "From", "the", "_format_level_1", "function", "we", "have", "a", "list", "of", "rows", ".", "Because", "of", "using", "joins", "we", "have", "as", "many", "rows", "as", "join", "result", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L466-L575
redhat-cip/dci-control-server
dci/api/v1/utils.py
common_values_dict
def common_values_dict(): """Build a basic values object used in every create method. All our resources contain a same subset of value. Instead of redoing this code everytime, this method ensures it is done only at one place. """ now = datetime.datetime.utcnow().isoformat() etag = ...
python
def common_values_dict(): """Build a basic values object used in every create method. All our resources contain a same subset of value. Instead of redoing this code everytime, this method ensures it is done only at one place. """ now = datetime.datetime.utcnow().isoformat() etag = ...
[ "def", "common_values_dict", "(", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ".", "isoformat", "(", ")", "etag", "=", "utils", ".", "gen_etag", "(", ")", "values", "=", "{", "'id'", ":", "utils", ".", "gen_uuid", "(",...
Build a basic values object used in every create method. All our resources contain a same subset of value. Instead of redoing this code everytime, this method ensures it is done only at one place.
[ "Build", "a", "basic", "values", "object", "used", "in", "every", "create", "method", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L586-L602
redhat-cip/dci-control-server
dci/api/v1/utils.py
QueryBuilder.execute
def execute(self, fetchall=False, fetchone=False, use_labels=True): """ :param fetchall: get all rows :param fetchone: get only one row :param use_labels: prefix row columns names by the table name :return: """ query = self.get_query(use_labels=use_labels) ...
python
def execute(self, fetchall=False, fetchone=False, use_labels=True): """ :param fetchall: get all rows :param fetchone: get only one row :param use_labels: prefix row columns names by the table name :return: """ query = self.get_query(use_labels=use_labels) ...
[ "def", "execute", "(", "self", ",", "fetchall", "=", "False", ",", "fetchone", "=", "False", ",", "use_labels", "=", "True", ")", ":", "query", "=", "self", ".", "get_query", "(", "use_labels", "=", "use_labels", ")", "if", "fetchall", ":", "return", "...
:param fetchall: get all rows :param fetchone: get only one row :param use_labels: prefix row columns names by the table name :return:
[ ":", "param", "fetchall", ":", "get", "all", "rows", ":", "param", "fetchone", ":", "get", "only", "one", "row", ":", "param", "use_labels", ":", "prefix", "row", "columns", "names", "by", "the", "table", "name", ":", "return", ":" ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L399-L410
redhat-cip/dci-control-server
dci/api/v1/identity.py
get_identity
def get_identity(identity): """Returns some information about the currently authenticated identity""" return flask.Response( json.dumps( { 'identity': { 'id': identity.id, 'etag': identity.etag, 'name': identity.name...
python
def get_identity(identity): """Returns some information about the currently authenticated identity""" return flask.Response( json.dumps( { 'identity': { 'id': identity.id, 'etag': identity.etag, 'name': identity.name...
[ "def", "get_identity", "(", "identity", ")", ":", "return", "flask", ".", "Response", "(", "json", ".", "dumps", "(", "{", "'identity'", ":", "{", "'id'", ":", "identity", ".", "id", ",", "'etag'", ":", "identity", ".", "etag", ",", "'name'", ":", "i...
Returns some information about the currently authenticated identity
[ "Returns", "some", "information", "about", "the", "currently", "authenticated", "identity" ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/identity.py#L36-L54
redhat-cip/dci-control-server
dci/api/v1/issues.py
get_issues_by_resource
def get_issues_by_resource(resource_id, table): """Get all issues for a specific job.""" v1_utils.verify_existence_and_get(resource_id, table) # When retrieving the issues for a job, we actually retrieve # the issues attach to the job itself + the issues attached to # the components the job has be...
python
def get_issues_by_resource(resource_id, table): """Get all issues for a specific job.""" v1_utils.verify_existence_and_get(resource_id, table) # When retrieving the issues for a job, we actually retrieve # the issues attach to the job itself + the issues attached to # the components the job has be...
[ "def", "get_issues_by_resource", "(", "resource_id", ",", "table", ")", ":", "v1_utils", ".", "verify_existence_and_get", "(", "resource_id", ",", "table", ")", "# When retrieving the issues for a job, we actually retrieve", "# the issues attach to the job itself + the issues attac...
Get all issues for a specific job.
[ "Get", "all", "issues", "for", "a", "specific", "job", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/issues.py#L63-L127
redhat-cip/dci-control-server
dci/api/v1/issues.py
unattach_issue
def unattach_issue(resource_id, issue_id, table): """Unattach an issue from a specific job.""" v1_utils.verify_existence_and_get(issue_id, _TABLE) if table.name == 'jobs': join_table = models.JOIN_JOBS_ISSUES where_clause = sql.and_(join_table.c.job_id == resource_id, ...
python
def unattach_issue(resource_id, issue_id, table): """Unattach an issue from a specific job.""" v1_utils.verify_existence_and_get(issue_id, _TABLE) if table.name == 'jobs': join_table = models.JOIN_JOBS_ISSUES where_clause = sql.and_(join_table.c.job_id == resource_id, ...
[ "def", "unattach_issue", "(", "resource_id", ",", "issue_id", ",", "table", ")", ":", "v1_utils", ".", "verify_existence_and_get", "(", "issue_id", ",", "_TABLE", ")", "if", "table", ".", "name", "==", "'jobs'", ":", "join_table", "=", "models", ".", "JOIN_J...
Unattach an issue from a specific job.
[ "Unattach", "an", "issue", "from", "a", "specific", "job", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/issues.py#L130-L149
redhat-cip/dci-control-server
dci/api/v1/issues.py
attach_issue
def attach_issue(resource_id, table, user_id): """Attach an issue to a specific job.""" data = schemas.issue.post(flask.request.json) issue = _get_or_create_issue(data) # Second, insert a join record in the JOIN_JOBS_ISSUES or # JOIN_COMPONENTS_ISSUES database. if table.name == 'jobs': ...
python
def attach_issue(resource_id, table, user_id): """Attach an issue to a specific job.""" data = schemas.issue.post(flask.request.json) issue = _get_or_create_issue(data) # Second, insert a join record in the JOIN_JOBS_ISSUES or # JOIN_COMPONENTS_ISSUES database. if table.name == 'jobs': ...
[ "def", "attach_issue", "(", "resource_id", ",", "table", ",", "user_id", ")", ":", "data", "=", "schemas", ".", "issue", ".", "post", "(", "flask", ".", "request", ".", "json", ")", "issue", "=", "_get_or_create_issue", "(", "data", ")", "# Second, insert ...
Attach an issue to a specific job.
[ "Attach", "an", "issue", "to", "a", "specific", "job", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/issues.py#L152-L178
inveniosoftware/invenio-assets
invenio_assets/collect.py
collect_staticroot_removal
def collect_staticroot_removal(app, blueprints): """Remove collect's static root folder from list.""" collect_root = app.extensions['collect'].static_root return [bp for bp in blueprints if ( bp.has_static_folder and bp.static_folder != collect_root)]
python
def collect_staticroot_removal(app, blueprints): """Remove collect's static root folder from list.""" collect_root = app.extensions['collect'].static_root return [bp for bp in blueprints if ( bp.has_static_folder and bp.static_folder != collect_root)]
[ "def", "collect_staticroot_removal", "(", "app", ",", "blueprints", ")", ":", "collect_root", "=", "app", ".", "extensions", "[", "'collect'", "]", ".", "static_root", "return", "[", "bp", "for", "bp", "in", "blueprints", "if", "(", "bp", ".", "has_static_fo...
Remove collect's static root folder from list.
[ "Remove", "collect", "s", "static", "root", "folder", "from", "list", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/collect.py#L14-L18
redhat-cip/dci-control-server
dci/api/v1/jobstates.py
get_all_jobstates
def get_all_jobstates(user, job_id): """Get all jobstates. """ args = schemas.args(flask.request.args.to_dict()) job = v1_utils.verify_existence_and_get(job_id, models.JOBS) if user.is_not_super_admin() and user.is_not_read_only_user(): if (job['team_id'] not in user.teams_ids and ...
python
def get_all_jobstates(user, job_id): """Get all jobstates. """ args = schemas.args(flask.request.args.to_dict()) job = v1_utils.verify_existence_and_get(job_id, models.JOBS) if user.is_not_super_admin() and user.is_not_read_only_user(): if (job['team_id'] not in user.teams_ids and ...
[ "def", "get_all_jobstates", "(", "user", ",", "job_id", ")", ":", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "job", "=", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", ...
Get all jobstates.
[ "Get", "all", "jobstates", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobstates.py#L100-L118
redhat-cip/dci-control-server
bin/keycloak-provision.py
create_client
def create_client(access_token): """Create the dci client in the master realm.""" url = 'http://keycloak:8080/auth/admin/realms/dci-test/clients' r = requests.post(url, data=json.dumps(client_data), headers=get_auth_headers(access_token)) if r.status_code in (...
python
def create_client(access_token): """Create the dci client in the master realm.""" url = 'http://keycloak:8080/auth/admin/realms/dci-test/clients' r = requests.post(url, data=json.dumps(client_data), headers=get_auth_headers(access_token)) if r.status_code in (...
[ "def", "create_client", "(", "access_token", ")", ":", "url", "=", "'http://keycloak:8080/auth/admin/realms/dci-test/clients'", "r", "=", "requests", ".", "post", "(", "url", ",", "data", "=", "json", ".", "dumps", "(", "client_data", ")", ",", "headers", "=", ...
Create the dci client in the master realm.
[ "Create", "the", "dci", "client", "in", "the", "master", "realm", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/bin/keycloak-provision.py#L193-L205
redhat-cip/dci-control-server
bin/keycloak-provision.py
create_user_dci
def create_user_dci(access_token): """Create the a dci user. username=dci, password=dci, email=dci@distributed-ci.io""" user_data = {'username': 'dci', 'email': 'dci@distributed-ci.io', 'enabled': True, 'emailVerified': True, 'credentials':...
python
def create_user_dci(access_token): """Create the a dci user. username=dci, password=dci, email=dci@distributed-ci.io""" user_data = {'username': 'dci', 'email': 'dci@distributed-ci.io', 'enabled': True, 'emailVerified': True, 'credentials':...
[ "def", "create_user_dci", "(", "access_token", ")", ":", "user_data", "=", "{", "'username'", ":", "'dci'", ",", "'email'", ":", "'dci@distributed-ci.io'", ",", "'enabled'", ":", "True", ",", "'emailVerified'", ":", "True", ",", "'credentials'", ":", "[", "{",...
Create the a dci user. username=dci, password=dci, email=dci@distributed-ci.io
[ "Create", "the", "a", "dci", "user", ".", "username", "=", "dci", "password", "=", "dci", "email", "=", "dci" ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/bin/keycloak-provision.py#L208-L224
mediawiki-utilities/python-mwxml
mwxml/iteration/site_info.py
SiteInfo.initialize
def initialize(self, name=None, dbname=None, base=None, generator=None, case=None, namespaces=None): self.name = none_or(name, str) """ The name of the site. : str | `None` """ self.dbname = none_or(dbname, str) """ The dbname of the site. : s...
python
def initialize(self, name=None, dbname=None, base=None, generator=None, case=None, namespaces=None): self.name = none_or(name, str) """ The name of the site. : str | `None` """ self.dbname = none_or(dbname, str) """ The dbname of the site. : s...
[ "def", "initialize", "(", "self", ",", "name", "=", "None", ",", "dbname", "=", "None", ",", "base", "=", "None", ",", "generator", "=", "None", ",", "case", "=", "None", ",", "namespaces", "=", "None", ")", ":", "self", ".", "name", "=", "none_or"...
The name of the site. : str | `None`
[ "The", "name", "of", "the", "site", ".", ":", "str", "|", "None" ]
train
https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/iteration/site_info.py#L32-L63
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom._serializeBooleans
def _serializeBooleans(params): """"Convert all booleans to lowercase strings""" serialized = {} for name, value in params.items(): if value is True: value = 'true' elif value is False: value = 'false' serialized[name] = value ...
python
def _serializeBooleans(params): """"Convert all booleans to lowercase strings""" serialized = {} for name, value in params.items(): if value is True: value = 'true' elif value is False: value = 'false' serialized[name] = value ...
[ "def", "_serializeBooleans", "(", "params", ")", ":", "serialized", "=", "{", "}", "for", "name", ",", "value", "in", "params", ".", "items", "(", ")", ":", "if", "value", "is", "True", ":", "value", "=", "'true'", "elif", "value", "is", "False", ":"...
Convert all booleans to lowercase strings
[ "Convert", "all", "booleans", "to", "lowercase", "strings" ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L37-L50
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.request
def request(self, method, url, parameters=dict()): """Requests wrapper function""" # The requests library uses urllib, which serializes to "True"/"False" while Pingdom requires lowercase parameters = self._serializeBooleans(parameters) headers = {'App-Key': self.apikey} if self...
python
def request(self, method, url, parameters=dict()): """Requests wrapper function""" # The requests library uses urllib, which serializes to "True"/"False" while Pingdom requires lowercase parameters = self._serializeBooleans(parameters) headers = {'App-Key': self.apikey} if self...
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "parameters", "=", "dict", "(", ")", ")", ":", "# The requests library uses urllib, which serializes to \"True\"/\"False\" while Pingdom requires lowercase", "parameters", "=", "self", ".", "_serializeBooleans",...
Requests wrapper function
[ "Requests", "wrapper", "function" ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L52-L97
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.actions
def actions(self, **parameters): """Returns a list of actions (alerts) that have been generated for your account. Optional Parameters: * from -- Only include actions generated later than this timestamp. Format is UNIX time. Type: Integer ...
python
def actions(self, **parameters): """Returns a list of actions (alerts) that have been generated for your account. Optional Parameters: * from -- Only include actions generated later than this timestamp. Format is UNIX time. Type: Integer ...
[ "def", "actions", "(", "self", ",", "*", "*", "parameters", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "parameters", ":", "if", "key", "not", "in", "[", "'from'", ",", "'to'", ",", "'limit'", ",", "'offset'", ",", "'checkids'", ...
Returns a list of actions (alerts) that have been generated for your account. Optional Parameters: * from -- Only include actions generated later than this timestamp. Format is UNIX time. Type: Integer Default: None *...
[ "Returns", "a", "list", "of", "actions", "(", "alerts", ")", "that", "have", "been", "generated", "for", "your", "account", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L99-L183
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.getChecks
def getChecks(self, **parameters): """Pulls all checks from pingdom Optional Parameters: * limit -- Limits the number of returned probes to the specified quantity. Type: Integer (max 25000) Default: 25000 * offset -- Offs...
python
def getChecks(self, **parameters): """Pulls all checks from pingdom Optional Parameters: * limit -- Limits the number of returned probes to the specified quantity. Type: Integer (max 25000) Default: 25000 * offset -- Offs...
[ "def", "getChecks", "(", "self", ",", "*", "*", "parameters", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "parameters", ":", "if", "key", "not", "in", "[", "'limit'", ",", "'offset'", ",", "'tags'", "]", ":", "sys", ".", "stderr...
Pulls all checks from pingdom Optional Parameters: * limit -- Limits the number of returned probes to the specified quantity. Type: Integer (max 25000) Default: 25000 * offset -- Offset for listing (requires limit.) ...
[ "Pulls", "all", "checks", "from", "pingdom" ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L191-L219
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.getCheck
def getCheck(self, checkid): """Returns a detailed description of a specified check.""" check = PingdomCheck(self, {'id': checkid}) check.getDetails() return check
python
def getCheck(self, checkid): """Returns a detailed description of a specified check.""" check = PingdomCheck(self, {'id': checkid}) check.getDetails() return check
[ "def", "getCheck", "(", "self", ",", "checkid", ")", ":", "check", "=", "PingdomCheck", "(", "self", ",", "{", "'id'", ":", "checkid", "}", ")", "check", ".", "getDetails", "(", ")", "return", "check" ]
Returns a detailed description of a specified check.
[ "Returns", "a", "detailed", "description", "of", "a", "specified", "check", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L221-L226
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.probes
def probes(self, **kwargs): """Returns a list of all Pingdom probe servers Parameters: * limit -- Limits the number of returned probes to the specified quantity Type: Integer * offset -- Offset for listing (requires limit). ...
python
def probes(self, **kwargs): """Returns a list of all Pingdom probe servers Parameters: * limit -- Limits the number of returned probes to the specified quantity Type: Integer * offset -- Offset for listing (requires limit). ...
[ "def", "probes", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "kwargs", ":", "if", "key", "not", "in", "[", "'limit'", ",", "'offset'", ",", "'onlyactive'", ",", "'includedeleted'", "]", ":", ...
Returns a list of all Pingdom probe servers Parameters: * limit -- Limits the number of returned probes to the specified quantity Type: Integer * offset -- Offset for listing (requires limit). Type: Integer De...
[ "Returns", "a", "list", "of", "all", "Pingdom", "probe", "servers" ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L621-L664
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.traceroute
def traceroute(self, host, probeid): """Perform a traceroute to a specified target from a specified Pingdom probe. Provide hostname to check and probeid to check from Returned structure: { 'result' : <String> Traceroute output 'probeid'...
python
def traceroute(self, host, probeid): """Perform a traceroute to a specified target from a specified Pingdom probe. Provide hostname to check and probeid to check from Returned structure: { 'result' : <String> Traceroute output 'probeid'...
[ "def", "traceroute", "(", "self", ",", "host", ",", "probeid", ")", ":", "response", "=", "self", ".", "request", "(", "'GET'", ",", "'traceroute'", ",", "{", "'host'", ":", "host", ",", "'probeid'", ":", "probeid", "}", ")", "return", "response", ".",...
Perform a traceroute to a specified target from a specified Pingdom probe. Provide hostname to check and probeid to check from Returned structure: { 'result' : <String> Traceroute output 'probeid' : <Integer> Probe identifier ...
[ "Perform", "a", "traceroute", "to", "a", "specified", "target", "from", "a", "specified", "Pingdom", "probe", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L733-L749
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.getContacts
def getContacts(self, **kwargs): """Returns a list of all contacts. Optional Parameters: * limit -- Limits the number of returned contacts to the specified quantity. Type: Integer Default: 100 * offset -- Offset for listi...
python
def getContacts(self, **kwargs): """Returns a list of all contacts. Optional Parameters: * limit -- Limits the number of returned contacts to the specified quantity. Type: Integer Default: 100 * offset -- Offset for listi...
[ "def", "getContacts", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "kwargs", ":", "if", "key", "not", "in", "[", "'limit'", ",", "'offset'", "]", ":", "sys", ".", "stderr", ".", "write", "(...
Returns a list of all contacts. Optional Parameters: * limit -- Limits the number of returned contacts to the specified quantity. Type: Integer Default: 100 * offset -- Offset for listing (requires limit.) Typ...
[ "Returns", "a", "list", "of", "all", "contacts", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L756-L793
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.newContact
def newContact(self, name, **kwargs): """Create a new contact. Provide new contact name and any optional arguments. Returns new PingdomContact instance Optional Parameters: * email -- Contact email address Type: String * cellphone -- Ce...
python
def newContact(self, name, **kwargs): """Create a new contact. Provide new contact name and any optional arguments. Returns new PingdomContact instance Optional Parameters: * email -- Contact email address Type: String * cellphone -- Ce...
[ "def", "newContact", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "kwargs", ":", "if", "key", "not", "in", "[", "'email'", ",", "'cellphone'", ",", "'countrycode'", ",", "'countryi...
Create a new contact. Provide new contact name and any optional arguments. Returns new PingdomContact instance Optional Parameters: * email -- Contact email address Type: String * cellphone -- Cellphone number, without the country code part. In...
[ "Create", "a", "new", "contact", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L795-L844
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.modifyContacts
def modifyContacts(self, contactids, paused): """Modifies a list of contacts. Provide comma separated list of contact ids and desired paused state Returns status message """ response = self.request("PUT", "notification_contacts", {'contactids': contactids, ...
python
def modifyContacts(self, contactids, paused): """Modifies a list of contacts. Provide comma separated list of contact ids and desired paused state Returns status message """ response = self.request("PUT", "notification_contacts", {'contactids': contactids, ...
[ "def", "modifyContacts", "(", "self", ",", "contactids", ",", "paused", ")", ":", "response", "=", "self", ".", "request", "(", "\"PUT\"", ",", "\"notification_contacts\"", ",", "{", "'contactids'", ":", "contactids", ",", "'paused'", ":", "paused", "}", ")"...
Modifies a list of contacts. Provide comma separated list of contact ids and desired paused state Returns status message
[ "Modifies", "a", "list", "of", "contacts", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L846-L856
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.getEmailReports
def getEmailReports(self): """Returns a list of PingdomEmailReport instances.""" reports = [PingdomEmailReport(self, x) for x in self.request('GET', 'reports.email').json()['subscriptions']] return reports
python
def getEmailReports(self): """Returns a list of PingdomEmailReport instances.""" reports = [PingdomEmailReport(self, x) for x in self.request('GET', 'reports.email').json()['subscriptions']] return reports
[ "def", "getEmailReports", "(", "self", ")", ":", "reports", "=", "[", "PingdomEmailReport", "(", "self", ",", "x", ")", "for", "x", "in", "self", ".", "request", "(", "'GET'", ",", "'reports.email'", ")", ".", "json", "(", ")", "[", "'subscriptions'", ...
Returns a list of PingdomEmailReport instances.
[ "Returns", "a", "list", "of", "PingdomEmailReport", "instances", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1170-L1177
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.newEmailReport
def newEmailReport(self, name, **kwargs): """Creates a new email report Returns status message for operation Optional parameters: * checkid -- Check identifier. If omitted, this will be an overview report Type: Integer * frequency -...
python
def newEmailReport(self, name, **kwargs): """Creates a new email report Returns status message for operation Optional parameters: * checkid -- Check identifier. If omitted, this will be an overview report Type: Integer * frequency -...
[ "def", "newEmailReport", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "kwargs", ":", "if", "key", "not", "in", "[", "'checkid'", ",", "'frequency'", ",", "'contactids'", ",", "'add...
Creates a new email report Returns status message for operation Optional parameters: * checkid -- Check identifier. If omitted, this will be an overview report Type: Integer * frequency -- Report frequency Type: String [...
[ "Creates", "a", "new", "email", "report" ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1179-L1214
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.getSharedReports
def getSharedReports(self): """Returns a list of PingdomSharedReport instances""" response = self.request('GET', 'reports.shared').json()['shared']['banners'] reports = [PingdomSharedReport(self, x) for x in response] return reports
python
def getSharedReports(self): """Returns a list of PingdomSharedReport instances""" response = self.request('GET', 'reports.shared').json()['shared']['banners'] reports = [PingdomSharedReport(self, x) for x in response] return reports
[ "def", "getSharedReports", "(", "self", ")", ":", "response", "=", "self", ".", "request", "(", "'GET'", ",", "'reports.shared'", ")", ".", "json", "(", ")", "[", "'shared'", "]", "[", "'banners'", "]", "reports", "=", "[", "PingdomSharedReport", "(", "s...
Returns a list of PingdomSharedReport instances
[ "Returns", "a", "list", "of", "PingdomSharedReport", "instances" ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1232-L1239
KennethWilke/PingdomLib
pingdomlib/pingdom.py
Pingdom.newSharedReport
def newSharedReport(self, checkid, **kwargs): """Create a shared report (banner). Returns status message for operation Optional parameters: * auto -- Automatic period (If false, requires: fromyear, frommonth, fromday, toyear, tomonth, today) Typ...
python
def newSharedReport(self, checkid, **kwargs): """Create a shared report (banner). Returns status message for operation Optional parameters: * auto -- Automatic period (If false, requires: fromyear, frommonth, fromday, toyear, tomonth, today) Typ...
[ "def", "newSharedReport", "(", "self", ",", "checkid", ",", "*", "*", "kwargs", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "kwargs", ":", "if", "key", "not", "in", "[", "'auto'", ",", "'type'", ",", "'fromyear'", ",", "'frommonth...
Create a shared report (banner). Returns status message for operation Optional parameters: * auto -- Automatic period (If false, requires: fromyear, frommonth, fromday, toyear, tomonth, today) Type: Boolean * type -- Banner type ...
[ "Create", "a", "shared", "report", "(", "banner", ")", "." ]
train
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1241-L1286
Antidote1911/cryptoshop
cryptoshop/_cascade_engine.py
encry_decry_cascade
def encry_decry_cascade(data, masterkey, bool_encry, assoc_data): """ When bool_encry is True, encrypt the data with master key. When it is False, the function extract the three nonce from the encrypted data (first 3*21 bytes), and decrypt the data. :param data: the data to encrypt or decrypt. :para...
python
def encry_decry_cascade(data, masterkey, bool_encry, assoc_data): """ When bool_encry is True, encrypt the data with master key. When it is False, the function extract the three nonce from the encrypted data (first 3*21 bytes), and decrypt the data. :param data: the data to encrypt or decrypt. :para...
[ "def", "encry_decry_cascade", "(", "data", ",", "masterkey", ",", "bool_encry", ",", "assoc_data", ")", ":", "engine1", "=", "botan", ".", "cipher", "(", "algo", "=", "\"Serpent/GCM\"", ",", "encrypt", "=", "bool_encry", ")", "engine2", "=", "botan", ".", ...
When bool_encry is True, encrypt the data with master key. When it is False, the function extract the three nonce from the encrypted data (first 3*21 bytes), and decrypt the data. :param data: the data to encrypt or decrypt. :param masterkey: a 32 bytes key in bytes. :param bool_encry: if bool_encry is ...
[ "When", "bool_encry", "is", "True", "encrypt", "the", "data", "with", "master", "key", ".", "When", "it", "is", "False", "the", "function", "extract", "the", "three", "nonce", "from", "the", "encrypted", "data", "(", "first", "3", "*", "21", "bytes", ")"...
train
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_cascade_engine.py#L39-L104
BrighterCommand/Brightside
brightside/registry.py
Registry.register
def register(self, request_class: Request, handler_factory: Callable[[], Handler]) -> None: """ Register the handler for the command :param request_class: The command or event to dispatch. It must implement getKey() :param handler_factory: A factory method to create the handler to dispat...
python
def register(self, request_class: Request, handler_factory: Callable[[], Handler]) -> None: """ Register the handler for the command :param request_class: The command or event to dispatch. It must implement getKey() :param handler_factory: A factory method to create the handler to dispat...
[ "def", "register", "(", "self", ",", "request_class", ":", "Request", ",", "handler_factory", ":", "Callable", "[", "[", "]", ",", "Handler", "]", ")", "->", "None", ":", "key", "=", "request_class", ".", "__name__", "is_command", "=", "request_class", "."...
Register the handler for the command :param request_class: The command or event to dispatch. It must implement getKey() :param handler_factory: A factory method to create the handler to dispatch to :return:
[ "Register", "the", "handler", "for", "the", "command", ":", "param", "request_class", ":", "The", "command", "or", "event", "to", "dispatch", ".", "It", "must", "implement", "getKey", "()", ":", "param", "handler_factory", ":", "A", "factory", "method", "to"...
train
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L45-L61
BrighterCommand/Brightside
brightside/registry.py
Registry.lookup
def lookup(self, request: Request) -> List[Callable[[], Handler]]: """ Looks up the handler associated with a request - matches the key on the request to a registered handler :param request: The request we want to find a handler for :return: """ key = request.__class__.__...
python
def lookup(self, request: Request) -> List[Callable[[], Handler]]: """ Looks up the handler associated with a request - matches the key on the request to a registered handler :param request: The request we want to find a handler for :return: """ key = request.__class__.__...
[ "def", "lookup", "(", "self", ",", "request", ":", "Request", ")", "->", "List", "[", "Callable", "[", "[", "]", ",", "Handler", "]", "]", ":", "key", "=", "request", ".", "__class__", ".", "__name__", "if", "key", "not", "in", "self", ".", "_regis...
Looks up the handler associated with a request - matches the key on the request to a registered handler :param request: The request we want to find a handler for :return:
[ "Looks", "up", "the", "handler", "associated", "with", "a", "request", "-", "matches", "the", "key", "on", "the", "request", "to", "a", "registered", "handler", ":", "param", "request", ":", "The", "request", "we", "want", "to", "find", "a", "handler", "...
train
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L63-L76
BrighterCommand/Brightside
brightside/registry.py
MessageMapperRegistry.register
def register(self, request_class: Request, mapper_func: Callable[[Request], BrightsideMessage]) -> None: """Adds a message mapper to a factory, using the requests key :param mapper_func: A callback that creates a BrightsideMessage from a Request :param request_class: A request type """ ...
python
def register(self, request_class: Request, mapper_func: Callable[[Request], BrightsideMessage]) -> None: """Adds a message mapper to a factory, using the requests key :param mapper_func: A callback that creates a BrightsideMessage from a Request :param request_class: A request type """ ...
[ "def", "register", "(", "self", ",", "request_class", ":", "Request", ",", "mapper_func", ":", "Callable", "[", "[", "Request", "]", ",", "BrightsideMessage", "]", ")", "->", "None", ":", "key", "=", "request_class", ".", "__name__", "if", "key", "not", ...
Adds a message mapper to a factory, using the requests key :param mapper_func: A callback that creates a BrightsideMessage from a Request :param request_class: A request type
[ "Adds", "a", "message", "mapper", "to", "a", "factory", "using", "the", "requests", "key", ":", "param", "mapper_func", ":", "A", "callback", "that", "creates", "a", "BrightsideMessage", "from", "a", "Request", ":", "param", "request_class", ":", "A", "reque...
train
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L89-L99
BrighterCommand/Brightside
brightside/registry.py
MessageMapperRegistry.lookup
def lookup(self, request_class: Request) -> Callable[[Request], BrightsideMessage]: """ Looks up the message mapper function associated with this class. Function should take in a Request derived class and return a BrightsideMessage derived class, for sending on the wire :param request_c...
python
def lookup(self, request_class: Request) -> Callable[[Request], BrightsideMessage]: """ Looks up the message mapper function associated with this class. Function should take in a Request derived class and return a BrightsideMessage derived class, for sending on the wire :param request_c...
[ "def", "lookup", "(", "self", ",", "request_class", ":", "Request", ")", "->", "Callable", "[", "[", "Request", "]", ",", "BrightsideMessage", "]", ":", "key", "=", "request_class", ".", "__class__", ".", "__name__", "if", "key", "not", "in", "self", "."...
Looks up the message mapper function associated with this class. Function should take in a Request derived class and return a BrightsideMessage derived class, for sending on the wire :param request_class: :return:
[ "Looks", "up", "the", "message", "mapper", "function", "associated", "with", "this", "class", ".", "Function", "should", "take", "in", "a", "Request", "derived", "class", "and", "return", "a", "BrightsideMessage", "derived", "class", "for", "sending", "on", "t...
train
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L101-L112
smarie/python-valid8
valid8/validation_lib/types.py
instance_of
def instance_of(*args): """ This type validation function can be used in two modes: * providing two arguments (x, ref_type), it returns `True` if isinstance(x, ref_type) and raises a HasWrongType error if not. If ref_type is a set of types, any match with one of the included types will do * provi...
python
def instance_of(*args): """ This type validation function can be used in two modes: * providing two arguments (x, ref_type), it returns `True` if isinstance(x, ref_type) and raises a HasWrongType error if not. If ref_type is a set of types, any match with one of the included types will do * provi...
[ "def", "instance_of", "(", "*", "args", ")", ":", "if", "len", "(", "args", ")", "==", "2", ":", "# Standard mode", "value", ",", "ref_type", "=", "args", "if", "not", "isinstance", "(", "ref_type", ",", "set", ")", ":", "# ref_type is a single type", "i...
This type validation function can be used in two modes: * providing two arguments (x, ref_type), it returns `True` if isinstance(x, ref_type) and raises a HasWrongType error if not. If ref_type is a set of types, any match with one of the included types will do * providing a single argument (ref_type), t...
[ "This", "type", "validation", "function", "can", "be", "used", "in", "two", "modes", ":", "*", "providing", "two", "arguments", "(", "x", "ref_type", ")", "it", "returns", "True", "if", "isinstance", "(", "x", "ref_type", ")", "and", "raises", "a", "HasW...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/types.py#L15-L78
smarie/python-valid8
valid8/validation_lib/types.py
subclass_of
def subclass_of(*args): """ This type validation function can be used in two modes: * providing two arguments (c, ref_type), it returns `True` if issubclass(c, ref_type) and raises a IsWrongType error if not. If ref_type is a set of types, any match with one of the included types will do * provid...
python
def subclass_of(*args): """ This type validation function can be used in two modes: * providing two arguments (c, ref_type), it returns `True` if issubclass(c, ref_type) and raises a IsWrongType error if not. If ref_type is a set of types, any match with one of the included types will do * provid...
[ "def", "subclass_of", "(", "*", "args", ")", ":", "if", "len", "(", "args", ")", "==", "2", ":", "# Standard mode", "typ", ",", "ref_type", "=", "args", "if", "not", "isinstance", "(", "ref_type", ",", "set", ")", ":", "# ref_type is a single type", "if"...
This type validation function can be used in two modes: * providing two arguments (c, ref_type), it returns `True` if issubclass(c, ref_type) and raises a IsWrongType error if not. If ref_type is a set of types, any match with one of the included types will do * providing a single argument (ref_type), th...
[ "This", "type", "validation", "function", "can", "be", "used", "in", "two", "modes", ":", "*", "providing", "two", "arguments", "(", "c", "ref_type", ")", "it", "returns", "True", "if", "issubclass", "(", "c", "ref_type", ")", "and", "raises", "a", "IsWr...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/types.py#L92-L153
danijar/sets
sets/utility.py
disk_cache
def disk_cache(basename, directory, method=False): """ Function decorator for caching pickleable return values on disk. Uses a hash computed from the function arguments for invalidation. If 'method', skip the first argument, usually being self or cls. The cache filepath is 'directory/basename-hash.p...
python
def disk_cache(basename, directory, method=False): """ Function decorator for caching pickleable return values on disk. Uses a hash computed from the function arguments for invalidation. If 'method', skip the first argument, usually being self or cls. The cache filepath is 'directory/basename-hash.p...
[ "def", "disk_cache", "(", "basename", ",", "directory", ",", "method", "=", "False", ")", ":", "directory", "=", "os", ".", "path", ".", "expanduser", "(", "directory", ")", "ensure_directory", "(", "directory", ")", "def", "wrapper", "(", "func", ")", "...
Function decorator for caching pickleable return values on disk. Uses a hash computed from the function arguments for invalidation. If 'method', skip the first argument, usually being self or cls. The cache filepath is 'directory/basename-hash.pickle'.
[ "Function", "decorator", "for", "caching", "pickleable", "return", "values", "on", "disk", ".", "Uses", "a", "hash", "computed", "from", "the", "function", "arguments", "for", "invalidation", ".", "If", "method", "skip", "the", "first", "argument", "usually", ...
train
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/utility.py#L23-L51
danijar/sets
sets/utility.py
download
def download(url, directory, filename=None): """ Download a file and return its filename on the local file system. If the file is already there, it will not be downloaded again. The filename is derived from the url if not provided. Return the filepath. """ if not filename: _, filename = ...
python
def download(url, directory, filename=None): """ Download a file and return its filename on the local file system. If the file is already there, it will not be downloaded again. The filename is derived from the url if not provided. Return the filepath. """ if not filename: _, filename = ...
[ "def", "download", "(", "url", ",", "directory", ",", "filename", "=", "None", ")", ":", "if", "not", "filename", ":", "_", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "url", ")", "directory", "=", "os", ".", "path", ".", "expanduse...
Download a file and return its filename on the local file system. If the file is already there, it will not be downloaded again. The filename is derived from the url if not provided. Return the filepath.
[ "Download", "a", "file", "and", "return", "its", "filename", "on", "the", "local", "file", "system", ".", "If", "the", "file", "is", "already", "there", "it", "will", "not", "be", "downloaded", "again", ".", "The", "filename", "is", "derived", "from", "t...
train
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/utility.py#L53-L69