repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
BYU-Hydroinformatics/HydroErr | HydroErr/HydroErr.py | treat_values | def treat_values(simulated_array, observed_array, replace_nan=None, replace_inf=None,
remove_neg=False, remove_zero=False):
"""Removes the nan, negative, and inf values in two numpy arrays"""
sim_copy = np.copy(simulated_array)
obs_copy = np.copy(observed_array)
# Checking to see if th... | python | def treat_values(simulated_array, observed_array, replace_nan=None, replace_inf=None,
remove_neg=False, remove_zero=False):
"""Removes the nan, negative, and inf values in two numpy arrays"""
sim_copy = np.copy(simulated_array)
obs_copy = np.copy(observed_array)
# Checking to see if th... | [
"def",
"treat_values",
"(",
"simulated_array",
",",
"observed_array",
",",
"replace_nan",
"=",
"None",
",",
"replace_inf",
"=",
"None",
",",
"remove_neg",
"=",
"False",
",",
"remove_zero",
"=",
"False",
")",
":",
"sim_copy",
"=",
"np",
".",
"copy",
"(",
"s... | Removes the nan, negative, and inf values in two numpy arrays | [
"Removes",
"the",
"nan",
"negative",
"and",
"inf",
"values",
"in",
"two",
"numpy",
"arrays"
] | train | https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L6210-L6315 |
jgorset/fandjango | fandjango/decorators.py | facebook_authorization_required | def facebook_authorization_required(redirect_uri=FACEBOOK_AUTHORIZATION_REDIRECT_URL, permissions=None):
"""
Require the user to authorize the application.
:param redirect_uri: A string describing an URL to redirect to after authorization is complete.
If ``None``, redirects to the ... | python | def facebook_authorization_required(redirect_uri=FACEBOOK_AUTHORIZATION_REDIRECT_URL, permissions=None):
"""
Require the user to authorize the application.
:param redirect_uri: A string describing an URL to redirect to after authorization is complete.
If ``None``, redirects to the ... | [
"def",
"facebook_authorization_required",
"(",
"redirect_uri",
"=",
"FACEBOOK_AUTHORIZATION_REDIRECT_URL",
",",
"permissions",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"wrapper",
"(",
"request... | Require the user to authorize the application.
:param redirect_uri: A string describing an URL to redirect to after authorization is complete.
If ``None``, redirects to the current URL in the Facebook canvas
(e.g. ``http://apps.facebook.com/myapp/current/path``). D... | [
"Require",
"the",
"user",
"to",
"authorize",
"the",
"application",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/decorators.py#L14-L65 |
jgorset/fandjango | fandjango/models.py | User.full_name | def full_name(self):
"""Return the user's first name."""
if self.first_name and self.middle_name and self.last_name:
return "%s %s %s" % (self.first_name, self.middle_name, self.last_name)
if self.first_name and self.last_name:
return "%s %s" % (self.first_name, self.last... | python | def full_name(self):
"""Return the user's first name."""
if self.first_name and self.middle_name and self.last_name:
return "%s %s %s" % (self.first_name, self.middle_name, self.last_name)
if self.first_name and self.last_name:
return "%s %s" % (self.first_name, self.last... | [
"def",
"full_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"first_name",
"and",
"self",
".",
"middle_name",
"and",
"self",
".",
"last_name",
":",
"return",
"\"%s %s %s\"",
"%",
"(",
"self",
".",
"first_name",
",",
"self",
".",
"middle_name",
",",
"sel... | Return the user's first name. | [
"Return",
"the",
"user",
"s",
"first",
"name",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/models.py#L86-L91 |
jgorset/fandjango | fandjango/models.py | User.permissions | def permissions(self):
"""
A list of strings describing `permissions`_ the user has granted your application.
.. _permissions: http://developers.facebook.com/docs/reference/api/permissions/
"""
records = self.graph.get('me/permissions')['data']
permissions = []
... | python | def permissions(self):
"""
A list of strings describing `permissions`_ the user has granted your application.
.. _permissions: http://developers.facebook.com/docs/reference/api/permissions/
"""
records = self.graph.get('me/permissions')['data']
permissions = []
... | [
"def",
"permissions",
"(",
"self",
")",
":",
"records",
"=",
"self",
".",
"graph",
".",
"get",
"(",
"'me/permissions'",
")",
"[",
"'data'",
"]",
"permissions",
"=",
"[",
"]",
"for",
"record",
"in",
"records",
":",
"if",
"record",
"[",
"'status'",
"]",
... | A list of strings describing `permissions`_ the user has granted your application.
.. _permissions: http://developers.facebook.com/docs/reference/api/permissions/ | [
"A",
"list",
"of",
"strings",
"describing",
"permissions",
"_",
"the",
"user",
"has",
"granted",
"your",
"application",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/models.py#L102-L115 |
jgorset/fandjango | fandjango/models.py | User.synchronize | def synchronize(self, graph_data=None):
"""
Synchronize ``facebook_username``, ``first_name``, ``middle_name``,
``last_name`` and ``birthday`` with Facebook.
:param graph_data: Optional pre-fetched graph data
"""
profile = graph_data or self.graph.get('me')
self... | python | def synchronize(self, graph_data=None):
"""
Synchronize ``facebook_username``, ``first_name``, ``middle_name``,
``last_name`` and ``birthday`` with Facebook.
:param graph_data: Optional pre-fetched graph data
"""
profile = graph_data or self.graph.get('me')
self... | [
"def",
"synchronize",
"(",
"self",
",",
"graph_data",
"=",
"None",
")",
":",
"profile",
"=",
"graph_data",
"or",
"self",
".",
"graph",
".",
"get",
"(",
"'me'",
")",
"self",
".",
"facebook_username",
"=",
"profile",
".",
"get",
"(",
"'username'",
")",
"... | Synchronize ``facebook_username``, ``first_name``, ``middle_name``,
``last_name`` and ``birthday`` with Facebook.
:param graph_data: Optional pre-fetched graph data | [
"Synchronize",
"facebook_username",
"first_name",
"middle_name",
"last_name",
"and",
"birthday",
"with",
"Facebook",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/models.py#L126-L144 |
jgorset/fandjango | fandjango/models.py | OAuthToken.extended | def extended(self):
"""Determine whether the OAuth token has been extended."""
if self.expires_at:
return self.expires_at - self.issued_at > timedelta(days=30)
else:
return False | python | def extended(self):
"""Determine whether the OAuth token has been extended."""
if self.expires_at:
return self.expires_at - self.issued_at > timedelta(days=30)
else:
return False | [
"def",
"extended",
"(",
"self",
")",
":",
"if",
"self",
".",
"expires_at",
":",
"return",
"self",
".",
"expires_at",
"-",
"self",
".",
"issued_at",
">",
"timedelta",
"(",
"days",
"=",
"30",
")",
"else",
":",
"return",
"False"
] | Determine whether the OAuth token has been extended. | [
"Determine",
"whether",
"the",
"OAuth",
"token",
"has",
"been",
"extended",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/models.py#L179-L184 |
jgorset/fandjango | fandjango/models.py | OAuthToken.extend | def extend(self):
"""Extend the OAuth token."""
graph = GraphAPI()
response = graph.get('oauth/access_token',
client_id = FACEBOOK_APPLICATION_ID,
client_secret = FACEBOOK_APPLICATION_SECRET_KEY,
grant_type = 'fb_exchange_token',
fb_exchange_token... | python | def extend(self):
"""Extend the OAuth token."""
graph = GraphAPI()
response = graph.get('oauth/access_token',
client_id = FACEBOOK_APPLICATION_ID,
client_secret = FACEBOOK_APPLICATION_SECRET_KEY,
grant_type = 'fb_exchange_token',
fb_exchange_token... | [
"def",
"extend",
"(",
"self",
")",
":",
"graph",
"=",
"GraphAPI",
"(",
")",
"response",
"=",
"graph",
".",
"get",
"(",
"'oauth/access_token'",
",",
"client_id",
"=",
"FACEBOOK_APPLICATION_ID",
",",
"client_secret",
"=",
"FACEBOOK_APPLICATION_SECRET_KEY",
",",
"g... | Extend the OAuth token. | [
"Extend",
"the",
"OAuth",
"token",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/models.py#L186-L202 |
jgorset/fandjango | fandjango/middleware.py | FacebookMiddleware.process_request | def process_request(self, request):
"""Process the signed request."""
# User has already been authed by alternate middleware
if hasattr(request, "facebook") and request.facebook:
return
request.facebook = False
if not self.is_valid_path(request):
return... | python | def process_request(self, request):
"""Process the signed request."""
# User has already been authed by alternate middleware
if hasattr(request, "facebook") and request.facebook:
return
request.facebook = False
if not self.is_valid_path(request):
return... | [
"def",
"process_request",
"(",
"self",
",",
"request",
")",
":",
"# User has already been authed by alternate middleware",
"if",
"hasattr",
"(",
"request",
",",
"\"facebook\"",
")",
"and",
"request",
".",
"facebook",
":",
"return",
"request",
".",
"facebook",
"=",
... | Process the signed request. | [
"Process",
"the",
"signed",
"request",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/middleware.py#L53-L141 |
jgorset/fandjango | fandjango/middleware.py | FacebookMiddleware.process_response | def process_response(self, request, response):
"""
Set compact P3P policies and save signed request to cookie.
P3P is a WC3 standard (see http://www.w3.org/TR/P3P/), and although largely ignored by most
browsers it is considered by IE before accepting third-party cookies (ie. cookies se... | python | def process_response(self, request, response):
"""
Set compact P3P policies and save signed request to cookie.
P3P is a WC3 standard (see http://www.w3.org/TR/P3P/), and although largely ignored by most
browsers it is considered by IE before accepting third-party cookies (ie. cookies se... | [
"def",
"process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"response",
"[",
"'P3P'",
"]",
"=",
"'CP=\"IDC CURa ADMa OUR IND PHY ONL COM STA\"'",
"if",
"FANDJANGO_CACHE_SIGNED_REQUEST",
":",
"if",
"hasattr",
"(",
"request",
",",
"\"facebook\"",
... | Set compact P3P policies and save signed request to cookie.
P3P is a WC3 standard (see http://www.w3.org/TR/P3P/), and although largely ignored by most
browsers it is considered by IE before accepting third-party cookies (ie. cookies set by
documents in iframes). If they are not set correctly, ... | [
"Set",
"compact",
"P3P",
"policies",
"and",
"save",
"signed",
"request",
"to",
"cookie",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/middleware.py#L143-L159 |
jgorset/fandjango | fandjango/middleware.py | FacebookWebMiddleware.process_request | def process_request(self, request):
"""Process the web-based auth request."""
# User has already been authed by alternate middleware
if hasattr(request, "facebook") and request.facebook:
return
request.facebook = False
if not self.is_valid_path(request):
... | python | def process_request(self, request):
"""Process the web-based auth request."""
# User has already been authed by alternate middleware
if hasattr(request, "facebook") and request.facebook:
return
request.facebook = False
if not self.is_valid_path(request):
... | [
"def",
"process_request",
"(",
"self",
",",
"request",
")",
":",
"# User has already been authed by alternate middleware",
"if",
"hasattr",
"(",
"request",
",",
"\"facebook\"",
")",
"and",
"request",
".",
"facebook",
":",
"return",
"request",
".",
"facebook",
"=",
... | Process the web-based auth request. | [
"Process",
"the",
"web",
"-",
"based",
"auth",
"request",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/middleware.py#L164-L274 |
jgorset/fandjango | fandjango/middleware.py | FacebookWebMiddleware.process_response | def process_response(self, request, response):
"""
Set compact P3P policies and save auth token to cookie.
P3P is a WC3 standard (see http://www.w3.org/TR/P3P/), and although largely ignored by most
browsers it is considered by IE before accepting third-party cookies (ie. cookies set by... | python | def process_response(self, request, response):
"""
Set compact P3P policies and save auth token to cookie.
P3P is a WC3 standard (see http://www.w3.org/TR/P3P/), and although largely ignored by most
browsers it is considered by IE before accepting third-party cookies (ie. cookies set by... | [
"def",
"process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"hasattr",
"(",
"request",
",",
"\"facebook\"",
")",
"and",
"request",
".",
"facebook",
"and",
"request",
".",
"facebook",
".",
"oauth_token",
":",
"if",
"\"code\"",
"... | Set compact P3P policies and save auth token to cookie.
P3P is a WC3 standard (see http://www.w3.org/TR/P3P/), and although largely ignored by most
browsers it is considered by IE before accepting third-party cookies (ie. cookies set by
documents in iframes). If they are not set correctly, IE w... | [
"Set",
"compact",
"P3P",
"policies",
"and",
"save",
"auth",
"token",
"to",
"cookie",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/middleware.py#L277-L297 |
thombashi/SimpleSQLite | simplesqlite/_logger/_logger.py | set_log_level | def set_log_level(log_level):
"""
Set logging level of this module. Using
`logbook <https://logbook.readthedocs.io/en/stable/>`__ module for logging.
:param int log_level:
One of the log level of
`logbook <https://logbook.readthedocs.io/en/stable/api/base.html>`__.
Disabled logg... | python | def set_log_level(log_level):
"""
Set logging level of this module. Using
`logbook <https://logbook.readthedocs.io/en/stable/>`__ module for logging.
:param int log_level:
One of the log level of
`logbook <https://logbook.readthedocs.io/en/stable/api/base.html>`__.
Disabled logg... | [
"def",
"set_log_level",
"(",
"log_level",
")",
":",
"if",
"not",
"LOGBOOK_INSTALLED",
":",
"return",
"# validate log level",
"logbook",
".",
"get_level_name",
"(",
"log_level",
")",
"if",
"log_level",
"==",
"logger",
".",
"level",
":",
"return",
"if",
"log_level... | Set logging level of this module. Using
`logbook <https://logbook.readthedocs.io/en/stable/>`__ module for logging.
:param int log_level:
One of the log level of
`logbook <https://logbook.readthedocs.io/en/stable/api/base.html>`__.
Disabled logging if ``log_level`` is ``logbook.NOTSET``... | [
"Set",
"logging",
"level",
"of",
"this",
"module",
".",
"Using",
"logbook",
"<https",
":",
"//",
"logbook",
".",
"readthedocs",
".",
"io",
"/",
"en",
"/",
"stable",
"/",
">",
"__",
"module",
"for",
"logging",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/_logger/_logger.py#L49-L83 |
thombashi/SimpleSQLite | simplesqlite/converter.py | RecordConvertor.to_record | def to_record(cls, attr_names, values):
"""
Convert values to a record to be inserted into a database.
:param list attr_names:
List of attributes for the converting record.
:param values: Values to be converted.
:type values: |dict|/|namedtuple|/|list|/|tuple|
... | python | def to_record(cls, attr_names, values):
"""
Convert values to a record to be inserted into a database.
:param list attr_names:
List of attributes for the converting record.
:param values: Values to be converted.
:type values: |dict|/|namedtuple|/|list|/|tuple|
... | [
"def",
"to_record",
"(",
"cls",
",",
"attr_names",
",",
"values",
")",
":",
"try",
":",
"# from a namedtuple to a dict",
"values",
"=",
"values",
".",
"_asdict",
"(",
")",
"except",
"AttributeError",
":",
"pass",
"try",
":",
"# from a dictionary to a list",
"ret... | Convert values to a record to be inserted into a database.
:param list attr_names:
List of attributes for the converting record.
:param values: Values to be converted.
:type values: |dict|/|namedtuple|/|list|/|tuple|
:raises ValueError: If the ``values`` is invalid. | [
"Convert",
"values",
"to",
"a",
"record",
"to",
"be",
"inserted",
"into",
"a",
"database",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/converter.py#L21-L47 |
thombashi/SimpleSQLite | simplesqlite/converter.py | RecordConvertor.to_records | def to_records(cls, attr_names, value_matrix):
"""
Convert a value matrix to records to be inserted into a database.
:param list attr_names:
List of attributes for the converting records.
:param value_matrix: Values to be converted.
:type value_matrix: list of |dict|... | python | def to_records(cls, attr_names, value_matrix):
"""
Convert a value matrix to records to be inserted into a database.
:param list attr_names:
List of attributes for the converting records.
:param value_matrix: Values to be converted.
:type value_matrix: list of |dict|... | [
"def",
"to_records",
"(",
"cls",
",",
"attr_names",
",",
"value_matrix",
")",
":",
"return",
"[",
"cls",
".",
"to_record",
"(",
"attr_names",
",",
"record",
")",
"for",
"record",
"in",
"value_matrix",
"]"
] | Convert a value matrix to records to be inserted into a database.
:param list attr_names:
List of attributes for the converting records.
:param value_matrix: Values to be converted.
:type value_matrix: list of |dict|/|namedtuple|/|list|/|tuple|
.. seealso:: :py:meth:`.to_re... | [
"Convert",
"a",
"value",
"matrix",
"to",
"records",
"to",
"be",
"inserted",
"into",
"a",
"database",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/converter.py#L50-L62 |
jgorset/fandjango | fandjango/utils.py | is_disabled_path | def is_disabled_path(path):
"""
Determine whether or not the path matches one or more paths
in the DISABLED_PATHS setting.
:param path: A string describing the path to be matched.
"""
for disabled_path in DISABLED_PATHS:
match = re.search(disabled_path, path[1:])
if match:
... | python | def is_disabled_path(path):
"""
Determine whether or not the path matches one or more paths
in the DISABLED_PATHS setting.
:param path: A string describing the path to be matched.
"""
for disabled_path in DISABLED_PATHS:
match = re.search(disabled_path, path[1:])
if match:
... | [
"def",
"is_disabled_path",
"(",
"path",
")",
":",
"for",
"disabled_path",
"in",
"DISABLED_PATHS",
":",
"match",
"=",
"re",
".",
"search",
"(",
"disabled_path",
",",
"path",
"[",
"1",
":",
"]",
")",
"if",
"match",
":",
"return",
"True",
"return",
"False"
... | Determine whether or not the path matches one or more paths
in the DISABLED_PATHS setting.
:param path: A string describing the path to be matched. | [
"Determine",
"whether",
"or",
"not",
"the",
"path",
"matches",
"one",
"or",
"more",
"paths",
"in",
"the",
"DISABLED_PATHS",
"setting",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/utils.py#L17-L28 |
jgorset/fandjango | fandjango/utils.py | is_enabled_path | def is_enabled_path(path):
"""
Determine whether or not the path matches one or more paths
in the ENABLED_PATHS setting.
:param path: A string describing the path to be matched.
"""
for enabled_path in ENABLED_PATHS:
match = re.search(enabled_path, path[1:])
if match:
... | python | def is_enabled_path(path):
"""
Determine whether or not the path matches one or more paths
in the ENABLED_PATHS setting.
:param path: A string describing the path to be matched.
"""
for enabled_path in ENABLED_PATHS:
match = re.search(enabled_path, path[1:])
if match:
... | [
"def",
"is_enabled_path",
"(",
"path",
")",
":",
"for",
"enabled_path",
"in",
"ENABLED_PATHS",
":",
"match",
"=",
"re",
".",
"search",
"(",
"enabled_path",
",",
"path",
"[",
"1",
":",
"]",
")",
"if",
"match",
":",
"return",
"True",
"return",
"False"
] | Determine whether or not the path matches one or more paths
in the ENABLED_PATHS setting.
:param path: A string describing the path to be matched. | [
"Determine",
"whether",
"or",
"not",
"the",
"path",
"matches",
"one",
"or",
"more",
"paths",
"in",
"the",
"ENABLED_PATHS",
"setting",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/utils.py#L30-L41 |
jgorset/fandjango | fandjango/utils.py | cached_property | def cached_property(**kwargs):
"""Cache the return value of a property."""
def decorator(function):
@wraps(function)
def wrapper(self):
key = 'fandjango.%(model)s.%(property)s_%(pk)s' % {
'model': self.__class__.__name__,
'pk': self.pk,
... | python | def cached_property(**kwargs):
"""Cache the return value of a property."""
def decorator(function):
@wraps(function)
def wrapper(self):
key = 'fandjango.%(model)s.%(property)s_%(pk)s' % {
'model': self.__class__.__name__,
'pk': self.pk,
... | [
"def",
"cached_property",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"wrapper",
"(",
"self",
")",
":",
"key",
"=",
"'fandjango.%(model)s.%(property)s_%(pk)s'",
"%",
"{",
"'mo... | Cache the return value of a property. | [
"Cache",
"the",
"return",
"value",
"of",
"a",
"property",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/utils.py#L43-L66 |
jgorset/fandjango | fandjango/utils.py | authorization_denied_view | def authorization_denied_view(request):
"""Proxy for the view referenced in ``FANDJANGO_AUTHORIZATION_DENIED_VIEW``."""
authorization_denied_module_name = AUTHORIZATION_DENIED_VIEW.rsplit('.', 1)[0]
authorization_denied_view_name = AUTHORIZATION_DENIED_VIEW.split('.')[-1]
authorization_denied_module = ... | python | def authorization_denied_view(request):
"""Proxy for the view referenced in ``FANDJANGO_AUTHORIZATION_DENIED_VIEW``."""
authorization_denied_module_name = AUTHORIZATION_DENIED_VIEW.rsplit('.', 1)[0]
authorization_denied_view_name = AUTHORIZATION_DENIED_VIEW.split('.')[-1]
authorization_denied_module = ... | [
"def",
"authorization_denied_view",
"(",
"request",
")",
":",
"authorization_denied_module_name",
"=",
"AUTHORIZATION_DENIED_VIEW",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
"authorization_denied_view_name",
"=",
"AUTHORIZATION_DENIED_VIEW",
".",
"split",... | Proxy for the view referenced in ``FANDJANGO_AUTHORIZATION_DENIED_VIEW``. | [
"Proxy",
"for",
"the",
"view",
"referenced",
"in",
"FANDJANGO_AUTHORIZATION_DENIED_VIEW",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/utils.py#L68-L76 |
jgorset/fandjango | fandjango/utils.py | get_post_authorization_redirect_url | def get_post_authorization_redirect_url(request, canvas=True):
"""
Determine the URL users should be redirected to upon authorization the application.
If request is non-canvas use user defined site url if set, else the site hostname.
"""
path = request.get_full_path()
if canvas:
if FA... | python | def get_post_authorization_redirect_url(request, canvas=True):
"""
Determine the URL users should be redirected to upon authorization the application.
If request is non-canvas use user defined site url if set, else the site hostname.
"""
path = request.get_full_path()
if canvas:
if FA... | [
"def",
"get_post_authorization_redirect_url",
"(",
"request",
",",
"canvas",
"=",
"True",
")",
":",
"path",
"=",
"request",
".",
"get_full_path",
"(",
")",
"if",
"canvas",
":",
"if",
"FACEBOOK_APPLICATION_CANVAS_URL",
":",
"path",
"=",
"path",
".",
"replace",
... | Determine the URL users should be redirected to upon authorization the application.
If request is non-canvas use user defined site url if set, else the site hostname. | [
"Determine",
"the",
"URL",
"users",
"should",
"be",
"redirected",
"to",
"upon",
"authorization",
"the",
"application",
".",
"If",
"request",
"is",
"non",
"-",
"canvas",
"use",
"user",
"defined",
"site",
"url",
"if",
"set",
"else",
"the",
"site",
"hostname",
... | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/utils.py#L78-L105 |
jgorset/fandjango | fandjango/utils.py | get_full_path | def get_full_path(request, remove_querystrings=[]):
"""Gets the current path, removing specified querstrings"""
path = request.get_full_path()
for qs in remove_querystrings:
path = re.sub(r'&?' + qs + '=?(.+)?&?', '', path)
return path | python | def get_full_path(request, remove_querystrings=[]):
"""Gets the current path, removing specified querstrings"""
path = request.get_full_path()
for qs in remove_querystrings:
path = re.sub(r'&?' + qs + '=?(.+)?&?', '', path)
return path | [
"def",
"get_full_path",
"(",
"request",
",",
"remove_querystrings",
"=",
"[",
"]",
")",
":",
"path",
"=",
"request",
".",
"get_full_path",
"(",
")",
"for",
"qs",
"in",
"remove_querystrings",
":",
"path",
"=",
"re",
".",
"sub",
"(",
"r'&?'",
"+",
"qs",
... | Gets the current path, removing specified querstrings | [
"Gets",
"the",
"current",
"path",
"removing",
"specified",
"querstrings"
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/utils.py#L107-L113 |
jgorset/fandjango | fandjango/views.py | authorize_application | def authorize_application(
request,
redirect_uri = 'https://%s/%s' % (FACEBOOK_APPLICATION_DOMAIN, FACEBOOK_APPLICATION_NAMESPACE),
permissions = FACEBOOK_APPLICATION_INITIAL_PERMISSIONS
):
"""
Redirect the user to authorize the application.
Redirection is done by rendering a JavaScript sni... | python | def authorize_application(
request,
redirect_uri = 'https://%s/%s' % (FACEBOOK_APPLICATION_DOMAIN, FACEBOOK_APPLICATION_NAMESPACE),
permissions = FACEBOOK_APPLICATION_INITIAL_PERMISSIONS
):
"""
Redirect the user to authorize the application.
Redirection is done by rendering a JavaScript sni... | [
"def",
"authorize_application",
"(",
"request",
",",
"redirect_uri",
"=",
"'https://%s/%s'",
"%",
"(",
"FACEBOOK_APPLICATION_DOMAIN",
",",
"FACEBOOK_APPLICATION_NAMESPACE",
")",
",",
"permissions",
"=",
"FACEBOOK_APPLICATION_INITIAL_PERMISSIONS",
")",
":",
"query",
"=",
"... | Redirect the user to authorize the application.
Redirection is done by rendering a JavaScript snippet that redirects the parent
window to the authorization URI, since Facebook will not allow this inside an iframe. | [
"Redirect",
"the",
"user",
"to",
"authorize",
"the",
"application",
"."
] | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/views.py#L15-L41 |
jgorset/fandjango | fandjango/views.py | deauthorize_application | def deauthorize_application(request):
"""
When a user deauthorizes an application, Facebook sends a HTTP POST request to the application's
"deauthorization callback" URL. This view picks up on requests of this sort and marks the corresponding
users as unauthorized.
"""
if request.facebook:
... | python | def deauthorize_application(request):
"""
When a user deauthorizes an application, Facebook sends a HTTP POST request to the application's
"deauthorization callback" URL. This view picks up on requests of this sort and marks the corresponding
users as unauthorized.
"""
if request.facebook:
... | [
"def",
"deauthorize_application",
"(",
"request",
")",
":",
"if",
"request",
".",
"facebook",
":",
"user",
"=",
"User",
".",
"objects",
".",
"get",
"(",
"facebook_id",
"=",
"request",
".",
"facebook",
".",
"signed_request",
".",
"user",
".",
"id",
")",
"... | When a user deauthorizes an application, Facebook sends a HTTP POST request to the application's
"deauthorization callback" URL. This view picks up on requests of this sort and marks the corresponding
users as unauthorized. | [
"When",
"a",
"user",
"deauthorizes",
"an",
"application",
"Facebook",
"sends",
"a",
"HTTP",
"POST",
"request",
"to",
"the",
"application",
"s",
"deauthorization",
"callback",
"URL",
".",
"This",
"view",
"picks",
"up",
"on",
"requests",
"of",
"this",
"sort",
... | train | https://github.com/jgorset/fandjango/blob/01334a76c1d9f0629842aa6830678ae097756551/fandjango/views.py#L53-L69 |
thombashi/SimpleSQLite | simplesqlite/sqlquery.py | SqlQuery.make_insert | def make_insert(cls, table, insert_tuple):
"""
[Deprecated] Make INSERT query.
:param str table: Table name of executing the query.
:param list/tuple insert_tuple: Insertion data.
:return: Query of SQLite.
:rtype: str
:raises ValueError: If ``insert_tuple`` is em... | python | def make_insert(cls, table, insert_tuple):
"""
[Deprecated] Make INSERT query.
:param str table: Table name of executing the query.
:param list/tuple insert_tuple: Insertion data.
:return: Query of SQLite.
:rtype: str
:raises ValueError: If ``insert_tuple`` is em... | [
"def",
"make_insert",
"(",
"cls",
",",
"table",
",",
"insert_tuple",
")",
":",
"validate_table_name",
"(",
"table",
")",
"table",
"=",
"Table",
"(",
"table",
")",
"if",
"typepy",
".",
"is_empty_sequence",
"(",
"insert_tuple",
")",
":",
"raise",
"ValueError",... | [Deprecated] Make INSERT query.
:param str table: Table name of executing the query.
:param list/tuple insert_tuple: Insertion data.
:return: Query of SQLite.
:rtype: str
:raises ValueError: If ``insert_tuple`` is empty |list|/|tuple|.
:raises simplesqlite.NameValidation... | [
"[",
"Deprecated",
"]",
"Make",
"INSERT",
"query",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/sqlquery.py#L22-L44 |
thombashi/SimpleSQLite | simplesqlite/sqlquery.py | SqlQuery.make_update | def make_update(cls, table, set_query, where=None):
"""
Make UPDATE query.
:param str table: Table name of executing the query.
:param str set_query: SET part of the UPDATE query.
:param str where:
Add a WHERE clause to execute query,
if the value is not ... | python | def make_update(cls, table, set_query, where=None):
"""
Make UPDATE query.
:param str table: Table name of executing the query.
:param str set_query: SET part of the UPDATE query.
:param str where:
Add a WHERE clause to execute query,
if the value is not ... | [
"def",
"make_update",
"(",
"cls",
",",
"table",
",",
"set_query",
",",
"where",
"=",
"None",
")",
":",
"validate_table_name",
"(",
"table",
")",
"if",
"typepy",
".",
"is_null_string",
"(",
"set_query",
")",
":",
"raise",
"ValueError",
"(",
"\"SET query is nu... | Make UPDATE query.
:param str table: Table name of executing the query.
:param str set_query: SET part of the UPDATE query.
:param str where:
Add a WHERE clause to execute query,
if the value is not |None|.
:return: Query of SQLite.
:rtype: str
:r... | [
"Make",
"UPDATE",
"query",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/sqlquery.py#L47-L71 |
thombashi/SimpleSQLite | simplesqlite/sqlquery.py | SqlQuery.make_where_in | def make_where_in(cls, key, value_list):
"""
Make part of WHERE IN query.
:param str key: Attribute name of the key.
:param str value_list:
List of values that the right hand side associated with the key.
:return: Part of WHERE query of SQLite.
:rtype: str
... | python | def make_where_in(cls, key, value_list):
"""
Make part of WHERE IN query.
:param str key: Attribute name of the key.
:param str value_list:
List of values that the right hand side associated with the key.
:return: Part of WHERE query of SQLite.
:rtype: str
... | [
"def",
"make_where_in",
"(",
"cls",
",",
"key",
",",
"value_list",
")",
":",
"return",
"\"{:s} IN ({:s})\"",
".",
"format",
"(",
"Attr",
"(",
"key",
")",
",",
"\", \"",
".",
"join",
"(",
"[",
"Value",
"(",
"value",
")",
".",
"to_query",
"(",
")",
"fo... | Make part of WHERE IN query.
:param str key: Attribute name of the key.
:param str value_list:
List of values that the right hand side associated with the key.
:return: Part of WHERE query of SQLite.
:rtype: str
:Examples:
>>> from simplesqlite.sqlquery ... | [
"Make",
"part",
"of",
"WHERE",
"IN",
"query",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/sqlquery.py#L74-L92 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.connect | def connect(self, database_path, mode="a"):
"""
Connect to a SQLite database.
:param str database_path:
Path to the SQLite database file to be connected.
:param str mode:
``"r"``: Open for read only.
``"w"``: Open for read/write.
Delete ex... | python | def connect(self, database_path, mode="a"):
"""
Connect to a SQLite database.
:param str database_path:
Path to the SQLite database file to be connected.
:param str mode:
``"r"``: Open for read only.
``"w"``: Open for read/write.
Delete ex... | [
"def",
"connect",
"(",
"self",
",",
"database_path",
",",
"mode",
"=",
"\"a\"",
")",
":",
"self",
".",
"close",
"(",
")",
"logger",
".",
"debug",
"(",
"\"connect to a SQLite database: path='{}', mode={}\"",
".",
"format",
"(",
"database_path",
",",
"mode",
")"... | Connect to a SQLite database.
:param str database_path:
Path to the SQLite database file to be connected.
:param str mode:
``"r"``: Open for read only.
``"w"``: Open for read/write.
Delete existing tables when connecting.
``"a"``: Open for rea... | [
"Connect",
"to",
"a",
"SQLite",
"database",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L216-L268 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.execute_query | def execute_query(self, query, caller=None):
"""
Send arbitrary SQLite query to the database.
:param str query: Query to executed.
:param tuple caller:
Caller information.
Expects the return value of :py:meth:`logging.Logger.findCaller`.
:return: The resu... | python | def execute_query(self, query, caller=None):
"""
Send arbitrary SQLite query to the database.
:param str query: Query to executed.
:param tuple caller:
Caller information.
Expects the return value of :py:meth:`logging.Logger.findCaller`.
:return: The resu... | [
"def",
"execute_query",
"(",
"self",
",",
"query",
",",
"caller",
"=",
"None",
")",
":",
"import",
"time",
"self",
".",
"check_connection",
"(",
")",
"if",
"typepy",
".",
"is_null_string",
"(",
"query",
")",
":",
"return",
"None",
"if",
"self",
".",
"d... | Send arbitrary SQLite query to the database.
:param str query: Query to executed.
:param tuple caller:
Caller information.
Expects the return value of :py:meth:`logging.Logger.findCaller`.
:return: The result of the query execution.
:rtype: sqlite3.Cursor
... | [
"Send",
"arbitrary",
"SQLite",
"query",
"to",
"the",
"database",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L270-L329 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.select | def select(self, select, table_name, where=None, extra=None):
"""
Send a SELECT query to the database.
:param str select: Attribute for the ``SELECT`` query.
:param str table_name: |arg_select_table_name|
:param where: |arg_select_where|
:type where: |arg_where_type|
... | python | def select(self, select, table_name, where=None, extra=None):
"""
Send a SELECT query to the database.
:param str select: Attribute for the ``SELECT`` query.
:param str table_name: |arg_select_table_name|
:param where: |arg_select_where|
:type where: |arg_where_type|
... | [
"def",
"select",
"(",
"self",
",",
"select",
",",
"table_name",
",",
"where",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"self",
".",
"verify_table_existence",
"(",
"table_name",
")",
"return",
"self",
".",
"execute_query",
"(",
"six",
".",
"text_... | Send a SELECT query to the database.
:param str select: Attribute for the ``SELECT`` query.
:param str table_name: |arg_select_table_name|
:param where: |arg_select_where|
:type where: |arg_where_type|
:param str extra: |arg_select_extra|
:return: Result of the query exe... | [
"Send",
"a",
"SELECT",
"query",
"to",
"the",
"database",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L340-L363 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.select_as_dataframe | def select_as_dataframe(self, table_name, columns=None, where=None, extra=None):
"""
Get data in the database and return fetched data as a
:py:class:`pandas.Dataframe` instance.
:param str table_name: |arg_select_table_name|
:param list columns: |arg_select_as_xx_columns|
... | python | def select_as_dataframe(self, table_name, columns=None, where=None, extra=None):
"""
Get data in the database and return fetched data as a
:py:class:`pandas.Dataframe` instance.
:param str table_name: |arg_select_table_name|
:param list columns: |arg_select_as_xx_columns|
... | [
"def",
"select_as_dataframe",
"(",
"self",
",",
"table_name",
",",
"columns",
"=",
"None",
",",
"where",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"import",
"pandas",
"if",
"columns",
"is",
"None",
":",
"columns",
"=",
"self",
".",
"fetch_attr_na... | Get data in the database and return fetched data as a
:py:class:`pandas.Dataframe` instance.
:param str table_name: |arg_select_table_name|
:param list columns: |arg_select_as_xx_columns|
:param str where: |arg_select_where|
:param str extra: |arg_select_extra|
:return: ... | [
"Get",
"data",
"in",
"the",
"database",
"and",
"return",
"fetched",
"data",
"as",
"a",
":",
"py",
":",
"class",
":",
"pandas",
".",
"Dataframe",
"instance",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L365-L401 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.select_as_tabledata | def select_as_tabledata(
self, table_name, columns=None, where=None, extra=None, type_hints=None
):
"""
Get data in the database and return fetched data as a
:py:class:`tabledata.TableData` instance.
:param str table_name: |arg_select_table_name|
:param list columns:... | python | def select_as_tabledata(
self, table_name, columns=None, where=None, extra=None, type_hints=None
):
"""
Get data in the database and return fetched data as a
:py:class:`tabledata.TableData` instance.
:param str table_name: |arg_select_table_name|
:param list columns:... | [
"def",
"select_as_tabledata",
"(",
"self",
",",
"table_name",
",",
"columns",
"=",
"None",
",",
"where",
"=",
"None",
",",
"extra",
"=",
"None",
",",
"type_hints",
"=",
"None",
")",
":",
"if",
"columns",
"is",
"None",
":",
"columns",
"=",
"self",
".",
... | Get data in the database and return fetched data as a
:py:class:`tabledata.TableData` instance.
:param str table_name: |arg_select_table_name|
:param list columns: |arg_select_as_xx_columns|
:param where: |arg_select_where|
:type where: |arg_where_type|
:param str extra:... | [
"Get",
"data",
"in",
"the",
"database",
"and",
"return",
"fetched",
"data",
"as",
"a",
":",
"py",
":",
"class",
":",
"tabledata",
".",
"TableData",
"instance",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L403-L445 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.select_as_dict | def select_as_dict(self, table_name, columns=None, where=None, extra=None):
"""
Get data in the database and return fetched data as a
|OrderedDict| list.
:param str table_name: |arg_select_table_name|
:param list columns: |arg_select_as_xx_columns|
:param where: |arg_sel... | python | def select_as_dict(self, table_name, columns=None, where=None, extra=None):
"""
Get data in the database and return fetched data as a
|OrderedDict| list.
:param str table_name: |arg_select_table_name|
:param list columns: |arg_select_as_xx_columns|
:param where: |arg_sel... | [
"def",
"select_as_dict",
"(",
"self",
",",
"table_name",
",",
"columns",
"=",
"None",
",",
"where",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"return",
"self",
".",
"select_as_tabledata",
"(",
"table_name",
",",
"columns",
",",
"where",
",",
"ext... | Get data in the database and return fetched data as a
|OrderedDict| list.
:param str table_name: |arg_select_table_name|
:param list columns: |arg_select_as_xx_columns|
:param where: |arg_select_where|
:type where: |arg_where_type|
:param str extra: |arg_select_extra|
... | [
"Get",
"data",
"in",
"the",
"database",
"and",
"return",
"fetched",
"data",
"as",
"a",
"|OrderedDict|",
"list",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L447-L469 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.select_as_memdb | def select_as_memdb(self, table_name, columns=None, where=None, extra=None):
"""
Get data in the database and return fetched data as a
in-memory |SimpleSQLite| instance.
:param str table_name: |arg_select_table_name|
:param list columns: |arg_select_as_xx_columns|
:param... | python | def select_as_memdb(self, table_name, columns=None, where=None, extra=None):
"""
Get data in the database and return fetched data as a
in-memory |SimpleSQLite| instance.
:param str table_name: |arg_select_table_name|
:param list columns: |arg_select_as_xx_columns|
:param... | [
"def",
"select_as_memdb",
"(",
"self",
",",
"table_name",
",",
"columns",
"=",
"None",
",",
"where",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"table_schema",
"=",
"self",
".",
"schema_extractor",
".",
"fetch_table_schema",
"(",
"table_name",
")",
... | Get data in the database and return fetched data as a
in-memory |SimpleSQLite| instance.
:param str table_name: |arg_select_table_name|
:param list columns: |arg_select_as_xx_columns|
:param where: |arg_select_where|
:type where: |arg_where_type|
:param str extra: |arg_s... | [
"Get",
"data",
"in",
"the",
"database",
"and",
"return",
"fetched",
"data",
"as",
"a",
"in",
"-",
"memory",
"|SimpleSQLite|",
"instance",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L471-L501 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.insert | def insert(self, table_name, record, attr_names=None):
"""
Send an INSERT query to the database.
:param str table_name: Table name of executing the query.
:param record: Record to be inserted.
:type record: |dict|/|namedtuple|/|list|/|tuple|
:raises IOError: |raises_writ... | python | def insert(self, table_name, record, attr_names=None):
"""
Send an INSERT query to the database.
:param str table_name: Table name of executing the query.
:param record: Record to be inserted.
:type record: |dict|/|namedtuple|/|list|/|tuple|
:raises IOError: |raises_writ... | [
"def",
"insert",
"(",
"self",
",",
"table_name",
",",
"record",
",",
"attr_names",
"=",
"None",
")",
":",
"self",
".",
"insert_many",
"(",
"table_name",
",",
"records",
"=",
"[",
"record",
"]",
",",
"attr_names",
"=",
"attr_names",
")"
] | Send an INSERT query to the database.
:param str table_name: Table name of executing the query.
:param record: Record to be inserted.
:type record: |dict|/|namedtuple|/|list|/|tuple|
:raises IOError: |raises_write_permission|
:raises simplesqlite.NullDatabaseConnectionError:
... | [
"Send",
"an",
"INSERT",
"query",
"to",
"the",
"database",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L503-L519 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.insert_many | def insert_many(self, table_name, records, attr_names=None):
"""
Send an INSERT query with multiple records to the database.
:param str table: Table name of executing the query.
:param records: Records to be inserted.
:type records: list of |dict|/|namedtuple|/|list|/|tuple|
... | python | def insert_many(self, table_name, records, attr_names=None):
"""
Send an INSERT query with multiple records to the database.
:param str table: Table name of executing the query.
:param records: Records to be inserted.
:type records: list of |dict|/|namedtuple|/|list|/|tuple|
... | [
"def",
"insert_many",
"(",
"self",
",",
"table_name",
",",
"records",
",",
"attr_names",
"=",
"None",
")",
":",
"self",
".",
"validate_access_permission",
"(",
"[",
"\"w\"",
",",
"\"a\"",
"]",
")",
"self",
".",
"verify_table_existence",
"(",
"table_name",
")... | Send an INSERT query with multiple records to the database.
:param str table: Table name of executing the query.
:param records: Records to be inserted.
:type records: list of |dict|/|namedtuple|/|list|/|tuple|
:return: Number of inserted records.
:rtype: int
:raises IOE... | [
"Send",
"an",
"INSERT",
"query",
"with",
"multiple",
"records",
"to",
"the",
"database",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L521-L593 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.update | def update(self, table_name, set_query, where=None):
"""Execute an UPDATE query.
Args:
table_name (|str|):
Table name of executing the query.
set_query (|str|):
``SET`` clause for the update query.
where (|arg_where_type| , optional):
... | python | def update(self, table_name, set_query, where=None):
"""Execute an UPDATE query.
Args:
table_name (|str|):
Table name of executing the query.
set_query (|str|):
``SET`` clause for the update query.
where (|arg_where_type| , optional):
... | [
"def",
"update",
"(",
"self",
",",
"table_name",
",",
"set_query",
",",
"where",
"=",
"None",
")",
":",
"self",
".",
"validate_access_permission",
"(",
"[",
"\"w\"",
",",
"\"a\"",
"]",
")",
"self",
".",
"verify_table_existence",
"(",
"table_name",
")",
"qu... | Execute an UPDATE query.
Args:
table_name (|str|):
Table name of executing the query.
set_query (|str|):
``SET`` clause for the update query.
where (|arg_where_type| , optional):
``WHERE`` clause for the update query.
... | [
"Execute",
"an",
"UPDATE",
"query",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L595-L623 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.delete | def delete(self, table_name, where=None):
"""
Send a DELETE query to the database.
:param str table_name: Table name of executing the query.
:param where: |arg_select_where|
:type where: |arg_where_type|
"""
self.validate_access_permission(["w", "a"])
se... | python | def delete(self, table_name, where=None):
"""
Send a DELETE query to the database.
:param str table_name: Table name of executing the query.
:param where: |arg_select_where|
:type where: |arg_where_type|
"""
self.validate_access_permission(["w", "a"])
se... | [
"def",
"delete",
"(",
"self",
",",
"table_name",
",",
"where",
"=",
"None",
")",
":",
"self",
".",
"validate_access_permission",
"(",
"[",
"\"w\"",
",",
"\"a\"",
"]",
")",
"self",
".",
"verify_table_existence",
"(",
"table_name",
")",
"query",
"=",
"\"DELE... | Send a DELETE query to the database.
:param str table_name: Table name of executing the query.
:param where: |arg_select_where|
:type where: |arg_where_type| | [
"Send",
"a",
"DELETE",
"query",
"to",
"the",
"database",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L625-L641 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.fetch_value | def fetch_value(self, select, table_name, where=None, extra=None):
"""
Fetch a value from the table. Return |None| if no value matches
the conditions, or the table not found in the database.
:param str select: Attribute for SELECT query
:param str table_name: Table name of execu... | python | def fetch_value(self, select, table_name, where=None, extra=None):
"""
Fetch a value from the table. Return |None| if no value matches
the conditions, or the table not found in the database.
:param str select: Attribute for SELECT query
:param str table_name: Table name of execu... | [
"def",
"fetch_value",
"(",
"self",
",",
"select",
",",
"table_name",
",",
"where",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"verify_table_existence",
"(",
"table_name",
")",
"except",
"TableNotFoundError",
"as",
"e",
":",
... | Fetch a value from the table. Return |None| if no value matches
the conditions, or the table not found in the database.
:param str select: Attribute for SELECT query
:param str table_name: Table name of executing the query.
:param where: |arg_select_where|
:type where: |arg_wher... | [
"Fetch",
"a",
"value",
"from",
"the",
"table",
".",
"Return",
"|None|",
"if",
"no",
"value",
"matches",
"the",
"conditions",
"or",
"the",
"table",
"not",
"found",
"in",
"the",
"database",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L643-L674 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.fetch_table_names | def fetch_table_names(self, include_system_table=False):
"""
:return: List of table names in the database.
:rtype: list
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises simplesqlite.OperationalError: |raises_operational_error|
... | python | def fetch_table_names(self, include_system_table=False):
"""
:return: List of table names in the database.
:rtype: list
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises simplesqlite.OperationalError: |raises_operational_error|
... | [
"def",
"fetch_table_names",
"(",
"self",
",",
"include_system_table",
"=",
"False",
")",
":",
"self",
".",
"check_connection",
"(",
")",
"return",
"self",
".",
"schema_extractor",
".",
"fetch_table_names",
"(",
"include_system_table",
")"
] | :return: List of table names in the database.
:rtype: list
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises simplesqlite.OperationalError: |raises_operational_error|
:Sample Code:
.. code:: python
from simplesql... | [
":",
"return",
":",
"List",
"of",
"table",
"names",
"in",
"the",
"database",
".",
":",
"rtype",
":",
"list",
":",
"raises",
"simplesqlite",
".",
"NullDatabaseConnectionError",
":",
"|raises_check_connection|",
":",
"raises",
"simplesqlite",
".",
"OperationalError"... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L683-L710 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.fetch_attr_names | def fetch_attr_names(self, table_name):
"""
:return: List of attribute names in the table.
:rtype: list
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
... | python | def fetch_attr_names(self, table_name):
"""
:return: List of attribute names in the table.
:rtype: list
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
... | [
"def",
"fetch_attr_names",
"(",
"self",
",",
"table_name",
")",
":",
"self",
".",
"verify_table_existence",
"(",
"table_name",
")",
"return",
"self",
".",
"schema_extractor",
".",
"fetch_table_schema",
"(",
"table_name",
")",
".",
"get_attr_names",
"(",
")"
] | :return: List of attribute names in the table.
:rtype: list
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
:raises simplesqlite.OperationalError: |raises_operatio... | [
":",
"return",
":",
"List",
"of",
"attribute",
"names",
"in",
"the",
"table",
".",
":",
"rtype",
":",
"list",
":",
"raises",
"simplesqlite",
".",
"NullDatabaseConnectionError",
":",
"|raises_check_connection|",
":",
"raises",
"simplesqlite",
".",
"TableNotFoundErr... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L719-L756 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.fetch_attr_type | def fetch_attr_type(self, table_name):
"""
:return:
Dictionary of attribute names and attribute types in the table.
:rtype: dict
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises simplesqlite.TableNotFoundError:
... | python | def fetch_attr_type(self, table_name):
"""
:return:
Dictionary of attribute names and attribute types in the table.
:rtype: dict
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises simplesqlite.TableNotFoundError:
... | [
"def",
"fetch_attr_type",
"(",
"self",
",",
"table_name",
")",
":",
"self",
".",
"verify_table_existence",
"(",
"table_name",
")",
"result",
"=",
"self",
".",
"execute_query",
"(",
"\"SELECT sql FROM sqlite_master WHERE type='table' and name={:s}\"",
".",
"format",
"(",... | :return:
Dictionary of attribute names and attribute types in the table.
:rtype: dict
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
:raises simplesql... | [
":",
"return",
":",
"Dictionary",
"of",
"attribute",
"names",
"and",
"attribute",
"types",
"in",
"the",
"table",
".",
":",
"rtype",
":",
"dict",
":",
"raises",
"simplesqlite",
".",
"NullDatabaseConnectionError",
":",
"|raises_check_connection|",
":",
"raises",
"... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L765-L793 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.fetch_num_records | def fetch_num_records(self, table_name, where=None):
"""
Fetch the number of records in a table.
:param str table_name: Table name to get number of records.
:param where: |arg_select_where|
:type where: |arg_where_type|
:return:
Number of records in the table... | python | def fetch_num_records(self, table_name, where=None):
"""
Fetch the number of records in a table.
:param str table_name: Table name to get number of records.
:param where: |arg_select_where|
:type where: |arg_where_type|
:return:
Number of records in the table... | [
"def",
"fetch_num_records",
"(",
"self",
",",
"table_name",
",",
"where",
"=",
"None",
")",
":",
"return",
"self",
".",
"fetch_value",
"(",
"select",
"=",
"\"COUNT(*)\"",
",",
"table_name",
"=",
"table_name",
",",
"where",
"=",
"where",
")"
] | Fetch the number of records in a table.
:param str table_name: Table name to get number of records.
:param where: |arg_select_where|
:type where: |arg_where_type|
:return:
Number of records in the table.
|None| if no value matches the conditions,
or t... | [
"Fetch",
"the",
"number",
"of",
"records",
"in",
"a",
"table",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L795-L809 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.get_profile | def get_profile(self, profile_count=50):
"""
Get profile of query execution time.
:param int profile_count:
Number of profiles to retrieve,
counted from the top query in descending order by
the cumulative execution time.
:return: Profile information f... | python | def get_profile(self, profile_count=50):
"""
Get profile of query execution time.
:param int profile_count:
Number of profiles to retrieve,
counted from the top query in descending order by
the cumulative execution time.
:return: Profile information f... | [
"def",
"get_profile",
"(",
"self",
",",
"profile_count",
"=",
"50",
")",
":",
"from",
"collections",
"import",
"namedtuple",
"profile_table_name",
"=",
"\"sql_profile\"",
"value_matrix",
"=",
"[",
"[",
"query",
",",
"execute_time",
",",
"self",
".",
"__dict_quer... | Get profile of query execution time.
:param int profile_count:
Number of profiles to retrieve,
counted from the top query in descending order by
the cumulative execution time.
:return: Profile information for each query.
:rtype: list of |namedtuple|
:... | [
"Get",
"profile",
"of",
"query",
"execution",
"time",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L816-L866 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.has_table | def has_table(self, table_name):
"""
:param str table_name: Table name to be tested.
:return: |True| if the database has the table.
:rtype: bool
:Sample Code:
.. code:: python
from simplesqlite import SimpleSQLite
con = SimpleSQLite(... | python | def has_table(self, table_name):
"""
:param str table_name: Table name to be tested.
:return: |True| if the database has the table.
:rtype: bool
:Sample Code:
.. code:: python
from simplesqlite import SimpleSQLite
con = SimpleSQLite(... | [
"def",
"has_table",
"(",
"self",
",",
"table_name",
")",
":",
"try",
":",
"validate_table_name",
"(",
"table_name",
")",
"except",
"NameValidationError",
":",
"return",
"False",
"return",
"table_name",
"in",
"self",
".",
"fetch_table_names",
"(",
")"
] | :param str table_name: Table name to be tested.
:return: |True| if the database has the table.
:rtype: bool
:Sample Code:
.. code:: python
from simplesqlite import SimpleSQLite
con = SimpleSQLite("sample.sqlite", "w")
con.create_tabl... | [
":",
"param",
"str",
"table_name",
":",
"Table",
"name",
"to",
"be",
"tested",
".",
":",
"return",
":",
"|True|",
"if",
"the",
"database",
"has",
"the",
"table",
".",
":",
"rtype",
":",
"bool"
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L922-L953 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.has_attr | def has_attr(self, table_name, attr_name):
"""
:param str table_name: Table name that the attribute exists.
:param str attr_name: Attribute name to be tested.
:return: |True| if the table has the attribute.
:rtype: bool
:raises simplesqlite.TableNotFoundError:
... | python | def has_attr(self, table_name, attr_name):
"""
:param str table_name: Table name that the attribute exists.
:param str attr_name: Attribute name to be tested.
:return: |True| if the table has the attribute.
:rtype: bool
:raises simplesqlite.TableNotFoundError:
... | [
"def",
"has_attr",
"(",
"self",
",",
"table_name",
",",
"attr_name",
")",
":",
"self",
".",
"verify_table_existence",
"(",
"table_name",
")",
"if",
"typepy",
".",
"is_null_string",
"(",
"attr_name",
")",
":",
"return",
"False",
"return",
"attr_name",
"in",
"... | :param str table_name: Table name that the attribute exists.
:param str attr_name: Attribute name to be tested.
:return: |True| if the table has the attribute.
:rtype: bool
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
:Sample Code:
... | [
":",
"param",
"str",
"table_name",
":",
"Table",
"name",
"that",
"the",
"attribute",
"exists",
".",
":",
"param",
"str",
"attr_name",
":",
"Attribute",
"name",
"to",
"be",
"tested",
".",
":",
"return",
":",
"|True|",
"if",
"the",
"table",
"has",
"the",
... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L955-L995 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.has_attrs | def has_attrs(self, table_name, attr_names):
"""
:param str table_name: Table name that attributes exists.
:param str attr_names: Attribute names to tested.
:return: |True| if the table has all of the attribute.
:rtype: bool
:raises simplesqlite.TableNotFoundError:
... | python | def has_attrs(self, table_name, attr_names):
"""
:param str table_name: Table name that attributes exists.
:param str attr_names: Attribute names to tested.
:return: |True| if the table has all of the attribute.
:rtype: bool
:raises simplesqlite.TableNotFoundError:
... | [
"def",
"has_attrs",
"(",
"self",
",",
"table_name",
",",
"attr_names",
")",
":",
"if",
"typepy",
".",
"is_empty_sequence",
"(",
"attr_names",
")",
":",
"return",
"False",
"not_exist_fields",
"=",
"[",
"attr_name",
"for",
"attr_name",
"in",
"attr_names",
"if",
... | :param str table_name: Table name that attributes exists.
:param str attr_names: Attribute names to tested.
:return: |True| if the table has all of the attribute.
:rtype: bool
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
:Sample Code:
... | [
":",
"param",
"str",
"table_name",
":",
"Table",
"name",
"that",
"attributes",
"exists",
".",
":",
"param",
"str",
"attr_names",
":",
"Attribute",
"names",
"to",
"tested",
".",
":",
"return",
":",
"|True|",
"if",
"the",
"table",
"has",
"all",
"of",
"the"... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L997-L1044 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.verify_table_existence | def verify_table_existence(self, table_name):
"""
:param str table_name: Table name to be tested.
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
:raises simplesqlite.NameValidationError:
|raises_validate_table_name|
:Sample Code:... | python | def verify_table_existence(self, table_name):
"""
:param str table_name: Table name to be tested.
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
:raises simplesqlite.NameValidationError:
|raises_validate_table_name|
:Sample Code:... | [
"def",
"verify_table_existence",
"(",
"self",
",",
"table_name",
")",
":",
"validate_table_name",
"(",
"table_name",
")",
"if",
"self",
".",
"has_table",
"(",
"table_name",
")",
":",
"return",
"raise",
"TableNotFoundError",
"(",
"\"'{}' table not found in '{}' databas... | :param str table_name: Table name to be tested.
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
:raises simplesqlite.NameValidationError:
|raises_validate_table_name|
:Sample Code:
.. code:: python
import simplesqlite... | [
":",
"param",
"str",
"table_name",
":",
"Table",
"name",
"to",
"be",
"tested",
".",
":",
"raises",
"simplesqlite",
".",
"TableNotFoundError",
":",
"|raises_verify_table_existence|",
":",
"raises",
"simplesqlite",
".",
"NameValidationError",
":",
"|raises_validate_tabl... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1051-L1089 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.verify_attr_existence | def verify_attr_existence(self, table_name, attr_name):
"""
:param str table_name: Table name that the attribute exists.
:param str attr_name: Attribute name to tested.
:raises simplesqlite.AttributeNotFoundError:
If attribute not found in the table
:raises simplesqli... | python | def verify_attr_existence(self, table_name, attr_name):
"""
:param str table_name: Table name that the attribute exists.
:param str attr_name: Attribute name to tested.
:raises simplesqlite.AttributeNotFoundError:
If attribute not found in the table
:raises simplesqli... | [
"def",
"verify_attr_existence",
"(",
"self",
",",
"table_name",
",",
"attr_name",
")",
":",
"self",
".",
"verify_table_existence",
"(",
"table_name",
")",
"if",
"self",
".",
"has_attr",
"(",
"table_name",
",",
"attr_name",
")",
":",
"return",
"raise",
"Attribu... | :param str table_name: Table name that the attribute exists.
:param str attr_name: Attribute name to tested.
:raises simplesqlite.AttributeNotFoundError:
If attribute not found in the table
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
... | [
":",
"param",
"str",
"table_name",
":",
"Table",
"name",
"that",
"the",
"attribute",
"exists",
".",
":",
"param",
"str",
"attr_name",
":",
"Attribute",
"name",
"to",
"tested",
".",
":",
"raises",
"simplesqlite",
".",
"AttributeNotFoundError",
":",
"If",
"att... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1091-L1139 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.validate_access_permission | def validate_access_permission(self, valid_permissions):
"""
:param valid_permissions:
List of permissions that access is allowed.
:type valid_permissions: |list|/|tuple|
:raises ValueError: If the |attr_mode| is invalid.
:raises IOError:
If the |attr_mode... | python | def validate_access_permission(self, valid_permissions):
"""
:param valid_permissions:
List of permissions that access is allowed.
:type valid_permissions: |list|/|tuple|
:raises ValueError: If the |attr_mode| is invalid.
:raises IOError:
If the |attr_mode... | [
"def",
"validate_access_permission",
"(",
"self",
",",
"valid_permissions",
")",
":",
"self",
".",
"check_connection",
"(",
")",
"if",
"typepy",
".",
"is_null_string",
"(",
"self",
".",
"mode",
")",
":",
"raise",
"ValueError",
"(",
"\"mode is not set\"",
")",
... | :param valid_permissions:
List of permissions that access is allowed.
:type valid_permissions: |list|/|tuple|
:raises ValueError: If the |attr_mode| is invalid.
:raises IOError:
If the |attr_mode| not in the ``valid_permissions``.
:raises simplesqlite.NullDatabase... | [
":",
"param",
"valid_permissions",
":",
"List",
"of",
"permissions",
"that",
"access",
"is",
"allowed",
".",
":",
"type",
"valid_permissions",
":",
"|list|",
"/",
"|tuple|",
":",
"raises",
"ValueError",
":",
"If",
"the",
"|attr_mode|",
"is",
"invalid",
".",
... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1141-L1163 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.drop_table | def drop_table(self, table_name):
"""
:param str table_name: Table name to drop.
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises IOError: |raises_write_permission|
"""
self.validate_access_permission(["w", "a"])
if... | python | def drop_table(self, table_name):
"""
:param str table_name: Table name to drop.
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises IOError: |raises_write_permission|
"""
self.validate_access_permission(["w", "a"])
if... | [
"def",
"drop_table",
"(",
"self",
",",
"table_name",
")",
":",
"self",
".",
"validate_access_permission",
"(",
"[",
"\"w\"",
",",
"\"a\"",
"]",
")",
"if",
"table_name",
"in",
"SQLITE_SYSTEM_TABLES",
":",
"# warning message",
"return",
"if",
"self",
".",
"has_t... | :param str table_name: Table name to drop.
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises IOError: |raises_write_permission| | [
":",
"param",
"str",
"table_name",
":",
"Table",
"name",
"to",
"drop",
".",
":",
"raises",
"simplesqlite",
".",
"NullDatabaseConnectionError",
":",
"|raises_check_connection|",
":",
"raises",
"IOError",
":",
"|raises_write_permission|"
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1165-L1182 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.create_table | def create_table(self, table_name, attr_descriptions):
"""
:param str table_name: Table name to create.
:param list attr_descriptions: List of table description.
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises IOError: |raises_write... | python | def create_table(self, table_name, attr_descriptions):
"""
:param str table_name: Table name to create.
:param list attr_descriptions: List of table description.
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises IOError: |raises_write... | [
"def",
"create_table",
"(",
"self",
",",
"table_name",
",",
"attr_descriptions",
")",
":",
"self",
".",
"validate_access_permission",
"(",
"[",
"\"w\"",
",",
"\"a\"",
"]",
")",
"table_name",
"=",
"table_name",
".",
"strip",
"(",
")",
"if",
"self",
".",
"ha... | :param str table_name: Table name to create.
:param list attr_descriptions: List of table description.
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises IOError: |raises_write_permission| | [
":",
"param",
"str",
"table_name",
":",
"Table",
"name",
"to",
"create",
".",
":",
"param",
"list",
"attr_descriptions",
":",
"List",
"of",
"table",
"description",
".",
":",
"raises",
"simplesqlite",
".",
"NullDatabaseConnectionError",
":",
"|raises_check_connecti... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1184-L1207 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.create_index | def create_index(self, table_name, attr_name):
"""
:param str table_name:
Table name that contains the attribute to be indexed.
:param str attr_name: Attribute name to create index.
:raises IOError: |raises_write_permission|
:raises simplesqlite.NullDatabaseConnection... | python | def create_index(self, table_name, attr_name):
"""
:param str table_name:
Table name that contains the attribute to be indexed.
:param str attr_name: Attribute name to create index.
:raises IOError: |raises_write_permission|
:raises simplesqlite.NullDatabaseConnection... | [
"def",
"create_index",
"(",
"self",
",",
"table_name",
",",
"attr_name",
")",
":",
"self",
".",
"verify_table_existence",
"(",
"table_name",
")",
"self",
".",
"validate_access_permission",
"(",
"[",
"\"w\"",
",",
"\"a\"",
"]",
")",
"query_format",
"=",
"\"CREA... | :param str table_name:
Table name that contains the attribute to be indexed.
:param str attr_name: Attribute name to create index.
:raises IOError: |raises_write_permission|
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises simple... | [
":",
"param",
"str",
"table_name",
":",
"Table",
"name",
"that",
"contains",
"the",
"attribute",
"to",
"be",
"indexed",
".",
":",
"param",
"str",
"attr_name",
":",
"Attribute",
"name",
"to",
"create",
"index",
".",
":",
"raises",
"IOError",
":",
"|raises_w... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1209-L1232 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.create_index_list | def create_index_list(self, table_name, attr_names):
"""
:param str table_name: Table name that exists attribute.
:param list attr_names:
List of attribute names to create indices.
Ignore attributes that are not existing in the table.
.. seealso:: :py:meth:`.crea... | python | def create_index_list(self, table_name, attr_names):
"""
:param str table_name: Table name that exists attribute.
:param list attr_names:
List of attribute names to create indices.
Ignore attributes that are not existing in the table.
.. seealso:: :py:meth:`.crea... | [
"def",
"create_index_list",
"(",
"self",
",",
"table_name",
",",
"attr_names",
")",
":",
"self",
".",
"validate_access_permission",
"(",
"[",
"\"w\"",
",",
"\"a\"",
"]",
")",
"if",
"typepy",
".",
"is_empty_sequence",
"(",
"attr_names",
")",
":",
"return",
"t... | :param str table_name: Table name that exists attribute.
:param list attr_names:
List of attribute names to create indices.
Ignore attributes that are not existing in the table.
.. seealso:: :py:meth:`.create_index` | [
":",
"param",
"str",
"table_name",
":",
"Table",
"name",
"that",
"exists",
"attribute",
".",
":",
"param",
"list",
"attr_names",
":",
"List",
"of",
"attribute",
"names",
"to",
"create",
"indices",
".",
"Ignore",
"attributes",
"that",
"are",
"not",
"existing"... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1234-L1253 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.create_table_from_data_matrix | def create_table_from_data_matrix(
self,
table_name,
attr_names,
data_matrix,
primary_key=None,
add_primary_key_column=False,
index_attrs=None,
):
"""
Create a table if not exists. Moreover, insert data into the created
table.
... | python | def create_table_from_data_matrix(
self,
table_name,
attr_names,
data_matrix,
primary_key=None,
add_primary_key_column=False,
index_attrs=None,
):
"""
Create a table if not exists. Moreover, insert data into the created
table.
... | [
"def",
"create_table_from_data_matrix",
"(",
"self",
",",
"table_name",
",",
"attr_names",
",",
"data_matrix",
",",
"primary_key",
"=",
"None",
",",
"add_primary_key_column",
"=",
"False",
",",
"index_attrs",
"=",
"None",
",",
")",
":",
"self",
".",
"__create_ta... | Create a table if not exists. Moreover, insert data into the created
table.
:param str table_name: Table name to create.
:param list attr_names: Attribute names of the table.
:param data_matrix: Data to be inserted into the table.
:type data_matrix: List of |dict|/|namedtuple|/|... | [
"Create",
"a",
"table",
"if",
"not",
"exists",
".",
"Moreover",
"insert",
"data",
"into",
"the",
"created",
"table",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1255-L1294 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.create_table_from_tabledata | def create_table_from_tabledata(
self, table_data, primary_key=None, add_primary_key_column=False, index_attrs=None
):
"""
Create a table from :py:class:`tabledata.TableData`.
:param tabledata.TableData table_data: Table data to create.
:param str primary_key: |primary_key|
... | python | def create_table_from_tabledata(
self, table_data, primary_key=None, add_primary_key_column=False, index_attrs=None
):
"""
Create a table from :py:class:`tabledata.TableData`.
:param tabledata.TableData table_data: Table data to create.
:param str primary_key: |primary_key|
... | [
"def",
"create_table_from_tabledata",
"(",
"self",
",",
"table_data",
",",
"primary_key",
"=",
"None",
",",
"add_primary_key_column",
"=",
"False",
",",
"index_attrs",
"=",
"None",
")",
":",
"self",
".",
"__create_table_from_tabledata",
"(",
"table_data",
",",
"pr... | Create a table from :py:class:`tabledata.TableData`.
:param tabledata.TableData table_data: Table data to create.
:param str primary_key: |primary_key|
:param tuple index_attrs: |index_attrs|
.. seealso::
:py:meth:`.create_table_from_data_matrix` | [
"Create",
"a",
"table",
"from",
":",
"py",
":",
"class",
":",
"tabledata",
".",
"TableData",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1296-L1312 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.create_table_from_csv | def create_table_from_csv(
self,
csv_source,
table_name="",
attr_names=(),
delimiter=",",
quotechar='"',
encoding="utf-8",
primary_key=None,
add_primary_key_column=False,
index_attrs=None,
):
"""
Create a table from a CS... | python | def create_table_from_csv(
self,
csv_source,
table_name="",
attr_names=(),
delimiter=",",
quotechar='"',
encoding="utf-8",
primary_key=None,
add_primary_key_column=False,
index_attrs=None,
):
"""
Create a table from a CS... | [
"def",
"create_table_from_csv",
"(",
"self",
",",
"csv_source",
",",
"table_name",
"=",
"\"\"",
",",
"attr_names",
"=",
"(",
")",
",",
"delimiter",
"=",
"\",\"",
",",
"quotechar",
"=",
"'\"'",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"primary_key",
"=",
"No... | Create a table from a CSV file/text.
:param str csv_source: Path to the CSV file or CSV text.
:param str table_name:
Table name to create.
Using CSV file basename as the table name if the value is empty.
:param list attr_names:
Attribute names of the table.
... | [
"Create",
"a",
"table",
"from",
"a",
"CSV",
"file",
"/",
"text",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1314-L1388 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.create_table_from_json | def create_table_from_json(
self,
json_source,
table_name="",
primary_key=None,
add_primary_key_column=False,
index_attrs=None,
):
"""
Create a table from a JSON file/text.
:param str json_source: Path to the JSON file or JSON text.
:p... | python | def create_table_from_json(
self,
json_source,
table_name="",
primary_key=None,
add_primary_key_column=False,
index_attrs=None,
):
"""
Create a table from a JSON file/text.
:param str json_source: Path to the JSON file or JSON text.
:p... | [
"def",
"create_table_from_json",
"(",
"self",
",",
"json_source",
",",
"table_name",
"=",
"\"\"",
",",
"primary_key",
"=",
"None",
",",
"add_primary_key_column",
"=",
"False",
",",
"index_attrs",
"=",
"None",
",",
")",
":",
"import",
"pytablereader",
"as",
"pt... | Create a table from a JSON file/text.
:param str json_source: Path to the JSON file or JSON text.
:param str table_name: Table name to create.
:param str primary_key: |primary_key|
:param tuple index_attrs: |index_attrs|
:Dependency Packages:
- `pytablereader <https... | [
"Create",
"a",
"table",
"from",
"a",
"JSON",
"file",
"/",
"text",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1390-L1437 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.create_table_from_dataframe | def create_table_from_dataframe(
self,
dataframe,
table_name="",
primary_key=None,
add_primary_key_column=False,
index_attrs=None,
):
"""
Create a table from a pandas.DataFrame instance.
:param pandas.DataFrame dataframe: DataFrame instance to... | python | def create_table_from_dataframe(
self,
dataframe,
table_name="",
primary_key=None,
add_primary_key_column=False,
index_attrs=None,
):
"""
Create a table from a pandas.DataFrame instance.
:param pandas.DataFrame dataframe: DataFrame instance to... | [
"def",
"create_table_from_dataframe",
"(",
"self",
",",
"dataframe",
",",
"table_name",
"=",
"\"\"",
",",
"primary_key",
"=",
"None",
",",
"add_primary_key_column",
"=",
"False",
",",
"index_attrs",
"=",
"None",
",",
")",
":",
"self",
".",
"__create_table_from_t... | Create a table from a pandas.DataFrame instance.
:param pandas.DataFrame dataframe: DataFrame instance to convert.
:param str table_name: Table name to create.
:param str primary_key: |primary_key|
:param tuple index_attrs: |index_attrs|
:Examples:
:ref:`example-cre... | [
"Create",
"a",
"table",
"from",
"a",
"pandas",
".",
"DataFrame",
"instance",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1439-L1464 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.rollback | def rollback(self):
"""
.. seealso:: :py:meth:`sqlite3.Connection.rollback`
"""
try:
self.check_connection()
except NullDatabaseConnectionError:
return
logger.debug("rollback: path='{}'".format(self.database_path))
self.connection.rollba... | python | def rollback(self):
"""
.. seealso:: :py:meth:`sqlite3.Connection.rollback`
"""
try:
self.check_connection()
except NullDatabaseConnectionError:
return
logger.debug("rollback: path='{}'".format(self.database_path))
self.connection.rollba... | [
"def",
"rollback",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"check_connection",
"(",
")",
"except",
"NullDatabaseConnectionError",
":",
"return",
"logger",
".",
"debug",
"(",
"\"rollback: path='{}'\"",
".",
"format",
"(",
"self",
".",
"database_path",
"... | .. seealso:: :py:meth:`sqlite3.Connection.rollback` | [
"..",
"seealso",
"::",
":",
"py",
":",
"meth",
":",
"sqlite3",
".",
"Connection",
".",
"rollback"
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1471-L1483 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.commit | def commit(self):
"""
.. seealso:: :py:meth:`sqlite3.Connection.commit`
"""
try:
self.check_connection()
except NullDatabaseConnectionError:
return
logger.debug("commit: path='{}'".format(self.database_path))
try:
self.connec... | python | def commit(self):
"""
.. seealso:: :py:meth:`sqlite3.Connection.commit`
"""
try:
self.check_connection()
except NullDatabaseConnectionError:
return
logger.debug("commit: path='{}'".format(self.database_path))
try:
self.connec... | [
"def",
"commit",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"check_connection",
"(",
")",
"except",
"NullDatabaseConnectionError",
":",
"return",
"logger",
".",
"debug",
"(",
"\"commit: path='{}'\"",
".",
"format",
"(",
"self",
".",
"database_path",
")",
... | .. seealso:: :py:meth:`sqlite3.Connection.commit` | [
"..",
"seealso",
"::",
":",
"py",
":",
"meth",
":",
"sqlite3",
".",
"Connection",
".",
"commit"
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1485-L1500 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.close | def close(self):
"""
Commit and close the connection.
.. seealso:: :py:meth:`sqlite3.Connection.close`
"""
if self.__delayed_connection_path and self.__connection is None:
self.__initialize_connection()
return
try:
self.check_connect... | python | def close(self):
"""
Commit and close the connection.
.. seealso:: :py:meth:`sqlite3.Connection.close`
"""
if self.__delayed_connection_path and self.__connection is None:
self.__initialize_connection()
return
try:
self.check_connect... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"__delayed_connection_path",
"and",
"self",
".",
"__connection",
"is",
"None",
":",
"self",
".",
"__initialize_connection",
"(",
")",
"return",
"try",
":",
"self",
".",
"check_connection",
"(",
")",
... | Commit and close the connection.
.. seealso:: :py:meth:`sqlite3.Connection.close` | [
"Commit",
"and",
"close",
"the",
"connection",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1502-L1522 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.__verify_db_file_existence | def __verify_db_file_existence(self, database_path):
"""
:raises SimpleSQLite.OperationalError: If unable to open database file.
"""
self.__validate_db_path(database_path)
if not os.path.isfile(os.path.realpath(database_path)):
raise IOError("file not found: " + data... | python | def __verify_db_file_existence(self, database_path):
"""
:raises SimpleSQLite.OperationalError: If unable to open database file.
"""
self.__validate_db_path(database_path)
if not os.path.isfile(os.path.realpath(database_path)):
raise IOError("file not found: " + data... | [
"def",
"__verify_db_file_existence",
"(",
"self",
",",
"database_path",
")",
":",
"self",
".",
"__validate_db_path",
"(",
"database_path",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"database_path",
")",... | :raises SimpleSQLite.OperationalError: If unable to open database file. | [
":",
"raises",
"SimpleSQLite",
".",
"OperationalError",
":",
"If",
"unable",
"to",
"open",
"database",
"file",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1546-L1560 |
thombashi/SimpleSQLite | simplesqlite/core.py | SimpleSQLite.__extract_col_type_from_tabledata | def __extract_col_type_from_tabledata(table_data):
"""
Extract data type name for each column as SQLite names.
:param tabledata.TableData table_data:
:return: { column_number : column_data_type }
:rtype: dictionary
"""
typename_table = {
typepy.Typec... | python | def __extract_col_type_from_tabledata(table_data):
"""
Extract data type name for each column as SQLite names.
:param tabledata.TableData table_data:
:return: { column_number : column_data_type }
:rtype: dictionary
"""
typename_table = {
typepy.Typec... | [
"def",
"__extract_col_type_from_tabledata",
"(",
"table_data",
")",
":",
"typename_table",
"=",
"{",
"typepy",
".",
"Typecode",
".",
"INTEGER",
":",
"\"INTEGER\"",
",",
"typepy",
".",
"Typecode",
".",
"REAL_NUMBER",
":",
"\"REAL\"",
",",
"typepy",
".",
"Typecode... | Extract data type name for each column as SQLite names.
:param tabledata.TableData table_data:
:return: { column_number : column_data_type }
:rtype: dictionary | [
"Extract",
"data",
"type",
"name",
"for",
"each",
"column",
"as",
"SQLite",
"names",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1615-L1635 |
thombashi/SimpleSQLite | simplesqlite/_func.py | validate_table_name | def validate_table_name(name):
"""
:param str name: Table name to validate.
:raises NameValidationError: |raises_validate_table_name|
"""
try:
validate_sqlite_table_name(name)
except (InvalidCharError, InvalidReservedNameError) as e:
raise NameValidationError(e)
except NullN... | python | def validate_table_name(name):
"""
:param str name: Table name to validate.
:raises NameValidationError: |raises_validate_table_name|
"""
try:
validate_sqlite_table_name(name)
except (InvalidCharError, InvalidReservedNameError) as e:
raise NameValidationError(e)
except NullN... | [
"def",
"validate_table_name",
"(",
"name",
")",
":",
"try",
":",
"validate_sqlite_table_name",
"(",
"name",
")",
"except",
"(",
"InvalidCharError",
",",
"InvalidReservedNameError",
")",
"as",
"e",
":",
"raise",
"NameValidationError",
"(",
"e",
")",
"except",
"Nu... | :param str name: Table name to validate.
:raises NameValidationError: |raises_validate_table_name| | [
":",
"param",
"str",
"name",
":",
"Table",
"name",
"to",
"validate",
".",
":",
"raises",
"NameValidationError",
":",
"|raises_validate_table_name|"
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/_func.py#L24-L37 |
thombashi/SimpleSQLite | simplesqlite/_func.py | validate_attr_name | def validate_attr_name(name):
"""
:param str name: Name to validate.
:raises NameValidationError: |raises_validate_attr_name|
"""
try:
validate_sqlite_attr_name(name)
except (InvalidCharError, InvalidReservedNameError) as e:
raise NameValidationError(e)
except NullNameError:... | python | def validate_attr_name(name):
"""
:param str name: Name to validate.
:raises NameValidationError: |raises_validate_attr_name|
"""
try:
validate_sqlite_attr_name(name)
except (InvalidCharError, InvalidReservedNameError) as e:
raise NameValidationError(e)
except NullNameError:... | [
"def",
"validate_attr_name",
"(",
"name",
")",
":",
"try",
":",
"validate_sqlite_attr_name",
"(",
"name",
")",
"except",
"(",
"InvalidCharError",
",",
"InvalidReservedNameError",
")",
"as",
"e",
":",
"raise",
"NameValidationError",
"(",
"e",
")",
"except",
"Null... | :param str name: Name to validate.
:raises NameValidationError: |raises_validate_attr_name| | [
":",
"param",
"str",
"name",
":",
"Name",
"to",
"validate",
".",
":",
"raises",
"NameValidationError",
":",
"|raises_validate_attr_name|"
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/_func.py#L40-L51 |
thombashi/SimpleSQLite | simplesqlite/_func.py | append_table | def append_table(src_con, dst_con, table_name):
"""
Append a table from source database to destination database.
:param SimpleSQLite src_con: Connection to the source database.
:param SimpleSQLite dst_con: Connection to the destination database.
:param str table_name: Table name to append.
:ret... | python | def append_table(src_con, dst_con, table_name):
"""
Append a table from source database to destination database.
:param SimpleSQLite src_con: Connection to the source database.
:param SimpleSQLite dst_con: Connection to the destination database.
:param str table_name: Table name to append.
:ret... | [
"def",
"append_table",
"(",
"src_con",
",",
"dst_con",
",",
"table_name",
")",
":",
"logger",
".",
"debug",
"(",
"\"append table: src={src_db}.{src_tbl}, dst={dst_db}.{dst_tbl}\"",
".",
"format",
"(",
"src_db",
"=",
"src_con",
".",
"database_path",
",",
"src_tbl",
"... | Append a table from source database to destination database.
:param SimpleSQLite src_con: Connection to the source database.
:param SimpleSQLite dst_con: Connection to the destination database.
:param str table_name: Table name to append.
:return: |True| if the append operation succeed.
:rtype: boo... | [
"Append",
"a",
"table",
"from",
"source",
"database",
"to",
"destination",
"database",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/_func.py#L54-L105 |
thombashi/SimpleSQLite | simplesqlite/_func.py | copy_table | def copy_table(src_con, dst_con, src_table_name, dst_table_name, is_overwrite=True):
"""
Copy a table from source to destination.
:param SimpleSQLite src_con: Connection to the source database.
:param SimpleSQLite dst_con: Connection to the destination database.
:param str src_table_name: Source ta... | python | def copy_table(src_con, dst_con, src_table_name, dst_table_name, is_overwrite=True):
"""
Copy a table from source to destination.
:param SimpleSQLite src_con: Connection to the source database.
:param SimpleSQLite dst_con: Connection to the destination database.
:param str src_table_name: Source ta... | [
"def",
"copy_table",
"(",
"src_con",
",",
"dst_con",
",",
"src_table_name",
",",
"dst_table_name",
",",
"is_overwrite",
"=",
"True",
")",
":",
"logger",
".",
"debug",
"(",
"\"copy table: src={src_db}.{src_tbl}, dst={dst_db}.{dst_tbl}\"",
".",
"format",
"(",
"src_db",
... | Copy a table from source to destination.
:param SimpleSQLite src_con: Connection to the source database.
:param SimpleSQLite dst_con: Connection to the destination database.
:param str src_table_name: Source table name to copy.
:param str dst_table_name: Destination table name.
:param bool is_overw... | [
"Copy",
"a",
"table",
"from",
"source",
"to",
"destination",
"."
] | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/_func.py#L108-L161 |
thombashi/SimpleSQLite | simplesqlite/_validator.py | validate_sqlite_table_name | def validate_sqlite_table_name(name):
"""
:param str name: Name to validate.
:raises pathvalidate.NullNameError: If the ``name`` is empty.
:raises pathvalidate.InvalidCharError:
If the ``name`` includes unprintable character(s).
:raises pathvalidate.InvalidReservedNameError:
|raises_... | python | def validate_sqlite_table_name(name):
"""
:param str name: Name to validate.
:raises pathvalidate.NullNameError: If the ``name`` is empty.
:raises pathvalidate.InvalidCharError:
If the ``name`` includes unprintable character(s).
:raises pathvalidate.InvalidReservedNameError:
|raises_... | [
"def",
"validate_sqlite_table_name",
"(",
"name",
")",
":",
"if",
"not",
"name",
":",
"raise",
"NullNameError",
"(",
"\"null name\"",
")",
"if",
"__RE_INVALID_CHARS",
".",
"search",
"(",
"name",
")",
":",
"raise",
"InvalidCharError",
"(",
"\"unprintable character ... | :param str name: Name to validate.
:raises pathvalidate.NullNameError: If the ``name`` is empty.
:raises pathvalidate.InvalidCharError:
If the ``name`` includes unprintable character(s).
:raises pathvalidate.InvalidReservedNameError:
|raises_sqlite_keywords|
And invalid as a table na... | [
":",
"param",
"str",
"name",
":",
"Name",
"to",
"validate",
".",
":",
"raises",
"pathvalidate",
".",
"NullNameError",
":",
"If",
"the",
"name",
"is",
"empty",
".",
":",
"raises",
"pathvalidate",
".",
"InvalidCharError",
":",
"If",
"the",
"name",
"includes"... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/_validator.py#L155-L181 |
thombashi/SimpleSQLite | simplesqlite/_validator.py | validate_sqlite_attr_name | def validate_sqlite_attr_name(name):
"""
:param str name: Name to validate.
:raises pathvalidate.NullNameError: If the ``name`` is empty.
:raises pathvalidate.InvalidCharError:
If the ``name`` includes unprintable character(s).
:raises pathvalidate.InvalidReservedNameError:
|raises_s... | python | def validate_sqlite_attr_name(name):
"""
:param str name: Name to validate.
:raises pathvalidate.NullNameError: If the ``name`` is empty.
:raises pathvalidate.InvalidCharError:
If the ``name`` includes unprintable character(s).
:raises pathvalidate.InvalidReservedNameError:
|raises_s... | [
"def",
"validate_sqlite_attr_name",
"(",
"name",
")",
":",
"if",
"not",
"name",
":",
"raise",
"NullNameError",
"(",
"\"null name\"",
")",
"if",
"__RE_INVALID_CHARS",
".",
"search",
"(",
"name",
")",
":",
"raise",
"InvalidCharError",
"(",
"\"unprintable character f... | :param str name: Name to validate.
:raises pathvalidate.NullNameError: If the ``name`` is empty.
:raises pathvalidate.InvalidCharError:
If the ``name`` includes unprintable character(s).
:raises pathvalidate.InvalidReservedNameError:
|raises_sqlite_keywords|
And invalid as an attribu... | [
":",
"param",
"str",
"name",
":",
"Name",
"to",
"validate",
".",
":",
"raises",
"pathvalidate",
".",
"NullNameError",
":",
"If",
"the",
"name",
"is",
"empty",
".",
":",
"raises",
"pathvalidate",
".",
"InvalidCharError",
":",
"If",
"the",
"name",
"includes"... | train | https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/_validator.py#L184-L210 |
alorence/django-modern-rpc | modernrpc/compat.py | _generic_convert_string | def _generic_convert_string(v, from_type, to_type, encoding):
"""
Generic method to convert any argument type (string type, list, set, tuple, dict) to an equivalent,
with string values converted to given 'to_type' (str or unicode).
This method must be used with Python 2 interpreter only.
:param v: ... | python | def _generic_convert_string(v, from_type, to_type, encoding):
"""
Generic method to convert any argument type (string type, list, set, tuple, dict) to an equivalent,
with string values converted to given 'to_type' (str or unicode).
This method must be used with Python 2 interpreter only.
:param v: ... | [
"def",
"_generic_convert_string",
"(",
"v",
",",
"from_type",
",",
"to_type",
",",
"encoding",
")",
":",
"assert",
"six",
".",
"PY2",
",",
"\"This function should be used with Python 2 only\"",
"assert",
"from_type",
"!=",
"to_type",
"if",
"from_type",
"==",
"six",
... | Generic method to convert any argument type (string type, list, set, tuple, dict) to an equivalent,
with string values converted to given 'to_type' (str or unicode).
This method must be used with Python 2 interpreter only.
:param v: The value to convert
:param from_type: The original string type to con... | [
"Generic",
"method",
"to",
"convert",
"any",
"argument",
"type",
"(",
"string",
"type",
"list",
"set",
"tuple",
"dict",
")",
"to",
"an",
"equivalent",
"with",
"string",
"values",
"converted",
"to",
"given",
"to_type",
"(",
"str",
"or",
"unicode",
")",
".",... | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/compat.py#L7-L35 |
alorence/django-modern-rpc | modernrpc/compat.py | standardize_strings | def standardize_strings(arg, strtype=settings.MODERNRPC_PY2_STR_TYPE, encoding=settings.MODERNRPC_PY2_STR_ENCODING):
"""
Python 2 only. Lookup given *arg* and convert its str or unicode value according to MODERNRPC_PY2_STR_TYPE and
MODERNRPC_PY2_STR_ENCODING settings.
"""
assert six.PY2, "This funct... | python | def standardize_strings(arg, strtype=settings.MODERNRPC_PY2_STR_TYPE, encoding=settings.MODERNRPC_PY2_STR_ENCODING):
"""
Python 2 only. Lookup given *arg* and convert its str or unicode value according to MODERNRPC_PY2_STR_TYPE and
MODERNRPC_PY2_STR_ENCODING settings.
"""
assert six.PY2, "This funct... | [
"def",
"standardize_strings",
"(",
"arg",
",",
"strtype",
"=",
"settings",
".",
"MODERNRPC_PY2_STR_TYPE",
",",
"encoding",
"=",
"settings",
".",
"MODERNRPC_PY2_STR_ENCODING",
")",
":",
"assert",
"six",
".",
"PY2",
",",
"\"This function should be used with Python 2 only\... | Python 2 only. Lookup given *arg* and convert its str or unicode value according to MODERNRPC_PY2_STR_TYPE and
MODERNRPC_PY2_STR_ENCODING settings. | [
"Python",
"2",
"only",
".",
"Lookup",
"given",
"*",
"arg",
"*",
"and",
"convert",
"its",
"str",
"or",
"unicode",
"value",
"according",
"to",
"MODERNRPC_PY2_STR_TYPE",
"and",
"MODERNRPC_PY2_STR_ENCODING",
"settings",
"."
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/compat.py#L38-L57 |
alorence/django-modern-rpc | modernrpc/helpers.py | get_builtin_date | def get_builtin_date(date, date_format="%Y-%m-%dT%H:%M:%S", raise_exception=False):
"""
Try to convert a date to a builtin instance of ``datetime.datetime``.
The input date can be a ``str``, a ``datetime.datetime``, a ``xmlrpc.client.Datetime`` or a ``xmlrpclib.Datetime``
instance. The returned object i... | python | def get_builtin_date(date, date_format="%Y-%m-%dT%H:%M:%S", raise_exception=False):
"""
Try to convert a date to a builtin instance of ``datetime.datetime``.
The input date can be a ``str``, a ``datetime.datetime``, a ``xmlrpc.client.Datetime`` or a ``xmlrpclib.Datetime``
instance. The returned object i... | [
"def",
"get_builtin_date",
"(",
"date",
",",
"date_format",
"=",
"\"%Y-%m-%dT%H:%M:%S\"",
",",
"raise_exception",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"date",
",",
"datetime",
".",
"datetime",
")",
":",
"# Default XML-RPC handler is configured to decode da... | Try to convert a date to a builtin instance of ``datetime.datetime``.
The input date can be a ``str``, a ``datetime.datetime``, a ``xmlrpc.client.Datetime`` or a ``xmlrpclib.Datetime``
instance. The returned object is a ``datetime.datetime``.
:param date: The date object to convert.
:param date_format:... | [
"Try",
"to",
"convert",
"a",
"date",
"to",
"a",
"builtin",
"instance",
"of",
"datetime",
".",
"datetime",
".",
"The",
"input",
"date",
"can",
"be",
"a",
"str",
"a",
"datetime",
".",
"datetime",
"a",
"xmlrpc",
".",
"client",
".",
"Datetime",
"or",
"a",
... | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/helpers.py#L7-L35 |
alorence/django-modern-rpc | modernrpc/auth/__init__.py | set_authentication_predicate | def set_authentication_predicate(predicate, params=()):
"""
Assign a new authentication predicate to an RPC method.
This is the most generic decorator used to implement authentication.
Predicate is a standard function with the following signature:
.. code:: python
def my_predicate(request, ... | python | def set_authentication_predicate(predicate, params=()):
"""
Assign a new authentication predicate to an RPC method.
This is the most generic decorator used to implement authentication.
Predicate is a standard function with the following signature:
.. code:: python
def my_predicate(request, ... | [
"def",
"set_authentication_predicate",
"(",
"predicate",
",",
"params",
"=",
"(",
")",
")",
":",
"def",
"wrapper",
"(",
"rpc_method",
")",
":",
"if",
"hasattr",
"(",
"rpc_method",
",",
"'modernrpc_auth_predicates'",
")",
":",
"rpc_method",
".",
"modernrpc_auth_p... | Assign a new authentication predicate to an RPC method.
This is the most generic decorator used to implement authentication.
Predicate is a standard function with the following signature:
.. code:: python
def my_predicate(request, *params):
# Inspect request and extract required informat... | [
"Assign",
"a",
"new",
"authentication",
"predicate",
"to",
"an",
"RPC",
"method",
".",
"This",
"is",
"the",
"most",
"generic",
"decorator",
"used",
"to",
"implement",
"authentication",
".",
"Predicate",
"is",
"a",
"standard",
"function",
"with",
"the",
"follow... | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/auth/__init__.py#L10-L43 |
alorence/django-modern-rpc | modernrpc/auth/__init__.py | user_in_group | def user_in_group(user, group):
"""Returns True if the given user is in given group"""
if isinstance(group, Group):
return user_is_superuser(user) or group in user.groups.all()
elif isinstance(group, six.string_types):
return user_is_superuser(user) or user.groups.filter(name=group).exists()... | python | def user_in_group(user, group):
"""Returns True if the given user is in given group"""
if isinstance(group, Group):
return user_is_superuser(user) or group in user.groups.all()
elif isinstance(group, six.string_types):
return user_is_superuser(user) or user.groups.filter(name=group).exists()... | [
"def",
"user_in_group",
"(",
"user",
",",
"group",
")",
":",
"if",
"isinstance",
"(",
"group",
",",
"Group",
")",
":",
"return",
"user_is_superuser",
"(",
"user",
")",
"or",
"group",
"in",
"user",
".",
"groups",
".",
"all",
"(",
")",
"elif",
"isinstanc... | Returns True if the given user is in given group | [
"Returns",
"True",
"if",
"the",
"given",
"user",
"is",
"in",
"given",
"group"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/auth/__init__.py#L77-L83 |
alorence/django-modern-rpc | modernrpc/auth/__init__.py | user_in_any_group | def user_in_any_group(user, groups):
"""Returns True if the given user is in at least 1 of the given groups"""
return user_is_superuser(user) or any(user_in_group(user, group) for group in groups) | python | def user_in_any_group(user, groups):
"""Returns True if the given user is in at least 1 of the given groups"""
return user_is_superuser(user) or any(user_in_group(user, group) for group in groups) | [
"def",
"user_in_any_group",
"(",
"user",
",",
"groups",
")",
":",
"return",
"user_is_superuser",
"(",
"user",
")",
"or",
"any",
"(",
"user_in_group",
"(",
"user",
",",
"group",
")",
"for",
"group",
"in",
"groups",
")"
] | Returns True if the given user is in at least 1 of the given groups | [
"Returns",
"True",
"if",
"the",
"given",
"user",
"is",
"in",
"at",
"least",
"1",
"of",
"the",
"given",
"groups"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/auth/__init__.py#L86-L88 |
alorence/django-modern-rpc | modernrpc/auth/__init__.py | user_in_all_groups | def user_in_all_groups(user, groups):
"""Returns True if the given user is in all given groups"""
return user_is_superuser(user) or all(user_in_group(user, group) for group in groups) | python | def user_in_all_groups(user, groups):
"""Returns True if the given user is in all given groups"""
return user_is_superuser(user) or all(user_in_group(user, group) for group in groups) | [
"def",
"user_in_all_groups",
"(",
"user",
",",
"groups",
")",
":",
"return",
"user_is_superuser",
"(",
"user",
")",
"or",
"all",
"(",
"user_in_group",
"(",
"user",
",",
"group",
")",
"for",
"group",
"in",
"groups",
")"
] | Returns True if the given user is in all given groups | [
"Returns",
"True",
"if",
"the",
"given",
"user",
"is",
"in",
"all",
"given",
"groups"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/auth/__init__.py#L91-L93 |
alorence/django-modern-rpc | modernrpc/views.py | RPCEntryPoint.get_handler_classes | def get_handler_classes(self):
"""Return the list of handlers to use when receiving RPC requests."""
handler_classes = [import_string(handler_cls) for handler_cls in settings.MODERNRPC_HANDLERS]
if self.protocol == ALL:
return handler_classes
else:
return [cls f... | python | def get_handler_classes(self):
"""Return the list of handlers to use when receiving RPC requests."""
handler_classes = [import_string(handler_cls) for handler_cls in settings.MODERNRPC_HANDLERS]
if self.protocol == ALL:
return handler_classes
else:
return [cls f... | [
"def",
"get_handler_classes",
"(",
"self",
")",
":",
"handler_classes",
"=",
"[",
"import_string",
"(",
"handler_cls",
")",
"for",
"handler_cls",
"in",
"settings",
".",
"MODERNRPC_HANDLERS",
"]",
"if",
"self",
".",
"protocol",
"==",
"ALL",
":",
"return",
"hand... | Return the list of handlers to use when receiving RPC requests. | [
"Return",
"the",
"list",
"of",
"handlers",
"to",
"use",
"when",
"receiving",
"RPC",
"requests",
"."
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/views.py#L57-L65 |
alorence/django-modern-rpc | modernrpc/views.py | RPCEntryPoint.post | def post(self, request, *args, **kwargs):
"""
Handle a XML-RPC or JSON-RPC request.
:param request: Incoming request
:param args: Additional arguments
:param kwargs: Additional named arguments
:return: A HttpResponse containing XML-RPC or JSON-RPC response, depending on ... | python | def post(self, request, *args, **kwargs):
"""
Handle a XML-RPC or JSON-RPC request.
:param request: Incoming request
:param args: Additional arguments
:param kwargs: Additional named arguments
:return: A HttpResponse containing XML-RPC or JSON-RPC response, depending on ... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'RPC request received...'",
")",
"for",
"handler_cls",
"in",
"self",
".",
"get_handler_classes",
"(",
")",
":",
"handler",
"=",... | Handle a XML-RPC or JSON-RPC request.
:param request: Incoming request
:param args: Additional arguments
:param kwargs: Additional named arguments
:return: A HttpResponse containing XML-RPC or JSON-RPC response, depending on the incoming request | [
"Handle",
"a",
"XML",
"-",
"RPC",
"or",
"JSON",
"-",
"RPC",
"request",
"."
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/views.py#L67-L110 |
alorence/django-modern-rpc | modernrpc/views.py | RPCEntryPoint.get_context_data | def get_context_data(self, **kwargs):
"""Update context data with list of RPC methods of the current entry point.
Will be used to display methods documentation page"""
kwargs.update({
'methods': registry.get_all_methods(self.entry_point, sort_methods=True),
})
return ... | python | def get_context_data(self, **kwargs):
"""Update context data with list of RPC methods of the current entry point.
Will be used to display methods documentation page"""
kwargs.update({
'methods': registry.get_all_methods(self.entry_point, sort_methods=True),
})
return ... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'methods'",
":",
"registry",
".",
"get_all_methods",
"(",
"self",
".",
"entry_point",
",",
"sort_methods",
"=",
"True",
")",
",",
"}",
")",
"... | Update context data with list of RPC methods of the current entry point.
Will be used to display methods documentation page | [
"Update",
"context",
"data",
"with",
"list",
"of",
"RPC",
"methods",
"of",
"the",
"current",
"entry",
"point",
".",
"Will",
"be",
"used",
"to",
"display",
"methods",
"documentation",
"page"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/views.py#L112-L118 |
alorence/django-modern-rpc | modernrpc/apps.py | ModernRpcConfig.rpc_methods_registration | def rpc_methods_registration():
"""Look into each module listed in settings.MODERNRPC_METHODS_MODULES, import each module and register
functions annotated with @rpc_method decorator in the registry"""
# In previous version, django-modern-rpc used the django cache system to store methods registr... | python | def rpc_methods_registration():
"""Look into each module listed in settings.MODERNRPC_METHODS_MODULES, import each module and register
functions annotated with @rpc_method decorator in the registry"""
# In previous version, django-modern-rpc used the django cache system to store methods registr... | [
"def",
"rpc_methods_registration",
"(",
")",
":",
"# In previous version, django-modern-rpc used the django cache system to store methods registry.",
"# It is useless now, so clean the cache from old data",
"clean_old_cache_content",
"(",
")",
"# For security (and unit tests), make sure the regi... | Look into each module listed in settings.MODERNRPC_METHODS_MODULES, import each module and register
functions annotated with @rpc_method decorator in the registry | [
"Look",
"into",
"each",
"module",
"listed",
"in",
"settings",
".",
"MODERNRPC_METHODS_MODULES",
"import",
"each",
"module",
"and",
"register",
"functions",
"annotated",
"with"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/apps.py#L43-L77 |
alorence/django-modern-rpc | modernrpc/auth/basic.py | http_basic_auth_get_user | def http_basic_auth_get_user(request):
"""Inspect the given request to find a logged user. If not found, the header HTTP_AUTHORIZATION
is read for 'Basic Auth' login and password, and try to authenticate against default UserModel.
Always return a User instance (possibly anonymous, meaning authentication fai... | python | def http_basic_auth_get_user(request):
"""Inspect the given request to find a logged user. If not found, the header HTTP_AUTHORIZATION
is read for 'Basic Auth' login and password, and try to authenticate against default UserModel.
Always return a User instance (possibly anonymous, meaning authentication fai... | [
"def",
"http_basic_auth_get_user",
"(",
"request",
")",
":",
"try",
":",
"# If standard auth middleware already authenticated a user, use it",
"if",
"user_is_authenticated",
"(",
"request",
".",
"user",
")",
":",
"return",
"request",
".",
"user",
"except",
"AttributeError... | Inspect the given request to find a logged user. If not found, the header HTTP_AUTHORIZATION
is read for 'Basic Auth' login and password, and try to authenticate against default UserModel.
Always return a User instance (possibly anonymous, meaning authentication failed) | [
"Inspect",
"the",
"given",
"request",
"to",
"find",
"a",
"logged",
"user",
".",
"If",
"not",
"found",
"the",
"header",
"HTTP_AUTHORIZATION",
"is",
"read",
"for",
"Basic",
"Auth",
"login",
"and",
"password",
"and",
"try",
"to",
"authenticate",
"against",
"def... | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/auth/basic.py#L24-L50 |
alorence/django-modern-rpc | modernrpc/auth/basic.py | http_basic_auth_login_required | def http_basic_auth_login_required(func=None):
"""Decorator. Use it to specify a RPC method is available only to logged users"""
wrapper = auth.set_authentication_predicate(http_basic_auth_check_user, [auth.user_is_authenticated])
# If @http_basic_auth_login_required() is used (with parenthesis)
if fu... | python | def http_basic_auth_login_required(func=None):
"""Decorator. Use it to specify a RPC method is available only to logged users"""
wrapper = auth.set_authentication_predicate(http_basic_auth_check_user, [auth.user_is_authenticated])
# If @http_basic_auth_login_required() is used (with parenthesis)
if fu... | [
"def",
"http_basic_auth_login_required",
"(",
"func",
"=",
"None",
")",
":",
"wrapper",
"=",
"auth",
".",
"set_authentication_predicate",
"(",
"http_basic_auth_check_user",
",",
"[",
"auth",
".",
"user_is_authenticated",
"]",
")",
"# If @http_basic_auth_login_required() i... | Decorator. Use it to specify a RPC method is available only to logged users | [
"Decorator",
".",
"Use",
"it",
"to",
"specify",
"a",
"RPC",
"method",
"is",
"available",
"only",
"to",
"logged",
"users"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/auth/basic.py#L54-L64 |
alorence/django-modern-rpc | modernrpc/auth/basic.py | http_basic_auth_superuser_required | def http_basic_auth_superuser_required(func=None):
"""Decorator. Use it to specify a RPC method is available only to logged superusers"""
wrapper = auth.set_authentication_predicate(http_basic_auth_check_user, [auth.user_is_superuser])
# If @http_basic_auth_superuser_required() is used (with parenthesis)
... | python | def http_basic_auth_superuser_required(func=None):
"""Decorator. Use it to specify a RPC method is available only to logged superusers"""
wrapper = auth.set_authentication_predicate(http_basic_auth_check_user, [auth.user_is_superuser])
# If @http_basic_auth_superuser_required() is used (with parenthesis)
... | [
"def",
"http_basic_auth_superuser_required",
"(",
"func",
"=",
"None",
")",
":",
"wrapper",
"=",
"auth",
".",
"set_authentication_predicate",
"(",
"http_basic_auth_check_user",
",",
"[",
"auth",
".",
"user_is_superuser",
"]",
")",
"# If @http_basic_auth_superuser_required... | Decorator. Use it to specify a RPC method is available only to logged superusers | [
"Decorator",
".",
"Use",
"it",
"to",
"specify",
"a",
"RPC",
"method",
"is",
"available",
"only",
"to",
"logged",
"superusers"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/auth/basic.py#L68-L78 |
alorence/django-modern-rpc | modernrpc/auth/basic.py | http_basic_auth_permissions_required | def http_basic_auth_permissions_required(permissions):
"""Decorator. Use it to specify a RPC method is available only to logged users with given permissions"""
if isinstance(permissions, six.string_types):
return auth.set_authentication_predicate(http_basic_auth_check_user, [auth.user_has_perm, permiss... | python | def http_basic_auth_permissions_required(permissions):
"""Decorator. Use it to specify a RPC method is available only to logged users with given permissions"""
if isinstance(permissions, six.string_types):
return auth.set_authentication_predicate(http_basic_auth_check_user, [auth.user_has_perm, permiss... | [
"def",
"http_basic_auth_permissions_required",
"(",
"permissions",
")",
":",
"if",
"isinstance",
"(",
"permissions",
",",
"six",
".",
"string_types",
")",
":",
"return",
"auth",
".",
"set_authentication_predicate",
"(",
"http_basic_auth_check_user",
",",
"[",
"auth",
... | Decorator. Use it to specify a RPC method is available only to logged users with given permissions | [
"Decorator",
".",
"Use",
"it",
"to",
"specify",
"a",
"RPC",
"method",
"is",
"available",
"only",
"to",
"logged",
"users",
"with",
"given",
"permissions"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/auth/basic.py#L82-L88 |
alorence/django-modern-rpc | modernrpc/auth/basic.py | http_basic_auth_group_member_required | def http_basic_auth_group_member_required(groups):
"""Decorator. Use it to specify a RPC method is available only to logged users with given permissions"""
if isinstance(groups, six.string_types):
# Check user is in a group
return auth.set_authentication_predicate(http_basic_auth_check_user, [a... | python | def http_basic_auth_group_member_required(groups):
"""Decorator. Use it to specify a RPC method is available only to logged users with given permissions"""
if isinstance(groups, six.string_types):
# Check user is in a group
return auth.set_authentication_predicate(http_basic_auth_check_user, [a... | [
"def",
"http_basic_auth_group_member_required",
"(",
"groups",
")",
":",
"if",
"isinstance",
"(",
"groups",
",",
"six",
".",
"string_types",
")",
":",
"# Check user is in a group",
"return",
"auth",
".",
"set_authentication_predicate",
"(",
"http_basic_auth_check_user",
... | Decorator. Use it to specify a RPC method is available only to logged users with given permissions | [
"Decorator",
".",
"Use",
"it",
"to",
"specify",
"a",
"RPC",
"method",
"is",
"available",
"only",
"to",
"logged",
"users",
"with",
"given",
"permissions"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/auth/basic.py#L98-L106 |
alorence/django-modern-rpc | modernrpc/core.py | rpc_method | def rpc_method(func=None, name=None, entry_point=ALL, protocol=ALL,
str_standardization=settings.MODERNRPC_PY2_STR_TYPE,
str_standardization_encoding=settings.MODERNRPC_PY2_STR_ENCODING):
"""
Mark a standard python function as RPC method.
All arguments are optional
:param... | python | def rpc_method(func=None, name=None, entry_point=ALL, protocol=ALL,
str_standardization=settings.MODERNRPC_PY2_STR_TYPE,
str_standardization_encoding=settings.MODERNRPC_PY2_STR_ENCODING):
"""
Mark a standard python function as RPC method.
All arguments are optional
:param... | [
"def",
"rpc_method",
"(",
"func",
"=",
"None",
",",
"name",
"=",
"None",
",",
"entry_point",
"=",
"ALL",
",",
"protocol",
"=",
"ALL",
",",
"str_standardization",
"=",
"settings",
".",
"MODERNRPC_PY2_STR_TYPE",
",",
"str_standardization_encoding",
"=",
"settings"... | Mark a standard python function as RPC method.
All arguments are optional
:param func: A standard function
:param name: Used as RPC method name instead of original function name
:param entry_point: Default: ALL. Used to limit usage of the RPC method for a specific set of entry points
:param protoc... | [
"Mark",
"a",
"standard",
"python",
"function",
"as",
"RPC",
"method",
"."
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L330-L369 |
alorence/django-modern-rpc | modernrpc/core.py | get_all_method_names | def get_all_method_names(entry_point=ALL, protocol=ALL, sort_methods=False):
"""For backward compatibility. Use registry.get_all_method_names() instead (with same arguments)"""
return registry.get_all_method_names(entry_point=entry_point, protocol=protocol, sort_methods=sort_methods) | python | def get_all_method_names(entry_point=ALL, protocol=ALL, sort_methods=False):
"""For backward compatibility. Use registry.get_all_method_names() instead (with same arguments)"""
return registry.get_all_method_names(entry_point=entry_point, protocol=protocol, sort_methods=sort_methods) | [
"def",
"get_all_method_names",
"(",
"entry_point",
"=",
"ALL",
",",
"protocol",
"=",
"ALL",
",",
"sort_methods",
"=",
"False",
")",
":",
"return",
"registry",
".",
"get_all_method_names",
"(",
"entry_point",
"=",
"entry_point",
",",
"protocol",
"=",
"protocol",
... | For backward compatibility. Use registry.get_all_method_names() instead (with same arguments) | [
"For",
"backward",
"compatibility",
".",
"Use",
"registry",
".",
"get_all_method_names",
"()",
"instead",
"(",
"with",
"same",
"arguments",
")"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L380-L382 |
alorence/django-modern-rpc | modernrpc/core.py | get_all_methods | def get_all_methods(entry_point=ALL, protocol=ALL, sort_methods=False):
"""For backward compatibility. Use registry.get_all_methods() instead (with same arguments)"""
return registry.get_all_methods(entry_point=entry_point, protocol=protocol, sort_methods=sort_methods) | python | def get_all_methods(entry_point=ALL, protocol=ALL, sort_methods=False):
"""For backward compatibility. Use registry.get_all_methods() instead (with same arguments)"""
return registry.get_all_methods(entry_point=entry_point, protocol=protocol, sort_methods=sort_methods) | [
"def",
"get_all_methods",
"(",
"entry_point",
"=",
"ALL",
",",
"protocol",
"=",
"ALL",
",",
"sort_methods",
"=",
"False",
")",
":",
"return",
"registry",
".",
"get_all_methods",
"(",
"entry_point",
"=",
"entry_point",
",",
"protocol",
"=",
"protocol",
",",
"... | For backward compatibility. Use registry.get_all_methods() instead (with same arguments) | [
"For",
"backward",
"compatibility",
".",
"Use",
"registry",
".",
"get_all_methods",
"()",
"instead",
"(",
"with",
"same",
"arguments",
")"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L385-L387 |
alorence/django-modern-rpc | modernrpc/core.py | RPCMethod.parse_docstring | def parse_docstring(self, content):
"""
Parse the given full docstring, and extract method description, arguments, and return documentation.
This method try to find arguments description and types, and put the information in "args_doc" and "signature"
members. Also parse return type and... | python | def parse_docstring(self, content):
"""
Parse the given full docstring, and extract method description, arguments, and return documentation.
This method try to find arguments description and types, and put the information in "args_doc" and "signature"
members. Also parse return type and... | [
"def",
"parse_docstring",
"(",
"self",
",",
"content",
")",
":",
"if",
"not",
"content",
":",
"return",
"raw_docstring",
"=",
"''",
"# We use the helper defined in django admindocs app to remove indentation chars from docstring,",
"# and parse it as title, body, metadata. We don't ... | Parse the given full docstring, and extract method description, arguments, and return documentation.
This method try to find arguments description and types, and put the information in "args_doc" and "signature"
members. Also parse return type and description, and put the information in "return_doc" me... | [
"Parse",
"the",
"given",
"full",
"docstring",
"and",
"extract",
"method",
"description",
"arguments",
"and",
"return",
"documentation",
"."
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L92-L159 |
alorence/django-modern-rpc | modernrpc/core.py | RPCMethod.html_doc | def html_doc(self):
"""Methods docstring, as HTML"""
if not self.raw_docstring:
result = ''
elif settings.MODERNRPC_DOC_FORMAT.lower() in ('rst', 'restructred', 'restructuredtext'):
from docutils.core import publish_parts
result = publish_parts(self.raw_docst... | python | def html_doc(self):
"""Methods docstring, as HTML"""
if not self.raw_docstring:
result = ''
elif settings.MODERNRPC_DOC_FORMAT.lower() in ('rst', 'restructred', 'restructuredtext'):
from docutils.core import publish_parts
result = publish_parts(self.raw_docst... | [
"def",
"html_doc",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"raw_docstring",
":",
"result",
"=",
"''",
"elif",
"settings",
".",
"MODERNRPC_DOC_FORMAT",
".",
"lower",
"(",
")",
"in",
"(",
"'rst'",
",",
"'restructred'",
",",
"'restructuredtext'",
")"... | Methods docstring, as HTML | [
"Methods",
"docstring",
"as",
"HTML"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L162-L178 |
alorence/django-modern-rpc | modernrpc/core.py | RPCMethod.check_permissions | def check_permissions(self, request):
"""Call the predicate(s) associated with the RPC method, to check if the current request
can actually call the method.
Return a boolean indicating if the method should be executed (True) or not (False)"""
if not self.predicates:
return T... | python | def check_permissions(self, request):
"""Call the predicate(s) associated with the RPC method, to check if the current request
can actually call the method.
Return a boolean indicating if the method should be executed (True) or not (False)"""
if not self.predicates:
return T... | [
"def",
"check_permissions",
"(",
"self",
",",
"request",
")",
":",
"if",
"not",
"self",
".",
"predicates",
":",
"return",
"True",
"# All registered authentication predicates must return True",
"return",
"all",
"(",
"predicate",
"(",
"request",
",",
"*",
"self",
".... | Call the predicate(s) associated with the RPC method, to check if the current request
can actually call the method.
Return a boolean indicating if the method should be executed (True) or not (False) | [
"Call",
"the",
"predicate",
"(",
"s",
")",
"associated",
"with",
"the",
"RPC",
"method",
"to",
"check",
"if",
"the",
"current",
"request",
"can",
"actually",
"call",
"the",
"method",
".",
"Return",
"a",
"boolean",
"indicating",
"if",
"the",
"method",
"shou... | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L180-L192 |
alorence/django-modern-rpc | modernrpc/core.py | RPCMethod.available_for_protocol | def available_for_protocol(self, protocol):
"""Check if the current function can be executed from a request defining the given protocol"""
if self.protocol == ALL or protocol == ALL:
return True
return protocol in ensure_sequence(self.protocol) | python | def available_for_protocol(self, protocol):
"""Check if the current function can be executed from a request defining the given protocol"""
if self.protocol == ALL or protocol == ALL:
return True
return protocol in ensure_sequence(self.protocol) | [
"def",
"available_for_protocol",
"(",
"self",
",",
"protocol",
")",
":",
"if",
"self",
".",
"protocol",
"==",
"ALL",
"or",
"protocol",
"==",
"ALL",
":",
"return",
"True",
"return",
"protocol",
"in",
"ensure_sequence",
"(",
"self",
".",
"protocol",
")"
] | Check if the current function can be executed from a request defining the given protocol | [
"Check",
"if",
"the",
"current",
"function",
"can",
"be",
"executed",
"from",
"a",
"request",
"defining",
"the",
"given",
"protocol"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L194-L199 |
alorence/django-modern-rpc | modernrpc/core.py | RPCMethod.available_for_entry_point | def available_for_entry_point(self, entry_point):
"""Check if the current function can be executed from a request to the given entry point"""
if self.entry_point == ALL or entry_point == ALL:
return True
return entry_point in ensure_sequence(self.entry_point) | python | def available_for_entry_point(self, entry_point):
"""Check if the current function can be executed from a request to the given entry point"""
if self.entry_point == ALL or entry_point == ALL:
return True
return entry_point in ensure_sequence(self.entry_point) | [
"def",
"available_for_entry_point",
"(",
"self",
",",
"entry_point",
")",
":",
"if",
"self",
".",
"entry_point",
"==",
"ALL",
"or",
"entry_point",
"==",
"ALL",
":",
"return",
"True",
"return",
"entry_point",
"in",
"ensure_sequence",
"(",
"self",
".",
"entry_po... | Check if the current function can be executed from a request to the given entry point | [
"Check",
"if",
"the",
"current",
"function",
"can",
"be",
"executed",
"from",
"a",
"request",
"to",
"the",
"given",
"entry",
"point"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L201-L206 |
alorence/django-modern-rpc | modernrpc/core.py | RPCMethod.is_valid_for | def is_valid_for(self, entry_point, protocol):
"""Check if the current function can be executed from a request to the given entry point
and with the given protocol"""
return self.available_for_entry_point(entry_point) and self.available_for_protocol(protocol) | python | def is_valid_for(self, entry_point, protocol):
"""Check if the current function can be executed from a request to the given entry point
and with the given protocol"""
return self.available_for_entry_point(entry_point) and self.available_for_protocol(protocol) | [
"def",
"is_valid_for",
"(",
"self",
",",
"entry_point",
",",
"protocol",
")",
":",
"return",
"self",
".",
"available_for_entry_point",
"(",
"entry_point",
")",
"and",
"self",
".",
"available_for_protocol",
"(",
"protocol",
")"
] | Check if the current function can be executed from a request to the given entry point
and with the given protocol | [
"Check",
"if",
"the",
"current",
"function",
"can",
"be",
"executed",
"from",
"a",
"request",
"to",
"the",
"given",
"entry",
"point",
"and",
"with",
"the",
"given",
"protocol"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L208-L211 |
alorence/django-modern-rpc | modernrpc/core.py | RPCMethod.is_return_doc_available | def is_return_doc_available(self):
"""Returns True if this method's return is documented"""
return bool(self.return_doc and (self.return_doc.get('text') or self.return_doc.get('type'))) | python | def is_return_doc_available(self):
"""Returns True if this method's return is documented"""
return bool(self.return_doc and (self.return_doc.get('text') or self.return_doc.get('type'))) | [
"def",
"is_return_doc_available",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"return_doc",
"and",
"(",
"self",
".",
"return_doc",
".",
"get",
"(",
"'text'",
")",
"or",
"self",
".",
"return_doc",
".",
"get",
"(",
"'type'",
")",
")",
")"
... | Returns True if this method's return is documented | [
"Returns",
"True",
"if",
"this",
"method",
"s",
"return",
"is",
"documented"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L228-L230 |
alorence/django-modern-rpc | modernrpc/core.py | _RPCRegistry.register_method | def register_method(self, func):
"""
Register a function to be available as RPC method.
The given function will be inspected to find external_name, protocol and entry_point values set by the decorator
@rpc_method.
:param func: A function previously decorated using @rpc_method
... | python | def register_method(self, func):
"""
Register a function to be available as RPC method.
The given function will be inspected to find external_name, protocol and entry_point values set by the decorator
@rpc_method.
:param func: A function previously decorated using @rpc_method
... | [
"def",
"register_method",
"(",
"self",
",",
"func",
")",
":",
"if",
"not",
"getattr",
"(",
"func",
",",
"'modernrpc_enabled'",
",",
"False",
")",
":",
"raise",
"ImproperlyConfigured",
"(",
"'Error: trying to register {} as RPC method, but it has not been decorated.'",
"... | Register a function to be available as RPC method.
The given function will be inspected to find external_name, protocol and entry_point values set by the decorator
@rpc_method.
:param func: A function previously decorated using @rpc_method
:return: The name of registered method | [
"Register",
"a",
"function",
"to",
"be",
"available",
"as",
"RPC",
"method",
"."
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L249-L291 |
alorence/django-modern-rpc | modernrpc/core.py | _RPCRegistry.get_all_method_names | def get_all_method_names(self, entry_point=ALL, protocol=ALL, sort_methods=False):
"""Return the names of all RPC methods registered supported by the given entry_point / protocol pair"""
method_names = [
name for name, method in self._registry.items() if method.is_valid_for(entry_point, pro... | python | def get_all_method_names(self, entry_point=ALL, protocol=ALL, sort_methods=False):
"""Return the names of all RPC methods registered supported by the given entry_point / protocol pair"""
method_names = [
name for name, method in self._registry.items() if method.is_valid_for(entry_point, pro... | [
"def",
"get_all_method_names",
"(",
"self",
",",
"entry_point",
"=",
"ALL",
",",
"protocol",
"=",
"ALL",
",",
"sort_methods",
"=",
"False",
")",
":",
"method_names",
"=",
"[",
"name",
"for",
"name",
",",
"method",
"in",
"self",
".",
"_registry",
".",
"it... | Return the names of all RPC methods registered supported by the given entry_point / protocol pair | [
"Return",
"the",
"names",
"of",
"all",
"RPC",
"methods",
"registered",
"supported",
"by",
"the",
"given",
"entry_point",
"/",
"protocol",
"pair"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L296-L306 |
alorence/django-modern-rpc | modernrpc/core.py | _RPCRegistry.get_all_methods | def get_all_methods(self, entry_point=ALL, protocol=ALL, sort_methods=False):
"""Return a list of all methods in the registry supported by the given entry_point / protocol pair"""
if sort_methods:
return [
method for (_, method) in sorted(self._registry.items()) if method.is... | python | def get_all_methods(self, entry_point=ALL, protocol=ALL, sort_methods=False):
"""Return a list of all methods in the registry supported by the given entry_point / protocol pair"""
if sort_methods:
return [
method for (_, method) in sorted(self._registry.items()) if method.is... | [
"def",
"get_all_methods",
"(",
"self",
",",
"entry_point",
"=",
"ALL",
",",
"protocol",
"=",
"ALL",
",",
"sort_methods",
"=",
"False",
")",
":",
"if",
"sort_methods",
":",
"return",
"[",
"method",
"for",
"(",
"_",
",",
"method",
")",
"in",
"sorted",
"(... | Return a list of all methods in the registry supported by the given entry_point / protocol pair | [
"Return",
"a",
"list",
"of",
"all",
"methods",
"in",
"the",
"registry",
"supported",
"by",
"the",
"given",
"entry_point",
"/",
"protocol",
"pair"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L308-L316 |
alorence/django-modern-rpc | modernrpc/core.py | _RPCRegistry.get_method | def get_method(self, name, entry_point, protocol):
"""Retrieve a method from the given name"""
if name in self._registry and self._registry[name].is_valid_for(entry_point, protocol):
return self._registry[name]
return None | python | def get_method(self, name, entry_point, protocol):
"""Retrieve a method from the given name"""
if name in self._registry and self._registry[name].is_valid_for(entry_point, protocol):
return self._registry[name]
return None | [
"def",
"get_method",
"(",
"self",
",",
"name",
",",
"entry_point",
",",
"protocol",
")",
":",
"if",
"name",
"in",
"self",
".",
"_registry",
"and",
"self",
".",
"_registry",
"[",
"name",
"]",
".",
"is_valid_for",
"(",
"entry_point",
",",
"protocol",
")",
... | Retrieve a method from the given name | [
"Retrieve",
"a",
"method",
"from",
"the",
"given",
"name"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/core.py#L318-L324 |
alorence/django-modern-rpc | modernrpc/utils.py | logger_has_handlers | def logger_has_handlers(logger):
"""
Check if given logger has at least 1 handler associated, return a boolean value.
Since Python 2 doesn't provide Logger.hasHandlers(), we have to perform the lookup by ourself.
"""
if six.PY3:
return logger.hasHandlers()
else:
c = logger
... | python | def logger_has_handlers(logger):
"""
Check if given logger has at least 1 handler associated, return a boolean value.
Since Python 2 doesn't provide Logger.hasHandlers(), we have to perform the lookup by ourself.
"""
if six.PY3:
return logger.hasHandlers()
else:
c = logger
... | [
"def",
"logger_has_handlers",
"(",
"logger",
")",
":",
"if",
"six",
".",
"PY3",
":",
"return",
"logger",
".",
"hasHandlers",
"(",
")",
"else",
":",
"c",
"=",
"logger",
"rv",
"=",
"False",
"while",
"c",
":",
"if",
"c",
".",
"handlers",
":",
"rv",
"=... | Check if given logger has at least 1 handler associated, return a boolean value.
Since Python 2 doesn't provide Logger.hasHandlers(), we have to perform the lookup by ourself. | [
"Check",
"if",
"given",
"logger",
"has",
"at",
"least",
"1",
"handler",
"associated",
"return",
"a",
"boolean",
"value",
"."
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/utils.py#L17-L36 |
alorence/django-modern-rpc | modernrpc/utils.py | get_modernrpc_logger | def get_modernrpc_logger(name):
"""Get a logger from default logging manager. If no handler is associated, add a default NullHandler"""
logger = logging.getLogger(name)
if not logger_has_handlers(logger):
# If logging is not configured in the current project, configure this logger to discard all log... | python | def get_modernrpc_logger(name):
"""Get a logger from default logging manager. If no handler is associated, add a default NullHandler"""
logger = logging.getLogger(name)
if not logger_has_handlers(logger):
# If logging is not configured in the current project, configure this logger to discard all log... | [
"def",
"get_modernrpc_logger",
"(",
"name",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"if",
"not",
"logger_has_handlers",
"(",
"logger",
")",
":",
"# If logging is not configured in the current project, configure this logger to discard all logs... | Get a logger from default logging manager. If no handler is associated, add a default NullHandler | [
"Get",
"a",
"logger",
"from",
"default",
"logging",
"manager",
".",
"If",
"no",
"handler",
"is",
"associated",
"add",
"a",
"default",
"NullHandler"
] | train | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/utils.py#L39-L47 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.