repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
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" ]
61f3fb0502c1f07a591388aaa7526e74c63eaeb1
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L9-L21
train
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", ":" ]
61f3fb0502c1f07a591388aaa7526e74c63eaeb1
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L37-L64
train
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", ":" ]
61f3fb0502c1f07a591388aaa7526e74c63eaeb1
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L66-L80
train
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", ":" ]
61f3fb0502c1f07a591388aaa7526e74c63eaeb1
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L82-L92
train
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...
a6d216d459644e01fbdfd5b318a535950bc5cdbb
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/searcher.py#L210-L250
train
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...
a6d216d459644e01fbdfd5b318a535950bc5cdbb
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/searcher.py#L340-L402
train
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", "." ]
a6d216d459644e01fbdfd5b318a535950bc5cdbb
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/searcher.py#L404-L414
train
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", "." ]
a6d216d459644e01fbdfd5b318a535950bc5cdbb
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/clientcredentials.py#L29-L58
train
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", "." ]
c0463edc599d96bc6f645084eb50e6e94e1f681a
https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/__init__.py#L37-L124
train
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" ]
beb750530045e4f7cf665675bfb28f82d6325007
https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L95-L99
train
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" ]
beb750530045e4f7cf665675bfb28f82d6325007
https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L131-L137
train
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" ]
beb750530045e4f7cf665675bfb28f82d6325007
https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L140-L145
train
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" ]
beb750530045e4f7cf665675bfb28f82d6325007
https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L148-L159
train
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", "." ]
2b3e96cb2e7703ee0402811096da8265a740f378
https://github.com/csirtgadgets/bearded-avenger-sdk-py/blob/2b3e96cb2e7703ee0402811096da8265a740f378/cifsdk/_version.py#L442-L495
train
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...
a6d216d459644e01fbdfd5b318a535950bc5cdbb
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/utilconfig.py#L6-L24
train
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", ")", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L45-L59
train
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", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L71-L74
train
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", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L77-L85
train
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", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L87-L92
train
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", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L110-L119
train
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", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L121-L133
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/auth_mechanism.py#L135-L149
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/trackers/github.py#L32-L62
train
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", "." ]
2542c28f43d0af18932cb5b82f54ffb6ae557d12
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/core/step.py#L12-L21
train
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", "." ]
2542c28f43d0af18932cb5b82f54ffb6ae557d12
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/core/step.py#L24-L28
train
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", "." ]
2542c28f43d0af18932cb5b82f54ffb6ae557d12
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/core/step.py#L31-L39
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/remotecis.py#L409-L427
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/remotecis.py#L430-L457
train
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"...
53b2f8323c3972609010a7386130249f3758f5fb
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/command_processor.py#L54-L65
train
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", "." ]
53b2f8323c3972609010a7386130249f3758f5fb
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/command_processor.py#L67-L76
train
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"...
53b2f8323c3972609010a7386130249f3758f5fb
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/command_processor.py#L78-L94
train
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", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/interface.py#L32-L44
train
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", ...
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/interface.py#L141-L161
train
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", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L103-L131
train
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", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L159-L169
train
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", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L177-L187
train
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", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L225-L235
train
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", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L261-L271
train
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"...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L41-L68
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L91-L118
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L121-L137
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L140-L147
train
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", "}", "]", ...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L417-L463
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L466-L575
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L586-L602
train
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", ":" ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L399-L410
train
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" ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/identity.py#L36-L54
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/issues.py#L63-L127
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/issues.py#L130-L149
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/issues.py#L152-L178
train
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", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/collect.py#L14-L18
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobstates.py#L100-L118
train
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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/bin/keycloak-provision.py#L193-L205
train
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" ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/bin/keycloak-provision.py#L208-L224
train
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" ]
6a8c18be99cd0bcee9c496e607f08bf4dfe5b510
https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/iteration/site_info.py#L32-L63
train
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" ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L37-L50
train
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" ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L52-L97
train
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", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L99-L183
train
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" ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L191-L219
train
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", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L221-L226
train
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" ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L621-L664
train
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", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L733-L749
train
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", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L756-L793
train
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", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L795-L844
train
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", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L846-L856
train
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", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1170-L1177
train
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" ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1179-L1214
train
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" ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1232-L1239
train
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", ")", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1241-L1286
train
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", ")"...
0b7ff4a6848f2733f4737606957e8042a4d6ca0b
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_cascade_engine.py#L39-L104
train
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"...
53b2f8323c3972609010a7386130249f3758f5fb
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L45-L61
train
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", "...
53b2f8323c3972609010a7386130249f3758f5fb
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L63-L76
train
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...
53b2f8323c3972609010a7386130249f3758f5fb
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L89-L99
train
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...
53b2f8323c3972609010a7386130249f3758f5fb
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L101-L112
train
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...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/types.py#L15-L78
train
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...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/types.py#L92-L153
train
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", ...
2542c28f43d0af18932cb5b82f54ffb6ae557d12
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/utility.py#L23-L51
train
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...
2542c28f43d0af18932cb5b82f54ffb6ae557d12
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/utility.py#L53-L69
train
danijar/sets
sets/utility.py
ensure_directory
def ensure_directory(directory): """ Create the directories along the provided directory path that do not exist. """ directory = os.path.expanduser(directory) try: os.makedirs(directory) except OSError as e: if e.errno != errno.EEXIST: raise e
python
def ensure_directory(directory): """ Create the directories along the provided directory path that do not exist. """ directory = os.path.expanduser(directory) try: os.makedirs(directory) except OSError as e: if e.errno != errno.EEXIST: raise e
[ "def", "ensure_directory", "(", "directory", ")", ":", "directory", "=", "os", ".", "path", ".", "expanduser", "(", "directory", ")", "try", ":", "os", ".", "makedirs", "(", "directory", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno"...
Create the directories along the provided directory path that do not exist.
[ "Create", "the", "directories", "along", "the", "provided", "directory", "path", "that", "do", "not", "exist", "." ]
2542c28f43d0af18932cb5b82f54ffb6ae557d12
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/utility.py#L71-L80
train
smarie/python-valid8
valid8/composition.py
_process_validation_function_s
def _process_validation_function_s(validation_func, # type: ValidationFuncs auto_and_wrapper=True # type: bool ): # type: (...) -> Union[Callable, List[Callable]] """ This function handles the various ways that users may enter 'val...
python
def _process_validation_function_s(validation_func, # type: ValidationFuncs auto_and_wrapper=True # type: bool ): # type: (...) -> Union[Callable, List[Callable]] """ This function handles the various ways that users may enter 'val...
[ "def", "_process_validation_function_s", "(", "validation_func", ",", "# type: ValidationFuncs", "auto_and_wrapper", "=", "True", "# type: bool", ")", ":", "# type: (...) -> Union[Callable, List[Callable]]", "# handle the case where validation_func is not yet a list or is empty or none", ...
This function handles the various ways that users may enter 'validation functions', so as to output a single callable method. Setting "auto_and_wrapper" to False allows callers to get a list of callables instead. valid8 supports the following expressions for 'validation functions' * <ValidationFunc> ...
[ "This", "function", "handles", "the", "various", "ways", "that", "users", "may", "enter", "validation", "functions", "so", "as", "to", "output", "a", "single", "callable", "method", ".", "Setting", "auto_and_wrapper", "to", "False", "allows", "callers", "to", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L43-L125
train
smarie/python-valid8
valid8/composition.py
and_
def and_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ An 'and' validator: it returns `True` if all of the provided validators return `True`, or raises a `AtLeastOneFailed` failure on the first `False` received or `Exception` caught. Note that an implicit `and_...
python
def and_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ An 'and' validator: it returns `True` if all of the provided validators return `True`, or raises a `AtLeastOneFailed` failure on the first `False` received or `Exception` caught. Note that an implicit `and_...
[ "def", "and_", "(", "*", "validation_func", "# type: ValidationFuncs", ")", ":", "# type: (...) -> Callable", "validation_func", "=", "_process_validation_function_s", "(", "list", "(", "validation_func", ")", ",", "auto_and_wrapper", "=", "False", ")", "if", "len", "...
An 'and' validator: it returns `True` if all of the provided validators return `True`, or raises a `AtLeastOneFailed` failure on the first `False` received or `Exception` caught. Note that an implicit `and_` is performed if you provide a list of validators to any of the entry points (`validate`, `validatio...
[ "An", "and", "validator", ":", "it", "returns", "True", "if", "all", "of", "the", "provided", "validators", "return", "True", "or", "raises", "a", "AtLeastOneFailed", "failure", "on", "the", "first", "False", "received", "or", "Exception", "caught", "." ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L229-L266
train
smarie/python-valid8
valid8/composition.py
not_
def not_(validation_func, # type: ValidationFuncs catch_all=False # type: bool ): # type: (...) -> Callable """ Generates the inverse of the provided validation functions: when the validator returns `False` or raises a `Failure`, this function returns `True`. Otherwise it raises a `...
python
def not_(validation_func, # type: ValidationFuncs catch_all=False # type: bool ): # type: (...) -> Callable """ Generates the inverse of the provided validation functions: when the validator returns `False` or raises a `Failure`, this function returns `True`. Otherwise it raises a `...
[ "def", "not_", "(", "validation_func", ",", "# type: ValidationFuncs", "catch_all", "=", "False", "# type: bool", ")", ":", "# type: (...) -> Callable", "def", "not_v_", "(", "x", ")", ":", "try", ":", "res", "=", "validation_func", "(", "x", ")", "if", "not",...
Generates the inverse of the provided validation functions: when the validator returns `False` or raises a `Failure`, this function returns `True`. Otherwise it raises a `DidNotFail` failure. By default, exceptions of types other than `Failure` are not caught and therefore fail the validation (`catch_all=F...
[ "Generates", "the", "inverse", "of", "the", "provided", "validation", "functions", ":", "when", "the", "validator", "returns", "False", "or", "raises", "a", "Failure", "this", "function", "returns", "True", ".", "Otherwise", "it", "raises", "a", "DidNotFail", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L274-L319
train
smarie/python-valid8
valid8/composition.py
or_
def or_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ An 'or' validator: returns `True` if at least one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `AllValidatorsFailed` failure will be raised, toget...
python
def or_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ An 'or' validator: returns `True` if at least one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `AllValidatorsFailed` failure will be raised, toget...
[ "def", "or_", "(", "*", "validation_func", "# type: ValidationFuncs", ")", ":", "# type: (...) -> Callable", "validation_func", "=", "_process_validation_function_s", "(", "list", "(", "validation_func", ")", ",", "auto_and_wrapper", "=", "False", ")", "if", "len", "(...
An 'or' validator: returns `True` if at least one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `AllValidatorsFailed` failure will be raised, together with details about all validation results. :param validation_func: the base validation fun...
[ "An", "or", "validator", ":", "returns", "True", "if", "at", "least", "one", "of", "the", "provided", "validators", "returns", "True", ".", "All", "exceptions", "will", "be", "silently", "caught", ".", "In", "case", "of", "failure", "a", "global", "AllVali...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L330-L367
train
smarie/python-valid8
valid8/composition.py
xor_
def xor_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ A 'xor' validation function: returns `True` if exactly one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `XorTooManySuccess` or `AllValidatorsFai...
python
def xor_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ A 'xor' validation function: returns `True` if exactly one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `XorTooManySuccess` or `AllValidatorsFai...
[ "def", "xor_", "(", "*", "validation_func", "# type: ValidationFuncs", ")", ":", "# type: (...) -> Callable", "validation_func", "=", "_process_validation_function_s", "(", "list", "(", "validation_func", ")", ",", "auto_and_wrapper", "=", "False", ")", "if", "len", "...
A 'xor' validation function: returns `True` if exactly one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `XorTooManySuccess` or `AllValidatorsFailed` will be raised, together with details about the various validation results. :param validati...
[ "A", "xor", "validation", "function", ":", "returns", "True", "if", "exactly", "one", "of", "the", "provided", "validators", "returns", "True", ".", "All", "exceptions", "will", "be", "silently", "caught", ".", "In", "case", "of", "failure", "a", "global", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L378-L424
train
smarie/python-valid8
valid8/composition.py
not_all
def not_all(*validation_func, # type: ValidationFuncs **kwargs ): # type: (...) -> Callable """ An alias for not_(and_(validators)). :param validation_func: the base validation function or list of base validation functions to use. A callable, a tuple(callable, help_msg_...
python
def not_all(*validation_func, # type: ValidationFuncs **kwargs ): # type: (...) -> Callable """ An alias for not_(and_(validators)). :param validation_func: the base validation function or list of base validation functions to use. A callable, a tuple(callable, help_msg_...
[ "def", "not_all", "(", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "# type: (...) -> Callable", "catch_all", "=", "pop_kwargs", "(", "kwargs", ",", "[", "(", "'catch_all'", ",", "False", ")", "]", ")", "# in case this is...
An alias for not_(and_(validators)). :param validation_func: the base validation function or list of base validation functions to use. A callable, a tuple(callable, help_msg_str), a tuple(callable, failure_type), or a list of several such elements. Nested lists are supported and indicate an implici...
[ "An", "alias", "for", "not_", "(", "and_", "(", "validators", "))", "." ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L436-L458
train
smarie/python-valid8
valid8/composition.py
failure_raiser
def failure_raiser(*validation_func, # type: ValidationFuncs **kwargs ): # type: (...) -> Callable """ This function is automatically used if you provide a tuple `(<function>, <msg>_or_<Failure_type>)`, to any of the methods in this page or to one of the `valid8` ...
python
def failure_raiser(*validation_func, # type: ValidationFuncs **kwargs ): # type: (...) -> Callable """ This function is automatically used if you provide a tuple `(<function>, <msg>_or_<Failure_type>)`, to any of the methods in this page or to one of the `valid8` ...
[ "def", "failure_raiser", "(", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "# type: (...) -> Callable", "failure_type", ",", "help_msg", "=", "pop_kwargs", "(", "kwargs", ",", "[", "(", "'failure_type'", ",", "None", ")", ...
This function is automatically used if you provide a tuple `(<function>, <msg>_or_<Failure_type>)`, to any of the methods in this page or to one of the `valid8` decorators. It transforms the provided `<function>` into a failure raiser, raising a subclass of `Failure` in case of failure (either not returning `Tr...
[ "This", "function", "is", "automatically", "used", "if", "you", "provide", "a", "tuple", "(", "<function", ">", "<msg", ">", "_or_<Failure_type", ">", ")", "to", "any", "of", "the", "methods", "in", "this", "page", "or", "to", "one", "of", "the", "valid8...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L473-L498
train
smarie/python-valid8
valid8/composition.py
pop_kwargs
def pop_kwargs(kwargs, names_with_defaults, # type: List[Tuple[str, Any]] allow_others=False ): """ Internal utility method to extract optional arguments from kwargs. :param kwargs: :param names_with_defaults: :param allow_others: if False (default) the...
python
def pop_kwargs(kwargs, names_with_defaults, # type: List[Tuple[str, Any]] allow_others=False ): """ Internal utility method to extract optional arguments from kwargs. :param kwargs: :param names_with_defaults: :param allow_others: if False (default) the...
[ "def", "pop_kwargs", "(", "kwargs", ",", "names_with_defaults", ",", "# type: List[Tuple[str, Any]]", "allow_others", "=", "False", ")", ":", "all_arguments", "=", "[", "]", "for", "name", ",", "default_", "in", "names_with_defaults", ":", "try", ":", "val", "="...
Internal utility method to extract optional arguments from kwargs. :param kwargs: :param names_with_defaults: :param allow_others: if False (default) then an error will be raised if kwargs still contains something at the end. :return:
[ "Internal", "utility", "method", "to", "extract", "optional", "arguments", "from", "kwargs", "." ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L539-L565
train
smarie/python-valid8
valid8/composition.py
CompositionFailure.get_details
def get_details(self): """ Overrides the base method in order to give details on the various successes and failures """ # transform the dictionary of failures into a printable form need_to_print_value = True failures_for_print = OrderedDict() for validator, failure in self.failu...
python
def get_details(self): """ Overrides the base method in order to give details on the various successes and failures """ # transform the dictionary of failures into a printable form need_to_print_value = True failures_for_print = OrderedDict() for validator, failure in self.failu...
[ "def", "get_details", "(", "self", ")", ":", "# transform the dictionary of failures into a printable form", "need_to_print_value", "=", "True", "failures_for_print", "=", "OrderedDict", "(", ")", "for", "validator", ",", "failure", "in", "self", ".", "failures", ".", ...
Overrides the base method in order to give details on the various successes and failures
[ "Overrides", "the", "base", "method", "in", "order", "to", "give", "details", "on", "the", "various", "successes", "and", "failures" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L160-L189
train
smarie/python-valid8
valid8/composition.py
CompositionFailure.play_all_validators
def play_all_validators(self, validators, value): """ Utility method to play all the provided validators on the provided value and output the :param validators: :param value: :return: """ successes = list() failures = OrderedDict() for validator i...
python
def play_all_validators(self, validators, value): """ Utility method to play all the provided validators on the provided value and output the :param validators: :param value: :return: """ successes = list() failures = OrderedDict() for validator i...
[ "def", "play_all_validators", "(", "self", ",", "validators", ",", "value", ")", ":", "successes", "=", "list", "(", ")", "failures", "=", "OrderedDict", "(", ")", "for", "validator", "in", "validators", ":", "name", "=", "get_callable_name", "(", "validator...
Utility method to play all the provided validators on the provided value and output the :param validators: :param value: :return:
[ "Utility", "method", "to", "play", "all", "the", "provided", "validators", "on", "the", "provided", "value", "and", "output", "the" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L191-L213
train
redhat-cip/dci-control-server
dci/common/signature.py
gen_secret
def gen_secret(length=64): """ Generates a secret of given length """ charset = string.ascii_letters + string.digits return ''.join(random.SystemRandom().choice(charset) for _ in range(length))
python
def gen_secret(length=64): """ Generates a secret of given length """ charset = string.ascii_letters + string.digits return ''.join(random.SystemRandom().choice(charset) for _ in range(length))
[ "def", "gen_secret", "(", "length", "=", "64", ")", ":", "charset", "=", "string", ".", "ascii_letters", "+", "string", ".", "digits", "return", "''", ".", "join", "(", "random", ".", "SystemRandom", "(", ")", ".", "choice", "(", "charset", ")", "for",...
Generates a secret of given length
[ "Generates", "a", "secret", "of", "given", "length" ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/common/signature.py#L21-L26
train
Antidote1911/cryptoshop
cryptoshop/cryptoshop.py
encryptfile
def encryptfile(filename, passphrase, algo='srp'): """ Encrypt a file and write it with .cryptoshop extension. :param filename: a string with the path to the file to encrypt. :param passphrase: a string with the user passphrase. :param algo: a string with the algorithm. Can be srp, aes, twf. Default...
python
def encryptfile(filename, passphrase, algo='srp'): """ Encrypt a file and write it with .cryptoshop extension. :param filename: a string with the path to the file to encrypt. :param passphrase: a string with the user passphrase. :param algo: a string with the algorithm. Can be srp, aes, twf. Default...
[ "def", "encryptfile", "(", "filename", ",", "passphrase", ",", "algo", "=", "'srp'", ")", ":", "try", ":", "if", "algo", "==", "\"srp\"", ":", "header", "=", "b\"Cryptoshop srp \"", "+", "b_version", "crypto_algo", "=", "\"Serpent/GCM\"", "if", "algo", "==",...
Encrypt a file and write it with .cryptoshop extension. :param filename: a string with the path to the file to encrypt. :param passphrase: a string with the user passphrase. :param algo: a string with the algorithm. Can be srp, aes, twf. Default is srp. :return: a string with "successfully encrypted" or...
[ "Encrypt", "a", "file", "and", "write", "it", "with", ".", "cryptoshop", "extension", ".", ":", "param", "filename", ":", "a", "string", "with", "the", "path", "to", "the", "file", "to", "encrypt", ".", ":", "param", "passphrase", ":", "a", "string", "...
0b7ff4a6848f2733f4737606957e8042a4d6ca0b
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/cryptoshop.py#L104-L161
train
Antidote1911/cryptoshop
cryptoshop/cryptoshop.py
decryptfile
def decryptfile(filename, passphrase): """ Decrypt a file and write corresponding decrypted file. We remove the .cryptoshop extension. :param filename: a string with the path to the file to decrypt. :param passphrase: a string with the user passphrase. :return: a string with "successfully decrypted"...
python
def decryptfile(filename, passphrase): """ Decrypt a file and write corresponding decrypted file. We remove the .cryptoshop extension. :param filename: a string with the path to the file to decrypt. :param passphrase: a string with the user passphrase. :return: a string with "successfully decrypted"...
[ "def", "decryptfile", "(", "filename", ",", "passphrase", ")", ":", "try", ":", "outname", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "0", "]", ".", "split", "(", "\"_\"", ")", "[", "-", "1", "]", "# create a string file name w...
Decrypt a file and write corresponding decrypted file. We remove the .cryptoshop extension. :param filename: a string with the path to the file to decrypt. :param passphrase: a string with the user passphrase. :return: a string with "successfully decrypted" or error.
[ "Decrypt", "a", "file", "and", "write", "corresponding", "decrypted", "file", ".", "We", "remove", "the", ".", "cryptoshop", "extension", ".", ":", "param", "filename", ":", "a", "string", "with", "the", "path", "to", "the", "file", "to", "decrypt", ".", ...
0b7ff4a6848f2733f4737606957e8042a4d6ca0b
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/cryptoshop.py#L164-L225
train
danijar/sets
sets/process/tokenize.py
Tokenize._tokenize
def _tokenize(cls, sentence): """ Split a sentence while preserving tags. """ while True: match = cls._regex_tag.search(sentence) if not match: yield from cls._split(sentence) return chunk = sentence[:match.start()] ...
python
def _tokenize(cls, sentence): """ Split a sentence while preserving tags. """ while True: match = cls._regex_tag.search(sentence) if not match: yield from cls._split(sentence) return chunk = sentence[:match.start()] ...
[ "def", "_tokenize", "(", "cls", ",", "sentence", ")", ":", "while", "True", ":", "match", "=", "cls", ".", "_regex_tag", ".", "search", "(", "sentence", ")", "if", "not", "match", ":", "yield", "from", "cls", ".", "_split", "(", "sentence", ")", "ret...
Split a sentence while preserving tags.
[ "Split", "a", "sentence", "while", "preserving", "tags", "." ]
2542c28f43d0af18932cb5b82f54ffb6ae557d12
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/process/tokenize.py#L22-L35
train
mediawiki-utilities/python-mwxml
mwxml/map/map.py
map
def map(process, paths, threads=None): """ Implements a distributed stategy for processing XML files. This function constructs a set of py:mod:`multiprocessing` threads (spread over multiple cores) and uses an internal queue to aggregate outputs. To use this function, implement a `process()` funct...
python
def map(process, paths, threads=None): """ Implements a distributed stategy for processing XML files. This function constructs a set of py:mod:`multiprocessing` threads (spread over multiple cores) and uses an internal queue to aggregate outputs. To use this function, implement a `process()` funct...
[ "def", "map", "(", "process", ",", "paths", ",", "threads", "=", "None", ")", ":", "paths", "=", "[", "mwtypes", ".", "files", ".", "normalize_path", "(", "path", ")", "for", "path", "in", "paths", "]", "def", "process_path", "(", "path", ")", ":", ...
Implements a distributed stategy for processing XML files. This function constructs a set of py:mod:`multiprocessing` threads (spread over multiple cores) and uses an internal queue to aggregate outputs. To use this function, implement a `process()` function that takes two arguments -- a :class:`mwxml...
[ "Implements", "a", "distributed", "stategy", "for", "processing", "XML", "files", ".", "This", "function", "constructs", "a", "set", "of", "py", ":", "mod", ":", "multiprocessing", "threads", "(", "spread", "over", "multiple", "cores", ")", "and", "uses", "a...
6a8c18be99cd0bcee9c496e607f08bf4dfe5b510
https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/map/map.py#L11-L49
train
redhat-cip/dci-control-server
dci/trackers/__init__.py
Tracker.dump
def dump(self): """Return the object itself.""" return { 'title': self.title, 'issue_id': self.issue_id, 'reporter': self.reporter, 'assignee': self.assignee, 'status': self.status, 'product': self.product, 'component':...
python
def dump(self): """Return the object itself.""" return { 'title': self.title, 'issue_id': self.issue_id, 'reporter': self.reporter, 'assignee': self.assignee, 'status': self.status, 'product': self.product, 'component':...
[ "def", "dump", "(", "self", ")", ":", "return", "{", "'title'", ":", "self", ".", "title", ",", "'issue_id'", ":", "self", ".", "issue_id", ",", "'reporter'", ":", "self", ".", "reporter", ",", "'assignee'", ":", "self", ".", "assignee", ",", "'status'...
Return the object itself.
[ "Return", "the", "object", "itself", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/trackers/__init__.py#L39-L54
train
smarie/python-valid8
valid8/utils_decoration.py
apply_on_each_func_args_sig
def apply_on_each_func_args_sig(func, cur_args, cur_kwargs, sig, # type: Signature func_to_apply, func_to_apply_params_dict): """ Applies func_to_apply...
python
def apply_on_each_func_args_sig(func, cur_args, cur_kwargs, sig, # type: Signature func_to_apply, func_to_apply_params_dict): """ Applies func_to_apply...
[ "def", "apply_on_each_func_args_sig", "(", "func", ",", "cur_args", ",", "cur_kwargs", ",", "sig", ",", "# type: Signature", "func_to_apply", ",", "func_to_apply_params_dict", ")", ":", "# match the received arguments with the signature to know who is who", "bound_values", "=",...
Applies func_to_apply on each argument of func according to what's received in current call (cur_args, cur_kwargs). For each argument of func named 'att' in its signature, the following method is called: `func_to_apply(cur_att_value, func_to_apply_paramers_dict[att], func, att_name)` :param func: :par...
[ "Applies", "func_to_apply", "on", "each", "argument", "of", "func", "according", "to", "what", "s", "received", "in", "current", "call", "(", "cur_args", "cur_kwargs", ")", ".", "For", "each", "argument", "of", "func", "named", "att", "in", "its", "signature...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/utils_decoration.py#L15-L45
train
redhat-cip/dci-control-server
dci/identity.py
Identity.is_product_owner
def is_product_owner(self, team_id): """Ensure the user is a PRODUCT_OWNER.""" if self.is_super_admin(): return True team_id = uuid.UUID(str(team_id)) return team_id in self.child_teams_ids
python
def is_product_owner(self, team_id): """Ensure the user is a PRODUCT_OWNER.""" if self.is_super_admin(): return True team_id = uuid.UUID(str(team_id)) return team_id in self.child_teams_ids
[ "def", "is_product_owner", "(", "self", ",", "team_id", ")", ":", "if", "self", ".", "is_super_admin", "(", ")", ":", "return", "True", "team_id", "=", "uuid", ".", "UUID", "(", "str", "(", "team_id", ")", ")", "return", "team_id", "in", "self", ".", ...
Ensure the user is a PRODUCT_OWNER.
[ "Ensure", "the", "user", "is", "a", "PRODUCT_OWNER", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L71-L77
train
redhat-cip/dci-control-server
dci/identity.py
Identity.is_in_team
def is_in_team(self, team_id): """Test if user is in team""" if self.is_super_admin(): return True team_id = uuid.UUID(str(team_id)) return team_id in self.teams or team_id in self.child_teams_ids
python
def is_in_team(self, team_id): """Test if user is in team""" if self.is_super_admin(): return True team_id = uuid.UUID(str(team_id)) return team_id in self.teams or team_id in self.child_teams_ids
[ "def", "is_in_team", "(", "self", ",", "team_id", ")", ":", "if", "self", ".", "is_super_admin", "(", ")", ":", "return", "True", "team_id", "=", "uuid", ".", "UUID", "(", "str", "(", "team_id", ")", ")", "return", "team_id", "in", "self", ".", "team...
Test if user is in team
[ "Test", "if", "user", "is", "in", "team" ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L96-L102
train
redhat-cip/dci-control-server
dci/identity.py
Identity.is_remoteci
def is_remoteci(self, team_id=None): """Ensure ther resource has the role REMOTECI.""" if team_id is None: return self._is_remoteci team_id = uuid.UUID(str(team_id)) if team_id not in self.teams_ids: return False return self.teams[team_id]['role'] == 'REMO...
python
def is_remoteci(self, team_id=None): """Ensure ther resource has the role REMOTECI.""" if team_id is None: return self._is_remoteci team_id = uuid.UUID(str(team_id)) if team_id not in self.teams_ids: return False return self.teams[team_id]['role'] == 'REMO...
[ "def", "is_remoteci", "(", "self", ",", "team_id", "=", "None", ")", ":", "if", "team_id", "is", "None", ":", "return", "self", ".", "_is_remoteci", "team_id", "=", "uuid", ".", "UUID", "(", "str", "(", "team_id", ")", ")", "if", "team_id", "not", "i...
Ensure ther resource has the role REMOTECI.
[ "Ensure", "ther", "resource", "has", "the", "role", "REMOTECI", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L112-L119
train
redhat-cip/dci-control-server
dci/identity.py
Identity.is_feeder
def is_feeder(self, team_id=None): """Ensure ther resource has the role FEEDER.""" if team_id is None: return self._is_feeder team_id = uuid.UUID(str(team_id)) if team_id not in self.teams_ids: return False return self.teams[team_id]['role'] == 'FEEDER'
python
def is_feeder(self, team_id=None): """Ensure ther resource has the role FEEDER.""" if team_id is None: return self._is_feeder team_id = uuid.UUID(str(team_id)) if team_id not in self.teams_ids: return False return self.teams[team_id]['role'] == 'FEEDER'
[ "def", "is_feeder", "(", "self", ",", "team_id", "=", "None", ")", ":", "if", "team_id", "is", "None", ":", "return", "self", ".", "_is_feeder", "team_id", "=", "uuid", ".", "UUID", "(", "str", "(", "team_id", ")", ")", "if", "team_id", "not", "in", ...
Ensure ther resource has the role FEEDER.
[ "Ensure", "ther", "resource", "has", "the", "role", "FEEDER", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L121-L128
train