id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
227,600 | atztogo/phonopy | phonopy/interface/__init__.py | get_default_physical_units | def get_default_physical_units(interface_mode=None):
"""Return physical units used for calculators
Physical units: energy, distance, atomic mass, force
vasp : eV, Angstrom, AMU, eV/Angstrom
wien2k : Ry, au(=borh), AMU, mRy/au
abinit : hartree, au,... | python | def get_default_physical_units(interface_mode=None):
"""Return physical units used for calculators
Physical units: energy, distance, atomic mass, force
vasp : eV, Angstrom, AMU, eV/Angstrom
wien2k : Ry, au(=borh), AMU, mRy/au
abinit : hartree, au,... | [
"def",
"get_default_physical_units",
"(",
"interface_mode",
"=",
"None",
")",
":",
"from",
"phonopy",
".",
"units",
"import",
"(",
"Wien2kToTHz",
",",
"AbinitToTHz",
",",
"PwscfToTHz",
",",
"ElkToTHz",
",",
"SiestaToTHz",
",",
"VaspToTHz",
",",
"CP2KToTHz",
",",... | Return physical units used for calculators
Physical units: energy, distance, atomic mass, force
vasp : eV, Angstrom, AMU, eV/Angstrom
wien2k : Ry, au(=borh), AMU, mRy/au
abinit : hartree, au, AMU, eV/Angstrom
elk : hartree... | [
"Return",
"physical",
"units",
"used",
"for",
"calculators"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/__init__.py#L231-L318 |
227,601 | atztogo/phonopy | phonopy/structure/tetrahedron_method.py | get_tetrahedra_integration_weight | def get_tetrahedra_integration_weight(omegas,
tetrahedra_omegas,
function='I'):
"""Returns integration weights
Parameters
----------
omegas : float or list of float values
Energy(s) at which the integration weight(s) ar... | python | def get_tetrahedra_integration_weight(omegas,
tetrahedra_omegas,
function='I'):
"""Returns integration weights
Parameters
----------
omegas : float or list of float values
Energy(s) at which the integration weight(s) ar... | [
"def",
"get_tetrahedra_integration_weight",
"(",
"omegas",
",",
"tetrahedra_omegas",
",",
"function",
"=",
"'I'",
")",
":",
"if",
"isinstance",
"(",
"omegas",
",",
"float",
")",
":",
"return",
"phonoc",
".",
"tetrahedra_integration_weight",
"(",
"omegas",
",",
"... | Returns integration weights
Parameters
----------
omegas : float or list of float values
Energy(s) at which the integration weight(s) are computed.
tetrahedra_omegas : ndarray of list of list
Energies at vertices of 24 tetrahedra
shape=(24, 4)
dytpe='double'
function... | [
"Returns",
"integration",
"weights"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/tetrahedron_method.py#L95-L125 |
227,602 | atztogo/phonopy | phonopy/structure/tetrahedron_method.py | TetrahedronMethod._g_1 | def _g_1(self):
"""omega1 < omega < omega2"""
# return 3 * self._n_1() / (self._omega - self._vertices_omegas[0])
return (3 * self._f(1, 0) * self._f(2, 0) /
(self._vertices_omegas[3] - self._vertices_omegas[0])) | python | def _g_1(self):
"""omega1 < omega < omega2"""
# return 3 * self._n_1() / (self._omega - self._vertices_omegas[0])
return (3 * self._f(1, 0) * self._f(2, 0) /
(self._vertices_omegas[3] - self._vertices_omegas[0])) | [
"def",
"_g_1",
"(",
"self",
")",
":",
"# return 3 * self._n_1() / (self._omega - self._vertices_omegas[0])",
"return",
"(",
"3",
"*",
"self",
".",
"_f",
"(",
"1",
",",
"0",
")",
"*",
"self",
".",
"_f",
"(",
"2",
",",
"0",
")",
"/",
"(",
"self",
".",
"_... | omega1 < omega < omega2 | [
"omega1",
"<",
"omega",
"<",
"omega2"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/tetrahedron_method.py#L438-L442 |
227,603 | atztogo/phonopy | phonopy/structure/tetrahedron_method.py | TetrahedronMethod._g_3 | def _g_3(self):
"""omega3 < omega < omega4"""
# return 3 * (1.0 - self._n_3()) / (self._vertices_omegas[3] - self._omega)
return (3 * self._f(1, 3) * self._f(2, 3) /
(self._vertices_omegas[3] - self._vertices_omegas[0])) | python | def _g_3(self):
"""omega3 < omega < omega4"""
# return 3 * (1.0 - self._n_3()) / (self._vertices_omegas[3] - self._omega)
return (3 * self._f(1, 3) * self._f(2, 3) /
(self._vertices_omegas[3] - self._vertices_omegas[0])) | [
"def",
"_g_3",
"(",
"self",
")",
":",
"# return 3 * (1.0 - self._n_3()) / (self._vertices_omegas[3] - self._omega)",
"return",
"(",
"3",
"*",
"self",
".",
"_f",
"(",
"1",
",",
"3",
")",
"*",
"self",
".",
"_f",
"(",
"2",
",",
"3",
")",
"/",
"(",
"self",
"... | omega3 < omega < omega4 | [
"omega3",
"<",
"omega",
"<",
"omega4"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/tetrahedron_method.py#L450-L454 |
227,604 | mattupstate/flask-security | flask_security/datastore.py | UserDatastore.deactivate_user | def deactivate_user(self, user):
"""Deactivates a specified user. Returns `True` if a change was made.
:param user: The user to deactivate
"""
if user.active:
user.active = False
return True
return False | python | def deactivate_user(self, user):
"""Deactivates a specified user. Returns `True` if a change was made.
:param user: The user to deactivate
"""
if user.active:
user.active = False
return True
return False | [
"def",
"deactivate_user",
"(",
"self",
",",
"user",
")",
":",
"if",
"user",
".",
"active",
":",
"user",
".",
"active",
"=",
"False",
"return",
"True",
"return",
"False"
] | Deactivates a specified user. Returns `True` if a change was made.
:param user: The user to deactivate | [
"Deactivates",
"a",
"specified",
"user",
".",
"Returns",
"True",
"if",
"a",
"change",
"was",
"made",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/datastore.py#L180-L188 |
227,605 | mattupstate/flask-security | flask_security/datastore.py | UserDatastore.activate_user | def activate_user(self, user):
"""Activates a specified user. Returns `True` if a change was made.
:param user: The user to activate
"""
if not user.active:
user.active = True
return True
return False | python | def activate_user(self, user):
"""Activates a specified user. Returns `True` if a change was made.
:param user: The user to activate
"""
if not user.active:
user.active = True
return True
return False | [
"def",
"activate_user",
"(",
"self",
",",
"user",
")",
":",
"if",
"not",
"user",
".",
"active",
":",
"user",
".",
"active",
"=",
"True",
"return",
"True",
"return",
"False"
] | Activates a specified user. Returns `True` if a change was made.
:param user: The user to activate | [
"Activates",
"a",
"specified",
"user",
".",
"Returns",
"True",
"if",
"a",
"change",
"was",
"made",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/datastore.py#L190-L198 |
227,606 | mattupstate/flask-security | flask_security/datastore.py | UserDatastore.create_role | def create_role(self, **kwargs):
"""Creates and returns a new role from the given parameters."""
role = self.role_model(**kwargs)
return self.put(role) | python | def create_role(self, **kwargs):
"""Creates and returns a new role from the given parameters."""
role = self.role_model(**kwargs)
return self.put(role) | [
"def",
"create_role",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"role",
"=",
"self",
".",
"role_model",
"(",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"put",
"(",
"role",
")"
] | Creates and returns a new role from the given parameters. | [
"Creates",
"and",
"returns",
"a",
"new",
"role",
"from",
"the",
"given",
"parameters",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/datastore.py#L200-L204 |
227,607 | mattupstate/flask-security | flask_security/datastore.py | UserDatastore.find_or_create_role | def find_or_create_role(self, name, **kwargs):
"""Returns a role matching the given name or creates it with any
additionally provided parameters.
"""
kwargs["name"] = name
return self.find_role(name) or self.create_role(**kwargs) | python | def find_or_create_role(self, name, **kwargs):
"""Returns a role matching the given name or creates it with any
additionally provided parameters.
"""
kwargs["name"] = name
return self.find_role(name) or self.create_role(**kwargs) | [
"def",
"find_or_create_role",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"name\"",
"]",
"=",
"name",
"return",
"self",
".",
"find_role",
"(",
"name",
")",
"or",
"self",
".",
"create_role",
"(",
"*",
"*",
"kwargs",
"... | Returns a role matching the given name or creates it with any
additionally provided parameters. | [
"Returns",
"a",
"role",
"matching",
"the",
"given",
"name",
"or",
"creates",
"it",
"with",
"any",
"additionally",
"provided",
"parameters",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/datastore.py#L206-L211 |
227,608 | mattupstate/flask-security | flask_security/decorators.py | http_auth_required | def http_auth_required(realm):
"""Decorator that protects endpoints using Basic HTTP authentication.
:param realm: optional realm name"""
def decorator(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
if _check_http_auth():
return fn(*args, **kwargs)
if... | python | def http_auth_required(realm):
"""Decorator that protects endpoints using Basic HTTP authentication.
:param realm: optional realm name"""
def decorator(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
if _check_http_auth():
return fn(*args, **kwargs)
if... | [
"def",
"http_auth_required",
"(",
"realm",
")",
":",
"def",
"decorator",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"_check_http_auth",
"(",
")",
":",
"return",
"f... | Decorator that protects endpoints using Basic HTTP authentication.
:param realm: optional realm name | [
"Decorator",
"that",
"protects",
"endpoints",
"using",
"Basic",
"HTTP",
"authentication",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/decorators.py#L93-L114 |
227,609 | mattupstate/flask-security | flask_security/decorators.py | auth_token_required | def auth_token_required(fn):
"""Decorator that protects endpoints using token authentication. The token
should be added to the request by the client by using a query string
variable with a name equal to the configuration value of
`SECURITY_TOKEN_AUTHENTICATION_KEY` or in a request header named that of
... | python | def auth_token_required(fn):
"""Decorator that protects endpoints using token authentication. The token
should be added to the request by the client by using a query string
variable with a name equal to the configuration value of
`SECURITY_TOKEN_AUTHENTICATION_KEY` or in a request header named that of
... | [
"def",
"auth_token_required",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"_check_token",
"(",
")",
":",
"return",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwarg... | Decorator that protects endpoints using token authentication. The token
should be added to the request by the client by using a query string
variable with a name equal to the configuration value of
`SECURITY_TOKEN_AUTHENTICATION_KEY` or in a request header named that of
the configuration value of `SECUR... | [
"Decorator",
"that",
"protects",
"endpoints",
"using",
"token",
"authentication",
".",
"The",
"token",
"should",
"be",
"added",
"to",
"the",
"request",
"by",
"the",
"client",
"by",
"using",
"a",
"query",
"string",
"variable",
"with",
"a",
"name",
"equal",
"t... | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/decorators.py#L117-L133 |
227,610 | mattupstate/flask-security | flask_security/confirmable.py | confirm_user | def confirm_user(user):
"""Confirms the specified user
:param user: The user to confirm
"""
if user.confirmed_at is not None:
return False
user.confirmed_at = _security.datetime_factory()
_datastore.put(user)
user_confirmed.send(app._get_current_object(), user=user)
return True | python | def confirm_user(user):
"""Confirms the specified user
:param user: The user to confirm
"""
if user.confirmed_at is not None:
return False
user.confirmed_at = _security.datetime_factory()
_datastore.put(user)
user_confirmed.send(app._get_current_object(), user=user)
return True | [
"def",
"confirm_user",
"(",
"user",
")",
":",
"if",
"user",
".",
"confirmed_at",
"is",
"not",
"None",
":",
"return",
"False",
"user",
".",
"confirmed_at",
"=",
"_security",
".",
"datetime_factory",
"(",
")",
"_datastore",
".",
"put",
"(",
"user",
")",
"u... | Confirms the specified user
:param user: The user to confirm | [
"Confirms",
"the",
"specified",
"user"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/confirmable.py#L82-L92 |
227,611 | mattupstate/flask-security | flask_security/recoverable.py | send_password_reset_notice | def send_password_reset_notice(user):
"""Sends the password reset notice email for the specified user.
:param user: The user to send the notice to
"""
if config_value('SEND_PASSWORD_RESET_NOTICE_EMAIL'):
_security.send_mail(config_value('EMAIL_SUBJECT_PASSWORD_NOTICE'),
... | python | def send_password_reset_notice(user):
"""Sends the password reset notice email for the specified user.
:param user: The user to send the notice to
"""
if config_value('SEND_PASSWORD_RESET_NOTICE_EMAIL'):
_security.send_mail(config_value('EMAIL_SUBJECT_PASSWORD_NOTICE'),
... | [
"def",
"send_password_reset_notice",
"(",
"user",
")",
":",
"if",
"config_value",
"(",
"'SEND_PASSWORD_RESET_NOTICE_EMAIL'",
")",
":",
"_security",
".",
"send_mail",
"(",
"config_value",
"(",
"'EMAIL_SUBJECT_PASSWORD_NOTICE'",
")",
",",
"user",
".",
"email",
",",
"'... | Sends the password reset notice email for the specified user.
:param user: The user to send the notice to | [
"Sends",
"the",
"password",
"reset",
"notice",
"email",
"for",
"the",
"specified",
"user",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/recoverable.py#L45-L52 |
227,612 | mattupstate/flask-security | flask_security/recoverable.py | update_password | def update_password(user, password):
"""Update the specified user's password
:param user: The user to update_password
:param password: The unhashed new password
"""
user.password = hash_password(password)
_datastore.put(user)
send_password_reset_notice(user)
password_reset.send(app._get... | python | def update_password(user, password):
"""Update the specified user's password
:param user: The user to update_password
:param password: The unhashed new password
"""
user.password = hash_password(password)
_datastore.put(user)
send_password_reset_notice(user)
password_reset.send(app._get... | [
"def",
"update_password",
"(",
"user",
",",
"password",
")",
":",
"user",
".",
"password",
"=",
"hash_password",
"(",
"password",
")",
"_datastore",
".",
"put",
"(",
"user",
")",
"send_password_reset_notice",
"(",
"user",
")",
"password_reset",
".",
"send",
... | Update the specified user's password
:param user: The user to update_password
:param password: The unhashed new password | [
"Update",
"the",
"specified",
"user",
"s",
"password"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/recoverable.py#L84-L93 |
227,613 | mattupstate/flask-security | flask_security/core.py | Security.init_app | def init_app(self, app, datastore=None, register_blueprint=None, **kwargs):
"""Initializes the Flask-Security extension for the specified
application and datastore implementation.
:param app: The application.
:param datastore: An instance of a user datastore.
:param register_blu... | python | def init_app(self, app, datastore=None, register_blueprint=None, **kwargs):
"""Initializes the Flask-Security extension for the specified
application and datastore implementation.
:param app: The application.
:param datastore: An instance of a user datastore.
:param register_blu... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"datastore",
"=",
"None",
",",
"register_blueprint",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"app",
"=",
"app",
"if",
"datastore",
"is",
"None",
":",
"datastore",
"=",
"self",
".",... | Initializes the Flask-Security extension for the specified
application and datastore implementation.
:param app: The application.
:param datastore: An instance of a user datastore.
:param register_blueprint: to register the Security blueprint or not. | [
"Initializes",
"the",
"Flask",
"-",
"Security",
"extension",
"for",
"the",
"specified",
"application",
"and",
"datastore",
"implementation",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/core.py#L511-L560 |
227,614 | mattupstate/flask-security | flask_security/views.py | login | def login():
"""View function for login view"""
form_class = _security.login_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class(request.form)
if form.validate_on_submit():
login_user(form.user, remember=form.remember.data)
... | python | def login():
"""View function for login view"""
form_class = _security.login_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class(request.form)
if form.validate_on_submit():
login_user(form.user, remember=form.remember.data)
... | [
"def",
"login",
"(",
")",
":",
"form_class",
"=",
"_security",
".",
"login_form",
"if",
"request",
".",
"is_json",
":",
"form",
"=",
"form_class",
"(",
"MultiDict",
"(",
"request",
".",
"get_json",
"(",
")",
")",
")",
"else",
":",
"form",
"=",
"form_cl... | View function for login view | [
"View",
"function",
"for",
"login",
"view"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L67-L89 |
227,615 | mattupstate/flask-security | flask_security/views.py | register | def register():
"""View function which handles a registration request."""
if _security.confirmable or request.is_json:
form_class = _security.confirm_register_form
else:
form_class = _security.register_form
if request.is_json:
form_data = MultiDict(request.get_json())
else:... | python | def register():
"""View function which handles a registration request."""
if _security.confirmable or request.is_json:
form_class = _security.confirm_register_form
else:
form_class = _security.register_form
if request.is_json:
form_data = MultiDict(request.get_json())
else:... | [
"def",
"register",
"(",
")",
":",
"if",
"_security",
".",
"confirmable",
"or",
"request",
".",
"is_json",
":",
"form_class",
"=",
"_security",
".",
"confirm_register_form",
"else",
":",
"form_class",
"=",
"_security",
".",
"register_form",
"if",
"request",
"."... | View function which handles a registration request. | [
"View",
"function",
"which",
"handles",
"a",
"registration",
"request",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L102-L139 |
227,616 | mattupstate/flask-security | flask_security/views.py | send_login | def send_login():
"""View function that sends login instructions for passwordless login"""
form_class = _security.passwordless_login_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_login... | python | def send_login():
"""View function that sends login instructions for passwordless login"""
form_class = _security.passwordless_login_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_login... | [
"def",
"send_login",
"(",
")",
":",
"form_class",
"=",
"_security",
".",
"passwordless_login_form",
"if",
"request",
".",
"is_json",
":",
"form",
"=",
"form_class",
"(",
"MultiDict",
"(",
"request",
".",
"get_json",
"(",
")",
")",
")",
"else",
":",
"form",... | View function that sends login instructions for passwordless login | [
"View",
"function",
"that",
"sends",
"login",
"instructions",
"for",
"passwordless",
"login"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L142-L162 |
227,617 | mattupstate/flask-security | flask_security/views.py | token_login | def token_login(token):
"""View function that handles passwordless login via a token"""
expired, invalid, user = login_token_status(token)
if invalid:
do_flash(*get_message('INVALID_LOGIN_TOKEN'))
if expired:
send_login_instructions(user)
do_flash(*get_message('LOGIN_EXPIRED', ... | python | def token_login(token):
"""View function that handles passwordless login via a token"""
expired, invalid, user = login_token_status(token)
if invalid:
do_flash(*get_message('INVALID_LOGIN_TOKEN'))
if expired:
send_login_instructions(user)
do_flash(*get_message('LOGIN_EXPIRED', ... | [
"def",
"token_login",
"(",
"token",
")",
":",
"expired",
",",
"invalid",
",",
"user",
"=",
"login_token_status",
"(",
"token",
")",
"if",
"invalid",
":",
"do_flash",
"(",
"*",
"get_message",
"(",
"'INVALID_LOGIN_TOKEN'",
")",
")",
"if",
"expired",
":",
"se... | View function that handles passwordless login via a token | [
"View",
"function",
"that",
"handles",
"passwordless",
"login",
"via",
"a",
"token"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L166-L184 |
227,618 | mattupstate/flask-security | flask_security/views.py | send_confirmation | def send_confirmation():
"""View function which sends confirmation instructions."""
form_class = _security.send_confirmation_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_confirmation_... | python | def send_confirmation():
"""View function which sends confirmation instructions."""
form_class = _security.send_confirmation_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_confirmation_... | [
"def",
"send_confirmation",
"(",
")",
":",
"form_class",
"=",
"_security",
".",
"send_confirmation_form",
"if",
"request",
".",
"is_json",
":",
"form",
"=",
"form_class",
"(",
"MultiDict",
"(",
"request",
".",
"get_json",
"(",
")",
")",
")",
"else",
":",
"... | View function which sends confirmation instructions. | [
"View",
"function",
"which",
"sends",
"confirmation",
"instructions",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L187-L210 |
227,619 | mattupstate/flask-security | flask_security/views.py | confirm_email | def confirm_email(token):
"""View function which handles a email confirmation request."""
expired, invalid, user = confirm_email_token_status(token)
if not user or invalid:
invalid = True
do_flash(*get_message('INVALID_CONFIRMATION_TOKEN'))
already_confirmed = user is not None and use... | python | def confirm_email(token):
"""View function which handles a email confirmation request."""
expired, invalid, user = confirm_email_token_status(token)
if not user or invalid:
invalid = True
do_flash(*get_message('INVALID_CONFIRMATION_TOKEN'))
already_confirmed = user is not None and use... | [
"def",
"confirm_email",
"(",
"token",
")",
":",
"expired",
",",
"invalid",
",",
"user",
"=",
"confirm_email_token_status",
"(",
"token",
")",
"if",
"not",
"user",
"or",
"invalid",
":",
"invalid",
"=",
"True",
"do_flash",
"(",
"*",
"get_message",
"(",
"'INV... | View function which handles a email confirmation request. | [
"View",
"function",
"which",
"handles",
"a",
"email",
"confirmation",
"request",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L213-L244 |
227,620 | mattupstate/flask-security | flask_security/views.py | forgot_password | def forgot_password():
"""View function that handles a forgotten password request."""
form_class = _security.forgot_password_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_reset_passwor... | python | def forgot_password():
"""View function that handles a forgotten password request."""
form_class = _security.forgot_password_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_reset_passwor... | [
"def",
"forgot_password",
"(",
")",
":",
"form_class",
"=",
"_security",
".",
"forgot_password_form",
"if",
"request",
".",
"is_json",
":",
"form",
"=",
"form_class",
"(",
"MultiDict",
"(",
"request",
".",
"get_json",
"(",
")",
")",
")",
"else",
":",
"form... | View function that handles a forgotten password request. | [
"View",
"function",
"that",
"handles",
"a",
"forgotten",
"password",
"request",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L248-L269 |
227,621 | mattupstate/flask-security | flask_security/views.py | reset_password | def reset_password(token):
"""View function that handles a reset password request."""
expired, invalid, user = reset_password_token_status(token)
if not user or invalid:
invalid = True
do_flash(*get_message('INVALID_RESET_PASSWORD_TOKEN'))
if expired:
send_reset_password_instr... | python | def reset_password(token):
"""View function that handles a reset password request."""
expired, invalid, user = reset_password_token_status(token)
if not user or invalid:
invalid = True
do_flash(*get_message('INVALID_RESET_PASSWORD_TOKEN'))
if expired:
send_reset_password_instr... | [
"def",
"reset_password",
"(",
"token",
")",
":",
"expired",
",",
"invalid",
",",
"user",
"=",
"reset_password_token_status",
"(",
"token",
")",
"if",
"not",
"user",
"or",
"invalid",
":",
"invalid",
"=",
"True",
"do_flash",
"(",
"*",
"get_message",
"(",
"'I... | View function that handles a reset password request. | [
"View",
"function",
"that",
"handles",
"a",
"reset",
"password",
"request",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L273-L303 |
227,622 | mattupstate/flask-security | flask_security/views.py | change_password | def change_password():
"""View function which handles a change password request."""
form_class = _security.change_password_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
after_this_request(_... | python | def change_password():
"""View function which handles a change password request."""
form_class = _security.change_password_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
after_this_request(_... | [
"def",
"change_password",
"(",
")",
":",
"form_class",
"=",
"_security",
".",
"change_password_form",
"if",
"request",
".",
"is_json",
":",
"form",
"=",
"form_class",
"(",
"MultiDict",
"(",
"request",
".",
"get_json",
"(",
")",
")",
")",
"else",
":",
"form... | View function which handles a change password request. | [
"View",
"function",
"which",
"handles",
"a",
"change",
"password",
"request",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L307-L334 |
227,623 | mattupstate/flask-security | flask_security/views.py | create_blueprint | def create_blueprint(state, import_name):
"""Creates the security extension blueprint"""
bp = Blueprint(state.blueprint_name, import_name,
url_prefix=state.url_prefix,
subdomain=state.subdomain,
template_folder='templates')
bp.route(state.logout_url... | python | def create_blueprint(state, import_name):
"""Creates the security extension blueprint"""
bp = Blueprint(state.blueprint_name, import_name,
url_prefix=state.url_prefix,
subdomain=state.subdomain,
template_folder='templates')
bp.route(state.logout_url... | [
"def",
"create_blueprint",
"(",
"state",
",",
"import_name",
")",
":",
"bp",
"=",
"Blueprint",
"(",
"state",
".",
"blueprint_name",
",",
"import_name",
",",
"url_prefix",
"=",
"state",
".",
"url_prefix",
",",
"subdomain",
"=",
"state",
".",
"subdomain",
",",... | Creates the security extension blueprint | [
"Creates",
"the",
"security",
"extension",
"blueprint"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L337-L387 |
227,624 | mattupstate/flask-security | flask_security/utils.py | login_user | def login_user(user, remember=None):
"""Perform the login routine.
If SECURITY_TRACKABLE is used, make sure you commit changes after this
request (i.e. ``app.security.datastore.commit()``).
:param user: The user to login
:param remember: Flag specifying if the remember cookie should be set.
... | python | def login_user(user, remember=None):
"""Perform the login routine.
If SECURITY_TRACKABLE is used, make sure you commit changes after this
request (i.e. ``app.security.datastore.commit()``).
:param user: The user to login
:param remember: Flag specifying if the remember cookie should be set.
... | [
"def",
"login_user",
"(",
"user",
",",
"remember",
"=",
"None",
")",
":",
"if",
"remember",
"is",
"None",
":",
"remember",
"=",
"config_value",
"(",
"'DEFAULT_REMEMBER_ME'",
")",
"if",
"not",
"_login_user",
"(",
"user",
",",
"remember",
")",
":",
"# pragma... | Perform the login routine.
If SECURITY_TRACKABLE is used, make sure you commit changes after this
request (i.e. ``app.security.datastore.commit()``).
:param user: The user to login
:param remember: Flag specifying if the remember cookie should be set.
Defaults to ``False`` | [
"Perform",
"the",
"login",
"routine",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L63-L98 |
227,625 | mattupstate/flask-security | flask_security/utils.py | logout_user | def logout_user():
"""Logs out the current.
This will also clean up the remember me cookie if it exists.
"""
for key in ('identity.name', 'identity.auth_type'):
session.pop(key, None)
identity_changed.send(current_app._get_current_object(),
identity=AnonymousIdent... | python | def logout_user():
"""Logs out the current.
This will also clean up the remember me cookie if it exists.
"""
for key in ('identity.name', 'identity.auth_type'):
session.pop(key, None)
identity_changed.send(current_app._get_current_object(),
identity=AnonymousIdent... | [
"def",
"logout_user",
"(",
")",
":",
"for",
"key",
"in",
"(",
"'identity.name'",
",",
"'identity.auth_type'",
")",
":",
"session",
".",
"pop",
"(",
"key",
",",
"None",
")",
"identity_changed",
".",
"send",
"(",
"current_app",
".",
"_get_current_object",
"(",... | Logs out the current.
This will also clean up the remember me cookie if it exists. | [
"Logs",
"out",
"the",
"current",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L101-L111 |
227,626 | mattupstate/flask-security | flask_security/utils.py | verify_password | def verify_password(password, password_hash):
"""Returns ``True`` if the password matches the supplied hash.
:param password: A plaintext password to verify
:param password_hash: The expected hash value of the password
(usually from your database)
"""
if use_double_hash(pa... | python | def verify_password(password, password_hash):
"""Returns ``True`` if the password matches the supplied hash.
:param password: A plaintext password to verify
:param password_hash: The expected hash value of the password
(usually from your database)
"""
if use_double_hash(pa... | [
"def",
"verify_password",
"(",
"password",
",",
"password_hash",
")",
":",
"if",
"use_double_hash",
"(",
"password_hash",
")",
":",
"password",
"=",
"get_hmac",
"(",
"password",
")",
"return",
"_pwd_context",
".",
"verify",
"(",
"password",
",",
"password_hash",... | Returns ``True`` if the password matches the supplied hash.
:param password: A plaintext password to verify
:param password_hash: The expected hash value of the password
(usually from your database) | [
"Returns",
"True",
"if",
"the",
"password",
"matches",
"the",
"supplied",
"hash",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L132-L142 |
227,627 | mattupstate/flask-security | flask_security/utils.py | find_redirect | def find_redirect(key):
"""Returns the URL to redirect to after a user logs in successfully.
:param key: The session or application configuration key to search for
"""
rv = (get_url(session.pop(key.lower(), None)) or
get_url(current_app.config[key.upper()] or None) or '/')
return rv | python | def find_redirect(key):
"""Returns the URL to redirect to after a user logs in successfully.
:param key: The session or application configuration key to search for
"""
rv = (get_url(session.pop(key.lower(), None)) or
get_url(current_app.config[key.upper()] or None) or '/')
return rv | [
"def",
"find_redirect",
"(",
"key",
")",
":",
"rv",
"=",
"(",
"get_url",
"(",
"session",
".",
"pop",
"(",
"key",
".",
"lower",
"(",
")",
",",
"None",
")",
")",
"or",
"get_url",
"(",
"current_app",
".",
"config",
"[",
"key",
".",
"upper",
"(",
")"... | Returns the URL to redirect to after a user logs in successfully.
:param key: The session or application configuration key to search for | [
"Returns",
"the",
"URL",
"to",
"redirect",
"to",
"after",
"a",
"user",
"logs",
"in",
"successfully",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L306-L313 |
227,628 | mattupstate/flask-security | flask_security/utils.py | send_mail | def send_mail(subject, recipient, template, **context):
"""Send an email via the Flask-Mail extension.
:param subject: Email subject
:param recipient: Email recipient
:param template: The name of the email template
:param context: The context to render the template with
"""
context.setdefa... | python | def send_mail(subject, recipient, template, **context):
"""Send an email via the Flask-Mail extension.
:param subject: Email subject
:param recipient: Email recipient
:param template: The name of the email template
:param context: The context to render the template with
"""
context.setdefa... | [
"def",
"send_mail",
"(",
"subject",
",",
"recipient",
",",
"template",
",",
"*",
"*",
"context",
")",
":",
"context",
".",
"setdefault",
"(",
"'security'",
",",
"_security",
")",
"context",
".",
"update",
"(",
"_security",
".",
"_run_ctx_processor",
"(",
"... | Send an email via the Flask-Mail extension.
:param subject: Email subject
:param recipient: Email recipient
:param template: The name of the email template
:param context: The context to render the template with | [
"Send",
"an",
"email",
"via",
"the",
"Flask",
"-",
"Mail",
"extension",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L373-L404 |
227,629 | mattupstate/flask-security | flask_security/utils.py | capture_registrations | def capture_registrations():
"""Testing utility for capturing registrations.
:param confirmation_sent_at: An optional datetime object to set the
user's `confirmation_sent_at` to
"""
registrations = []
def _on(app, **data):
registrations.append(data)
us... | python | def capture_registrations():
"""Testing utility for capturing registrations.
:param confirmation_sent_at: An optional datetime object to set the
user's `confirmation_sent_at` to
"""
registrations = []
def _on(app, **data):
registrations.append(data)
us... | [
"def",
"capture_registrations",
"(",
")",
":",
"registrations",
"=",
"[",
"]",
"def",
"_on",
"(",
"app",
",",
"*",
"*",
"data",
")",
":",
"registrations",
".",
"append",
"(",
"data",
")",
"user_registered",
".",
"connect",
"(",
"_on",
")",
"try",
":",
... | Testing utility for capturing registrations.
:param confirmation_sent_at: An optional datetime object to set the
user's `confirmation_sent_at` to | [
"Testing",
"utility",
"for",
"capturing",
"registrations",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L481-L497 |
227,630 | mattupstate/flask-security | flask_security/utils.py | capture_reset_password_requests | def capture_reset_password_requests(reset_password_sent_at=None):
"""Testing utility for capturing password reset requests.
:param reset_password_sent_at: An optional datetime object to set the
user's `reset_password_sent_at` to
"""
reset_requests = []
def _on(ap... | python | def capture_reset_password_requests(reset_password_sent_at=None):
"""Testing utility for capturing password reset requests.
:param reset_password_sent_at: An optional datetime object to set the
user's `reset_password_sent_at` to
"""
reset_requests = []
def _on(ap... | [
"def",
"capture_reset_password_requests",
"(",
"reset_password_sent_at",
"=",
"None",
")",
":",
"reset_requests",
"=",
"[",
"]",
"def",
"_on",
"(",
"app",
",",
"*",
"*",
"data",
")",
":",
"reset_requests",
".",
"append",
"(",
"data",
")",
"reset_password_instr... | Testing utility for capturing password reset requests.
:param reset_password_sent_at: An optional datetime object to set the
user's `reset_password_sent_at` to | [
"Testing",
"utility",
"for",
"capturing",
"password",
"reset",
"requests",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L501-L517 |
227,631 | mattupstate/flask-security | flask_security/passwordless.py | send_login_instructions | def send_login_instructions(user):
"""Sends the login instructions email for the specified user.
:param user: The user to send the instructions to
:param token: The login token
"""
token = generate_login_token(user)
login_link = url_for_security('token_login', token=token, _external=True)
... | python | def send_login_instructions(user):
"""Sends the login instructions email for the specified user.
:param user: The user to send the instructions to
:param token: The login token
"""
token = generate_login_token(user)
login_link = url_for_security('token_login', token=token, _external=True)
... | [
"def",
"send_login_instructions",
"(",
"user",
")",
":",
"token",
"=",
"generate_login_token",
"(",
"user",
")",
"login_link",
"=",
"url_for_security",
"(",
"'token_login'",
",",
"token",
"=",
"token",
",",
"_external",
"=",
"True",
")",
"_security",
".",
"sen... | Sends the login instructions email for the specified user.
:param user: The user to send the instructions to
:param token: The login token | [
"Sends",
"the",
"login",
"instructions",
"email",
"for",
"the",
"specified",
"user",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/passwordless.py#L24-L37 |
227,632 | mattupstate/flask-security | flask_security/cli.py | roles_add | def roles_add(user, role):
"""Add user to role."""
user, role = _datastore._prepare_role_modify_args(user, role)
if user is None:
raise click.UsageError('Cannot find user.')
if role is None:
raise click.UsageError('Cannot find role.')
if _datastore.add_role_to_user(user, role):
... | python | def roles_add(user, role):
"""Add user to role."""
user, role = _datastore._prepare_role_modify_args(user, role)
if user is None:
raise click.UsageError('Cannot find user.')
if role is None:
raise click.UsageError('Cannot find role.')
if _datastore.add_role_to_user(user, role):
... | [
"def",
"roles_add",
"(",
"user",
",",
"role",
")",
":",
"user",
",",
"role",
"=",
"_datastore",
".",
"_prepare_role_modify_args",
"(",
"user",
",",
"role",
")",
"if",
"user",
"is",
"None",
":",
"raise",
"click",
".",
"UsageError",
"(",
"'Cannot find user.'... | Add user to role. | [
"Add",
"user",
"to",
"role",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/cli.py#L93-L104 |
227,633 | mattupstate/flask-security | flask_security/cli.py | roles_remove | def roles_remove(user, role):
"""Remove user from role."""
user, role = _datastore._prepare_role_modify_args(user, role)
if user is None:
raise click.UsageError('Cannot find user.')
if role is None:
raise click.UsageError('Cannot find role.')
if _datastore.remove_role_from_user(user,... | python | def roles_remove(user, role):
"""Remove user from role."""
user, role = _datastore._prepare_role_modify_args(user, role)
if user is None:
raise click.UsageError('Cannot find user.')
if role is None:
raise click.UsageError('Cannot find role.')
if _datastore.remove_role_from_user(user,... | [
"def",
"roles_remove",
"(",
"user",
",",
"role",
")",
":",
"user",
",",
"role",
"=",
"_datastore",
".",
"_prepare_role_modify_args",
"(",
"user",
",",
"role",
")",
"if",
"user",
"is",
"None",
":",
"raise",
"click",
".",
"UsageError",
"(",
"'Cannot find use... | Remove user from role. | [
"Remove",
"user",
"from",
"role",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/cli.py#L112-L123 |
227,634 | mattupstate/flask-security | flask_security/changeable.py | send_password_changed_notice | def send_password_changed_notice(user):
"""Sends the password changed notice email for the specified user.
:param user: The user to send the notice to
"""
if config_value('SEND_PASSWORD_CHANGE_EMAIL'):
subject = config_value('EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE')
_security.send_mail(su... | python | def send_password_changed_notice(user):
"""Sends the password changed notice email for the specified user.
:param user: The user to send the notice to
"""
if config_value('SEND_PASSWORD_CHANGE_EMAIL'):
subject = config_value('EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE')
_security.send_mail(su... | [
"def",
"send_password_changed_notice",
"(",
"user",
")",
":",
"if",
"config_value",
"(",
"'SEND_PASSWORD_CHANGE_EMAIL'",
")",
":",
"subject",
"=",
"config_value",
"(",
"'EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE'",
")",
"_security",
".",
"send_mail",
"(",
"subject",
",",
"... | Sends the password changed notice email for the specified user.
:param user: The user to send the notice to | [
"Sends",
"the",
"password",
"changed",
"notice",
"email",
"for",
"the",
"specified",
"user",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/changeable.py#L25-L32 |
227,635 | mattupstate/flask-security | flask_security/changeable.py | change_user_password | def change_user_password(user, password):
"""Change the specified user's password
:param user: The user to change_password
:param password: The unhashed new password
"""
user.password = hash_password(password)
_datastore.put(user)
send_password_changed_notice(user)
password_changed.send... | python | def change_user_password(user, password):
"""Change the specified user's password
:param user: The user to change_password
:param password: The unhashed new password
"""
user.password = hash_password(password)
_datastore.put(user)
send_password_changed_notice(user)
password_changed.send... | [
"def",
"change_user_password",
"(",
"user",
",",
"password",
")",
":",
"user",
".",
"password",
"=",
"hash_password",
"(",
"password",
")",
"_datastore",
".",
"put",
"(",
"user",
")",
"send_password_changed_notice",
"(",
"user",
")",
"password_changed",
".",
"... | Change the specified user's password
:param user: The user to change_password
:param password: The unhashed new password | [
"Change",
"the",
"specified",
"user",
"s",
"password"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/changeable.py#L35-L45 |
227,636 | jd/tenacity | tenacity/after.py | after_log | def after_log(logger, log_level, sec_format="%0.3f"):
"""After call strategy that logs to some logger the finished attempt."""
log_tpl = ("Finished call to '%s' after " + str(sec_format) + "(s), "
"this was the %s time calling it.")
def log_it(retry_state):
logger.log(log_level, log_... | python | def after_log(logger, log_level, sec_format="%0.3f"):
"""After call strategy that logs to some logger the finished attempt."""
log_tpl = ("Finished call to '%s' after " + str(sec_format) + "(s), "
"this was the %s time calling it.")
def log_it(retry_state):
logger.log(log_level, log_... | [
"def",
"after_log",
"(",
"logger",
",",
"log_level",
",",
"sec_format",
"=",
"\"%0.3f\"",
")",
":",
"log_tpl",
"=",
"(",
"\"Finished call to '%s' after \"",
"+",
"str",
"(",
"sec_format",
")",
"+",
"\"(s), \"",
"\"this was the %s time calling it.\"",
")",
"def",
"... | After call strategy that logs to some logger the finished attempt. | [
"After",
"call",
"strategy",
"that",
"logs",
"to",
"some",
"logger",
"the",
"finished",
"attempt",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/after.py#L24-L35 |
227,637 | jd/tenacity | tenacity/__init__.py | retry | def retry(*dargs, **dkw):
"""Wrap a function with a new `Retrying` object.
:param dargs: positional arguments passed to Retrying object
:param dkw: keyword arguments passed to the Retrying object
"""
# support both @retry and @retry() as valid syntax
if len(dargs) == 1 and callable(dargs[0]):
... | python | def retry(*dargs, **dkw):
"""Wrap a function with a new `Retrying` object.
:param dargs: positional arguments passed to Retrying object
:param dkw: keyword arguments passed to the Retrying object
"""
# support both @retry and @retry() as valid syntax
if len(dargs) == 1 and callable(dargs[0]):
... | [
"def",
"retry",
"(",
"*",
"dargs",
",",
"*",
"*",
"dkw",
")",
":",
"# support both @retry and @retry() as valid syntax",
"if",
"len",
"(",
"dargs",
")",
"==",
"1",
"and",
"callable",
"(",
"dargs",
"[",
"0",
"]",
")",
":",
"return",
"retry",
"(",
")",
"... | Wrap a function with a new `Retrying` object.
:param dargs: positional arguments passed to Retrying object
:param dkw: keyword arguments passed to the Retrying object | [
"Wrap",
"a",
"function",
"with",
"a",
"new",
"Retrying",
"object",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/__init__.py#L88-L109 |
227,638 | jd/tenacity | tenacity/__init__.py | BaseRetrying.copy | def copy(self, sleep=_unset, stop=_unset, wait=_unset,
retry=_unset, before=_unset, after=_unset, before_sleep=_unset,
reraise=_unset):
"""Copy this object with some parameters changed if needed."""
if before_sleep is _unset:
before_sleep = self.before_sleep
... | python | def copy(self, sleep=_unset, stop=_unset, wait=_unset,
retry=_unset, before=_unset, after=_unset, before_sleep=_unset,
reraise=_unset):
"""Copy this object with some parameters changed if needed."""
if before_sleep is _unset:
before_sleep = self.before_sleep
... | [
"def",
"copy",
"(",
"self",
",",
"sleep",
"=",
"_unset",
",",
"stop",
"=",
"_unset",
",",
"wait",
"=",
"_unset",
",",
"retry",
"=",
"_unset",
",",
"before",
"=",
"_unset",
",",
"after",
"=",
"_unset",
",",
"before_sleep",
"=",
"_unset",
",",
"reraise... | Copy this object with some parameters changed if needed. | [
"Copy",
"this",
"object",
"with",
"some",
"parameters",
"changed",
"if",
"needed",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/__init__.py#L231-L246 |
227,639 | jd/tenacity | tenacity/__init__.py | BaseRetrying.statistics | def statistics(self):
"""Return a dictionary of runtime statistics.
This dictionary will be empty when the controller has never been
ran. When it is running or has ran previously it should have (but
may not) have useful and/or informational keys and values when
running is underw... | python | def statistics(self):
"""Return a dictionary of runtime statistics.
This dictionary will be empty when the controller has never been
ran. When it is running or has ran previously it should have (but
may not) have useful and/or informational keys and values when
running is underw... | [
"def",
"statistics",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_local",
".",
"statistics",
"except",
"AttributeError",
":",
"self",
".",
"_local",
".",
"statistics",
"=",
"{",
"}",
"return",
"self",
".",
"_local",
".",
"statistics"
] | Return a dictionary of runtime statistics.
This dictionary will be empty when the controller has never been
ran. When it is running or has ran previously it should have (but
may not) have useful and/or informational keys and values when
running is underway and/or completed.
.. ... | [
"Return",
"a",
"dictionary",
"of",
"runtime",
"statistics",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/__init__.py#L258-L283 |
227,640 | jd/tenacity | tenacity/__init__.py | BaseRetrying.wraps | def wraps(self, f):
"""Wrap a function for retrying.
:param f: A function to wraps for retrying.
"""
@_utils.wraps(f)
def wrapped_f(*args, **kw):
return self.call(f, *args, **kw)
def retry_with(*args, **kwargs):
return self.copy(*args, **kwargs).... | python | def wraps(self, f):
"""Wrap a function for retrying.
:param f: A function to wraps for retrying.
"""
@_utils.wraps(f)
def wrapped_f(*args, **kw):
return self.call(f, *args, **kw)
def retry_with(*args, **kwargs):
return self.copy(*args, **kwargs).... | [
"def",
"wraps",
"(",
"self",
",",
"f",
")",
":",
"@",
"_utils",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped_f",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"return",
"self",
".",
"call",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kw"... | Wrap a function for retrying.
:param f: A function to wraps for retrying. | [
"Wrap",
"a",
"function",
"for",
"retrying",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/__init__.py#L285-L300 |
227,641 | jd/tenacity | tenacity/__init__.py | Future.construct | def construct(cls, attempt_number, value, has_exception):
"""Construct a new Future object."""
fut = cls(attempt_number)
if has_exception:
fut.set_exception(value)
else:
fut.set_result(value)
return fut | python | def construct(cls, attempt_number, value, has_exception):
"""Construct a new Future object."""
fut = cls(attempt_number)
if has_exception:
fut.set_exception(value)
else:
fut.set_result(value)
return fut | [
"def",
"construct",
"(",
"cls",
",",
"attempt_number",
",",
"value",
",",
"has_exception",
")",
":",
"fut",
"=",
"cls",
"(",
"attempt_number",
")",
"if",
"has_exception",
":",
"fut",
".",
"set_exception",
"(",
"value",
")",
"else",
":",
"fut",
".",
"set_... | Construct a new Future object. | [
"Construct",
"a",
"new",
"Future",
"object",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/__init__.py#L388-L395 |
227,642 | jd/tenacity | tenacity/_utils.py | get_callback_name | def get_callback_name(cb):
"""Get a callback fully-qualified name.
If no name can be produced ``repr(cb)`` is called and returned.
"""
segments = []
try:
segments.append(cb.__qualname__)
except AttributeError:
try:
segments.append(cb.__name__)
if inspect.... | python | def get_callback_name(cb):
"""Get a callback fully-qualified name.
If no name can be produced ``repr(cb)`` is called and returned.
"""
segments = []
try:
segments.append(cb.__qualname__)
except AttributeError:
try:
segments.append(cb.__name__)
if inspect.... | [
"def",
"get_callback_name",
"(",
"cb",
")",
":",
"segments",
"=",
"[",
"]",
"try",
":",
"segments",
".",
"append",
"(",
"cb",
".",
"__qualname__",
")",
"except",
"AttributeError",
":",
"try",
":",
"segments",
".",
"append",
"(",
"cb",
".",
"__name__",
... | Get a callback fully-qualified name.
If no name can be produced ``repr(cb)`` is called and returned. | [
"Get",
"a",
"callback",
"fully",
"-",
"qualified",
"name",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/_utils.py#L98-L128 |
227,643 | jd/tenacity | tenacity/compat.py | make_retry_state | def make_retry_state(previous_attempt_number, delay_since_first_attempt,
last_result=None):
"""Construct RetryCallState for given attempt number & delay.
Only used in testing and thus is extra careful about timestamp arithmetics.
"""
required_parameter_unset = (previous_attempt_num... | python | def make_retry_state(previous_attempt_number, delay_since_first_attempt,
last_result=None):
"""Construct RetryCallState for given attempt number & delay.
Only used in testing and thus is extra careful about timestamp arithmetics.
"""
required_parameter_unset = (previous_attempt_num... | [
"def",
"make_retry_state",
"(",
"previous_attempt_number",
",",
"delay_since_first_attempt",
",",
"last_result",
"=",
"None",
")",
":",
"required_parameter_unset",
"=",
"(",
"previous_attempt_number",
"is",
"_unset",
"or",
"delay_since_first_attempt",
"is",
"_unset",
")",... | Construct RetryCallState for given attempt number & delay.
Only used in testing and thus is extra careful about timestamp arithmetics. | [
"Construct",
"RetryCallState",
"for",
"given",
"attempt",
"number",
"&",
"delay",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L57-L79 |
227,644 | jd/tenacity | tenacity/compat.py | func_takes_last_result | def func_takes_last_result(waiter):
"""Check if function has a "last_result" parameter.
Needed to provide backward compatibility for wait functions that didn't
take "last_result" in the beginning.
"""
if not six.callable(waiter):
return False
if not inspect.isfunction(waiter) and not in... | python | def func_takes_last_result(waiter):
"""Check if function has a "last_result" parameter.
Needed to provide backward compatibility for wait functions that didn't
take "last_result" in the beginning.
"""
if not six.callable(waiter):
return False
if not inspect.isfunction(waiter) and not in... | [
"def",
"func_takes_last_result",
"(",
"waiter",
")",
":",
"if",
"not",
"six",
".",
"callable",
"(",
"waiter",
")",
":",
"return",
"False",
"if",
"not",
"inspect",
".",
"isfunction",
"(",
"waiter",
")",
"and",
"not",
"inspect",
".",
"ismethod",
"(",
"wait... | Check if function has a "last_result" parameter.
Needed to provide backward compatibility for wait functions that didn't
take "last_result" in the beginning. | [
"Check",
"if",
"function",
"has",
"a",
"last_result",
"parameter",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L82-L94 |
227,645 | jd/tenacity | tenacity/compat.py | stop_func_accept_retry_state | def stop_func_accept_retry_state(stop_func):
"""Wrap "stop" function to accept "retry_state" parameter."""
if not six.callable(stop_func):
return stop_func
if func_takes_retry_state(stop_func):
return stop_func
@_utils.wraps(stop_func)
def wrapped_stop_func(retry_state):
wa... | python | def stop_func_accept_retry_state(stop_func):
"""Wrap "stop" function to accept "retry_state" parameter."""
if not six.callable(stop_func):
return stop_func
if func_takes_retry_state(stop_func):
return stop_func
@_utils.wraps(stop_func)
def wrapped_stop_func(retry_state):
wa... | [
"def",
"stop_func_accept_retry_state",
"(",
"stop_func",
")",
":",
"if",
"not",
"six",
".",
"callable",
"(",
"stop_func",
")",
":",
"return",
"stop_func",
"if",
"func_takes_retry_state",
"(",
"stop_func",
")",
":",
"return",
"stop_func",
"@",
"_utils",
".",
"w... | Wrap "stop" function to accept "retry_state" parameter. | [
"Wrap",
"stop",
"function",
"to",
"accept",
"retry_state",
"parameter",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L120-L136 |
227,646 | jd/tenacity | tenacity/compat.py | wait_func_accept_retry_state | def wait_func_accept_retry_state(wait_func):
"""Wrap wait function to accept "retry_state" parameter."""
if not six.callable(wait_func):
return wait_func
if func_takes_retry_state(wait_func):
return wait_func
if func_takes_last_result(wait_func):
@_utils.wraps(wait_func)
... | python | def wait_func_accept_retry_state(wait_func):
"""Wrap wait function to accept "retry_state" parameter."""
if not six.callable(wait_func):
return wait_func
if func_takes_retry_state(wait_func):
return wait_func
if func_takes_last_result(wait_func):
@_utils.wraps(wait_func)
... | [
"def",
"wait_func_accept_retry_state",
"(",
"wait_func",
")",
":",
"if",
"not",
"six",
".",
"callable",
"(",
"wait_func",
")",
":",
"return",
"wait_func",
"if",
"func_takes_retry_state",
"(",
"wait_func",
")",
":",
"return",
"wait_func",
"if",
"func_takes_last_res... | Wrap wait function to accept "retry_state" parameter. | [
"Wrap",
"wait",
"function",
"to",
"accept",
"retry_state",
"parameter",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L164-L191 |
227,647 | jd/tenacity | tenacity/compat.py | retry_func_accept_retry_state | def retry_func_accept_retry_state(retry_func):
"""Wrap "retry" function to accept "retry_state" parameter."""
if not six.callable(retry_func):
return retry_func
if func_takes_retry_state(retry_func):
return retry_func
@_utils.wraps(retry_func)
def wrapped_retry_func(retry_state):
... | python | def retry_func_accept_retry_state(retry_func):
"""Wrap "retry" function to accept "retry_state" parameter."""
if not six.callable(retry_func):
return retry_func
if func_takes_retry_state(retry_func):
return retry_func
@_utils.wraps(retry_func)
def wrapped_retry_func(retry_state):
... | [
"def",
"retry_func_accept_retry_state",
"(",
"retry_func",
")",
":",
"if",
"not",
"six",
".",
"callable",
"(",
"retry_func",
")",
":",
"return",
"retry_func",
"if",
"func_takes_retry_state",
"(",
"retry_func",
")",
":",
"return",
"retry_func",
"@",
"_utils",
"."... | Wrap "retry" function to accept "retry_state" parameter. | [
"Wrap",
"retry",
"function",
"to",
"accept",
"retry_state",
"parameter",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L215-L228 |
227,648 | jd/tenacity | tenacity/compat.py | before_func_accept_retry_state | def before_func_accept_retry_state(fn):
"""Wrap "before" function to accept "retry_state"."""
if not six.callable(fn):
return fn
if func_takes_retry_state(fn):
return fn
@_utils.wraps(fn)
def wrapped_before_func(retry_state):
# func, trial_number, trial_time_taken
w... | python | def before_func_accept_retry_state(fn):
"""Wrap "before" function to accept "retry_state"."""
if not six.callable(fn):
return fn
if func_takes_retry_state(fn):
return fn
@_utils.wraps(fn)
def wrapped_before_func(retry_state):
# func, trial_number, trial_time_taken
w... | [
"def",
"before_func_accept_retry_state",
"(",
"fn",
")",
":",
"if",
"not",
"six",
".",
"callable",
"(",
"fn",
")",
":",
"return",
"fn",
"if",
"func_takes_retry_state",
"(",
"fn",
")",
":",
"return",
"fn",
"@",
"_utils",
".",
"wraps",
"(",
"fn",
")",
"d... | Wrap "before" function to accept "retry_state". | [
"Wrap",
"before",
"function",
"to",
"accept",
"retry_state",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L231-L247 |
227,649 | jd/tenacity | tenacity/compat.py | after_func_accept_retry_state | def after_func_accept_retry_state(fn):
"""Wrap "after" function to accept "retry_state"."""
if not six.callable(fn):
return fn
if func_takes_retry_state(fn):
return fn
@_utils.wraps(fn)
def wrapped_after_sleep_func(retry_state):
# func, trial_number, trial_time_taken
... | python | def after_func_accept_retry_state(fn):
"""Wrap "after" function to accept "retry_state"."""
if not six.callable(fn):
return fn
if func_takes_retry_state(fn):
return fn
@_utils.wraps(fn)
def wrapped_after_sleep_func(retry_state):
# func, trial_number, trial_time_taken
... | [
"def",
"after_func_accept_retry_state",
"(",
"fn",
")",
":",
"if",
"not",
"six",
".",
"callable",
"(",
"fn",
")",
":",
"return",
"fn",
"if",
"func_takes_retry_state",
"(",
"fn",
")",
":",
"return",
"fn",
"@",
"_utils",
".",
"wraps",
"(",
"fn",
")",
"de... | Wrap "after" function to accept "retry_state". | [
"Wrap",
"after",
"function",
"to",
"accept",
"retry_state",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L250-L266 |
227,650 | jd/tenacity | tenacity/compat.py | before_sleep_func_accept_retry_state | def before_sleep_func_accept_retry_state(fn):
"""Wrap "before_sleep" function to accept "retry_state"."""
if not six.callable(fn):
return fn
if func_takes_retry_state(fn):
return fn
@_utils.wraps(fn)
def wrapped_before_sleep_func(retry_state):
# retry_object, sleep, last_re... | python | def before_sleep_func_accept_retry_state(fn):
"""Wrap "before_sleep" function to accept "retry_state"."""
if not six.callable(fn):
return fn
if func_takes_retry_state(fn):
return fn
@_utils.wraps(fn)
def wrapped_before_sleep_func(retry_state):
# retry_object, sleep, last_re... | [
"def",
"before_sleep_func_accept_retry_state",
"(",
"fn",
")",
":",
"if",
"not",
"six",
".",
"callable",
"(",
"fn",
")",
":",
"return",
"fn",
"if",
"func_takes_retry_state",
"(",
"fn",
")",
":",
"return",
"fn",
"@",
"_utils",
".",
"wraps",
"(",
"fn",
")"... | Wrap "before_sleep" function to accept "retry_state". | [
"Wrap",
"before_sleep",
"function",
"to",
"accept",
"retry_state",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L269-L286 |
227,651 | divio/django-filer | filer/admin/patched/admin_utils.py | NestedObjects.nested | def nested(self, format_callback=None):
"""
Return the graph as a nested list.
"""
seen = set()
roots = []
for root in self.edges.get(None, ()):
roots.extend(self._nested(root, seen, format_callback))
return roots | python | def nested(self, format_callback=None):
"""
Return the graph as a nested list.
"""
seen = set()
roots = []
for root in self.edges.get(None, ()):
roots.extend(self._nested(root, seen, format_callback))
return roots | [
"def",
"nested",
"(",
"self",
",",
"format_callback",
"=",
"None",
")",
":",
"seen",
"=",
"set",
"(",
")",
"roots",
"=",
"[",
"]",
"for",
"root",
"in",
"self",
".",
"edges",
".",
"get",
"(",
"None",
",",
"(",
")",
")",
":",
"roots",
".",
"exten... | Return the graph as a nested list. | [
"Return",
"the",
"graph",
"as",
"a",
"nested",
"list",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/patched/admin_utils.py#L132-L140 |
227,652 | divio/django-filer | filer/utils/files.py | get_valid_filename | def get_valid_filename(s):
"""
like the regular get_valid_filename, but also slugifies away
umlauts and stuff.
"""
s = get_valid_filename_django(s)
filename, ext = os.path.splitext(s)
filename = slugify(filename)
ext = slugify(ext)
if ext:
return "%s.%s" % (filename, ext)
... | python | def get_valid_filename(s):
"""
like the regular get_valid_filename, but also slugifies away
umlauts and stuff.
"""
s = get_valid_filename_django(s)
filename, ext = os.path.splitext(s)
filename = slugify(filename)
ext = slugify(ext)
if ext:
return "%s.%s" % (filename, ext)
... | [
"def",
"get_valid_filename",
"(",
"s",
")",
":",
"s",
"=",
"get_valid_filename_django",
"(",
"s",
")",
"filename",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"s",
")",
"filename",
"=",
"slugify",
"(",
"filename",
")",
"ext",
"=",
"slugif... | like the regular get_valid_filename, but also slugifies away
umlauts and stuff. | [
"like",
"the",
"regular",
"get_valid_filename",
"but",
"also",
"slugifies",
"away",
"umlauts",
"and",
"stuff",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/files.py#L122-L134 |
227,653 | divio/django-filer | filer/management/commands/import_files.py | FileImporter.walker | def walker(self, path=None, base_folder=None):
"""
This method walk a directory structure and create the
Folders and Files as they appear.
"""
path = path or self.path or ''
base_folder = base_folder or self.base_folder
# prevent trailing slashes and other inconsi... | python | def walker(self, path=None, base_folder=None):
"""
This method walk a directory structure and create the
Folders and Files as they appear.
"""
path = path or self.path or ''
base_folder = base_folder or self.base_folder
# prevent trailing slashes and other inconsi... | [
"def",
"walker",
"(",
"self",
",",
"path",
"=",
"None",
",",
"base_folder",
"=",
"None",
")",
":",
"path",
"=",
"path",
"or",
"self",
".",
"path",
"or",
"''",
"base_folder",
"=",
"base_folder",
"or",
"self",
".",
"base_folder",
"# prevent trailing slashes ... | This method walk a directory structure and create the
Folders and Files as they appear. | [
"This",
"method",
"walk",
"a",
"directory",
"structure",
"and",
"create",
"the",
"Folders",
"and",
"Files",
"as",
"they",
"appear",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/management/commands/import_files.py#L79-L108 |
227,654 | divio/django-filer | filer/utils/zip.py | unzip | def unzip(file_obj):
"""
Take a path to a zipfile and checks if it is a valid zip file
and returns...
"""
files = []
# TODO: implement try-except here
zip = ZipFile(file_obj)
bad_file = zip.testzip()
if bad_file:
raise Exception('"%s" in the .zip archive is corrupt.' % bad_fi... | python | def unzip(file_obj):
"""
Take a path to a zipfile and checks if it is a valid zip file
and returns...
"""
files = []
# TODO: implement try-except here
zip = ZipFile(file_obj)
bad_file = zip.testzip()
if bad_file:
raise Exception('"%s" in the .zip archive is corrupt.' % bad_fi... | [
"def",
"unzip",
"(",
"file_obj",
")",
":",
"files",
"=",
"[",
"]",
"# TODO: implement try-except here",
"zip",
"=",
"ZipFile",
"(",
"file_obj",
")",
"bad_file",
"=",
"zip",
".",
"testzip",
"(",
")",
"if",
"bad_file",
":",
"raise",
"Exception",
"(",
"'\"%s\... | Take a path to a zipfile and checks if it is a valid zip file
and returns... | [
"Take",
"a",
"path",
"to",
"a",
"zipfile",
"and",
"checks",
"if",
"it",
"is",
"a",
"valid",
"zip",
"file",
"and",
"returns",
"..."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/zip.py#L9-L27 |
227,655 | divio/django-filer | filer/utils/filer_easy_thumbnails.py | ThumbnailerNameMixin.get_thumbnail_name | def get_thumbnail_name(self, thumbnail_options, transparent=False,
high_resolution=False):
"""
A version of ``Thumbnailer.get_thumbnail_name`` that produces a
reproducible thumbnail name that can be converted back to the original
filename.
"""
p... | python | def get_thumbnail_name(self, thumbnail_options, transparent=False,
high_resolution=False):
"""
A version of ``Thumbnailer.get_thumbnail_name`` that produces a
reproducible thumbnail name that can be converted back to the original
filename.
"""
p... | [
"def",
"get_thumbnail_name",
"(",
"self",
",",
"thumbnail_options",
",",
"transparent",
"=",
"False",
",",
"high_resolution",
"=",
"False",
")",
":",
"path",
",",
"source_filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"self",
".",
"name",
")",
"sour... | A version of ``Thumbnailer.get_thumbnail_name`` that produces a
reproducible thumbnail name that can be converted back to the original
filename. | [
"A",
"version",
"of",
"Thumbnailer",
".",
"get_thumbnail_name",
"that",
"produces",
"a",
"reproducible",
"thumbnail",
"name",
"that",
"can",
"be",
"converted",
"back",
"to",
"the",
"original",
"filename",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/filer_easy_thumbnails.py#L29-L72 |
227,656 | divio/django-filer | filer/utils/filer_easy_thumbnails.py | ActionThumbnailerMixin.get_thumbnail_name | def get_thumbnail_name(self, thumbnail_options, transparent=False,
high_resolution=False):
"""
A version of ``Thumbnailer.get_thumbnail_name`` that returns the original
filename to resize.
"""
path, filename = os.path.split(self.name)
basedir =... | python | def get_thumbnail_name(self, thumbnail_options, transparent=False,
high_resolution=False):
"""
A version of ``Thumbnailer.get_thumbnail_name`` that returns the original
filename to resize.
"""
path, filename = os.path.split(self.name)
basedir =... | [
"def",
"get_thumbnail_name",
"(",
"self",
",",
"thumbnail_options",
",",
"transparent",
"=",
"False",
",",
"high_resolution",
"=",
"False",
")",
":",
"path",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"self",
".",
"name",
")",
"basedir",
... | A version of ``Thumbnailer.get_thumbnail_name`` that returns the original
filename to resize. | [
"A",
"version",
"of",
"Thumbnailer",
".",
"get_thumbnail_name",
"that",
"returns",
"the",
"original",
"filename",
"to",
"resize",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/filer_easy_thumbnails.py#L80-L91 |
227,657 | divio/django-filer | filer/admin/folderadmin.py | FolderAdmin.owner_search_fields | def owner_search_fields(self):
"""
Returns all the fields that are CharFields except for password from the
User model. For the built-in User model, that means username,
first_name, last_name, and email.
"""
try:
from django.contrib.auth import get_user_model
... | python | def owner_search_fields(self):
"""
Returns all the fields that are CharFields except for password from the
User model. For the built-in User model, that means username,
first_name, last_name, and email.
"""
try:
from django.contrib.auth import get_user_model
... | [
"def",
"owner_search_fields",
"(",
"self",
")",
":",
"try",
":",
"from",
"django",
".",
"contrib",
".",
"auth",
"import",
"get_user_model",
"except",
"ImportError",
":",
"# Django < 1.5",
"from",
"django",
".",
"contrib",
".",
"auth",
".",
"models",
"import",
... | Returns all the fields that are CharFields except for password from the
User model. For the built-in User model, that means username,
first_name, last_name, and email. | [
"Returns",
"all",
"the",
"fields",
"that",
"are",
"CharFields",
"except",
"for",
"password",
"from",
"the",
"User",
"model",
".",
"For",
"the",
"built",
"-",
"in",
"User",
"model",
"that",
"means",
"username",
"first_name",
"last_name",
"and",
"email",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/folderadmin.py#L481-L496 |
227,658 | divio/django-filer | filer/admin/folderadmin.py | FolderAdmin.move_to_clipboard | def move_to_clipboard(self, request, files_queryset, folders_queryset):
"""
Action which moves the selected files and files in selected folders
to clipboard.
"""
if not self.has_change_permission(request):
raise PermissionDenied
if request.method != 'POST':
... | python | def move_to_clipboard(self, request, files_queryset, folders_queryset):
"""
Action which moves the selected files and files in selected folders
to clipboard.
"""
if not self.has_change_permission(request):
raise PermissionDenied
if request.method != 'POST':
... | [
"def",
"move_to_clipboard",
"(",
"self",
",",
"request",
",",
"files_queryset",
",",
"folders_queryset",
")",
":",
"if",
"not",
"self",
".",
"has_change_permission",
"(",
"request",
")",
":",
"raise",
"PermissionDenied",
"if",
"request",
".",
"method",
"!=",
"... | Action which moves the selected files and files in selected folders
to clipboard. | [
"Action",
"which",
"moves",
"the",
"selected",
"files",
"and",
"files",
"in",
"selected",
"folders",
"to",
"clipboard",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/folderadmin.py#L596-L634 |
227,659 | divio/django-filer | filer/admin/tools.py | admin_url_params | def admin_url_params(request, params=None):
"""
given a request, looks at GET and POST values to determine which params
should be added. Is used to keep the context of popup and picker mode.
"""
params = params or {}
if popup_status(request):
params[IS_POPUP_VAR] = '1'
pick_type = po... | python | def admin_url_params(request, params=None):
"""
given a request, looks at GET and POST values to determine which params
should be added. Is used to keep the context of popup and picker mode.
"""
params = params or {}
if popup_status(request):
params[IS_POPUP_VAR] = '1'
pick_type = po... | [
"def",
"admin_url_params",
"(",
"request",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"params",
"or",
"{",
"}",
"if",
"popup_status",
"(",
"request",
")",
":",
"params",
"[",
"IS_POPUP_VAR",
"]",
"=",
"'1'",
"pick_type",
"=",
"popup_pick_type",
... | given a request, looks at GET and POST values to determine which params
should be added. Is used to keep the context of popup and picker mode. | [
"given",
"a",
"request",
"looks",
"at",
"GET",
"and",
"POST",
"values",
"to",
"determine",
"which",
"params",
"should",
"be",
"added",
".",
"Is",
"used",
"to",
"keep",
"the",
"context",
"of",
"popup",
"and",
"picker",
"mode",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/tools.py#L70-L81 |
227,660 | divio/django-filer | filer/admin/imageadmin.py | ImageAdminForm.clean_subject_location | def clean_subject_location(self):
"""
Validate subject_location preserving last saved value.
Last valid value of the subject_location field is shown to the user
for subject location widget to receive valid coordinates on field
validation errors.
"""
cleaned_data ... | python | def clean_subject_location(self):
"""
Validate subject_location preserving last saved value.
Last valid value of the subject_location field is shown to the user
for subject location widget to receive valid coordinates on field
validation errors.
"""
cleaned_data ... | [
"def",
"clean_subject_location",
"(",
"self",
")",
":",
"cleaned_data",
"=",
"super",
"(",
"ImageAdminForm",
",",
"self",
")",
".",
"clean",
"(",
")",
"subject_location",
"=",
"cleaned_data",
"[",
"'subject_location'",
"]",
"if",
"not",
"subject_location",
":",
... | Validate subject_location preserving last saved value.
Last valid value of the subject_location field is shown to the user
for subject location widget to receive valid coordinates on field
validation errors. | [
"Validate",
"subject_location",
"preserving",
"last",
"saved",
"value",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/imageadmin.py#L42-L80 |
227,661 | divio/django-filer | filer/utils/loader.py | load_object | def load_object(import_path):
"""
Loads an object from an 'import_path', like in MIDDLEWARE_CLASSES and the
likes.
Import paths should be: "mypackage.mymodule.MyObject". It then imports the
module up until the last dot and tries to get the attribute after that dot
from the imported module.
... | python | def load_object(import_path):
"""
Loads an object from an 'import_path', like in MIDDLEWARE_CLASSES and the
likes.
Import paths should be: "mypackage.mymodule.MyObject". It then imports the
module up until the last dot and tries to get the attribute after that dot
from the imported module.
... | [
"def",
"load_object",
"(",
"import_path",
")",
":",
"if",
"not",
"isinstance",
"(",
"import_path",
",",
"six",
".",
"string_types",
")",
":",
"return",
"import_path",
"if",
"'.'",
"not",
"in",
"import_path",
":",
"raise",
"TypeError",
"(",
"\"'import_path' arg... | Loads an object from an 'import_path', like in MIDDLEWARE_CLASSES and the
likes.
Import paths should be: "mypackage.mymodule.MyObject". It then imports the
module up until the last dot and tries to get the attribute after that dot
from the imported module.
If the import path does not contain any d... | [
"Loads",
"an",
"object",
"from",
"an",
"import_path",
"like",
"in",
"MIDDLEWARE_CLASSES",
"and",
"the",
"likes",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/loader.py#L18-L41 |
227,662 | divio/django-filer | filer/management/commands/generate_thumbnails.py | Command.handle | def handle(self, *args, **options):
"""
Generates image thumbnails
NOTE: To keep memory consumption stable avoid iteration over the Image queryset
"""
pks = Image.objects.all().values_list('id', flat=True)
total = len(pks)
for idx, pk in enumerate(pks):
... | python | def handle(self, *args, **options):
"""
Generates image thumbnails
NOTE: To keep memory consumption stable avoid iteration over the Image queryset
"""
pks = Image.objects.all().values_list('id', flat=True)
total = len(pks)
for idx, pk in enumerate(pks):
... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"pks",
"=",
"Image",
".",
"objects",
".",
"all",
"(",
")",
".",
"values_list",
"(",
"'id'",
",",
"flat",
"=",
"True",
")",
"total",
"=",
"len",
"(",
"pks",
")",... | Generates image thumbnails
NOTE: To keep memory consumption stable avoid iteration over the Image queryset | [
"Generates",
"image",
"thumbnails"
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/management/commands/generate_thumbnails.py#L9-L29 |
227,663 | divio/django-filer | filer/utils/compatibility.py | upath | def upath(path):
"""
Always return a unicode path.
"""
if six.PY2 and not isinstance(path, six.text_type):
return path.decode(fs_encoding)
return path | python | def upath(path):
"""
Always return a unicode path.
"""
if six.PY2 and not isinstance(path, six.text_type):
return path.decode(fs_encoding)
return path | [
"def",
"upath",
"(",
"path",
")",
":",
"if",
"six",
".",
"PY2",
"and",
"not",
"isinstance",
"(",
"path",
",",
"six",
".",
"text_type",
")",
":",
"return",
"path",
".",
"decode",
"(",
"fs_encoding",
")",
"return",
"path"
] | Always return a unicode path. | [
"Always",
"return",
"a",
"unicode",
"path",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/compatibility.py#L60-L66 |
227,664 | divio/django-filer | filer/utils/model_label.py | get_model_label | def get_model_label(model):
"""
Take a model class or model label and return its model label.
>>> get_model_label(MyModel)
"myapp.MyModel"
>>> get_model_label("myapp.MyModel")
"myapp.MyModel"
"""
if isinstance(model, six.string_types):
return model
else:
return "%s.... | python | def get_model_label(model):
"""
Take a model class or model label and return its model label.
>>> get_model_label(MyModel)
"myapp.MyModel"
>>> get_model_label("myapp.MyModel")
"myapp.MyModel"
"""
if isinstance(model, six.string_types):
return model
else:
return "%s.... | [
"def",
"get_model_label",
"(",
"model",
")",
":",
"if",
"isinstance",
"(",
"model",
",",
"six",
".",
"string_types",
")",
":",
"return",
"model",
"else",
":",
"return",
"\"%s.%s\"",
"%",
"(",
"model",
".",
"_meta",
".",
"app_label",
",",
"model",
".",
... | Take a model class or model label and return its model label.
>>> get_model_label(MyModel)
"myapp.MyModel"
>>> get_model_label("myapp.MyModel")
"myapp.MyModel" | [
"Take",
"a",
"model",
"class",
"or",
"model",
"label",
"and",
"return",
"its",
"model",
"label",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/model_label.py#L8-L24 |
227,665 | divio/django-filer | filer/admin/clipboardadmin.py | ajax_upload | def ajax_upload(request, folder_id=None):
"""
Receives an upload from the uploader. Receives only one file at a time.
"""
folder = None
if folder_id:
try:
# Get folder
folder = Folder.objects.get(pk=folder_id)
except Folder.DoesNotExist:
return Jso... | python | def ajax_upload(request, folder_id=None):
"""
Receives an upload from the uploader. Receives only one file at a time.
"""
folder = None
if folder_id:
try:
# Get folder
folder = Folder.objects.get(pk=folder_id)
except Folder.DoesNotExist:
return Jso... | [
"def",
"ajax_upload",
"(",
"request",
",",
"folder_id",
"=",
"None",
")",
":",
"folder",
"=",
"None",
"if",
"folder_id",
":",
"try",
":",
"# Get folder",
"folder",
"=",
"Folder",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"folder_id",
")",
"except",
"... | Receives an upload from the uploader. Receives only one file at a time. | [
"Receives",
"an",
"upload",
"from",
"the",
"uploader",
".",
"Receives",
"only",
"one",
"file",
"at",
"a",
"time",
"."
] | 946629087943d41eff290f07bfdf240b8853dd88 | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/clipboardadmin.py#L72-L174 |
227,666 | pyeve/cerberus | cerberus/validator.py | BareValidator.__store_config | def __store_config(self, args, kwargs):
""" Assign args to kwargs and store configuration. """
signature = (
'schema',
'ignore_none_values',
'allow_unknown',
'require_all',
'purge_unknown',
'purge_readonly',
)
for i,... | python | def __store_config(self, args, kwargs):
""" Assign args to kwargs and store configuration. """
signature = (
'schema',
'ignore_none_values',
'allow_unknown',
'require_all',
'purge_unknown',
'purge_readonly',
)
for i,... | [
"def",
"__store_config",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"signature",
"=",
"(",
"'schema'",
",",
"'ignore_none_values'",
",",
"'allow_unknown'",
",",
"'require_all'",
",",
"'purge_unknown'",
",",
"'purge_readonly'",
",",
")",
"for",
"i",
","... | Assign args to kwargs and store configuration. | [
"Assign",
"args",
"to",
"kwargs",
"and",
"store",
"configuration",
"."
] | 688a67a4069e88042ed424bda7be0f4fa5fc3910 | https://github.com/pyeve/cerberus/blob/688a67a4069e88042ed424bda7be0f4fa5fc3910/cerberus/validator.py#L207-L225 |
227,667 | pyeve/cerberus | cerberus/validator.py | BareValidator._error | def _error(self, *args):
""" Creates and adds one or multiple errors.
:param args: Accepts different argument's signatures.
*1. Bulk addition of errors:*
- :term:`iterable` of
:class:`~cerberus.errors.ValidationError`-instances
... | python | def _error(self, *args):
""" Creates and adds one or multiple errors.
:param args: Accepts different argument's signatures.
*1. Bulk addition of errors:*
- :term:`iterable` of
:class:`~cerberus.errors.ValidationError`-instances
... | [
"def",
"_error",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"self",
".",
"_errors",
".",
"extend",
"(",
"args",
"[",
"0",
"]",
")",
"self",
".",
"_errors",
".",
"sort",
"(",
")",
"for",
"error",
"i... | Creates and adds one or multiple errors.
:param args: Accepts different argument's signatures.
*1. Bulk addition of errors:*
- :term:`iterable` of
:class:`~cerberus.errors.ValidationError`-instances
The errors will be adde... | [
"Creates",
"and",
"adds",
"one",
"or",
"multiple",
"errors",
"."
] | 688a67a4069e88042ed424bda7be0f4fa5fc3910 | https://github.com/pyeve/cerberus/blob/688a67a4069e88042ed424bda7be0f4fa5fc3910/cerberus/validator.py#L232-L308 |
227,668 | pyeve/cerberus | cerberus/validator.py | BareValidator.__validate_definitions | def __validate_definitions(self, definitions, field):
""" Validate a field's value against its defined rules. """
def validate_rule(rule):
validator = self.__get_rule_handler('validate', rule)
return validator(definitions.get(rule, None), field, value)
definitions = sel... | python | def __validate_definitions(self, definitions, field):
""" Validate a field's value against its defined rules. """
def validate_rule(rule):
validator = self.__get_rule_handler('validate', rule)
return validator(definitions.get(rule, None), field, value)
definitions = sel... | [
"def",
"__validate_definitions",
"(",
"self",
",",
"definitions",
",",
"field",
")",
":",
"def",
"validate_rule",
"(",
"rule",
")",
":",
"validator",
"=",
"self",
".",
"__get_rule_handler",
"(",
"'validate'",
",",
"rule",
")",
"return",
"validator",
"(",
"de... | Validate a field's value against its defined rules. | [
"Validate",
"a",
"field",
"s",
"value",
"against",
"its",
"defined",
"rules",
"."
] | 688a67a4069e88042ed424bda7be0f4fa5fc3910 | https://github.com/pyeve/cerberus/blob/688a67a4069e88042ed424bda7be0f4fa5fc3910/cerberus/validator.py#L1036-L1073 |
227,669 | mobolic/facebook-sdk | facebook/__init__.py | get_user_from_cookie | def get_user_from_cookie(cookies, app_id, app_secret):
"""Parses the cookie set by the official Facebook JavaScript SDK.
cookies should be a dictionary-like object mapping cookie names to
cookie values.
If the user is logged in via Facebook, we return a dictionary with
the keys "uid" and "access_t... | python | def get_user_from_cookie(cookies, app_id, app_secret):
"""Parses the cookie set by the official Facebook JavaScript SDK.
cookies should be a dictionary-like object mapping cookie names to
cookie values.
If the user is logged in via Facebook, we return a dictionary with
the keys "uid" and "access_t... | [
"def",
"get_user_from_cookie",
"(",
"cookies",
",",
"app_id",
",",
"app_secret",
")",
":",
"cookie",
"=",
"cookies",
".",
"get",
"(",
"\"fbsr_\"",
"+",
"app_id",
",",
"\"\"",
")",
"if",
"not",
"cookie",
":",
"return",
"None",
"parsed_request",
"=",
"parse_... | Parses the cookie set by the official Facebook JavaScript SDK.
cookies should be a dictionary-like object mapping cookie names to
cookie values.
If the user is logged in via Facebook, we return a dictionary with
the keys "uid" and "access_token". The former is the user's
Facebook ID, and the latte... | [
"Parses",
"the",
"cookie",
"set",
"by",
"the",
"official",
"Facebook",
"JavaScript",
"SDK",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L443-L472 |
227,670 | mobolic/facebook-sdk | facebook/__init__.py | parse_signed_request | def parse_signed_request(signed_request, app_secret):
""" Return dictionary with signed request data.
We return a dictionary containing the information in the
signed_request. This includes a user_id if the user has authorised
your application, as well as any information requested.
If the signed_re... | python | def parse_signed_request(signed_request, app_secret):
""" Return dictionary with signed request data.
We return a dictionary containing the information in the
signed_request. This includes a user_id if the user has authorised
your application, as well as any information requested.
If the signed_re... | [
"def",
"parse_signed_request",
"(",
"signed_request",
",",
"app_secret",
")",
":",
"try",
":",
"encoded_sig",
",",
"payload",
"=",
"map",
"(",
"str",
",",
"signed_request",
".",
"split",
"(",
"\".\"",
",",
"1",
")",
")",
"sig",
"=",
"base64",
".",
"urlsa... | Return dictionary with signed request data.
We return a dictionary containing the information in the
signed_request. This includes a user_id if the user has authorised
your application, as well as any information requested.
If the signed_request is malformed or corrupted, False is returned. | [
"Return",
"dictionary",
"with",
"signed",
"request",
"data",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L475-L519 |
227,671 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.get_permissions | def get_permissions(self, user_id):
"""Fetches the permissions object from the graph."""
response = self.request(
"{0}/{1}/permissions".format(self.version, user_id), {}
)["data"]
return {x["permission"] for x in response if x["status"] == "granted"} | python | def get_permissions(self, user_id):
"""Fetches the permissions object from the graph."""
response = self.request(
"{0}/{1}/permissions".format(self.version, user_id), {}
)["data"]
return {x["permission"] for x in response if x["status"] == "granted"} | [
"def",
"get_permissions",
"(",
"self",
",",
"user_id",
")",
":",
"response",
"=",
"self",
".",
"request",
"(",
"\"{0}/{1}/permissions\"",
".",
"format",
"(",
"self",
".",
"version",
",",
"user_id",
")",
",",
"{",
"}",
")",
"[",
"\"data\"",
"]",
"return",... | Fetches the permissions object from the graph. | [
"Fetches",
"the",
"permissions",
"object",
"from",
"the",
"graph",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L126-L131 |
227,672 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.get_object | def get_object(self, id, **args):
"""Fetches the given object from the graph."""
return self.request("{0}/{1}".format(self.version, id), args) | python | def get_object(self, id, **args):
"""Fetches the given object from the graph."""
return self.request("{0}/{1}".format(self.version, id), args) | [
"def",
"get_object",
"(",
"self",
",",
"id",
",",
"*",
"*",
"args",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"{0}/{1}\"",
".",
"format",
"(",
"self",
".",
"version",
",",
"id",
")",
",",
"args",
")"
] | Fetches the given object from the graph. | [
"Fetches",
"the",
"given",
"object",
"from",
"the",
"graph",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L133-L135 |
227,673 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.get_objects | def get_objects(self, ids, **args):
"""Fetches all of the given object from the graph.
We return a map from ID to object. If any of the IDs are
invalid, we raise an exception.
"""
args["ids"] = ",".join(ids)
return self.request(self.version + "/", args) | python | def get_objects(self, ids, **args):
"""Fetches all of the given object from the graph.
We return a map from ID to object. If any of the IDs are
invalid, we raise an exception.
"""
args["ids"] = ",".join(ids)
return self.request(self.version + "/", args) | [
"def",
"get_objects",
"(",
"self",
",",
"ids",
",",
"*",
"*",
"args",
")",
":",
"args",
"[",
"\"ids\"",
"]",
"=",
"\",\"",
".",
"join",
"(",
"ids",
")",
"return",
"self",
".",
"request",
"(",
"self",
".",
"version",
"+",
"\"/\"",
",",
"args",
")"... | Fetches all of the given object from the graph.
We return a map from ID to object. If any of the IDs are
invalid, we raise an exception. | [
"Fetches",
"all",
"of",
"the",
"given",
"object",
"from",
"the",
"graph",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L137-L144 |
227,674 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.get_connections | def get_connections(self, id, connection_name, **args):
"""Fetches the connections for given object."""
return self.request(
"{0}/{1}/{2}".format(self.version, id, connection_name), args
) | python | def get_connections(self, id, connection_name, **args):
"""Fetches the connections for given object."""
return self.request(
"{0}/{1}/{2}".format(self.version, id, connection_name), args
) | [
"def",
"get_connections",
"(",
"self",
",",
"id",
",",
"connection_name",
",",
"*",
"*",
"args",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"{0}/{1}/{2}\"",
".",
"format",
"(",
"self",
".",
"version",
",",
"id",
",",
"connection_name",
")",
",",
... | Fetches the connections for given object. | [
"Fetches",
"the",
"connections",
"for",
"given",
"object",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L156-L160 |
227,675 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.get_all_connections | def get_all_connections(self, id, connection_name, **args):
"""Get all pages from a get_connections call
This will iterate over all pages returned by a get_connections call
and yield the individual items.
"""
while True:
page = self.get_connections(id, connection_nam... | python | def get_all_connections(self, id, connection_name, **args):
"""Get all pages from a get_connections call
This will iterate over all pages returned by a get_connections call
and yield the individual items.
"""
while True:
page = self.get_connections(id, connection_nam... | [
"def",
"get_all_connections",
"(",
"self",
",",
"id",
",",
"connection_name",
",",
"*",
"*",
"args",
")",
":",
"while",
"True",
":",
"page",
"=",
"self",
".",
"get_connections",
"(",
"id",
",",
"connection_name",
",",
"*",
"*",
"args",
")",
"for",
"pos... | Get all pages from a get_connections call
This will iterate over all pages returned by a get_connections call
and yield the individual items. | [
"Get",
"all",
"pages",
"from",
"a",
"get_connections",
"call"
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L162-L176 |
227,676 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.put_object | def put_object(self, parent_object, connection_name, **data):
"""Writes the given object to the graph, connected to the given parent.
For example,
graph.put_object("me", "feed", message="Hello, world")
writes "Hello, world" to the active user's wall. Likewise, this
will co... | python | def put_object(self, parent_object, connection_name, **data):
"""Writes the given object to the graph, connected to the given parent.
For example,
graph.put_object("me", "feed", message="Hello, world")
writes "Hello, world" to the active user's wall. Likewise, this
will co... | [
"def",
"put_object",
"(",
"self",
",",
"parent_object",
",",
"connection_name",
",",
"*",
"*",
"data",
")",
":",
"assert",
"self",
".",
"access_token",
",",
"\"Write operations require an access token\"",
"return",
"self",
".",
"request",
"(",
"\"{0}/{1}/{2}\"",
"... | Writes the given object to the graph, connected to the given parent.
For example,
graph.put_object("me", "feed", message="Hello, world")
writes "Hello, world" to the active user's wall. Likewise, this
will comment on the first post of the active user's feed:
feed = gr... | [
"Writes",
"the",
"given",
"object",
"to",
"the",
"graph",
"connected",
"to",
"the",
"given",
"parent",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L178-L202 |
227,677 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.delete_request | def delete_request(self, user_id, request_id):
"""Deletes the Request with the given ID for the given user."""
return self.request(
"{0}_{1}".format(request_id, user_id), method="DELETE"
) | python | def delete_request(self, user_id, request_id):
"""Deletes the Request with the given ID for the given user."""
return self.request(
"{0}_{1}".format(request_id, user_id), method="DELETE"
) | [
"def",
"delete_request",
"(",
"self",
",",
"user_id",
",",
"request_id",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"{0}_{1}\"",
".",
"format",
"(",
"request_id",
",",
"user_id",
")",
",",
"method",
"=",
"\"DELETE\"",
")"
] | Deletes the Request with the given ID for the given user. | [
"Deletes",
"the",
"Request",
"with",
"the",
"given",
"ID",
"for",
"the",
"given",
"user",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L218-L222 |
227,678 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.get_version | def get_version(self):
"""Fetches the current version number of the Graph API being used."""
args = {"access_token": self.access_token}
try:
response = self.session.request(
"GET",
FACEBOOK_GRAPH_URL + self.version + "/me",
params=args,... | python | def get_version(self):
"""Fetches the current version number of the Graph API being used."""
args = {"access_token": self.access_token}
try:
response = self.session.request(
"GET",
FACEBOOK_GRAPH_URL + self.version + "/me",
params=args,... | [
"def",
"get_version",
"(",
"self",
")",
":",
"args",
"=",
"{",
"\"access_token\"",
":",
"self",
".",
"access_token",
"}",
"try",
":",
"response",
"=",
"self",
".",
"session",
".",
"request",
"(",
"\"GET\"",
",",
"FACEBOOK_GRAPH_URL",
"+",
"self",
".",
"v... | Fetches the current version number of the Graph API being used. | [
"Fetches",
"the",
"current",
"version",
"number",
"of",
"the",
"Graph",
"API",
"being",
"used",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L239-L259 |
227,679 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.request | def request(
self, path, args=None, post_args=None, files=None, method=None
):
"""Fetches the given path in the Graph API.
We translate args to a valid query string. If post_args is
given, we send a POST request to the given path with the given
arguments.
"""
... | python | def request(
self, path, args=None, post_args=None, files=None, method=None
):
"""Fetches the given path in the Graph API.
We translate args to a valid query string. If post_args is
given, we send a POST request to the given path with the given
arguments.
"""
... | [
"def",
"request",
"(",
"self",
",",
"path",
",",
"args",
"=",
"None",
",",
"post_args",
"=",
"None",
",",
"files",
"=",
"None",
",",
"method",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"dict",
"(",
")",
"if",
"post_args... | Fetches the given path in the Graph API.
We translate args to a valid query string. If post_args is
given, we send a POST request to the given path with the given
arguments. | [
"Fetches",
"the",
"given",
"path",
"in",
"the",
"Graph",
"API",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L261-L323 |
227,680 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.get_access_token_from_code | def get_access_token_from_code(
self, code, redirect_uri, app_id, app_secret
):
"""Get an access token from the "code" returned from an OAuth dialog.
Returns a dict containing the user-specific access token and its
expiration date (if applicable).
"""
args = {
... | python | def get_access_token_from_code(
self, code, redirect_uri, app_id, app_secret
):
"""Get an access token from the "code" returned from an OAuth dialog.
Returns a dict containing the user-specific access token and its
expiration date (if applicable).
"""
args = {
... | [
"def",
"get_access_token_from_code",
"(",
"self",
",",
"code",
",",
"redirect_uri",
",",
"app_id",
",",
"app_secret",
")",
":",
"args",
"=",
"{",
"\"code\"",
":",
"code",
",",
"\"redirect_uri\"",
":",
"redirect_uri",
",",
"\"client_id\"",
":",
"app_id",
",",
... | Get an access token from the "code" returned from an OAuth dialog.
Returns a dict containing the user-specific access token and its
expiration date (if applicable). | [
"Get",
"an",
"access",
"token",
"from",
"the",
"code",
"returned",
"from",
"an",
"OAuth",
"dialog",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L346-L364 |
227,681 | mobolic/facebook-sdk | facebook/__init__.py | GraphAPI.get_auth_url | def get_auth_url(self, app_id, canvas_url, perms=None, **kwargs):
"""Build a URL to create an OAuth dialog."""
url = "{0}{1}/{2}".format(
FACEBOOK_WWW_URL, self.version, FACEBOOK_OAUTH_DIALOG_PATH
)
args = {"client_id": app_id, "redirect_uri": canvas_url}
if perms:
... | python | def get_auth_url(self, app_id, canvas_url, perms=None, **kwargs):
"""Build a URL to create an OAuth dialog."""
url = "{0}{1}/{2}".format(
FACEBOOK_WWW_URL, self.version, FACEBOOK_OAUTH_DIALOG_PATH
)
args = {"client_id": app_id, "redirect_uri": canvas_url}
if perms:
... | [
"def",
"get_auth_url",
"(",
"self",
",",
"app_id",
",",
"canvas_url",
",",
"perms",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"\"{0}{1}/{2}\"",
".",
"format",
"(",
"FACEBOOK_WWW_URL",
",",
"self",
".",
"version",
",",
"FACEBOOK_OAUTH_DIAL... | Build a URL to create an OAuth dialog. | [
"Build",
"a",
"URL",
"to",
"create",
"an",
"OAuth",
"dialog",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L401-L411 |
227,682 | mobolic/facebook-sdk | examples/flask/app/views.py | get_current_user | def get_current_user():
"""Set g.user to the currently logged in user.
Called before each request, get_current_user sets the global g.user
variable to the currently logged in user. A currently logged in user is
determined by seeing if it exists in Flask's session dictionary.
If it is the first ti... | python | def get_current_user():
"""Set g.user to the currently logged in user.
Called before each request, get_current_user sets the global g.user
variable to the currently logged in user. A currently logged in user is
determined by seeing if it exists in Flask's session dictionary.
If it is the first ti... | [
"def",
"get_current_user",
"(",
")",
":",
"# Set the user in the session dictionary as a global g.user and bail out",
"# of this function early.",
"if",
"session",
".",
"get",
"(",
"\"user\"",
")",
":",
"g",
".",
"user",
"=",
"session",
".",
"get",
"(",
"\"user\"",
")... | Set g.user to the currently logged in user.
Called before each request, get_current_user sets the global g.user
variable to the currently logged in user. A currently logged in user is
determined by seeing if it exists in Flask's session dictionary.
If it is the first time the user is logging into thi... | [
"Set",
"g",
".",
"user",
"to",
"the",
"currently",
"logged",
"in",
"user",
"."
] | 65ff582e77f7ed68b6e9643a7490e5dee2a1031b | https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/examples/flask/app/views.py#L38-L95 |
227,683 | NetEaseGame/ATX | atx/record/scene_detector.py | SceneDetector.build_tree | def build_tree(self, directory):
'''build scene tree from images'''
confile = os.path.join(directory, 'config.yml')
conf = {}
if os.path.exists(confile):
conf = yaml.load(open(confile).read())
class node(defaultdict):
name = ''
parent... | python | def build_tree(self, directory):
'''build scene tree from images'''
confile = os.path.join(directory, 'config.yml')
conf = {}
if os.path.exists(confile):
conf = yaml.load(open(confile).read())
class node(defaultdict):
name = ''
parent... | [
"def",
"build_tree",
"(",
"self",
",",
"directory",
")",
":",
"confile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"'config.yml'",
")",
"conf",
"=",
"{",
"}",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"confile",
")",
":",
"conf... | build scene tree from images | [
"build",
"scene",
"tree",
"from",
"images"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/scene_detector.py#L81-L126 |
227,684 | NetEaseGame/ATX | atx/adbkit/openstf/service.py | pack | def pack(mtype, request, rid=None):
'''pack request to delimited data'''
envelope = wire.Envelope()
if rid is not None:
envelope.id = rid
envelope.type = mtype
envelope.message = request.SerializeToString()
data = envelope.SerializeToString()
data = encoder._VarintBytes(len(data)) +... | python | def pack(mtype, request, rid=None):
'''pack request to delimited data'''
envelope = wire.Envelope()
if rid is not None:
envelope.id = rid
envelope.type = mtype
envelope.message = request.SerializeToString()
data = envelope.SerializeToString()
data = encoder._VarintBytes(len(data)) +... | [
"def",
"pack",
"(",
"mtype",
",",
"request",
",",
"rid",
"=",
"None",
")",
":",
"envelope",
"=",
"wire",
".",
"Envelope",
"(",
")",
"if",
"rid",
"is",
"not",
"None",
":",
"envelope",
".",
"id",
"=",
"rid",
"envelope",
".",
"type",
"=",
"mtype",
"... | pack request to delimited data | [
"pack",
"request",
"to",
"delimited",
"data"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/openstf/service.py#L75-L84 |
227,685 | NetEaseGame/ATX | atx/adbkit/openstf/service.py | unpack | def unpack(data):
'''unpack from delimited data'''
size, position = decoder._DecodeVarint(data, 0)
envelope = wire.Envelope()
envelope.ParseFromString(data[position:position+size])
return envelope | python | def unpack(data):
'''unpack from delimited data'''
size, position = decoder._DecodeVarint(data, 0)
envelope = wire.Envelope()
envelope.ParseFromString(data[position:position+size])
return envelope | [
"def",
"unpack",
"(",
"data",
")",
":",
"size",
",",
"position",
"=",
"decoder",
".",
"_DecodeVarint",
"(",
"data",
",",
"0",
")",
"envelope",
"=",
"wire",
".",
"Envelope",
"(",
")",
"envelope",
".",
"ParseFromString",
"(",
"data",
"[",
"position",
":"... | unpack from delimited data | [
"unpack",
"from",
"delimited",
"data"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/openstf/service.py#L86-L91 |
227,686 | NetEaseGame/ATX | atx/adbkit/openstf/service.py | check_stf_agent | def check_stf_agent(adbprefix=None, kill=False):
'''return True if agent is alive.'''
if adbprefix is None:
adbprefix = ['adb']
command = adbprefix + ['shell', 'ps']
out = subprocess.check_output(command).strip()
out = out.splitlines()
if len(out) > 1:
first, out = out[0], out[1... | python | def check_stf_agent(adbprefix=None, kill=False):
'''return True if agent is alive.'''
if adbprefix is None:
adbprefix = ['adb']
command = adbprefix + ['shell', 'ps']
out = subprocess.check_output(command).strip()
out = out.splitlines()
if len(out) > 1:
first, out = out[0], out[1... | [
"def",
"check_stf_agent",
"(",
"adbprefix",
"=",
"None",
",",
"kill",
"=",
"False",
")",
":",
"if",
"adbprefix",
"is",
"None",
":",
"adbprefix",
"=",
"[",
"'adb'",
"]",
"command",
"=",
"adbprefix",
"+",
"[",
"'shell'",
",",
"'ps'",
"]",
"out",
"=",
"... | return True if agent is alive. | [
"return",
"True",
"if",
"agent",
"is",
"alive",
"."
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/openstf/service.py#L182-L205 |
227,687 | NetEaseGame/ATX | atx/cmds/tkgui.py | insert_code | def insert_code(filename, code, save=True, marker='# ATX CODE END'):
""" Auto append code """
content = ''
found = False
for line in open(filename, 'rb'):
if not found and line.strip() == marker:
found = True
cnt = line.find(marker)
content += line[:cnt] + cod... | python | def insert_code(filename, code, save=True, marker='# ATX CODE END'):
""" Auto append code """
content = ''
found = False
for line in open(filename, 'rb'):
if not found and line.strip() == marker:
found = True
cnt = line.find(marker)
content += line[:cnt] + cod... | [
"def",
"insert_code",
"(",
"filename",
",",
"code",
",",
"save",
"=",
"True",
",",
"marker",
"=",
"'# ATX CODE END'",
")",
":",
"content",
"=",
"''",
"found",
"=",
"False",
"for",
"line",
"in",
"open",
"(",
"filename",
",",
"'rb'",
")",
":",
"if",
"n... | Auto append code | [
"Auto",
"append",
"code"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/cmds/tkgui.py#L41-L58 |
227,688 | NetEaseGame/ATX | scripts/image.py | find_image_position | def find_image_position(origin='origin.png', query='query.png', outfile=None):
'''
find all image positions
@return None if not found else a tuple: (origin.shape, query.shape, postions)
might raise Exception
'''
img1 = cv2.imread(query, 0) # query image(small)
img2 = cv2.imread(origin, 0) # ... | python | def find_image_position(origin='origin.png', query='query.png', outfile=None):
'''
find all image positions
@return None if not found else a tuple: (origin.shape, query.shape, postions)
might raise Exception
'''
img1 = cv2.imread(query, 0) # query image(small)
img2 = cv2.imread(origin, 0) # ... | [
"def",
"find_image_position",
"(",
"origin",
"=",
"'origin.png'",
",",
"query",
"=",
"'query.png'",
",",
"outfile",
"=",
"None",
")",
":",
"img1",
"=",
"cv2",
".",
"imread",
"(",
"query",
",",
"0",
")",
"# query image(small)",
"img2",
"=",
"cv2",
".",
"i... | find all image positions
@return None if not found else a tuple: (origin.shape, query.shape, postions)
might raise Exception | [
"find",
"all",
"image",
"positions"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/scripts/image.py#L46-L102 |
227,689 | NetEaseGame/ATX | atx/taskqueue/__main__.py | TaskQueueHandler.get | def get(self, udid):
''' get new task '''
timeout = self.get_argument('timeout', 20.0)
if timeout is not None:
timeout = float(timeout)
que = self.ques[udid]
try:
item = yield que.get(timeout=time.time()+timeout) # timeout is a timestamp, strange
... | python | def get(self, udid):
''' get new task '''
timeout = self.get_argument('timeout', 20.0)
if timeout is not None:
timeout = float(timeout)
que = self.ques[udid]
try:
item = yield que.get(timeout=time.time()+timeout) # timeout is a timestamp, strange
... | [
"def",
"get",
"(",
"self",
",",
"udid",
")",
":",
"timeout",
"=",
"self",
".",
"get_argument",
"(",
"'timeout'",
",",
"20.0",
")",
"if",
"timeout",
"is",
"not",
"None",
":",
"timeout",
"=",
"float",
"(",
"timeout",
")",
"que",
"=",
"self",
".",
"qu... | get new task | [
"get",
"new",
"task"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/taskqueue/__main__.py#L42-L57 |
227,690 | NetEaseGame/ATX | atx/taskqueue/__main__.py | TaskQueueHandler.post | def post(self, udid):
''' add new task '''
que = self.ques[udid]
timeout = self.get_argument('timeout', 10.0)
if timeout is not None:
timeout = float(timeout)
data = tornado.escape.json_decode(self.request.body)
data = {'id': str(uuid.uuid1()), 'data': data}
... | python | def post(self, udid):
''' add new task '''
que = self.ques[udid]
timeout = self.get_argument('timeout', 10.0)
if timeout is not None:
timeout = float(timeout)
data = tornado.escape.json_decode(self.request.body)
data = {'id': str(uuid.uuid1()), 'data': data}
... | [
"def",
"post",
"(",
"self",
",",
"udid",
")",
":",
"que",
"=",
"self",
".",
"ques",
"[",
"udid",
"]",
"timeout",
"=",
"self",
".",
"get_argument",
"(",
"'timeout'",
",",
"10.0",
")",
"if",
"timeout",
"is",
"not",
"None",
":",
"timeout",
"=",
"float... | add new task | [
"add",
"new",
"task"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/taskqueue/__main__.py#L60-L71 |
227,691 | NetEaseGame/ATX | atx/record/android_hooks.py | InputParser._process_touch_batch | def _process_touch_batch(self):
'''a batch syncs in about 0.001 seconds.'''
if not self._touch_batch:
return
_time = self._temp_status_time
changed = False
for (_time, _device, _type, _code, _value) in self._touch_batch:
if _code == 'ABS_MT_TRAC... | python | def _process_touch_batch(self):
'''a batch syncs in about 0.001 seconds.'''
if not self._touch_batch:
return
_time = self._temp_status_time
changed = False
for (_time, _device, _type, _code, _value) in self._touch_batch:
if _code == 'ABS_MT_TRAC... | [
"def",
"_process_touch_batch",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_touch_batch",
":",
"return",
"_time",
"=",
"self",
".",
"_temp_status_time",
"changed",
"=",
"False",
"for",
"(",
"_time",
",",
"_device",
",",
"_type",
",",
"_code",
",",
... | a batch syncs in about 0.001 seconds. | [
"a",
"batch",
"syncs",
"in",
"about",
"0",
".",
"001",
"seconds",
"."
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/android_hooks.py#L218-L283 |
227,692 | NetEaseGame/ATX | atx/record/android_hooks.py | GestureRecognizer.process | def process(self):
'''handle events and trigger time-related events'''
timediff = 0
while True:
try:
time.sleep(0.001)
event = self.queue.get_nowait()
self.handle_event(event)
if event.msg & HC.KEY_ANY:
... | python | def process(self):
'''handle events and trigger time-related events'''
timediff = 0
while True:
try:
time.sleep(0.001)
event = self.queue.get_nowait()
self.handle_event(event)
if event.msg & HC.KEY_ANY:
... | [
"def",
"process",
"(",
"self",
")",
":",
"timediff",
"=",
"0",
"while",
"True",
":",
"try",
":",
"time",
".",
"sleep",
"(",
"0.001",
")",
"event",
"=",
"self",
".",
"queue",
".",
"get_nowait",
"(",
")",
"self",
".",
"handle_event",
"(",
"event",
")... | handle events and trigger time-related events | [
"handle",
"events",
"and",
"trigger",
"time",
"-",
"related",
"events"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/android_hooks.py#L334-L367 |
227,693 | NetEaseGame/ATX | atx/drivers/mixin.py | DeviceMixin.exists | def exists(self, pattern, **match_kwargs):
"""Check if image exists in screen
Returns:
If exists, return FindPoint, or
return None if result.confidence < self.image_match_threshold
"""
ret = self.match(pattern, **match_kwargs)
if ret is None:
... | python | def exists(self, pattern, **match_kwargs):
"""Check if image exists in screen
Returns:
If exists, return FindPoint, or
return None if result.confidence < self.image_match_threshold
"""
ret = self.match(pattern, **match_kwargs)
if ret is None:
... | [
"def",
"exists",
"(",
"self",
",",
"pattern",
",",
"*",
"*",
"match_kwargs",
")",
":",
"ret",
"=",
"self",
".",
"match",
"(",
"pattern",
",",
"*",
"*",
"match_kwargs",
")",
"if",
"ret",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"ret",
".",
... | Check if image exists in screen
Returns:
If exists, return FindPoint, or
return None if result.confidence < self.image_match_threshold | [
"Check",
"if",
"image",
"exists",
"in",
"screen"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L143-L155 |
227,694 | NetEaseGame/ATX | atx/drivers/mixin.py | DeviceMixin._match_auto | def _match_auto(self, screen, search_img, threshold):
"""Maybe not a good idea
"""
# 1. try template first
ret = ac.find_template(screen, search_img)
if ret and ret['confidence'] > threshold:
return FindPoint(ret['result'], ret['confidence'], consts.IMAGE_MATCH_METHOD... | python | def _match_auto(self, screen, search_img, threshold):
"""Maybe not a good idea
"""
# 1. try template first
ret = ac.find_template(screen, search_img)
if ret and ret['confidence'] > threshold:
return FindPoint(ret['result'], ret['confidence'], consts.IMAGE_MATCH_METHOD... | [
"def",
"_match_auto",
"(",
"self",
",",
"screen",
",",
"search_img",
",",
"threshold",
")",
":",
"# 1. try template first",
"ret",
"=",
"ac",
".",
"find_template",
"(",
"screen",
",",
"search_img",
")",
"if",
"ret",
"and",
"ret",
"[",
"'confidence'",
"]",
... | Maybe not a good idea | [
"Maybe",
"not",
"a",
"good",
"idea"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L217-L233 |
227,695 | NetEaseGame/ATX | atx/drivers/mixin.py | DeviceMixin.match_all | def match_all(self, pattern):
"""
Test method, not suggested to use
"""
pattern = self.pattern_open(pattern)
search_img = pattern.image
screen = self.region_screenshot()
screen = imutils.from_pillow(screen)
points = ac.find_all_template(screen, search_img,... | python | def match_all(self, pattern):
"""
Test method, not suggested to use
"""
pattern = self.pattern_open(pattern)
search_img = pattern.image
screen = self.region_screenshot()
screen = imutils.from_pillow(screen)
points = ac.find_all_template(screen, search_img,... | [
"def",
"match_all",
"(",
"self",
",",
"pattern",
")",
":",
"pattern",
"=",
"self",
".",
"pattern_open",
"(",
"pattern",
")",
"search_img",
"=",
"pattern",
".",
"image",
"screen",
"=",
"self",
".",
"region_screenshot",
"(",
")",
"screen",
"=",
"imutils",
... | Test method, not suggested to use | [
"Test",
"method",
"not",
"suggested",
"to",
"use"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L235-L244 |
227,696 | NetEaseGame/ATX | atx/drivers/mixin.py | DeviceMixin.region_screenshot | def region_screenshot(self, filename=None):
"""Deprecated
Take part of the screenshot
"""
# warnings.warn("deprecated, use screenshot().crop(bounds) instead", DeprecationWarning)
screen = self.__last_screen if self.__keep_screen else self.screenshot()
if self.bounds:
... | python | def region_screenshot(self, filename=None):
"""Deprecated
Take part of the screenshot
"""
# warnings.warn("deprecated, use screenshot().crop(bounds) instead", DeprecationWarning)
screen = self.__last_screen if self.__keep_screen else self.screenshot()
if self.bounds:
... | [
"def",
"region_screenshot",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"# warnings.warn(\"deprecated, use screenshot().crop(bounds) instead\", DeprecationWarning)",
"screen",
"=",
"self",
".",
"__last_screen",
"if",
"self",
".",
"__keep_screen",
"else",
"self",
... | Deprecated
Take part of the screenshot | [
"Deprecated",
"Take",
"part",
"of",
"the",
"screenshot"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L375-L385 |
227,697 | NetEaseGame/ATX | atx/drivers/mixin.py | DeviceMixin.screenshot | def screenshot(self, filename=None):
"""
Take screen snapshot
Args:
- filename: filename where save to, optional
Returns:
PIL.Image object
Raises:
TypeError, IOError
"""
if self.__keep_screen:
return self.__last_s... | python | def screenshot(self, filename=None):
"""
Take screen snapshot
Args:
- filename: filename where save to, optional
Returns:
PIL.Image object
Raises:
TypeError, IOError
"""
if self.__keep_screen:
return self.__last_s... | [
"def",
"screenshot",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"if",
"self",
".",
"__keep_screen",
":",
"return",
"self",
".",
"__last_screen",
"try",
":",
"screen",
"=",
"self",
".",
"_take_screenshot",
"(",
")",
"except",
"IOError",
":",
"# ... | Take screen snapshot
Args:
- filename: filename where save to, optional
Returns:
PIL.Image object
Raises:
TypeError, IOError | [
"Take",
"screen",
"snapshot"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L388-L415 |
227,698 | NetEaseGame/ATX | atx/drivers/mixin.py | DeviceMixin.click_nowait | def click_nowait(self, pattern, action='click', desc=None, **match_kwargs):
""" Return immediately if no image found
Args:
- pattern (str or Pattern): filename or an opencv image object.
- action (str): click or long_click
Returns:
Click point or None
... | python | def click_nowait(self, pattern, action='click', desc=None, **match_kwargs):
""" Return immediately if no image found
Args:
- pattern (str or Pattern): filename or an opencv image object.
- action (str): click or long_click
Returns:
Click point or None
... | [
"def",
"click_nowait",
"(",
"self",
",",
"pattern",
",",
"action",
"=",
"'click'",
",",
"desc",
"=",
"None",
",",
"*",
"*",
"match_kwargs",
")",
":",
"point",
"=",
"self",
".",
"match",
"(",
"pattern",
",",
"*",
"*",
"match_kwargs",
")",
"if",
"not",... | Return immediately if no image found
Args:
- pattern (str or Pattern): filename or an opencv image object.
- action (str): click or long_click
Returns:
Click point or None | [
"Return",
"immediately",
"if",
"no",
"image",
"found"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L471-L487 |
227,699 | NetEaseGame/ATX | atx/drivers/mixin.py | DeviceMixin.click_image | def click_image(self, pattern, timeout=20.0, action='click', safe=False, desc=None, delay=None, **match_kwargs):
"""Simulate click according image position
Args:
- pattern (str or Pattern): filename or an opencv image object.
- timeout (float): if image not found during this tim... | python | def click_image(self, pattern, timeout=20.0, action='click', safe=False, desc=None, delay=None, **match_kwargs):
"""Simulate click according image position
Args:
- pattern (str or Pattern): filename or an opencv image object.
- timeout (float): if image not found during this tim... | [
"def",
"click_image",
"(",
"self",
",",
"pattern",
",",
"timeout",
"=",
"20.0",
",",
"action",
"=",
"'click'",
",",
"safe",
"=",
"False",
",",
"desc",
"=",
"None",
",",
"delay",
"=",
"None",
",",
"*",
"*",
"match_kwargs",
")",
":",
"pattern",
"=",
... | Simulate click according image position
Args:
- pattern (str or Pattern): filename or an opencv image object.
- timeout (float): if image not found during this time, ImageNotFoundError will raise.
- action (str): click or long_click
- safe (bool): if safe is True... | [
"Simulate",
"click",
"according",
"image",
"position"
] | f4415c57b45cb0730e08899cbc92a2af1c047ffb | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L503-L555 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.