partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | Tigre._get_local_files | Returns a dictionary of all the files under a path. | tigre/tigre.py | def _get_local_files(self, path):
"""Returns a dictionary of all the files under a path."""
if not path:
raise ValueError("No path specified")
files = defaultdict(lambda: None)
path_len = len(path) + 1
for root, dirs, filenames in os.walk(path):
for name i... | def _get_local_files(self, path):
"""Returns a dictionary of all the files under a path."""
if not path:
raise ValueError("No path specified")
files = defaultdict(lambda: None)
path_len = len(path) + 1
for root, dirs, filenames in os.walk(path):
for name i... | [
"Returns",
"a",
"dictionary",
"of",
"all",
"the",
"files",
"under",
"a",
"path",
"."
] | varikin/Tigre | python | https://github.com/varikin/Tigre/blob/6ffac1de52f087cf92cbf368997b336c35a0e3c0/tigre/tigre.py#L64-L74 | [
"def",
"_get_local_files",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
"\"No path specified\"",
")",
"files",
"=",
"defaultdict",
"(",
"lambda",
":",
"None",
")",
"path_len",
"=",
"len",
"(",
"path",
")",
"+"... | 6ffac1de52f087cf92cbf368997b336c35a0e3c0 |
test | Tigre.sync_folder | Syncs a local directory with an S3 bucket.
Currently does not delete files from S3 that are not in the local directory.
path: The path to the directory to sync to S3
bucket: The name of the bucket on S3 | tigre/tigre.py | def sync_folder(self, path, bucket):
"""Syncs a local directory with an S3 bucket.
Currently does not delete files from S3 that are not in the local directory.
path: The path to the directory to sync to S3
bucket: The name of the bucket on S3
"""
bucket = self.conn... | def sync_folder(self, path, bucket):
"""Syncs a local directory with an S3 bucket.
Currently does not delete files from S3 that are not in the local directory.
path: The path to the directory to sync to S3
bucket: The name of the bucket on S3
"""
bucket = self.conn... | [
"Syncs",
"a",
"local",
"directory",
"with",
"an",
"S3",
"bucket",
".",
"Currently",
"does",
"not",
"delete",
"files",
"from",
"S3",
"that",
"are",
"not",
"in",
"the",
"local",
"directory",
"."
] | varikin/Tigre | python | https://github.com/varikin/Tigre/blob/6ffac1de52f087cf92cbf368997b336c35a0e3c0/tigre/tigre.py#L87-L106 | [
"def",
"sync_folder",
"(",
"self",
",",
"path",
",",
"bucket",
")",
":",
"bucket",
"=",
"self",
".",
"conn",
".",
"get_bucket",
"(",
"bucket",
")",
"local_files",
"=",
"self",
".",
"_get_local_files",
"(",
"path",
")",
"s3_files",
"=",
"self",
".",
"_g... | 6ffac1de52f087cf92cbf368997b336c35a0e3c0 |
test | Tigre.sync | Syncs a list of folders to their assicated buckets.
folders: A list of 2-tuples in the form (folder, bucket) | tigre/tigre.py | def sync(self, folders):
"""Syncs a list of folders to their assicated buckets.
folders: A list of 2-tuples in the form (folder, bucket)
"""
if not folders:
raise ValueError("No folders to sync given")
for folder in folders:
self.sync_folder(*fold... | def sync(self, folders):
"""Syncs a list of folders to their assicated buckets.
folders: A list of 2-tuples in the form (folder, bucket)
"""
if not folders:
raise ValueError("No folders to sync given")
for folder in folders:
self.sync_folder(*fold... | [
"Syncs",
"a",
"list",
"of",
"folders",
"to",
"their",
"assicated",
"buckets",
".",
"folders",
":",
"A",
"list",
"of",
"2",
"-",
"tuples",
"in",
"the",
"form",
"(",
"folder",
"bucket",
")"
] | varikin/Tigre | python | https://github.com/varikin/Tigre/blob/6ffac1de52f087cf92cbf368997b336c35a0e3c0/tigre/tigre.py#L108-L116 | [
"def",
"sync",
"(",
"self",
",",
"folders",
")",
":",
"if",
"not",
"folders",
":",
"raise",
"ValueError",
"(",
"\"No folders to sync given\"",
")",
"for",
"folder",
"in",
"folders",
":",
"self",
".",
"sync_folder",
"(",
"*",
"folder",
")"
] | 6ffac1de52f087cf92cbf368997b336c35a0e3c0 |
test | login_required | Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary. | ci/views.py | def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME,
login_url=None):
"""
Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary.
"""
actual_decorator = request_passes_test(
lambda r: r.session.get('use... | def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME,
login_url=None):
"""
Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary.
"""
actual_decorator = request_passes_test(
lambda r: r.session.get('use... | [
"Decorator",
"for",
"views",
"that",
"checks",
"that",
"the",
"user",
"is",
"logged",
"in",
"redirecting",
"to",
"the",
"log",
"-",
"in",
"page",
"if",
"necessary",
"."
] | praekeltfoundation/seed-control-interface | python | https://github.com/praekeltfoundation/seed-control-interface/blob/32ddad88b5bc2f8f4d80b848361899da2e081636/ci/views.py#L111-L124 | [
"def",
"login_required",
"(",
"function",
"=",
"None",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
",",
"login_url",
"=",
"None",
")",
":",
"actual_decorator",
"=",
"request_passes_test",
"(",
"lambda",
"r",
":",
"r",
".",
"session",
".",
"get",
"(... | 32ddad88b5bc2f8f4d80b848361899da2e081636 |
test | permission_required | Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary. | ci/views.py | def permission_required(function=None, permission=None, object_id=None,
redirect_field_name=REDIRECT_FIELD_NAME,
login_url=None):
"""
Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary.
"""
actual_de... | def permission_required(function=None, permission=None, object_id=None,
redirect_field_name=REDIRECT_FIELD_NAME,
login_url=None):
"""
Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary.
"""
actual_de... | [
"Decorator",
"for",
"views",
"that",
"checks",
"that",
"the",
"user",
"is",
"logged",
"in",
"redirecting",
"to",
"the",
"log",
"-",
"in",
"page",
"if",
"necessary",
"."
] | praekeltfoundation/seed-control-interface | python | https://github.com/praekeltfoundation/seed-control-interface/blob/32ddad88b5bc2f8f4d80b848361899da2e081636/ci/views.py#L136-L150 | [
"def",
"permission_required",
"(",
"function",
"=",
"None",
",",
"permission",
"=",
"None",
",",
"object_id",
"=",
"None",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
",",
"login_url",
"=",
"None",
")",
":",
"actual_decorator",
"=",
"request_passes_tes... | 32ddad88b5bc2f8f4d80b848361899da2e081636 |
test | tokens_required | Ensure the user has the necessary tokens for the specified services | ci/views.py | def tokens_required(service_list):
"""
Ensure the user has the necessary tokens for the specified services
"""
def decorator(func):
@wraps(func)
def inner(request, *args, **kwargs):
for service in service_list:
if service not in request.session["user_tokens"]:... | def tokens_required(service_list):
"""
Ensure the user has the necessary tokens for the specified services
"""
def decorator(func):
@wraps(func)
def inner(request, *args, **kwargs):
for service in service_list:
if service not in request.session["user_tokens"]:... | [
"Ensure",
"the",
"user",
"has",
"the",
"necessary",
"tokens",
"for",
"the",
"specified",
"services"
] | praekeltfoundation/seed-control-interface | python | https://github.com/praekeltfoundation/seed-control-interface/blob/32ddad88b5bc2f8f4d80b848361899da2e081636/ci/views.py#L153-L165 | [
"def",
"tokens_required",
"(",
"service_list",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"inner",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"service",
"in",
"service_... | 32ddad88b5bc2f8f4d80b848361899da2e081636 |
test | login | Displays the login form and handles the login action. | ci/views.py | def login(request, template_name='ci/login.html',
redirect_field_name=REDIRECT_FIELD_NAME,
authentication_form=AuthenticationForm):
"""
Displays the login form and handles the login action.
"""
redirect_to = request.POST.get(redirect_field_name,
req... | def login(request, template_name='ci/login.html',
redirect_field_name=REDIRECT_FIELD_NAME,
authentication_form=AuthenticationForm):
"""
Displays the login form and handles the login action.
"""
redirect_to = request.POST.get(redirect_field_name,
req... | [
"Displays",
"the",
"login",
"form",
"and",
"handles",
"the",
"login",
"action",
"."
] | praekeltfoundation/seed-control-interface | python | https://github.com/praekeltfoundation/seed-control-interface/blob/32ddad88b5bc2f8f4d80b848361899da2e081636/ci/views.py#L168-L232 | [
"def",
"login",
"(",
"request",
",",
"template_name",
"=",
"'ci/login.html'",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
",",
"authentication_form",
"=",
"AuthenticationForm",
")",
":",
"redirect_to",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"red... | 32ddad88b5bc2f8f4d80b848361899da2e081636 |
test | build | Build CLI dynamically based on the package structure. | yhy/commands/__init__.py | def build(cli, path, package):
"""Build CLI dynamically based on the package structure.
"""
for _, name, ispkg in iter_modules(path):
module = import_module(f'.{name}', package)
if ispkg:
build(cli.group(name)(module.group),
module.__path__,
mo... | def build(cli, path, package):
"""Build CLI dynamically based on the package structure.
"""
for _, name, ispkg in iter_modules(path):
module = import_module(f'.{name}', package)
if ispkg:
build(cli.group(name)(module.group),
module.__path__,
mo... | [
"Build",
"CLI",
"dynamically",
"based",
"on",
"the",
"package",
"structure",
"."
] | yeonghoey/yhy | python | https://github.com/yeonghoey/yhy/blob/4bce1482c31aeeccff96c4cfd1803b83932604e7/yhy/commands/__init__.py#L5-L15 | [
"def",
"build",
"(",
"cli",
",",
"path",
",",
"package",
")",
":",
"for",
"_",
",",
"name",
",",
"ispkg",
"in",
"iter_modules",
"(",
"path",
")",
":",
"module",
"=",
"import_module",
"(",
"f'.{name}'",
",",
"package",
")",
"if",
"ispkg",
":",
"build"... | 4bce1482c31aeeccff96c4cfd1803b83932604e7 |
test | Fridge.readonly | Return an already closed read-only instance of Fridge.
Arguments are the same as for the constructor. | fridge.py | def readonly(cls, *args, **kwargs):
"""
Return an already closed read-only instance of Fridge.
Arguments are the same as for the constructor.
"""
fridge = cls(*args, **kwargs)
fridge.close()
return fridge | def readonly(cls, *args, **kwargs):
"""
Return an already closed read-only instance of Fridge.
Arguments are the same as for the constructor.
"""
fridge = cls(*args, **kwargs)
fridge.close()
return fridge | [
"Return",
"an",
"already",
"closed",
"read",
"-",
"only",
"instance",
"of",
"Fridge",
".",
"Arguments",
"are",
"the",
"same",
"as",
"for",
"the",
"constructor",
"."
] | swarmer/fridge | python | https://github.com/swarmer/fridge/blob/fcf6481307ce268c40c22f5e0062d01334f6cd95/fridge.py#L30-L37 | [
"def",
"readonly",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"fridge",
"=",
"cls",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"fridge",
".",
"close",
"(",
")",
"return",
"fridge"
] | fcf6481307ce268c40c22f5e0062d01334f6cd95 |
test | Fridge.load | Force reloading the data from the file.
All data in the in-memory dictionary is discarded.
This method is called automatically by the constructor, normally you
don't need to call it. | fridge.py | def load(self):
"""
Force reloading the data from the file.
All data in the in-memory dictionary is discarded.
This method is called automatically by the constructor, normally you
don't need to call it.
"""
self._check_open()
try:
data = json.l... | def load(self):
"""
Force reloading the data from the file.
All data in the in-memory dictionary is discarded.
This method is called automatically by the constructor, normally you
don't need to call it.
"""
self._check_open()
try:
data = json.l... | [
"Force",
"reloading",
"the",
"data",
"from",
"the",
"file",
".",
"All",
"data",
"in",
"the",
"in",
"-",
"memory",
"dictionary",
"is",
"discarded",
".",
"This",
"method",
"is",
"called",
"automatically",
"by",
"the",
"constructor",
"normally",
"you",
"don",
... | swarmer/fridge | python | https://github.com/swarmer/fridge/blob/fcf6481307ce268c40c22f5e0062d01334f6cd95/fridge.py#L90-L105 | [
"def",
"load",
"(",
"self",
")",
":",
"self",
".",
"_check_open",
"(",
")",
"try",
":",
"data",
"=",
"json",
".",
"load",
"(",
"self",
".",
"file",
",",
"*",
"*",
"self",
".",
"load_args",
")",
"except",
"ValueError",
":",
"data",
"=",
"{",
"}",
... | fcf6481307ce268c40c22f5e0062d01334f6cd95 |
test | Fridge.save | Force saving the dictionary to the file.
All data in the file is discarded.
This method is called automatically by :meth:`close`. | fridge.py | def save(self):
"""
Force saving the dictionary to the file.
All data in the file is discarded.
This method is called automatically by :meth:`close`.
"""
self._check_open()
self.file.truncate(0)
self.file.seek(0)
json.dump(self, self.file, **self.d... | def save(self):
"""
Force saving the dictionary to the file.
All data in the file is discarded.
This method is called automatically by :meth:`close`.
"""
self._check_open()
self.file.truncate(0)
self.file.seek(0)
json.dump(self, self.file, **self.d... | [
"Force",
"saving",
"the",
"dictionary",
"to",
"the",
"file",
".",
"All",
"data",
"in",
"the",
"file",
"is",
"discarded",
".",
"This",
"method",
"is",
"called",
"automatically",
"by",
":",
"meth",
":",
"close",
"."
] | swarmer/fridge | python | https://github.com/swarmer/fridge/blob/fcf6481307ce268c40c22f5e0062d01334f6cd95/fridge.py#L107-L116 | [
"def",
"save",
"(",
"self",
")",
":",
"self",
".",
"_check_open",
"(",
")",
"self",
".",
"file",
".",
"truncate",
"(",
"0",
")",
"self",
".",
"file",
".",
"seek",
"(",
"0",
")",
"json",
".",
"dump",
"(",
"self",
",",
"self",
".",
"file",
",",
... | fcf6481307ce268c40c22f5e0062d01334f6cd95 |
test | Fridge.close | Close the fridge.
Calls :meth:`save` and closes the underlying file object unless
an already open file was passed to the constructor.
This method has no effect if the object is already closed.
After the fridge is closed :meth:`save` and :meth:`load` will raise an exception
but y... | fridge.py | def close(self):
"""
Close the fridge.
Calls :meth:`save` and closes the underlying file object unless
an already open file was passed to the constructor.
This method has no effect if the object is already closed.
After the fridge is closed :meth:`save` and :meth:`load` ... | def close(self):
"""
Close the fridge.
Calls :meth:`save` and closes the underlying file object unless
an already open file was passed to the constructor.
This method has no effect if the object is already closed.
After the fridge is closed :meth:`save` and :meth:`load` ... | [
"Close",
"the",
"fridge",
".",
"Calls",
":",
"meth",
":",
"save",
"and",
"closes",
"the",
"underlying",
"file",
"object",
"unless",
"an",
"already",
"open",
"file",
"was",
"passed",
"to",
"the",
"constructor",
".",
"This",
"method",
"has",
"no",
"effect",
... | swarmer/fridge | python | https://github.com/swarmer/fridge/blob/fcf6481307ce268c40c22f5e0062d01334f6cd95/fridge.py#L118-L132 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"closed",
":",
"self",
".",
"save",
"(",
")",
"if",
"self",
".",
"close_file",
":",
"self",
".",
"file",
".",
"close",
"(",
")",
"self",
".",
"closed",
"=",
"True"
] | fcf6481307ce268c40c22f5e0062d01334f6cd95 |
test | self_sign_jwks | Create a signed JWT containing a JWKS. The JWT is signed by one of the
keys in the JWKS.
:param keyjar: A KeyJar instance with at least one private signing key
:param iss: issuer of the JWT, should be the owner of the keys
:param kid: A key ID if a special key should be used otherwise one
is pi... | src/fedoidcmsg/utils.py | def self_sign_jwks(keyjar, iss, kid='', lifetime=3600):
"""
Create a signed JWT containing a JWKS. The JWT is signed by one of the
keys in the JWKS.
:param keyjar: A KeyJar instance with at least one private signing key
:param iss: issuer of the JWT, should be the owner of the keys
:param kid: ... | def self_sign_jwks(keyjar, iss, kid='', lifetime=3600):
"""
Create a signed JWT containing a JWKS. The JWT is signed by one of the
keys in the JWKS.
:param keyjar: A KeyJar instance with at least one private signing key
:param iss: issuer of the JWT, should be the owner of the keys
:param kid: ... | [
"Create",
"a",
"signed",
"JWT",
"containing",
"a",
"JWKS",
".",
"The",
"JWT",
"is",
"signed",
"by",
"one",
"of",
"the",
"keys",
"in",
"the",
"JWKS",
"."
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/utils.py#L15-L33 | [
"def",
"self_sign_jwks",
"(",
"keyjar",
",",
"iss",
",",
"kid",
"=",
"''",
",",
"lifetime",
"=",
"3600",
")",
":",
"# _json = json.dumps(jwks)",
"_jwt",
"=",
"JWT",
"(",
"keyjar",
",",
"iss",
"=",
"iss",
",",
"lifetime",
"=",
"lifetime",
")",
"jwks",
"... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | verify_self_signed_jwks | Verify the signature of a signed JWT containing a JWKS.
The JWT is signed by one of the keys in the JWKS.
In the JWT the JWKS is stored using this format ::
'jwks': {
'keys': [ ]
}
:param sjwt: Signed Jason Web Token
:return: Dictionary containing 'jwks' (the JWKS) and... | src/fedoidcmsg/utils.py | def verify_self_signed_jwks(sjwt):
"""
Verify the signature of a signed JWT containing a JWKS.
The JWT is signed by one of the keys in the JWKS.
In the JWT the JWKS is stored using this format ::
'jwks': {
'keys': [ ]
}
:param sjwt: Signed Jason Web Token
:retu... | def verify_self_signed_jwks(sjwt):
"""
Verify the signature of a signed JWT containing a JWKS.
The JWT is signed by one of the keys in the JWKS.
In the JWT the JWKS is stored using this format ::
'jwks': {
'keys': [ ]
}
:param sjwt: Signed Jason Web Token
:retu... | [
"Verify",
"the",
"signature",
"of",
"a",
"signed",
"JWT",
"containing",
"a",
"JWKS",
".",
"The",
"JWT",
"is",
"signed",
"by",
"one",
"of",
"the",
"keys",
"in",
"the",
"JWKS",
".",
"In",
"the",
"JWT",
"the",
"JWKS",
"is",
"stored",
"using",
"this",
"f... | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/utils.py#L36-L67 | [
"def",
"verify_self_signed_jwks",
"(",
"sjwt",
")",
":",
"_jws",
"=",
"factory",
"(",
"sjwt",
")",
"_json",
"=",
"_jws",
".",
"jwt",
".",
"part",
"[",
"1",
"]",
"_body",
"=",
"json",
".",
"loads",
"(",
"as_unicode",
"(",
"_json",
")",
")",
"iss",
"... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | request_signed_by_signing_keys | A metadata statement signing request with 'signing_keys' signed by one
of the keys in 'signing_keys'.
:param keyjar: A KeyJar instance with the private signing key
:param msreq: Metadata statement signing request. A MetadataStatement
instance.
:param iss: Issuer of the signing request also the... | src/fedoidcmsg/utils.py | def request_signed_by_signing_keys(keyjar, msreq, iss, lifetime, kid=''):
"""
A metadata statement signing request with 'signing_keys' signed by one
of the keys in 'signing_keys'.
:param keyjar: A KeyJar instance with the private signing key
:param msreq: Metadata statement signing request. A Metad... | def request_signed_by_signing_keys(keyjar, msreq, iss, lifetime, kid=''):
"""
A metadata statement signing request with 'signing_keys' signed by one
of the keys in 'signing_keys'.
:param keyjar: A KeyJar instance with the private signing key
:param msreq: Metadata statement signing request. A Metad... | [
"A",
"metadata",
"statement",
"signing",
"request",
"with",
"signing_keys",
"signed",
"by",
"one",
"of",
"the",
"keys",
"in",
"signing_keys",
"."
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/utils.py#L70-L91 | [
"def",
"request_signed_by_signing_keys",
"(",
"keyjar",
",",
"msreq",
",",
"iss",
",",
"lifetime",
",",
"kid",
"=",
"''",
")",
":",
"try",
":",
"jwks_to_keyjar",
"(",
"msreq",
"[",
"'signing_keys'",
"]",
",",
"iss",
")",
"except",
"KeyError",
":",
"jwks",
... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | verify_request_signed_by_signing_keys | Verify that a JWT is signed with a key that is inside the JWT.
:param smsreq: Signed Metadata Statement signing request
:return: Dictionary containing 'ms' (the signed request) and 'iss' (the
issuer of the JWT). | src/fedoidcmsg/utils.py | def verify_request_signed_by_signing_keys(smsreq):
"""
Verify that a JWT is signed with a key that is inside the JWT.
:param smsreq: Signed Metadata Statement signing request
:return: Dictionary containing 'ms' (the signed request) and 'iss' (the
issuer of the JWT).
"""
_jws = fact... | def verify_request_signed_by_signing_keys(smsreq):
"""
Verify that a JWT is signed with a key that is inside the JWT.
:param smsreq: Signed Metadata Statement signing request
:return: Dictionary containing 'ms' (the signed request) and 'iss' (the
issuer of the JWT).
"""
_jws = fact... | [
"Verify",
"that",
"a",
"JWT",
"is",
"signed",
"with",
"a",
"key",
"that",
"is",
"inside",
"the",
"JWT",
".",
":",
"param",
"smsreq",
":",
"Signed",
"Metadata",
"Statement",
"signing",
"request",
":",
"return",
":",
"Dictionary",
"containing",
"ms",
"(",
... | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/utils.py#L94-L130 | [
"def",
"verify_request_signed_by_signing_keys",
"(",
"smsreq",
")",
":",
"_jws",
"=",
"factory",
"(",
"smsreq",
")",
"_json",
"=",
"_jws",
".",
"jwt",
".",
"part",
"[",
"1",
"]",
"_body",
"=",
"json",
".",
"loads",
"(",
"as_unicode",
"(",
"_json",
")",
... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | card | A decorator for providing a unittesting function/method with every card in
a librarian card library database when it is called. | greencard/greencard.py | def card(func):
"""
A decorator for providing a unittesting function/method with every card in
a librarian card library database when it is called.
"""
@wraps(func)
def wrapped(*args, **kwargs):
"""Transparent wrapper."""
return func(*args, **kwargs)
TESTS.append(wrapped)
... | def card(func):
"""
A decorator for providing a unittesting function/method with every card in
a librarian card library database when it is called.
"""
@wraps(func)
def wrapped(*args, **kwargs):
"""Transparent wrapper."""
return func(*args, **kwargs)
TESTS.append(wrapped)
... | [
"A",
"decorator",
"for",
"providing",
"a",
"unittesting",
"function",
"/",
"method",
"with",
"every",
"card",
"in",
"a",
"librarian",
"card",
"library",
"database",
"when",
"it",
"is",
"called",
"."
] | Nekroze/greencard | python | https://github.com/Nekroze/greencard/blob/30fe7eba5742c31b666027e31f33aaa641699857/greencard/greencard.py#L9-L19 | [
"def",
"card",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Transparent wrapper.\"\"\"",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"TESTS"... | 30fe7eba5742c31b666027e31f33aaa641699857 |
test | library | A decorator for providing a unittest with a library and have it called only
once. | greencard/greencard.py | def library(func):
"""
A decorator for providing a unittest with a library and have it called only
once.
"""
@wraps(func)
def wrapped(*args, **kwargs):
"""Transparent wrapper."""
return func(*args, **kwargs)
SINGLES.append(wrapped)
return wrapped | def library(func):
"""
A decorator for providing a unittest with a library and have it called only
once.
"""
@wraps(func)
def wrapped(*args, **kwargs):
"""Transparent wrapper."""
return func(*args, **kwargs)
SINGLES.append(wrapped)
return wrapped | [
"A",
"decorator",
"for",
"providing",
"a",
"unittest",
"with",
"a",
"library",
"and",
"have",
"it",
"called",
"only",
"once",
"."
] | Nekroze/greencard | python | https://github.com/Nekroze/greencard/blob/30fe7eba5742c31b666027e31f33aaa641699857/greencard/greencard.py#L22-L32 | [
"def",
"library",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Transparent wrapper.\"\"\"",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"SIN... | 30fe7eba5742c31b666027e31f33aaa641699857 |
test | descovery | Descover and load greencard tests. | greencard/greencard.py | def descovery(testdir):
"""Descover and load greencard tests."""
from os.path import join, exists, isdir, splitext, basename, sep
if not testdir or not exists(testdir) or not isdir(testdir):
return None
from os import walk
import fnmatch
import imp
for root, _, filenames in walk(te... | def descovery(testdir):
"""Descover and load greencard tests."""
from os.path import join, exists, isdir, splitext, basename, sep
if not testdir or not exists(testdir) or not isdir(testdir):
return None
from os import walk
import fnmatch
import imp
for root, _, filenames in walk(te... | [
"Descover",
"and",
"load",
"greencard",
"tests",
"."
] | Nekroze/greencard | python | https://github.com/Nekroze/greencard/blob/30fe7eba5742c31b666027e31f33aaa641699857/greencard/greencard.py#L35-L49 | [
"def",
"descovery",
"(",
"testdir",
")",
":",
"from",
"os",
".",
"path",
"import",
"join",
",",
"exists",
",",
"isdir",
",",
"splitext",
",",
"basename",
",",
"sep",
"if",
"not",
"testdir",
"or",
"not",
"exists",
"(",
"testdir",
")",
"or",
"not",
"is... | 30fe7eba5742c31b666027e31f33aaa641699857 |
test | main | Command line entry point. | greencard/greencard.py | def main(clargs=None):
"""Command line entry point."""
from argparse import ArgumentParser
from librarian.library import Library
import sys
parser = ArgumentParser(
description="A test runner for each card in a librarian library.")
parser.add_argument("library", help="Library database")... | def main(clargs=None):
"""Command line entry point."""
from argparse import ArgumentParser
from librarian.library import Library
import sys
parser = ArgumentParser(
description="A test runner for each card in a librarian library.")
parser.add_argument("library", help="Library database")... | [
"Command",
"line",
"entry",
"point",
"."
] | Nekroze/greencard | python | https://github.com/Nekroze/greencard/blob/30fe7eba5742c31b666027e31f33aaa641699857/greencard/greencard.py#L98-L117 | [
"def",
"main",
"(",
"clargs",
"=",
"None",
")",
":",
"from",
"argparse",
"import",
"ArgumentParser",
"from",
"librarian",
".",
"library",
"import",
"Library",
"import",
"sys",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"\"A test runner for each card... | 30fe7eba5742c31b666027e31f33aaa641699857 |
test | letter_score | Returns the Scrabble score of a letter.
Args:
letter: a single character string
Raises:
TypeError if a non-Scrabble character is supplied | nagaram/scrabble.py | def letter_score(letter):
"""Returns the Scrabble score of a letter.
Args:
letter: a single character string
Raises:
TypeError if a non-Scrabble character is supplied
"""
score_map = {
1: ["a", "e", "i", "o", "u", "l", "n", "r", "s", "t"],
2: ["d", "g"],
3:... | def letter_score(letter):
"""Returns the Scrabble score of a letter.
Args:
letter: a single character string
Raises:
TypeError if a non-Scrabble character is supplied
"""
score_map = {
1: ["a", "e", "i", "o", "u", "l", "n", "r", "s", "t"],
2: ["d", "g"],
3:... | [
"Returns",
"the",
"Scrabble",
"score",
"of",
"a",
"letter",
"."
] | a-tal/nagaram | python | https://github.com/a-tal/nagaram/blob/2edcb0ef8cb569ebd1c398be826472b4831d6110/nagaram/scrabble.py#L7-L31 | [
"def",
"letter_score",
"(",
"letter",
")",
":",
"score_map",
"=",
"{",
"1",
":",
"[",
"\"a\"",
",",
"\"e\"",
",",
"\"i\"",
",",
"\"o\"",
",",
"\"u\"",
",",
"\"l\"",
",",
"\"n\"",
",",
"\"r\"",
",",
"\"s\"",
",",
"\"t\"",
"]",
",",
"2",
":",
"[",
... | 2edcb0ef8cb569ebd1c398be826472b4831d6110 |
test | word_score | Checks the Scrabble score of a single word.
Args:
word: a string to check the Scrabble score of
input_letters: the letters in our rack
questions: integer of the tiles already on the board to build on
Returns:
an integer Scrabble score amount for the word | nagaram/scrabble.py | def word_score(word, input_letters, questions=0):
"""Checks the Scrabble score of a single word.
Args:
word: a string to check the Scrabble score of
input_letters: the letters in our rack
questions: integer of the tiles already on the board to build on
Returns:
an integer S... | def word_score(word, input_letters, questions=0):
"""Checks the Scrabble score of a single word.
Args:
word: a string to check the Scrabble score of
input_letters: the letters in our rack
questions: integer of the tiles already on the board to build on
Returns:
an integer S... | [
"Checks",
"the",
"Scrabble",
"score",
"of",
"a",
"single",
"word",
"."
] | a-tal/nagaram | python | https://github.com/a-tal/nagaram/blob/2edcb0ef8cb569ebd1c398be826472b4831d6110/nagaram/scrabble.py#L34-L69 | [
"def",
"word_score",
"(",
"word",
",",
"input_letters",
",",
"questions",
"=",
"0",
")",
":",
"score",
"=",
"0",
"bingo",
"=",
"0",
"filled_by_blanks",
"=",
"[",
"]",
"rack",
"=",
"list",
"(",
"input_letters",
")",
"# make a copy to speed up find_anagrams()",
... | 2edcb0ef8cb569ebd1c398be826472b4831d6110 |
test | blank_tiles | Searches a string for blank tile characters ("?" and "_").
Args:
input_word: the user supplied string to search through
Returns:
a tuple of:
input_word without blanks
integer number of blanks (no points)
integer number of questions (points) | nagaram/scrabble.py | def blank_tiles(input_word):
"""Searches a string for blank tile characters ("?" and "_").
Args:
input_word: the user supplied string to search through
Returns:
a tuple of:
input_word without blanks
integer number of blanks (no points)
integer number of ... | def blank_tiles(input_word):
"""Searches a string for blank tile characters ("?" and "_").
Args:
input_word: the user supplied string to search through
Returns:
a tuple of:
input_word without blanks
integer number of blanks (no points)
integer number of ... | [
"Searches",
"a",
"string",
"for",
"blank",
"tile",
"characters",
"(",
"?",
"and",
"_",
")",
"."
] | a-tal/nagaram | python | https://github.com/a-tal/nagaram/blob/2edcb0ef8cb569ebd1c398be826472b4831d6110/nagaram/scrabble.py#L72-L95 | [
"def",
"blank_tiles",
"(",
"input_word",
")",
":",
"blanks",
"=",
"0",
"questions",
"=",
"0",
"input_letters",
"=",
"[",
"]",
"for",
"letter",
"in",
"input_word",
":",
"if",
"letter",
"==",
"\"_\"",
":",
"blanks",
"+=",
"1",
"elif",
"letter",
"==",
"\"... | 2edcb0ef8cb569ebd1c398be826472b4831d6110 |
test | word_list | Opens the word list file.
Args:
sowpods: a boolean to declare using the sowpods list or TWL (default)
start: a string of starting characters to find anagrams based on
end: a string of ending characters to find anagrams based on
Yeilds:
a word at a time out of 178691 words for T... | nagaram/scrabble.py | def word_list(sowpods=False, start="", end=""):
"""Opens the word list file.
Args:
sowpods: a boolean to declare using the sowpods list or TWL (default)
start: a string of starting characters to find anagrams based on
end: a string of ending characters to find anagrams based on
Yei... | def word_list(sowpods=False, start="", end=""):
"""Opens the word list file.
Args:
sowpods: a boolean to declare using the sowpods list or TWL (default)
start: a string of starting characters to find anagrams based on
end: a string of ending characters to find anagrams based on
Yei... | [
"Opens",
"the",
"word",
"list",
"file",
"."
] | a-tal/nagaram | python | https://github.com/a-tal/nagaram/blob/2edcb0ef8cb569ebd1c398be826472b4831d6110/nagaram/scrabble.py#L98-L133 | [
"def",
"word_list",
"(",
"sowpods",
"=",
"False",
",",
"start",
"=",
"\"\"",
",",
"end",
"=",
"\"\"",
")",
":",
"location",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",... | 2edcb0ef8cb569ebd1c398be826472b4831d6110 |
test | valid_scrabble_word | Checks if the input word could be played with a full bag of tiles.
Returns:
True or false | nagaram/scrabble.py | def valid_scrabble_word(word):
"""Checks if the input word could be played with a full bag of tiles.
Returns:
True or false
"""
letters_in_bag = {
"a": 9,
"b": 2,
"c": 2,
"d": 4,
"e": 12,
"f": 2,
"g": 3,
"h": 2,
"i": 9,
... | def valid_scrabble_word(word):
"""Checks if the input word could be played with a full bag of tiles.
Returns:
True or false
"""
letters_in_bag = {
"a": 9,
"b": 2,
"c": 2,
"d": 4,
"e": 12,
"f": 2,
"g": 3,
"h": 2,
"i": 9,
... | [
"Checks",
"if",
"the",
"input",
"word",
"could",
"be",
"played",
"with",
"a",
"full",
"bag",
"of",
"tiles",
"."
] | a-tal/nagaram | python | https://github.com/a-tal/nagaram/blob/2edcb0ef8cb569ebd1c398be826472b4831d6110/nagaram/scrabble.py#L136-L184 | [
"def",
"valid_scrabble_word",
"(",
"word",
")",
":",
"letters_in_bag",
"=",
"{",
"\"a\"",
":",
"9",
",",
"\"b\"",
":",
"2",
",",
"\"c\"",
":",
"2",
",",
"\"d\"",
":",
"4",
",",
"\"e\"",
":",
"12",
",",
"\"f\"",
":",
"2",
",",
"\"g\"",
":",
"3",
... | 2edcb0ef8cb569ebd1c398be826472b4831d6110 |
test | main | docstring for main | howto/howto.py | def main(args):
"""docstring for main"""
try:
args.query = ' '.join(args.query).replace('?', '')
so = SOSearch(args.query, args.tags)
result = so.first_q().best_answer.code
if result != None:
print result
else:
print("Sorry I can't find your answe... | def main(args):
"""docstring for main"""
try:
args.query = ' '.join(args.query).replace('?', '')
so = SOSearch(args.query, args.tags)
result = so.first_q().best_answer.code
if result != None:
print result
else:
print("Sorry I can't find your answe... | [
"docstring",
"for",
"main"
] | sp4ke/howto | python | https://github.com/sp4ke/howto/blob/2588144a587be5138d45ca9db0ce6ab125fa7d0c/howto/howto.py#L64-L75 | [
"def",
"main",
"(",
"args",
")",
":",
"try",
":",
"args",
".",
"query",
"=",
"' '",
".",
"join",
"(",
"args",
".",
"query",
")",
".",
"replace",
"(",
"'?'",
",",
"''",
")",
"so",
"=",
"SOSearch",
"(",
"args",
".",
"query",
",",
"args",
".",
"... | 2588144a587be5138d45ca9db0ce6ab125fa7d0c |
test | cli_run | docstring for argparse | howto/howto.py | def cli_run():
"""docstring for argparse"""
parser = argparse.ArgumentParser(description='Stupidly simple code answers from StackOverflow')
parser.add_argument('query', help="What's the problem ?", type=str, nargs='+')
parser.add_argument('-t','--tags', help='semicolon separated tags -> python;lambda')
... | def cli_run():
"""docstring for argparse"""
parser = argparse.ArgumentParser(description='Stupidly simple code answers from StackOverflow')
parser.add_argument('query', help="What's the problem ?", type=str, nargs='+')
parser.add_argument('-t','--tags', help='semicolon separated tags -> python;lambda')
... | [
"docstring",
"for",
"argparse"
] | sp4ke/howto | python | https://github.com/sp4ke/howto/blob/2588144a587be5138d45ca9db0ce6ab125fa7d0c/howto/howto.py#L78-L84 | [
"def",
"cli_run",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Stupidly simple code answers from StackOverflow'",
")",
"parser",
".",
"add_argument",
"(",
"'query'",
",",
"help",
"=",
"\"What's the problem ?\"",
",",
"t... | 2588144a587be5138d45ca9db0ce6ab125fa7d0c |
test | JSONAMPDialectReceiver.stringReceived | Handle a JSON AMP dialect request.
First, the JSON is parsed. Then, all JSON dialect specific
values in the request are turned into the correct objects.
Then, finds the correct responder function, calls it, and
serializes the result (or error). | txampext/jsondialect.py | def stringReceived(self, string):
"""Handle a JSON AMP dialect request.
First, the JSON is parsed. Then, all JSON dialect specific
values in the request are turned into the correct objects.
Then, finds the correct responder function, calls it, and
serializes the result (or error... | def stringReceived(self, string):
"""Handle a JSON AMP dialect request.
First, the JSON is parsed. Then, all JSON dialect specific
values in the request are turned into the correct objects.
Then, finds the correct responder function, calls it, and
serializes the result (or error... | [
"Handle",
"a",
"JSON",
"AMP",
"dialect",
"request",
"."
] | lvh/txampext | python | https://github.com/lvh/txampext/blob/a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9/txampext/jsondialect.py#L29-L46 | [
"def",
"stringReceived",
"(",
"self",
",",
"string",
")",
":",
"request",
"=",
"loads",
"(",
"string",
")",
"identifier",
"=",
"request",
".",
"pop",
"(",
"\"_ask\"",
")",
"commandName",
"=",
"request",
".",
"pop",
"(",
"\"_command\"",
")",
"command",
",... | a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9 |
test | JSONAMPDialectReceiver._getCommandAndResponder | Gets the command class and matching responder function for the
given command name. | txampext/jsondialect.py | def _getCommandAndResponder(self, commandName):
"""Gets the command class and matching responder function for the
given command name.
"""
# DISGUSTING IMPLEMENTATION DETAIL EXPLOITING HACK
locator = self._remote.boxReceiver.locator
responder = locator.locateResponder(com... | def _getCommandAndResponder(self, commandName):
"""Gets the command class and matching responder function for the
given command name.
"""
# DISGUSTING IMPLEMENTATION DETAIL EXPLOITING HACK
locator = self._remote.boxReceiver.locator
responder = locator.locateResponder(com... | [
"Gets",
"the",
"command",
"class",
"and",
"matching",
"responder",
"function",
"for",
"the",
"given",
"command",
"name",
"."
] | lvh/txampext | python | https://github.com/lvh/txampext/blob/a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9/txampext/jsondialect.py#L49-L59 | [
"def",
"_getCommandAndResponder",
"(",
"self",
",",
"commandName",
")",
":",
"# DISGUSTING IMPLEMENTATION DETAIL EXPLOITING HACK",
"locator",
"=",
"self",
".",
"_remote",
".",
"boxReceiver",
".",
"locator",
"responder",
"=",
"locator",
".",
"locateResponder",
"(",
"co... | a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9 |
test | JSONAMPDialectReceiver._parseRequestValues | Parses all the values in the request that are in a form specific
to the JSON AMP dialect. | txampext/jsondialect.py | def _parseRequestValues(self, request, command):
"""Parses all the values in the request that are in a form specific
to the JSON AMP dialect.
"""
for key, ampType in command.arguments:
ampClass = ampType.__class__
if ampClass is exposed.ExposedResponderLocator:
... | def _parseRequestValues(self, request, command):
"""Parses all the values in the request that are in a form specific
to the JSON AMP dialect.
"""
for key, ampType in command.arguments:
ampClass = ampType.__class__
if ampClass is exposed.ExposedResponderLocator:
... | [
"Parses",
"all",
"the",
"values",
"in",
"the",
"request",
"that",
"are",
"in",
"a",
"form",
"specific",
"to",
"the",
"JSON",
"AMP",
"dialect",
"."
] | lvh/txampext | python | https://github.com/lvh/txampext/blob/a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9/txampext/jsondialect.py#L62-L77 | [
"def",
"_parseRequestValues",
"(",
"self",
",",
"request",
",",
"command",
")",
":",
"for",
"key",
",",
"ampType",
"in",
"command",
".",
"arguments",
":",
"ampClass",
"=",
"ampType",
".",
"__class__",
"if",
"ampClass",
"is",
"exposed",
".",
"ExposedResponder... | a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9 |
test | JSONAMPDialectReceiver._runResponder | Run the responser function. If it succeeds, add the _answer key.
If it fails with an error known to the command, serialize the
error. | txampext/jsondialect.py | def _runResponder(self, responder, request, command, identifier):
"""Run the responser function. If it succeeds, add the _answer key.
If it fails with an error known to the command, serialize the
error.
"""
d = defer.maybeDeferred(responder, **request)
def _addIdentifie... | def _runResponder(self, responder, request, command, identifier):
"""Run the responser function. If it succeeds, add the _answer key.
If it fails with an error known to the command, serialize the
error.
"""
d = defer.maybeDeferred(responder, **request)
def _addIdentifie... | [
"Run",
"the",
"responser",
"function",
".",
"If",
"it",
"succeeds",
"add",
"the",
"_answer",
"key",
".",
"If",
"it",
"fails",
"with",
"an",
"error",
"known",
"to",
"the",
"command",
"serialize",
"the",
"error",
"."
] | lvh/txampext | python | https://github.com/lvh/txampext/blob/a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9/txampext/jsondialect.py#L80-L108 | [
"def",
"_runResponder",
"(",
"self",
",",
"responder",
",",
"request",
",",
"command",
",",
"identifier",
")",
":",
"d",
"=",
"defer",
".",
"maybeDeferred",
"(",
"responder",
",",
"*",
"*",
"request",
")",
"def",
"_addIdentifier",
"(",
"response",
")",
"... | a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9 |
test | JSONAMPDialectReceiver._writeResponse | Serializes the response to JSON, and writes it to the transport. | txampext/jsondialect.py | def _writeResponse(self, response):
"""
Serializes the response to JSON, and writes it to the transport.
"""
encoded = dumps(response, default=_default)
self.transport.write(encoded) | def _writeResponse(self, response):
"""
Serializes the response to JSON, and writes it to the transport.
"""
encoded = dumps(response, default=_default)
self.transport.write(encoded) | [
"Serializes",
"the",
"response",
"to",
"JSON",
"and",
"writes",
"it",
"to",
"the",
"transport",
"."
] | lvh/txampext | python | https://github.com/lvh/txampext/blob/a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9/txampext/jsondialect.py#L111-L116 | [
"def",
"_writeResponse",
"(",
"self",
",",
"response",
")",
":",
"encoded",
"=",
"dumps",
"(",
"response",
",",
"default",
"=",
"_default",
")",
"self",
".",
"transport",
".",
"write",
"(",
"encoded",
")"
] | a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9 |
test | JSONAMPDialectReceiver.connectionLost | Tells the box receiver to stop receiving boxes. | txampext/jsondialect.py | def connectionLost(self, reason):
"""
Tells the box receiver to stop receiving boxes.
"""
self._remote.boxReceiver.stopReceivingBoxes(reason)
return basic.NetstringReceiver.connectionLost(self, reason) | def connectionLost(self, reason):
"""
Tells the box receiver to stop receiving boxes.
"""
self._remote.boxReceiver.stopReceivingBoxes(reason)
return basic.NetstringReceiver.connectionLost(self, reason) | [
"Tells",
"the",
"box",
"receiver",
"to",
"stop",
"receiving",
"boxes",
"."
] | lvh/txampext | python | https://github.com/lvh/txampext/blob/a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9/txampext/jsondialect.py#L119-L124 | [
"def",
"connectionLost",
"(",
"self",
",",
"reason",
")",
":",
"self",
".",
"_remote",
".",
"boxReceiver",
".",
"stopReceivingBoxes",
"(",
"reason",
")",
"return",
"basic",
".",
"NetstringReceiver",
".",
"connectionLost",
"(",
"self",
",",
"reason",
")"
] | a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9 |
test | JSONAMPDialectFactory.buildProtocol | Builds a bridge and associates it with an AMP protocol instance. | txampext/jsondialect.py | def buildProtocol(self, addr):
"""
Builds a bridge and associates it with an AMP protocol instance.
"""
proto = self._factory.buildProtocol(addr)
return JSONAMPDialectReceiver(proto) | def buildProtocol(self, addr):
"""
Builds a bridge and associates it with an AMP protocol instance.
"""
proto = self._factory.buildProtocol(addr)
return JSONAMPDialectReceiver(proto) | [
"Builds",
"a",
"bridge",
"and",
"associates",
"it",
"with",
"an",
"AMP",
"protocol",
"instance",
"."
] | lvh/txampext | python | https://github.com/lvh/txampext/blob/a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9/txampext/jsondialect.py#L159-L164 | [
"def",
"buildProtocol",
"(",
"self",
",",
"addr",
")",
":",
"proto",
"=",
"self",
".",
"_factory",
".",
"buildProtocol",
"(",
"addr",
")",
"return",
"JSONAMPDialectReceiver",
"(",
"proto",
")"
] | a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9 |
test | get_bundle | Read a signed JWKS bundle from disc, verify the signature and
instantiate a JWKSBundle instance with the information from the file.
:param iss:
:param ver_keys:
:param bundle_file:
:return: | src/fedoidcmsg/bundle.py | def get_bundle(iss, ver_keys, bundle_file):
"""
Read a signed JWKS bundle from disc, verify the signature and
instantiate a JWKSBundle instance with the information from the file.
:param iss:
:param ver_keys:
:param bundle_file:
:return:
"""
fp = open(bundle_file, 'r')
signe... | def get_bundle(iss, ver_keys, bundle_file):
"""
Read a signed JWKS bundle from disc, verify the signature and
instantiate a JWKSBundle instance with the information from the file.
:param iss:
:param ver_keys:
:param bundle_file:
:return:
"""
fp = open(bundle_file, 'r')
signe... | [
"Read",
"a",
"signed",
"JWKS",
"bundle",
"from",
"disc",
"verify",
"the",
"signature",
"and",
"instantiate",
"a",
"JWKSBundle",
"instance",
"with",
"the",
"information",
"from",
"the",
"file",
".",
":",
"param",
"iss",
":",
":",
"param",
"ver_keys",
":",
"... | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/bundle.py#L212-L225 | [
"def",
"get_bundle",
"(",
"iss",
",",
"ver_keys",
",",
"bundle_file",
")",
":",
"fp",
"=",
"open",
"(",
"bundle_file",
",",
"'r'",
")",
"signed_bundle",
"=",
"fp",
".",
"read",
"(",
")",
"fp",
".",
"close",
"(",
")",
"return",
"JWKSBundle",
"(",
"iss... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | get_signing_keys | If the *key_file* file exists then read the keys from there, otherwise
create the keys and store them a file with the name *key_file*.
:param eid: The ID of the entity that the keys belongs to
:param keydef: What keys to create
:param key_file: A file name
:return: A :py:class:`oidcmsg.key_jar.KeyJ... | src/fedoidcmsg/bundle.py | def get_signing_keys(eid, keydef, key_file):
"""
If the *key_file* file exists then read the keys from there, otherwise
create the keys and store them a file with the name *key_file*.
:param eid: The ID of the entity that the keys belongs to
:param keydef: What keys to create
:param key_file: A... | def get_signing_keys(eid, keydef, key_file):
"""
If the *key_file* file exists then read the keys from there, otherwise
create the keys and store them a file with the name *key_file*.
:param eid: The ID of the entity that the keys belongs to
:param keydef: What keys to create
:param key_file: A... | [
"If",
"the",
"*",
"key_file",
"*",
"file",
"exists",
"then",
"read",
"the",
"keys",
"from",
"there",
"otherwise",
"create",
"the",
"keys",
"and",
"store",
"them",
"a",
"file",
"with",
"the",
"name",
"*",
"key_file",
"*",
"."
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/bundle.py#L228-L249 | [
"def",
"get_signing_keys",
"(",
"eid",
",",
"keydef",
",",
"key_file",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"key_file",
")",
":",
"kj",
"=",
"KeyJar",
"(",
")",
"kj",
".",
"import_jwks",
"(",
"json",
".",
"loads",
"(",
"open",
"("... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | jwks_to_keyjar | Convert a JWKS to a KeyJar instance.
:param jwks: String representation of a JWKS
:return: A :py:class:`oidcmsg.key_jar.KeyJar` instance | src/fedoidcmsg/bundle.py | def jwks_to_keyjar(jwks, iss=''):
"""
Convert a JWKS to a KeyJar instance.
:param jwks: String representation of a JWKS
:return: A :py:class:`oidcmsg.key_jar.KeyJar` instance
"""
if not isinstance(jwks, dict):
try:
jwks = json.loads(jwks)
except json.JSONDecodeError:... | def jwks_to_keyjar(jwks, iss=''):
"""
Convert a JWKS to a KeyJar instance.
:param jwks: String representation of a JWKS
:return: A :py:class:`oidcmsg.key_jar.KeyJar` instance
"""
if not isinstance(jwks, dict):
try:
jwks = json.loads(jwks)
except json.JSONDecodeError:... | [
"Convert",
"a",
"JWKS",
"to",
"a",
"KeyJar",
"instance",
"."
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/bundle.py#L252-L267 | [
"def",
"jwks_to_keyjar",
"(",
"jwks",
",",
"iss",
"=",
"''",
")",
":",
"if",
"not",
"isinstance",
"(",
"jwks",
",",
"dict",
")",
":",
"try",
":",
"jwks",
"=",
"json",
".",
"loads",
"(",
"jwks",
")",
"except",
"json",
".",
"JSONDecodeError",
":",
"r... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | JWKSBundle.create_signed_bundle | Create a signed JWT containing a dictionary with Issuer IDs as keys
and JWKSs as values. If iss_list is empty then all available issuers are
included.
:param sign_alg: Which algorithm to use when signing the JWT
:param iss_list: A list of issuer IDs who's keys should be included... | src/fedoidcmsg/bundle.py | def create_signed_bundle(self, sign_alg='RS256', iss_list=None):
"""
Create a signed JWT containing a dictionary with Issuer IDs as keys
and JWKSs as values. If iss_list is empty then all available issuers are
included.
:param sign_alg: Which algorithm to use when signin... | def create_signed_bundle(self, sign_alg='RS256', iss_list=None):
"""
Create a signed JWT containing a dictionary with Issuer IDs as keys
and JWKSs as values. If iss_list is empty then all available issuers are
included.
:param sign_alg: Which algorithm to use when signin... | [
"Create",
"a",
"signed",
"JWT",
"containing",
"a",
"dictionary",
"with",
"Issuer",
"IDs",
"as",
"keys",
"and",
"JWKSs",
"as",
"values",
".",
"If",
"iss_list",
"is",
"empty",
"then",
"all",
"available",
"issuers",
"are",
"included",
".",
":",
"param",
"sign... | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/bundle.py#L92-L105 | [
"def",
"create_signed_bundle",
"(",
"self",
",",
"sign_alg",
"=",
"'RS256'",
",",
"iss_list",
"=",
"None",
")",
":",
"data",
"=",
"self",
".",
"dict",
"(",
"iss_list",
")",
"_jwt",
"=",
"JWT",
"(",
"self",
".",
"sign_keys",
",",
"iss",
"=",
"self",
"... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | JWKSBundle.loads | Upload a bundle from an unsigned JSON document
:param jstr: A bundle as a dictionary or a JSON document | src/fedoidcmsg/bundle.py | def loads(self, jstr):
"""
Upload a bundle from an unsigned JSON document
:param jstr: A bundle as a dictionary or a JSON document
"""
if isinstance(jstr, dict):
_info = jstr
else:
_info = json.loads(jstr)
for iss, jwks in _info.items():
... | def loads(self, jstr):
"""
Upload a bundle from an unsigned JSON document
:param jstr: A bundle as a dictionary or a JSON document
"""
if isinstance(jstr, dict):
_info = jstr
else:
_info = json.loads(jstr)
for iss, jwks in _info.items():
... | [
"Upload",
"a",
"bundle",
"from",
"an",
"unsigned",
"JSON",
"document"
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/bundle.py#L107-L125 | [
"def",
"loads",
"(",
"self",
",",
"jstr",
")",
":",
"if",
"isinstance",
"(",
"jstr",
",",
"dict",
")",
":",
"_info",
"=",
"jstr",
"else",
":",
"_info",
"=",
"json",
".",
"loads",
"(",
"jstr",
")",
"for",
"iss",
",",
"jwks",
"in",
"_info",
".",
... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | JWKSBundle.dict | Return the bundle of keys as a dictionary with the issuer IDs as
the keys and the key sets represented as JWKS instances.
:param iss_list: List of Issuer IDs that should be part of the
output
:rtype: Dictionary | src/fedoidcmsg/bundle.py | def dict(self, iss_list=None):
"""
Return the bundle of keys as a dictionary with the issuer IDs as
the keys and the key sets represented as JWKS instances.
:param iss_list: List of Issuer IDs that should be part of the
output
:rtype: Dictionary
"""
... | def dict(self, iss_list=None):
"""
Return the bundle of keys as a dictionary with the issuer IDs as
the keys and the key sets represented as JWKS instances.
:param iss_list: List of Issuer IDs that should be part of the
output
:rtype: Dictionary
"""
... | [
"Return",
"the",
"bundle",
"of",
"keys",
"as",
"a",
"dictionary",
"with",
"the",
"issuer",
"IDs",
"as",
"the",
"keys",
"and",
"the",
"key",
"sets",
"represented",
"as",
"JWKS",
"instances",
".",
":",
"param",
"iss_list",
":",
"List",
"of",
"Issuer",
"IDs... | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/bundle.py#L151-L167 | [
"def",
"dict",
"(",
"self",
",",
"iss_list",
"=",
"None",
")",
":",
"_int",
"=",
"{",
"}",
"for",
"iss",
",",
"kj",
"in",
"self",
".",
"bundle",
".",
"items",
"(",
")",
":",
"if",
"iss_list",
"is",
"None",
"or",
"iss",
"in",
"iss_list",
":",
"t... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | JWKSBundle.upload_signed_bundle | Input is a signed JWT with a JSON document representing the key bundle
as body. This method verifies the signature and the updates the instance
bundle with whatever was in the received package. Note, that as with
dictionary update if an Issuer ID already exists in the instance bundle
t... | src/fedoidcmsg/bundle.py | def upload_signed_bundle(self, sign_bundle, ver_keys):
"""
Input is a signed JWT with a JSON document representing the key bundle
as body. This method verifies the signature and the updates the instance
bundle with whatever was in the received package. Note, that as with
dictio... | def upload_signed_bundle(self, sign_bundle, ver_keys):
"""
Input is a signed JWT with a JSON document representing the key bundle
as body. This method verifies the signature and the updates the instance
bundle with whatever was in the received package. Note, that as with
dictio... | [
"Input",
"is",
"a",
"signed",
"JWT",
"with",
"a",
"JSON",
"document",
"representing",
"the",
"key",
"bundle",
"as",
"body",
".",
"This",
"method",
"verifies",
"the",
"signature",
"and",
"the",
"updates",
"the",
"instance",
"bundle",
"with",
"whatever",
"was"... | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/bundle.py#L169-L181 | [
"def",
"upload_signed_bundle",
"(",
"self",
",",
"sign_bundle",
",",
"ver_keys",
")",
":",
"jwt",
"=",
"verify_signed_bundle",
"(",
"sign_bundle",
",",
"ver_keys",
")",
"self",
".",
"loads",
"(",
"jwt",
"[",
"'bundle'",
"]",
")"
] | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | JWKSBundle.as_keyjar | Convert a key bundle into a KeyJar instance.
:return: An :py:class:`oidcmsg.key_jar.KeyJar` instance | src/fedoidcmsg/bundle.py | def as_keyjar(self):
"""
Convert a key bundle into a KeyJar instance.
:return: An :py:class:`oidcmsg.key_jar.KeyJar` instance
"""
kj = KeyJar()
for iss, k in self.bundle.items():
try:
kj.issuer_keys[iss] = k.issuer_keys[iss]
... | def as_keyjar(self):
"""
Convert a key bundle into a KeyJar instance.
:return: An :py:class:`oidcmsg.key_jar.KeyJar` instance
"""
kj = KeyJar()
for iss, k in self.bundle.items():
try:
kj.issuer_keys[iss] = k.issuer_keys[iss]
... | [
"Convert",
"a",
"key",
"bundle",
"into",
"a",
"KeyJar",
"instance",
".",
":",
"return",
":",
"An",
":",
"py",
":",
"class",
":",
"oidcmsg",
".",
"key_jar",
".",
"KeyJar",
"instance"
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/bundle.py#L183-L195 | [
"def",
"as_keyjar",
"(",
"self",
")",
":",
"kj",
"=",
"KeyJar",
"(",
")",
"for",
"iss",
",",
"k",
"in",
"self",
".",
"bundle",
".",
"items",
"(",
")",
":",
"try",
":",
"kj",
".",
"issuer_keys",
"[",
"iss",
"]",
"=",
"k",
".",
"issuer_keys",
"["... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | make_shortcut | return a function which runs the given cmd
make_shortcut('ls') returns a function which executes
envoy.run('ls ' + arguments) | pub/shortcuts/shortcuts.py | def make_shortcut(cmd):
"""return a function which runs the given cmd
make_shortcut('ls') returns a function which executes
envoy.run('ls ' + arguments)"""
def _(cmd_arguments, *args, **kwargs):
return run("%s %s" % (cmd, cmd_arguments), *args, **kwargs)
return _ | def make_shortcut(cmd):
"""return a function which runs the given cmd
make_shortcut('ls') returns a function which executes
envoy.run('ls ' + arguments)"""
def _(cmd_arguments, *args, **kwargs):
return run("%s %s" % (cmd, cmd_arguments), *args, **kwargs)
return _ | [
"return",
"a",
"function",
"which",
"runs",
"the",
"given",
"cmd",
"make_shortcut",
"(",
"ls",
")",
"returns",
"a",
"function",
"which",
"executes",
"envoy",
".",
"run",
"(",
"ls",
"+",
"arguments",
")"
] | llimllib/pub | python | https://github.com/llimllib/pub/blob/bd8472f04800612c50cac0682a4aee0a441b1d56/pub/shortcuts/shortcuts.py#L21-L28 | [
"def",
"make_shortcut",
"(",
"cmd",
")",
":",
"def",
"_",
"(",
"cmd_arguments",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"run",
"(",
"\"%s %s\"",
"%",
"(",
"cmd",
",",
"cmd_arguments",
")",
",",
"*",
"args",
",",
"*",
"*",
"... | bd8472f04800612c50cac0682a4aee0a441b1d56 |
test | nova_process | This function deal with the nova notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya default process.
:param body: dict of open... | ternya/process.py | def nova_process(body, message):
"""
This function deal with the nova notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya d... | def nova_process(body, message):
"""
This function deal with the nova notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya d... | [
"This",
"function",
"deal",
"with",
"the",
"nova",
"notification",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/process.py#L27-L54 | [
"def",
"nova_process",
"(",
"body",
",",
"message",
")",
":",
"event_type",
"=",
"body",
"[",
"'event_type'",
"]",
"process",
"=",
"nova_customer_process",
".",
"get",
"(",
"event_type",
")",
"if",
"process",
"is",
"not",
"None",
":",
"process",
"(",
"body... | c05aec10029e645d63ff04313dbcf2644743481f |
test | cinder_process | This function deal with the cinder notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya default process.
:param body: dict of op... | ternya/process.py | def cinder_process(body, message):
"""
This function deal with the cinder notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use tern... | def cinder_process(body, message):
"""
This function deal with the cinder notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use tern... | [
"This",
"function",
"deal",
"with",
"the",
"cinder",
"notification",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/process.py#L57-L84 | [
"def",
"cinder_process",
"(",
"body",
",",
"message",
")",
":",
"event_type",
"=",
"body",
"[",
"'event_type'",
"]",
"process",
"=",
"cinder_customer_process",
".",
"get",
"(",
"event_type",
")",
"if",
"process",
"is",
"not",
"None",
":",
"process",
"(",
"... | c05aec10029e645d63ff04313dbcf2644743481f |
test | neutron_process | This function deal with the neutron notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya default process.
:param body: dict of o... | ternya/process.py | def neutron_process(body, message):
"""
This function deal with the neutron notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use te... | def neutron_process(body, message):
"""
This function deal with the neutron notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use te... | [
"This",
"function",
"deal",
"with",
"the",
"neutron",
"notification",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/process.py#L87-L114 | [
"def",
"neutron_process",
"(",
"body",
",",
"message",
")",
":",
"event_type",
"=",
"body",
"[",
"'event_type'",
"]",
"process",
"=",
"neutron_customer_process",
".",
"get",
"(",
"event_type",
")",
"if",
"process",
"is",
"not",
"None",
":",
"process",
"(",
... | c05aec10029e645d63ff04313dbcf2644743481f |
test | glance_process | This function deal with the glance notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya default process.
:param body: dict of op... | ternya/process.py | def glance_process(body, message):
"""
This function deal with the glance notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use tern... | def glance_process(body, message):
"""
This function deal with the glance notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use tern... | [
"This",
"function",
"deal",
"with",
"the",
"glance",
"notification",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/process.py#L117-L144 | [
"def",
"glance_process",
"(",
"body",
",",
"message",
")",
":",
"event_type",
"=",
"body",
"[",
"'event_type'",
"]",
"process",
"=",
"glance_customer_process",
".",
"get",
"(",
"event_type",
")",
"if",
"process",
"is",
"not",
"None",
":",
"process",
"(",
"... | c05aec10029e645d63ff04313dbcf2644743481f |
test | swift_process | This function deal with the swift notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya default process.
:param body: dict of ope... | ternya/process.py | def swift_process(body, message):
"""
This function deal with the swift notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya... | def swift_process(body, message):
"""
This function deal with the swift notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya... | [
"This",
"function",
"deal",
"with",
"the",
"swift",
"notification",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/process.py#L147-L174 | [
"def",
"swift_process",
"(",
"body",
",",
"message",
")",
":",
"event_type",
"=",
"body",
"[",
"'event_type'",
"]",
"process",
"=",
"swift_customer_process",
".",
"get",
"(",
"event_type",
")",
"if",
"process",
"is",
"not",
"None",
":",
"process",
"(",
"bo... | c05aec10029e645d63ff04313dbcf2644743481f |
test | keystone_process | This function deal with the keystone notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya default process.
:param body: dict of ... | ternya/process.py | def keystone_process(body, message):
"""
This function deal with the keystone notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ... | def keystone_process(body, message):
"""
This function deal with the keystone notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ... | [
"This",
"function",
"deal",
"with",
"the",
"keystone",
"notification",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/process.py#L177-L204 | [
"def",
"keystone_process",
"(",
"body",
",",
"message",
")",
":",
"event_type",
"=",
"body",
"[",
"'event_type'",
"]",
"process",
"=",
"keystone_customer_process",
".",
"get",
"(",
"event_type",
")",
"if",
"process",
"is",
"not",
"None",
":",
"process",
"(",... | c05aec10029e645d63ff04313dbcf2644743481f |
test | heat_process | This function deal with the heat notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya default process.
:param body: dict of open... | ternya/process.py | def heat_process(body, message):
"""
This function deal with the heat notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya d... | def heat_process(body, message):
"""
This function deal with the heat notification.
First, find process from customer_process that not include wildcard.
if not find from customer_process, then find process from customer_process_wildcard.
if not find from customer_process_wildcard, then use ternya d... | [
"This",
"function",
"deal",
"with",
"the",
"heat",
"notification",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/process.py#L207-L234 | [
"def",
"heat_process",
"(",
"body",
",",
"message",
")",
":",
"event_type",
"=",
"body",
"[",
"'event_type'",
"]",
"process",
"=",
"heat_customer_process",
".",
"get",
"(",
"event_type",
")",
"if",
"process",
"is",
"not",
"None",
":",
"process",
"(",
"body... | c05aec10029e645d63ff04313dbcf2644743481f |
test | App.serve | Serve app using wsgiref or provided server.
Args:
- server (callable): An callable | punch/app.py | def serve(self, server=None):
"""Serve app using wsgiref or provided server.
Args:
- server (callable): An callable
"""
if server is None:
from wsgiref.simple_server import make_server
server = lambda app: make_server('', 8000, app).serve_forever()
... | def serve(self, server=None):
"""Serve app using wsgiref or provided server.
Args:
- server (callable): An callable
"""
if server is None:
from wsgiref.simple_server import make_server
server = lambda app: make_server('', 8000, app).serve_forever()
... | [
"Serve",
"app",
"using",
"wsgiref",
"or",
"provided",
"server",
"."
] | rochacon/punch | python | https://github.com/rochacon/punch/blob/7f6fb81221049ab74ef561fb40a4174bdb3e77ef/punch/app.py#L70-L83 | [
"def",
"serve",
"(",
"self",
",",
"server",
"=",
"None",
")",
":",
"if",
"server",
"is",
"None",
":",
"from",
"wsgiref",
".",
"simple_server",
"import",
"make_server",
"server",
"=",
"lambda",
"app",
":",
"make_server",
"(",
"''",
",",
"8000",
",",
"ap... | 7f6fb81221049ab74ef561fb40a4174bdb3e77ef |
test | pout | Print 'msg' to stdout, and option 'log' at info level. | nicfit/console/_io.py | def pout(msg, log=None):
"""Print 'msg' to stdout, and option 'log' at info level."""
_print(msg, sys.stdout, log_func=log.info if log else None) | def pout(msg, log=None):
"""Print 'msg' to stdout, and option 'log' at info level."""
_print(msg, sys.stdout, log_func=log.info if log else None) | [
"Print",
"msg",
"to",
"stdout",
"and",
"option",
"log",
"at",
"info",
"level",
"."
] | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/console/_io.py#L4-L6 | [
"def",
"pout",
"(",
"msg",
",",
"log",
"=",
"None",
")",
":",
"_print",
"(",
"msg",
",",
"sys",
".",
"stdout",
",",
"log_func",
"=",
"log",
".",
"info",
"if",
"log",
"else",
"None",
")"
] | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | perr | Print 'msg' to stderr, and option 'log' at info level. | nicfit/console/_io.py | def perr(msg, log=None):
"""Print 'msg' to stderr, and option 'log' at info level."""
_print(msg, sys.stderr, log_func=log.error if log else None) | def perr(msg, log=None):
"""Print 'msg' to stderr, and option 'log' at info level."""
_print(msg, sys.stderr, log_func=log.error if log else None) | [
"Print",
"msg",
"to",
"stderr",
"and",
"option",
"log",
"at",
"info",
"level",
"."
] | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/console/_io.py#L9-L11 | [
"def",
"perr",
"(",
"msg",
",",
"log",
"=",
"None",
")",
":",
"_print",
"(",
"msg",
",",
"sys",
".",
"stderr",
",",
"log_func",
"=",
"log",
".",
"error",
"if",
"log",
"else",
"None",
")"
] | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | register | A class decorator for Command classes to register in the default set. | nicfit/command.py | def register(CommandSubClass):
"""A class decorator for Command classes to register in the default set."""
name = CommandSubClass.name()
if name in Command._all_commands:
raise ValueError("Command already exists: " + name)
Command._all_commands[name] = CommandSubClass
return CommandSubClass | def register(CommandSubClass):
"""A class decorator for Command classes to register in the default set."""
name = CommandSubClass.name()
if name in Command._all_commands:
raise ValueError("Command already exists: " + name)
Command._all_commands[name] = CommandSubClass
return CommandSubClass | [
"A",
"class",
"decorator",
"for",
"Command",
"classes",
"to",
"register",
"in",
"the",
"default",
"set",
"."
] | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/command.py#L11-L17 | [
"def",
"register",
"(",
"CommandSubClass",
")",
":",
"name",
"=",
"CommandSubClass",
".",
"name",
"(",
")",
"if",
"name",
"in",
"Command",
".",
"_all_commands",
":",
"raise",
"ValueError",
"(",
"\"Command already exists: \"",
"+",
"name",
")",
"Command",
".",
... | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | Command.register | A class decorator for Command classes to register. | nicfit/command.py | def register(Class, CommandSubClass):
"""A class decorator for Command classes to register."""
for name in [CommandSubClass.name()] + CommandSubClass.aliases():
if name in Class._registered_commands[Class]:
raise ValueError("Command already exists: " + name)
Class... | def register(Class, CommandSubClass):
"""A class decorator for Command classes to register."""
for name in [CommandSubClass.name()] + CommandSubClass.aliases():
if name in Class._registered_commands[Class]:
raise ValueError("Command already exists: " + name)
Class... | [
"A",
"class",
"decorator",
"for",
"Command",
"classes",
"to",
"register",
"."
] | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/command.py#L37-L43 | [
"def",
"register",
"(",
"Class",
",",
"CommandSubClass",
")",
":",
"for",
"name",
"in",
"[",
"CommandSubClass",
".",
"name",
"(",
")",
"]",
"+",
"CommandSubClass",
".",
"aliases",
"(",
")",
":",
"if",
"name",
"in",
"Class",
".",
"_registered_commands",
"... | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | Command.loadCommandMap | Instantiate each registered command to a dict mapping name/alias to
instance.
Due to aliases, the returned length may be greater there the number of
commands, but the unique instance count will match. | nicfit/command.py | def loadCommandMap(Class, subparsers=None, instantiate=True, **cmd_kwargs):
"""Instantiate each registered command to a dict mapping name/alias to
instance.
Due to aliases, the returned length may be greater there the number of
commands, but the unique instance count will match.
... | def loadCommandMap(Class, subparsers=None, instantiate=True, **cmd_kwargs):
"""Instantiate each registered command to a dict mapping name/alias to
instance.
Due to aliases, the returned length may be greater there the number of
commands, but the unique instance count will match.
... | [
"Instantiate",
"each",
"registered",
"command",
"to",
"a",
"dict",
"mapping",
"name",
"/",
"alias",
"to",
"instance",
"."
] | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/command.py#L118-L135 | [
"def",
"loadCommandMap",
"(",
"Class",
",",
"subparsers",
"=",
"None",
",",
"instantiate",
"=",
"True",
",",
"*",
"*",
"cmd_kwargs",
")",
":",
"if",
"not",
"Class",
".",
"_registered_commands",
":",
"raise",
"ValueError",
"(",
"\"No commands have been registered... | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | ConstrainedArgument.toString | If all of the constraints are satisfied with the given value, defers
to the composed AMP argument's ``toString`` method. | txampext/constraints.py | def toString(self, value):
"""
If all of the constraints are satisfied with the given value, defers
to the composed AMP argument's ``toString`` method.
"""
self._checkConstraints(value)
return self.baseArgument.toString(value) | def toString(self, value):
"""
If all of the constraints are satisfied with the given value, defers
to the composed AMP argument's ``toString`` method.
"""
self._checkConstraints(value)
return self.baseArgument.toString(value) | [
"If",
"all",
"of",
"the",
"constraints",
"are",
"satisfied",
"with",
"the",
"given",
"value",
"defers",
"to",
"the",
"composed",
"AMP",
"argument",
"s",
"toString",
"method",
"."
] | lvh/txampext | python | https://github.com/lvh/txampext/blob/a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9/txampext/constraints.py#L20-L26 | [
"def",
"toString",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_checkConstraints",
"(",
"value",
")",
"return",
"self",
".",
"baseArgument",
".",
"toString",
"(",
"value",
")"
] | a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9 |
test | ConstrainedArgument.fromString | Converts the string to a value using the composed AMP argument, then
checks all the constraints against that value. | txampext/constraints.py | def fromString(self, string):
"""
Converts the string to a value using the composed AMP argument, then
checks all the constraints against that value.
"""
value = self.baseArgument.fromString(string)
self._checkConstraints(value)
return value | def fromString(self, string):
"""
Converts the string to a value using the composed AMP argument, then
checks all the constraints against that value.
"""
value = self.baseArgument.fromString(string)
self._checkConstraints(value)
return value | [
"Converts",
"the",
"string",
"to",
"a",
"value",
"using",
"the",
"composed",
"AMP",
"argument",
"then",
"checks",
"all",
"the",
"constraints",
"against",
"that",
"value",
"."
] | lvh/txampext | python | https://github.com/lvh/txampext/blob/a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9/txampext/constraints.py#L29-L36 | [
"def",
"fromString",
"(",
"self",
",",
"string",
")",
":",
"value",
"=",
"self",
".",
"baseArgument",
".",
"fromString",
"(",
"string",
")",
"self",
".",
"_checkConstraints",
"(",
"value",
")",
"return",
"value"
] | a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9 |
test | _updateCompleterDict | Merges ``cdict`` into ``completers``. In the event that a key
in cdict already exists in the completers dict a ValueError is raised
iff ``regex`` false'y. If a regex str is provided it and the duplicate
key are updated to be unique, and the updated regex is returned. | nicfit/shell/completion.py | def _updateCompleterDict(completers, cdict, regex=None):
"""Merges ``cdict`` into ``completers``. In the event that a key
in cdict already exists in the completers dict a ValueError is raised
iff ``regex`` false'y. If a regex str is provided it and the duplicate
key are updated to be uni... | def _updateCompleterDict(completers, cdict, regex=None):
"""Merges ``cdict`` into ``completers``. In the event that a key
in cdict already exists in the completers dict a ValueError is raised
iff ``regex`` false'y. If a regex str is provided it and the duplicate
key are updated to be uni... | [
"Merges",
"cdict",
"into",
"completers",
".",
"In",
"the",
"event",
"that",
"a",
"key",
"in",
"cdict",
"already",
"exists",
"in",
"the",
"completers",
"dict",
"a",
"ValueError",
"is",
"raised",
"iff",
"regex",
"false",
"y",
".",
"If",
"a",
"regex",
"str"... | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/shell/completion.py#L13-L30 | [
"def",
"_updateCompleterDict",
"(",
"completers",
",",
"cdict",
",",
"regex",
"=",
"None",
")",
":",
"for",
"key",
"in",
"cdict",
":",
"if",
"key",
"in",
"completers",
"and",
"not",
"regex",
":",
"raise",
"ValueError",
"(",
"f\"Duplicate completion key: {key}\... | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | WordCompleter.get_completions | log.debug("------------------------------------------------------")
log.debug(f"** WORD {self.WORD}")
log.debug(f"** words {self.words}")
log.debug(f"** word_before_cursor {word_before_cursor}") | nicfit/shell/completion.py | def get_completions(self, document, complete_event):
# Get word/text before cursor.
if self.sentence:
word_before_cursor = document.text_before_cursor
else:
word_before_cursor = document.get_word_before_cursor(WORD=self.WORD)
if self.ignore_case:
word... | def get_completions(self, document, complete_event):
# Get word/text before cursor.
if self.sentence:
word_before_cursor = document.text_before_cursor
else:
word_before_cursor = document.get_word_before_cursor(WORD=self.WORD)
if self.ignore_case:
word... | [
"log",
".",
"debug",
"(",
"------------------------------------------------------",
")",
"log",
".",
"debug",
"(",
"f",
"**",
"WORD",
"{",
"self",
".",
"WORD",
"}",
")",
"log",
".",
"debug",
"(",
"f",
"**",
"words",
"{",
"self",
".",
"words",
"}",
")",
... | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/shell/completion.py#L76-L110 | [
"def",
"get_completions",
"(",
"self",
",",
"document",
",",
"complete_event",
")",
":",
"# Get word/text before cursor.",
"if",
"self",
".",
"sentence",
":",
"word_before_cursor",
"=",
"document",
".",
"text_before_cursor",
"else",
":",
"word_before_cursor",
"=",
"... | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | Ternya.work | Start ternya work.
First, import customer's service modules.
Second, init openstack mq.
Third, keep a ternya connection that can auto-reconnect. | ternya/ternya.py | def work(self):
"""
Start ternya work.
First, import customer's service modules.
Second, init openstack mq.
Third, keep a ternya connection that can auto-reconnect.
"""
self.init_modules()
connection = self.init_mq()
TernyaConnection(self, connect... | def work(self):
"""
Start ternya work.
First, import customer's service modules.
Second, init openstack mq.
Third, keep a ternya connection that can auto-reconnect.
"""
self.init_modules()
connection = self.init_mq()
TernyaConnection(self, connect... | [
"Start",
"ternya",
"work",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L62-L72 | [
"def",
"work",
"(",
"self",
")",
":",
"self",
".",
"init_modules",
"(",
")",
"connection",
"=",
"self",
".",
"init_mq",
"(",
")",
"TernyaConnection",
"(",
"self",
",",
"connection",
")",
".",
"connect",
"(",
")"
] | c05aec10029e645d63ff04313dbcf2644743481f |
test | Ternya.init_mq | Init connection and consumer with openstack mq. | ternya/ternya.py | def init_mq(self):
"""Init connection and consumer with openstack mq."""
mq = self.init_connection()
self.init_consumer(mq)
return mq.connection | def init_mq(self):
"""Init connection and consumer with openstack mq."""
mq = self.init_connection()
self.init_consumer(mq)
return mq.connection | [
"Init",
"connection",
"and",
"consumer",
"with",
"openstack",
"mq",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L74-L78 | [
"def",
"init_mq",
"(",
"self",
")",
":",
"mq",
"=",
"self",
".",
"init_connection",
"(",
")",
"self",
".",
"init_consumer",
"(",
"mq",
")",
"return",
"mq",
".",
"connection"
] | c05aec10029e645d63ff04313dbcf2644743481f |
test | Ternya.init_modules | Import customer's service modules. | ternya/ternya.py | def init_modules(self):
"""Import customer's service modules."""
if not self.config:
raise ValueError("please read your config file.")
log.debug("begin to import customer's service modules.")
modules = ServiceModules(self.config)
modules.import_modules()
log.... | def init_modules(self):
"""Import customer's service modules."""
if not self.config:
raise ValueError("please read your config file.")
log.debug("begin to import customer's service modules.")
modules = ServiceModules(self.config)
modules.import_modules()
log.... | [
"Import",
"customer",
"s",
"service",
"modules",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L80-L88 | [
"def",
"init_modules",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"config",
":",
"raise",
"ValueError",
"(",
"\"please read your config file.\"",
")",
"log",
".",
"debug",
"(",
"\"begin to import customer's service modules.\"",
")",
"modules",
"=",
"ServiceMod... | c05aec10029e645d63ff04313dbcf2644743481f |
test | Ternya.init_nova_consumer | Init openstack nova mq
1. Check if enable listening nova notification
2. Create consumer
:param mq: class ternya.mq.MQ | ternya/ternya.py | def init_nova_consumer(self, mq):
"""
Init openstack nova mq
1. Check if enable listening nova notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Nova):
log.debug("disable listening n... | def init_nova_consumer(self, mq):
"""
Init openstack nova mq
1. Check if enable listening nova notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Nova):
log.debug("disable listening n... | [
"Init",
"openstack",
"nova",
"mq"
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L106-L123 | [
"def",
"init_nova_consumer",
"(",
"self",
",",
"mq",
")",
":",
"if",
"not",
"self",
".",
"enable_component_notification",
"(",
"Openstack",
".",
"Nova",
")",
":",
"log",
".",
"debug",
"(",
"\"disable listening nova notification\"",
")",
"return",
"for",
"i",
"... | c05aec10029e645d63ff04313dbcf2644743481f |
test | Ternya.init_cinder_consumer | Init openstack cinder mq
1. Check if enable listening cinder notification
2. Create consumer
:param mq: class ternya.mq.MQ | ternya/ternya.py | def init_cinder_consumer(self, mq):
"""
Init openstack cinder mq
1. Check if enable listening cinder notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Cinder):
log.debug("disable lis... | def init_cinder_consumer(self, mq):
"""
Init openstack cinder mq
1. Check if enable listening cinder notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Cinder):
log.debug("disable lis... | [
"Init",
"openstack",
"cinder",
"mq"
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L125-L143 | [
"def",
"init_cinder_consumer",
"(",
"self",
",",
"mq",
")",
":",
"if",
"not",
"self",
".",
"enable_component_notification",
"(",
"Openstack",
".",
"Cinder",
")",
":",
"log",
".",
"debug",
"(",
"\"disable listening cinder notification\"",
")",
"return",
"for",
"i... | c05aec10029e645d63ff04313dbcf2644743481f |
test | Ternya.init_neutron_consumer | Init openstack neutron mq
1. Check if enable listening neutron notification
2. Create consumer
:param mq: class ternya.mq.MQ | ternya/ternya.py | def init_neutron_consumer(self, mq):
"""
Init openstack neutron mq
1. Check if enable listening neutron notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Neutron):
log.debug("disable... | def init_neutron_consumer(self, mq):
"""
Init openstack neutron mq
1. Check if enable listening neutron notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Neutron):
log.debug("disable... | [
"Init",
"openstack",
"neutron",
"mq"
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L145-L163 | [
"def",
"init_neutron_consumer",
"(",
"self",
",",
"mq",
")",
":",
"if",
"not",
"self",
".",
"enable_component_notification",
"(",
"Openstack",
".",
"Neutron",
")",
":",
"log",
".",
"debug",
"(",
"\"disable listening neutron notification\"",
")",
"return",
"for",
... | c05aec10029e645d63ff04313dbcf2644743481f |
test | Ternya.init_glance_consumer | Init openstack glance mq
1. Check if enable listening glance notification
2. Create consumer
:param mq: class ternya.mq.MQ | ternya/ternya.py | def init_glance_consumer(self, mq):
"""
Init openstack glance mq
1. Check if enable listening glance notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Glance):
log.debug("disable lis... | def init_glance_consumer(self, mq):
"""
Init openstack glance mq
1. Check if enable listening glance notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Glance):
log.debug("disable lis... | [
"Init",
"openstack",
"glance",
"mq"
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L165-L183 | [
"def",
"init_glance_consumer",
"(",
"self",
",",
"mq",
")",
":",
"if",
"not",
"self",
".",
"enable_component_notification",
"(",
"Openstack",
".",
"Glance",
")",
":",
"log",
".",
"debug",
"(",
"\"disable listening glance notification\"",
")",
"return",
"for",
"i... | c05aec10029e645d63ff04313dbcf2644743481f |
test | Ternya.init_swift_consumer | Init openstack swift mq
1. Check if enable listening swift notification
2. Create consumer
:param mq: class ternya.mq.MQ | ternya/ternya.py | def init_swift_consumer(self, mq):
"""
Init openstack swift mq
1. Check if enable listening swift notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Swift):
log.debug("disable listeni... | def init_swift_consumer(self, mq):
"""
Init openstack swift mq
1. Check if enable listening swift notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Swift):
log.debug("disable listeni... | [
"Init",
"openstack",
"swift",
"mq"
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L185-L203 | [
"def",
"init_swift_consumer",
"(",
"self",
",",
"mq",
")",
":",
"if",
"not",
"self",
".",
"enable_component_notification",
"(",
"Openstack",
".",
"Swift",
")",
":",
"log",
".",
"debug",
"(",
"\"disable listening swift notification\"",
")",
"return",
"for",
"i",
... | c05aec10029e645d63ff04313dbcf2644743481f |
test | Ternya.init_keystone_consumer | Init openstack swift mq
1. Check if enable listening keystone notification
2. Create consumer
:param mq: class ternya.mq.MQ | ternya/ternya.py | def init_keystone_consumer(self, mq):
"""
Init openstack swift mq
1. Check if enable listening keystone notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Keystone):
log.debug("disabl... | def init_keystone_consumer(self, mq):
"""
Init openstack swift mq
1. Check if enable listening keystone notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Keystone):
log.debug("disabl... | [
"Init",
"openstack",
"swift",
"mq"
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L205-L223 | [
"def",
"init_keystone_consumer",
"(",
"self",
",",
"mq",
")",
":",
"if",
"not",
"self",
".",
"enable_component_notification",
"(",
"Openstack",
".",
"Keystone",
")",
":",
"log",
".",
"debug",
"(",
"\"disable listening keystone notification\"",
")",
"return",
"for"... | c05aec10029e645d63ff04313dbcf2644743481f |
test | Ternya.init_heat_consumer | Init openstack heat mq
1. Check if enable listening heat notification
2. Create consumer
:param mq: class ternya.mq.MQ | ternya/ternya.py | def init_heat_consumer(self, mq):
"""
Init openstack heat mq
1. Check if enable listening heat notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Heat):
log.debug("disable listening h... | def init_heat_consumer(self, mq):
"""
Init openstack heat mq
1. Check if enable listening heat notification
2. Create consumer
:param mq: class ternya.mq.MQ
"""
if not self.enable_component_notification(Openstack.Heat):
log.debug("disable listening h... | [
"Init",
"openstack",
"heat",
"mq"
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L225-L243 | [
"def",
"init_heat_consumer",
"(",
"self",
",",
"mq",
")",
":",
"if",
"not",
"self",
".",
"enable_component_notification",
"(",
"Openstack",
".",
"Heat",
")",
":",
"log",
".",
"debug",
"(",
"\"disable listening heat notification\"",
")",
"return",
"for",
"i",
"... | c05aec10029e645d63ff04313dbcf2644743481f |
test | Ternya.enable_component_notification | Check if customer enable openstack component notification.
:param openstack_component: Openstack component type. | ternya/ternya.py | def enable_component_notification(self, openstack_component):
"""
Check if customer enable openstack component notification.
:param openstack_component: Openstack component type.
"""
openstack_component_mapping = {
Openstack.Nova: self.config.listen_nova_notification... | def enable_component_notification(self, openstack_component):
"""
Check if customer enable openstack component notification.
:param openstack_component: Openstack component type.
"""
openstack_component_mapping = {
Openstack.Nova: self.config.listen_nova_notification... | [
"Check",
"if",
"customer",
"enable",
"openstack",
"component",
"notification",
"."
] | ndrlslz/ternya | python | https://github.com/ndrlslz/ternya/blob/c05aec10029e645d63ff04313dbcf2644743481f/ternya/ternya.py#L245-L260 | [
"def",
"enable_component_notification",
"(",
"self",
",",
"openstack_component",
")",
":",
"openstack_component_mapping",
"=",
"{",
"Openstack",
".",
"Nova",
":",
"self",
".",
"config",
".",
"listen_nova_notification",
",",
"Openstack",
".",
"Cinder",
":",
"self",
... | c05aec10029e645d63ff04313dbcf2644743481f |
test | music_info | Get music info from baidu music api | bmd/bmd.py | def music_info(songid):
"""
Get music info from baidu music api
"""
if isinstance(songid, list):
songid = ','.join(songid)
data = {
"hq": 1,
"songIds": songid
}
res = requests.post(MUSIC_INFO_URL, data=data)
info = res.json()
music_data = info["data"]
son... | def music_info(songid):
"""
Get music info from baidu music api
"""
if isinstance(songid, list):
songid = ','.join(songid)
data = {
"hq": 1,
"songIds": songid
}
res = requests.post(MUSIC_INFO_URL, data=data)
info = res.json()
music_data = info["data"]
son... | [
"Get",
"music",
"info",
"from",
"baidu",
"music",
"api"
] | maralla/bmd | python | https://github.com/maralla/bmd/blob/bbf87dc01de9a363ae5031e22a5ccc50d506f78a/bmd/bmd.py#L61-L85 | [
"def",
"music_info",
"(",
"songid",
")",
":",
"if",
"isinstance",
"(",
"songid",
",",
"list",
")",
":",
"songid",
"=",
"','",
".",
"join",
"(",
"songid",
")",
"data",
"=",
"{",
"\"hq\"",
":",
"1",
",",
"\"songIds\"",
":",
"songid",
"}",
"res",
"=",... | bbf87dc01de9a363ae5031e22a5ccc50d506f78a |
test | download_music | process for downing music with multiple threads | bmd/bmd.py | def download_music(song, thread_num=4):
"""
process for downing music with multiple threads
"""
filename = "{}.mp3".format(song["name"])
if os.path.exists(filename):
os.remove(filename)
part = int(song["size"] / thread_num)
if part <= 1024:
thread_num = 1
_id = uuid.uu... | def download_music(song, thread_num=4):
"""
process for downing music with multiple threads
"""
filename = "{}.mp3".format(song["name"])
if os.path.exists(filename):
os.remove(filename)
part = int(song["size"] / thread_num)
if part <= 1024:
thread_num = 1
_id = uuid.uu... | [
"process",
"for",
"downing",
"music",
"with",
"multiple",
"threads"
] | maralla/bmd | python | https://github.com/maralla/bmd/blob/bbf87dc01de9a363ae5031e22a5ccc50d506f78a/bmd/bmd.py#L88-L127 | [
"def",
"download_music",
"(",
"song",
",",
"thread_num",
"=",
"4",
")",
":",
"filename",
"=",
"\"{}.mp3\"",
".",
"format",
"(",
"song",
"[",
"\"name\"",
"]",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"os",
".",
"remove",... | bbf87dc01de9a363ae5031e22a5ccc50d506f78a |
test | Machine.execute | Execute a code object
The inputs and behavior of this function should match those of
eval_ and exec_.
.. _eval: https://docs.python.org/3/library/functions.html?highlight=eval#eval
.. _exec: https://docs.python.org/3/library/functions.html?highlight=exec#exec
.. note::... | codemach/machine.py | def execute(self, globals_=None, _locals=None):
"""
Execute a code object
The inputs and behavior of this function should match those of
eval_ and exec_.
.. _eval: https://docs.python.org/3/library/functions.html?highlight=eval#eval
.. _exec: https://docs.python... | def execute(self, globals_=None, _locals=None):
"""
Execute a code object
The inputs and behavior of this function should match those of
eval_ and exec_.
.. _eval: https://docs.python.org/3/library/functions.html?highlight=eval#eval
.. _exec: https://docs.python... | [
"Execute",
"a",
"code",
"object",
"The",
"inputs",
"and",
"behavior",
"of",
"this",
"function",
"should",
"match",
"those",
"of",
"eval_",
"and",
"exec_",
"."
] | chuck1/codemach | python | https://github.com/chuck1/codemach/blob/b0e02f363da7aa58de7d6ad6499784282958adeb/codemach/machine.py#L262-L291 | [
"def",
"execute",
"(",
"self",
",",
"globals_",
"=",
"None",
",",
"_locals",
"=",
"None",
")",
":",
"if",
"globals_",
"is",
"None",
":",
"globals_",
"=",
"globals",
"(",
")",
"if",
"_locals",
"is",
"None",
":",
"self",
".",
"_locals",
"=",
"globals_"... | b0e02f363da7aa58de7d6ad6499784282958adeb |
test | Machine.load_name | Implementation of the LOAD_NAME operation | codemach/machine.py | def load_name(self, name):
"""
Implementation of the LOAD_NAME operation
"""
if name in self.globals_:
return self.globals_[name]
b = self.globals_['__builtins__']
if isinstance(b, dict):
return b[name]
else:
return get... | def load_name(self, name):
"""
Implementation of the LOAD_NAME operation
"""
if name in self.globals_:
return self.globals_[name]
b = self.globals_['__builtins__']
if isinstance(b, dict):
return b[name]
else:
return get... | [
"Implementation",
"of",
"the",
"LOAD_NAME",
"operation"
] | chuck1/codemach | python | https://github.com/chuck1/codemach/blob/b0e02f363da7aa58de7d6ad6499784282958adeb/codemach/machine.py#L353-L364 | [
"def",
"load_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"globals_",
":",
"return",
"self",
".",
"globals_",
"[",
"name",
"]",
"b",
"=",
"self",
".",
"globals_",
"[",
"'__builtins__'",
"]",
"if",
"isinstance",
"(",
"b"... | b0e02f363da7aa58de7d6ad6499784282958adeb |
test | Machine.pop | Pop the **n** topmost items from the stack and return them as a ``list``. | codemach/machine.py | def pop(self, n):
"""
Pop the **n** topmost items from the stack and return them as a ``list``.
"""
poped = self.__stack[len(self.__stack) - n:]
del self.__stack[len(self.__stack) - n:]
return poped | def pop(self, n):
"""
Pop the **n** topmost items from the stack and return them as a ``list``.
"""
poped = self.__stack[len(self.__stack) - n:]
del self.__stack[len(self.__stack) - n:]
return poped | [
"Pop",
"the",
"**",
"n",
"**",
"topmost",
"items",
"from",
"the",
"stack",
"and",
"return",
"them",
"as",
"a",
"list",
"."
] | chuck1/codemach | python | https://github.com/chuck1/codemach/blob/b0e02f363da7aa58de7d6ad6499784282958adeb/codemach/machine.py#L374-L380 | [
"def",
"pop",
"(",
"self",
",",
"n",
")",
":",
"poped",
"=",
"self",
".",
"__stack",
"[",
"len",
"(",
"self",
".",
"__stack",
")",
"-",
"n",
":",
"]",
"del",
"self",
".",
"__stack",
"[",
"len",
"(",
"self",
".",
"__stack",
")",
"-",
"n",
":",... | b0e02f363da7aa58de7d6ad6499784282958adeb |
test | Machine.build_class | Implement ``builtins.__build_class__``.
We must wrap all class member functions using :py:func:`function_wrapper`.
This requires using a :py:class:`Machine` to execute the class source code
and then recreating the class source code using an :py:class:`Assembler`.
.. note: We might be ab... | codemach/machine.py | def build_class(self, callable_, args):
"""
Implement ``builtins.__build_class__``.
We must wrap all class member functions using :py:func:`function_wrapper`.
This requires using a :py:class:`Machine` to execute the class source code
and then recreating the class source code usin... | def build_class(self, callable_, args):
"""
Implement ``builtins.__build_class__``.
We must wrap all class member functions using :py:func:`function_wrapper`.
This requires using a :py:class:`Machine` to execute the class source code
and then recreating the class source code usin... | [
"Implement",
"builtins",
".",
"__build_class__",
".",
"We",
"must",
"wrap",
"all",
"class",
"member",
"functions",
"using",
":",
"py",
":",
"func",
":",
"function_wrapper",
".",
"This",
"requires",
"using",
"a",
":",
"py",
":",
"class",
":",
"Machine",
"to... | chuck1/codemach | python | https://github.com/chuck1/codemach/blob/b0e02f363da7aa58de7d6ad6499784282958adeb/codemach/machine.py#L385-L431 | [
"def",
"build_class",
"(",
"self",
",",
"callable_",
",",
"args",
")",
":",
"self",
".",
"_print",
"(",
"'build_class'",
")",
"self",
".",
"_print",
"(",
"callable_",
")",
"self",
".",
"_print",
"(",
"'args='",
",",
"args",
")",
"if",
"isinstance",
"("... | b0e02f363da7aa58de7d6ad6499784282958adeb |
test | Machine.call_function | Implement the CALL_FUNCTION_ operation.
.. _CALL_FUNCTION: https://docs.python.org/3/library/dis.html#opcode-CALL_FUNCTION | codemach/machine.py | def call_function(self, c, i):
"""
Implement the CALL_FUNCTION_ operation.
.. _CALL_FUNCTION: https://docs.python.org/3/library/dis.html#opcode-CALL_FUNCTION
"""
callable_ = self.__stack[-1-i.arg]
args = tuple(self.__stack[len(self.__stack) - i.arg:])
... | def call_function(self, c, i):
"""
Implement the CALL_FUNCTION_ operation.
.. _CALL_FUNCTION: https://docs.python.org/3/library/dis.html#opcode-CALL_FUNCTION
"""
callable_ = self.__stack[-1-i.arg]
args = tuple(self.__stack[len(self.__stack) - i.arg:])
... | [
"Implement",
"the",
"CALL_FUNCTION_",
"operation",
"."
] | chuck1/codemach | python | https://github.com/chuck1/codemach/blob/b0e02f363da7aa58de7d6ad6499784282958adeb/codemach/machine.py#L433-L464 | [
"def",
"call_function",
"(",
"self",
",",
"c",
",",
"i",
")",
":",
"callable_",
"=",
"self",
".",
"__stack",
"[",
"-",
"1",
"-",
"i",
".",
"arg",
"]",
"args",
"=",
"tuple",
"(",
"self",
".",
"__stack",
"[",
"len",
"(",
"self",
".",
"__stack",
"... | b0e02f363da7aa58de7d6ad6499784282958adeb |
test | dump | Perfoms a mysqldump backup.
Create a database dump for the given database.
returns statuscode and shelloutput | pyque/db/mysql.py | def dump(filename, dbname, username=None, password=None, host=None,
port=None, tempdir='/tmp', mysqldump_path='mysqldump'):
"""Perfoms a mysqldump backup.
Create a database dump for the given database.
returns statuscode and shelloutput
"""
filepath = os.path.join(tempdir, filename)
cmd = ... | def dump(filename, dbname, username=None, password=None, host=None,
port=None, tempdir='/tmp', mysqldump_path='mysqldump'):
"""Perfoms a mysqldump backup.
Create a database dump for the given database.
returns statuscode and shelloutput
"""
filepath = os.path.join(tempdir, filename)
cmd = ... | [
"Perfoms",
"a",
"mysqldump",
"backup",
".",
"Create",
"a",
"database",
"dump",
"for",
"the",
"given",
"database",
".",
"returns",
"statuscode",
"and",
"shelloutput"
] | bmaeser/pyque | python | https://github.com/bmaeser/pyque/blob/856dceab8d89cf3771cf21e682466c29a85ae8eb/pyque/db/mysql.py#L11-L35 | [
"def",
"dump",
"(",
"filename",
",",
"dbname",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"tempdir",
"=",
"'/tmp'",
",",
"mysqldump_path",
"=",
"'mysqldump'",
")",
":",
"filepath... | 856dceab8d89cf3771cf21e682466c29a85ae8eb |
test | _connection | returns a connected cursor to the database-server. | pyque/db/mysql.py | def _connection(username=None, password=None, host=None, port=None):
"returns a connected cursor to the database-server."
c_opts = {}
if username: c_opts['user'] = username
if password: c_opts['passwd'] = password
if host: c_opts['host'] = host
if port: c_opts['port'] = port
dbc = MySQLdb... | def _connection(username=None, password=None, host=None, port=None):
"returns a connected cursor to the database-server."
c_opts = {}
if username: c_opts['user'] = username
if password: c_opts['passwd'] = password
if host: c_opts['host'] = host
if port: c_opts['port'] = port
dbc = MySQLdb... | [
"returns",
"a",
"connected",
"cursor",
"to",
"the",
"database",
"-",
"server",
"."
] | bmaeser/pyque | python | https://github.com/bmaeser/pyque/blob/856dceab8d89cf3771cf21e682466c29a85ae8eb/pyque/db/mysql.py#L37-L49 | [
"def",
"_connection",
"(",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
")",
":",
"c_opts",
"=",
"{",
"}",
"if",
"username",
":",
"c_opts",
"[",
"'user'",
"]",
"=",
"username",
"if",
"pa... | 856dceab8d89cf3771cf21e682466c29a85ae8eb |
test | render_ditaa | Render ditaa code into a PNG output file. | docs/_exts/ditaa.py | def render_ditaa(self, code, options, prefix='ditaa'):
"""Render ditaa code into a PNG output file."""
hashkey = code.encode('utf-8') + str(options) + \
str(self.builder.config.ditaa) + \
str(self.builder.config.ditaa_args)
infname = '%s-%s.%s' % (prefix, sha(hashkey).hexdigest()... | def render_ditaa(self, code, options, prefix='ditaa'):
"""Render ditaa code into a PNG output file."""
hashkey = code.encode('utf-8') + str(options) + \
str(self.builder.config.ditaa) + \
str(self.builder.config.ditaa_args)
infname = '%s-%s.%s' % (prefix, sha(hashkey).hexdigest()... | [
"Render",
"ditaa",
"code",
"into",
"a",
"PNG",
"output",
"file",
"."
] | lvh/txampext | python | https://github.com/lvh/txampext/blob/a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9/docs/_exts/ditaa.py#L96-L160 | [
"def",
"render_ditaa",
"(",
"self",
",",
"code",
",",
"options",
",",
"prefix",
"=",
"'ditaa'",
")",
":",
"hashkey",
"=",
"code",
".",
"encode",
"(",
"'utf-8'",
")",
"+",
"str",
"(",
"options",
")",
"+",
"str",
"(",
"self",
".",
"builder",
".",
"co... | a7d6cb9f1e9200dba597378cd40eb6a2096d4fd9 |
test | Application._atexit | Invoked in the 'finally' block of Application.run. | nicfit/app.py | def _atexit(self):
"""Invoked in the 'finally' block of Application.run."""
self.log.debug("Application._atexit")
if self._atexit_func:
self._atexit_func(self) | def _atexit(self):
"""Invoked in the 'finally' block of Application.run."""
self.log.debug("Application._atexit")
if self._atexit_func:
self._atexit_func(self) | [
"Invoked",
"in",
"the",
"finally",
"block",
"of",
"Application",
".",
"run",
"."
] | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/app.py#L59-L63 | [
"def",
"_atexit",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Application._atexit\"",
")",
"if",
"self",
".",
"_atexit_func",
":",
"self",
".",
"_atexit_func",
"(",
"self",
")"
] | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | Application.run | Run Application.main and exits with the return value. | nicfit/app.py | def run(self, args_list=None):
"""Run Application.main and exits with the return value."""
self.log.debug("Application.run: {args_list}".format(**locals()))
retval = None
try:
retval = self._run(args_list=args_list)
except KeyboardInterrupt:
self.log.verbo... | def run(self, args_list=None):
"""Run Application.main and exits with the return value."""
self.log.debug("Application.run: {args_list}".format(**locals()))
retval = None
try:
retval = self._run(args_list=args_list)
except KeyboardInterrupt:
self.log.verbo... | [
"Run",
"Application",
".",
"main",
"and",
"exits",
"with",
"the",
"return",
"value",
"."
] | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/app.py#L74-L98 | [
"def",
"run",
"(",
"self",
",",
"args_list",
"=",
"None",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Application.run: {args_list}\"",
".",
"format",
"(",
"*",
"*",
"locals",
"(",
")",
")",
")",
"retval",
"=",
"None",
"try",
":",
"retval",
"=... | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | cd | Context manager that changes to directory `path` and return to CWD
when exited. | nicfit/util.py | def cd(path):
"""Context manager that changes to directory `path` and return to CWD
when exited.
"""
old_path = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(old_path) | def cd(path):
"""Context manager that changes to directory `path` and return to CWD
when exited.
"""
old_path = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(old_path) | [
"Context",
"manager",
"that",
"changes",
"to",
"directory",
"path",
"and",
"return",
"to",
"CWD",
"when",
"exited",
"."
] | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/util.py#L16-L25 | [
"def",
"cd",
"(",
"path",
")",
":",
"old_path",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"path",
")",
"try",
":",
"yield",
"finally",
":",
"os",
".",
"chdir",
"(",
"old_path",
")"
] | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | copytree | Modified from shutil.copytree docs code sample, merges files rather than
requiring dst to not exist. | nicfit/util.py | def copytree(src, dst, symlinks=True):
"""
Modified from shutil.copytree docs code sample, merges files rather than
requiring dst to not exist.
"""
from shutil import copy2, Error, copystat
names = os.listdir(src)
if not Path(dst).exists():
os.makedirs(dst)
errors = []
for... | def copytree(src, dst, symlinks=True):
"""
Modified from shutil.copytree docs code sample, merges files rather than
requiring dst to not exist.
"""
from shutil import copy2, Error, copystat
names = os.listdir(src)
if not Path(dst).exists():
os.makedirs(dst)
errors = []
for... | [
"Modified",
"from",
"shutil",
".",
"copytree",
"docs",
"code",
"sample",
"merges",
"files",
"rather",
"than",
"requiring",
"dst",
"to",
"not",
"exist",
"."
] | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/util.py#L28-L66 | [
"def",
"copytree",
"(",
"src",
",",
"dst",
",",
"symlinks",
"=",
"True",
")",
":",
"from",
"shutil",
"import",
"copy2",
",",
"Error",
",",
"copystat",
"names",
"=",
"os",
".",
"listdir",
"(",
"src",
")",
"if",
"not",
"Path",
"(",
"dst",
")",
".",
... | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | debugger | If called in the context of an exception, calls post_mortem; otherwise
set_trace.
``ipdb`` is preferred over ``pdb`` if installed. | nicfit/util.py | def debugger():
"""If called in the context of an exception, calls post_mortem; otherwise
set_trace.
``ipdb`` is preferred over ``pdb`` if installed.
"""
e, m, tb = sys.exc_info()
if tb is not None:
_debugger.post_mortem(tb)
else:
_debugger.set_trace() | def debugger():
"""If called in the context of an exception, calls post_mortem; otherwise
set_trace.
``ipdb`` is preferred over ``pdb`` if installed.
"""
e, m, tb = sys.exc_info()
if tb is not None:
_debugger.post_mortem(tb)
else:
_debugger.set_trace() | [
"If",
"called",
"in",
"the",
"context",
"of",
"an",
"exception",
"calls",
"post_mortem",
";",
"otherwise",
"set_trace",
".",
"ipdb",
"is",
"preferred",
"over",
"pdb",
"if",
"installed",
"."
] | nicfit/nicfit.py | python | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/util.py#L95-L104 | [
"def",
"debugger",
"(",
")",
":",
"e",
",",
"m",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"if",
"tb",
"is",
"not",
"None",
":",
"_debugger",
".",
"post_mortem",
"(",
"tb",
")",
"else",
":",
"_debugger",
".",
"set_trace",
"(",
")"
] | 8313f8edbc5e7361ddad496d6d818324b5236c7a |
test | FileSystem.keys | Implements the dict.keys() method | src/fedoidcmsg/file_system.py | def keys(self):
"""
Implements the dict.keys() method
"""
self.sync()
for k in self.db.keys():
try:
yield self.key_conv['from'](k)
except KeyError:
yield k | def keys(self):
"""
Implements the dict.keys() method
"""
self.sync()
for k in self.db.keys():
try:
yield self.key_conv['from'](k)
except KeyError:
yield k | [
"Implements",
"the",
"dict",
".",
"keys",
"()",
"method"
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/file_system.py#L99-L108 | [
"def",
"keys",
"(",
"self",
")",
":",
"self",
".",
"sync",
"(",
")",
"for",
"k",
"in",
"self",
".",
"db",
".",
"keys",
"(",
")",
":",
"try",
":",
"yield",
"self",
".",
"key_conv",
"[",
"'from'",
"]",
"(",
"k",
")",
"except",
"KeyError",
":",
... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | FileSystem.get_mtime | Find the time this file was last modified.
:param fname: File name
:return: The last time the file was modified. | src/fedoidcmsg/file_system.py | def get_mtime(fname):
"""
Find the time this file was last modified.
:param fname: File name
:return: The last time the file was modified.
"""
try:
mtime = os.stat(fname).st_mtime_ns
except OSError:
# The file might be right in the middle ... | def get_mtime(fname):
"""
Find the time this file was last modified.
:param fname: File name
:return: The last time the file was modified.
"""
try:
mtime = os.stat(fname).st_mtime_ns
except OSError:
# The file might be right in the middle ... | [
"Find",
"the",
"time",
"this",
"file",
"was",
"last",
"modified",
"."
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/file_system.py#L111-L126 | [
"def",
"get_mtime",
"(",
"fname",
")",
":",
"try",
":",
"mtime",
"=",
"os",
".",
"stat",
"(",
"fname",
")",
".",
"st_mtime_ns",
"except",
"OSError",
":",
"# The file might be right in the middle of being written",
"# so sleep",
"time",
".",
"sleep",
"(",
"1",
... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | FileSystem.is_changed | Find out if this item has been modified since last
:param item: A key
:return: True/False | src/fedoidcmsg/file_system.py | def is_changed(self, item):
"""
Find out if this item has been modified since last
:param item: A key
:return: True/False
"""
fname = os.path.join(self.fdir, item)
if os.path.isfile(fname):
mtime = self.get_mtime(fname)
try:
... | def is_changed(self, item):
"""
Find out if this item has been modified since last
:param item: A key
:return: True/False
"""
fname = os.path.join(self.fdir, item)
if os.path.isfile(fname):
mtime = self.get_mtime(fname)
try:
... | [
"Find",
"out",
"if",
"this",
"item",
"has",
"been",
"modified",
"since",
"last"
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/file_system.py#L128-L152 | [
"def",
"is_changed",
"(",
"self",
",",
"item",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"fdir",
",",
"item",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"fname",
")",
":",
"mtime",
"=",
"self",
".",
"get_m... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | FileSystem.sync | Goes through the directory and builds a local cache based on
the content of the directory. | src/fedoidcmsg/file_system.py | def sync(self):
"""
Goes through the directory and builds a local cache based on
the content of the directory.
"""
if not os.path.isdir(self.fdir):
os.makedirs(self.fdir)
for f in os.listdir(self.fdir):
fname = os.path.join(self.fdir, f)
... | def sync(self):
"""
Goes through the directory and builds a local cache based on
the content of the directory.
"""
if not os.path.isdir(self.fdir):
os.makedirs(self.fdir)
for f in os.listdir(self.fdir):
fname = os.path.join(self.fdir, f)
... | [
"Goes",
"through",
"the",
"directory",
"and",
"builds",
"a",
"local",
"cache",
"based",
"on",
"the",
"content",
"of",
"the",
"directory",
"."
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/file_system.py#L170-L188 | [
"def",
"sync",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"fdir",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"fdir",
")",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"fdir",
")... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | FileSystem.items | Implements the dict.items() method | src/fedoidcmsg/file_system.py | def items(self):
"""
Implements the dict.items() method
"""
self.sync()
for k, v in self.db.items():
try:
yield self.key_conv['from'](k), v
except KeyError:
yield k, v | def items(self):
"""
Implements the dict.items() method
"""
self.sync()
for k, v in self.db.items():
try:
yield self.key_conv['from'](k), v
except KeyError:
yield k, v | [
"Implements",
"the",
"dict",
".",
"items",
"()",
"method"
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/file_system.py#L190-L199 | [
"def",
"items",
"(",
"self",
")",
":",
"self",
".",
"sync",
"(",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"db",
".",
"items",
"(",
")",
":",
"try",
":",
"yield",
"self",
".",
"key_conv",
"[",
"'from'",
"]",
"(",
"k",
")",
",",
"v",
"ex... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | FileSystem.clear | Completely resets the database. This means that all information in
the local cache and on disc will be erased. | src/fedoidcmsg/file_system.py | def clear(self):
"""
Completely resets the database. This means that all information in
the local cache and on disc will be erased.
"""
if not os.path.isdir(self.fdir):
os.makedirs(self.fdir, exist_ok=True)
return
for f in os.listdir(self.fdir):
... | def clear(self):
"""
Completely resets the database. This means that all information in
the local cache and on disc will be erased.
"""
if not os.path.isdir(self.fdir):
os.makedirs(self.fdir, exist_ok=True)
return
for f in os.listdir(self.fdir):
... | [
"Completely",
"resets",
"the",
"database",
".",
"This",
"means",
"that",
"all",
"information",
"in",
"the",
"local",
"cache",
"and",
"on",
"disc",
"will",
"be",
"erased",
"."
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/file_system.py#L201-L211 | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"fdir",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"fdir",
",",
"exist_ok",
"=",
"True",
")",
"return",
"for",
"f",
"in",
"os",
".",
... | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | FileSystem.update | Implements the dict.update() method | src/fedoidcmsg/file_system.py | def update(self, ava):
"""
Implements the dict.update() method
"""
for key, val in ava.items():
self[key] = val | def update(self, ava):
"""
Implements the dict.update() method
"""
for key, val in ava.items():
self[key] = val | [
"Implements",
"the",
"dict",
".",
"update",
"()",
"method"
] | IdentityPython/fedoidcmsg | python | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/file_system.py#L213-L218 | [
"def",
"update",
"(",
"self",
",",
"ava",
")",
":",
"for",
"key",
",",
"val",
"in",
"ava",
".",
"items",
"(",
")",
":",
"self",
"[",
"key",
"]",
"=",
"val"
] | d30107be02521fa6cdfe285da3b6b0cdd153c8cc |
test | chr | x-->int / byte
Returns-->BYTE (not str in python3)
Behaves like PY2 chr() in PY2 or PY3
if x is str of length > 1 or int > 256
raises ValueError/TypeError is not SUPPRESS_ERRORS | cffi_utils/py2to3.py | def chr(x):
'''
x-->int / byte
Returns-->BYTE (not str in python3)
Behaves like PY2 chr() in PY2 or PY3
if x is str of length > 1 or int > 256
raises ValueError/TypeError is not SUPPRESS_ERRORS
'''
global _chr
if isinstance(x, int):
if x > 256:
if SUPPRESS... | def chr(x):
'''
x-->int / byte
Returns-->BYTE (not str in python3)
Behaves like PY2 chr() in PY2 or PY3
if x is str of length > 1 or int > 256
raises ValueError/TypeError is not SUPPRESS_ERRORS
'''
global _chr
if isinstance(x, int):
if x > 256:
if SUPPRESS... | [
"x",
"--",
">",
"int",
"/",
"byte",
"Returns",
"--",
">",
"BYTE",
"(",
"not",
"str",
"in",
"python3",
")",
"Behaves",
"like",
"PY2",
"chr",
"()",
"in",
"PY2",
"or",
"PY3",
"if",
"x",
"is",
"str",
"of",
"length",
">",
"1",
"or",
"int",
">",
"256... | sundarnagarajan/cffi_utils | python | https://github.com/sundarnagarajan/cffi_utils/blob/1d5ab2d2fcb962372228033106bc23f1d73d31fa/cffi_utils/py2to3.py#L121-L149 | [
"def",
"chr",
"(",
"x",
")",
":",
"global",
"_chr",
"if",
"isinstance",
"(",
"x",
",",
"int",
")",
":",
"if",
"x",
">",
"256",
":",
"if",
"SUPPRESS_ERRORS",
":",
"x",
"=",
"x",
"%",
"256",
"return",
"toBytes",
"(",
"_chr",
"(",
"x",
")",
")",
... | 1d5ab2d2fcb962372228033106bc23f1d73d31fa |
test | ord | x-->char (str of length 1)
Returns-->int
Behaves like PY2 ord() in PY2 or PY3
if x is str of length > 1 or int > 256
raises ValueError/TypeError is not SUPPRESS_ERRORS | cffi_utils/py2to3.py | def ord(x):
'''
x-->char (str of length 1)
Returns-->int
Behaves like PY2 ord() in PY2 or PY3
if x is str of length > 1 or int > 256
raises ValueError/TypeError is not SUPPRESS_ERRORS
'''
global _ord
if isinstance(x, int):
if x > 256:
if not SUPPRESS_ERROR... | def ord(x):
'''
x-->char (str of length 1)
Returns-->int
Behaves like PY2 ord() in PY2 or PY3
if x is str of length > 1 or int > 256
raises ValueError/TypeError is not SUPPRESS_ERRORS
'''
global _ord
if isinstance(x, int):
if x > 256:
if not SUPPRESS_ERROR... | [
"x",
"--",
">",
"char",
"(",
"str",
"of",
"length",
"1",
")",
"Returns",
"--",
">",
"int",
"Behaves",
"like",
"PY2",
"ord",
"()",
"in",
"PY2",
"or",
"PY3",
"if",
"x",
"is",
"str",
"of",
"length",
">",
"1",
"or",
"int",
">",
"256",
"raises",
"Va... | sundarnagarajan/cffi_utils | python | https://github.com/sundarnagarajan/cffi_utils/blob/1d5ab2d2fcb962372228033106bc23f1d73d31fa/cffi_utils/py2to3.py#L152-L178 | [
"def",
"ord",
"(",
"x",
")",
":",
"global",
"_ord",
"if",
"isinstance",
"(",
"x",
",",
"int",
")",
":",
"if",
"x",
">",
"256",
":",
"if",
"not",
"SUPPRESS_ERRORS",
":",
"raise",
"ValueError",
"(",
"'ord() arg not in range(256)'",
")",
"return",
"x",
"%... | 1d5ab2d2fcb962372228033106bc23f1d73d31fa |
test | hex | x-->bytes | bytearray
Returns-->bytes: hex-encoded | cffi_utils/py2to3.py | def hex(x):
'''
x-->bytes | bytearray
Returns-->bytes: hex-encoded
'''
if isinstance(x, bytearray):
x = bytes(x)
return encode(x, 'hex') | def hex(x):
'''
x-->bytes | bytearray
Returns-->bytes: hex-encoded
'''
if isinstance(x, bytearray):
x = bytes(x)
return encode(x, 'hex') | [
"x",
"--",
">",
"bytes",
"|",
"bytearray",
"Returns",
"--",
">",
"bytes",
":",
"hex",
"-",
"encoded"
] | sundarnagarajan/cffi_utils | python | https://github.com/sundarnagarajan/cffi_utils/blob/1d5ab2d2fcb962372228033106bc23f1d73d31fa/cffi_utils/py2to3.py#L191-L198 | [
"def",
"hex",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"bytearray",
")",
":",
"x",
"=",
"bytes",
"(",
"x",
")",
"return",
"encode",
"(",
"x",
",",
"'hex'",
")"
] | 1d5ab2d2fcb962372228033106bc23f1d73d31fa |
test | fromBytes | x-->unicode string | bytearray | bytes
Returns-->unicode string, with encoding=latin1 | cffi_utils/py2to3.py | def fromBytes(x):
'''
x-->unicode string | bytearray | bytes
Returns-->unicode string, with encoding=latin1
'''
if isinstance(x, unicode):
return x
if isinstance(x, bytearray):
x = bytes(x)
elif isinstance(x, bytes):
pass
else:
return x # unchanged (int e... | def fromBytes(x):
'''
x-->unicode string | bytearray | bytes
Returns-->unicode string, with encoding=latin1
'''
if isinstance(x, unicode):
return x
if isinstance(x, bytearray):
x = bytes(x)
elif isinstance(x, bytes):
pass
else:
return x # unchanged (int e... | [
"x",
"--",
">",
"unicode",
"string",
"|",
"bytearray",
"|",
"bytes",
"Returns",
"--",
">",
"unicode",
"string",
"with",
"encoding",
"=",
"latin1"
] | sundarnagarajan/cffi_utils | python | https://github.com/sundarnagarajan/cffi_utils/blob/1d5ab2d2fcb962372228033106bc23f1d73d31fa/cffi_utils/py2to3.py#L201-L214 | [
"def",
"fromBytes",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"unicode",
")",
":",
"return",
"x",
"if",
"isinstance",
"(",
"x",
",",
"bytearray",
")",
":",
"x",
"=",
"bytes",
"(",
"x",
")",
"elif",
"isinstance",
"(",
"x",
",",
"bytes... | 1d5ab2d2fcb962372228033106bc23f1d73d31fa |
test | toBytes | x-->unicode string | bytearray | bytes
Returns-->bytes
If x is unicode, MUST have encoding=latin1 | cffi_utils/py2to3.py | def toBytes(x):
'''
x-->unicode string | bytearray | bytes
Returns-->bytes
If x is unicode, MUST have encoding=latin1
'''
if isinstance(x, bytes):
return x
elif isinstance(x, bytearray):
return bytes(x)
elif isinstance(x, unicode):
pass
else:
return x ... | def toBytes(x):
'''
x-->unicode string | bytearray | bytes
Returns-->bytes
If x is unicode, MUST have encoding=latin1
'''
if isinstance(x, bytes):
return x
elif isinstance(x, bytearray):
return bytes(x)
elif isinstance(x, unicode):
pass
else:
return x ... | [
"x",
"--",
">",
"unicode",
"string",
"|",
"bytearray",
"|",
"bytes",
"Returns",
"--",
">",
"bytes",
"If",
"x",
"is",
"unicode",
"MUST",
"have",
"encoding",
"=",
"latin1"
] | sundarnagarajan/cffi_utils | python | https://github.com/sundarnagarajan/cffi_utils/blob/1d5ab2d2fcb962372228033106bc23f1d73d31fa/cffi_utils/py2to3.py#L217-L232 | [
"def",
"toBytes",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"bytes",
")",
":",
"return",
"x",
"elif",
"isinstance",
"(",
"x",
",",
"bytearray",
")",
":",
"return",
"bytes",
"(",
"x",
")",
"elif",
"isinstance",
"(",
"x",
",",
"unicode",... | 1d5ab2d2fcb962372228033106bc23f1d73d31fa |
test | get_rand_int | encoding-->str: one of ENCODINGS
avoid-->list of int: to void (unprintable chars etc)
Returns-->int that can be converted to requested encoding
which is NOT in avoid | cffi_utils/py2to3.py | def get_rand_int(encoding='latin1', avoid=[]):
'''
encoding-->str: one of ENCODINGS
avoid-->list of int: to void (unprintable chars etc)
Returns-->int that can be converted to requested encoding
which is NOT in avoid
'''
UNICODE_LIMIT = 0x10ffff
# See: https://en.wikipedia.org/... | def get_rand_int(encoding='latin1', avoid=[]):
'''
encoding-->str: one of ENCODINGS
avoid-->list of int: to void (unprintable chars etc)
Returns-->int that can be converted to requested encoding
which is NOT in avoid
'''
UNICODE_LIMIT = 0x10ffff
# See: https://en.wikipedia.org/... | [
"encoding",
"--",
">",
"str",
":",
"one",
"of",
"ENCODINGS",
"avoid",
"--",
">",
"list",
"of",
"int",
":",
"to",
"void",
"(",
"unprintable",
"chars",
"etc",
")",
"Returns",
"--",
">",
"int",
"that",
"can",
"be",
"converted",
"to",
"requested",
"encodin... | sundarnagarajan/cffi_utils | python | https://github.com/sundarnagarajan/cffi_utils/blob/1d5ab2d2fcb962372228033106bc23f1d73d31fa/cffi_utils/py2to3.py#L306-L336 | [
"def",
"get_rand_int",
"(",
"encoding",
"=",
"'latin1'",
",",
"avoid",
"=",
"[",
"]",
")",
":",
"UNICODE_LIMIT",
"=",
"0x10ffff",
"# See: https://en.wikipedia.org/wiki/UTF-8#Invalid_code_points",
"SURROGATE_RANGE",
"=",
"(",
"0xD800",
",",
"0xDFFF",
")",
"if",
"enco... | 1d5ab2d2fcb962372228033106bc23f1d73d31fa |
test | get_rand_str | encoding-->str: one of ENCODINGS
l-->int: length of returned str
avoid-->list of int: to void (unprintable chars etc)
Returns-->unicode str of the requested encoding | cffi_utils/py2to3.py | def get_rand_str(encoding='latin1', l=64, avoid=[]):
'''
encoding-->str: one of ENCODINGS
l-->int: length of returned str
avoid-->list of int: to void (unprintable chars etc)
Returns-->unicode str of the requested encoding
'''
ret = unicode('')
while len(ret) < l:
rndint = get_ra... | def get_rand_str(encoding='latin1', l=64, avoid=[]):
'''
encoding-->str: one of ENCODINGS
l-->int: length of returned str
avoid-->list of int: to void (unprintable chars etc)
Returns-->unicode str of the requested encoding
'''
ret = unicode('')
while len(ret) < l:
rndint = get_ra... | [
"encoding",
"--",
">",
"str",
":",
"one",
"of",
"ENCODINGS",
"l",
"--",
">",
"int",
":",
"length",
"of",
"returned",
"str",
"avoid",
"--",
">",
"list",
"of",
"int",
":",
"to",
"void",
"(",
"unprintable",
"chars",
"etc",
")",
"Returns",
"--",
">",
"... | sundarnagarajan/cffi_utils | python | https://github.com/sundarnagarajan/cffi_utils/blob/1d5ab2d2fcb962372228033106bc23f1d73d31fa/cffi_utils/py2to3.py#L339-L350 | [
"def",
"get_rand_str",
"(",
"encoding",
"=",
"'latin1'",
",",
"l",
"=",
"64",
",",
"avoid",
"=",
"[",
"]",
")",
":",
"ret",
"=",
"unicode",
"(",
"''",
")",
"while",
"len",
"(",
"ret",
")",
"<",
"l",
":",
"rndint",
"=",
"get_rand_int",
"(",
"encod... | 1d5ab2d2fcb962372228033106bc23f1d73d31fa |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.