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_documentation_string stringlengths 1 47.2k | 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... | Removes the nan, negative, and inf values in two numpy arrays | 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 ... | 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... | 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... | Return the user's first name. | 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 = []
... | A list of strings describing `permissions`_ the user has granted your application.
.. _permissions: http://developers.facebook.com/docs/reference/api/permissions/ | 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... | Synchronize ``facebook_username``, ``first_name``, ``middle_name``,
``last_name`` and ``birthday`` with Facebook.
:param graph_data: Optional pre-fetched graph data | 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 | Determine whether the OAuth token has been extended. | 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... | Extend the OAuth token. | 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... | Process the signed request. | 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... | 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, ... | 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):
... | Process the web-based auth request. | 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... | 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... | 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... | 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``... | 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|
... | 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. | 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|... | 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... | 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:
... | 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. | 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:
... | 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. | 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,
... | Cache the return value of a property. | 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 = ... | Proxy for the view referenced in ``FANDJANGO_AUTHORIZATION_DENIED_VIEW``. | 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... | 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. | 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 | Gets the current path, removing specified querstrings | 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... | 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. | 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:
... | 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. | 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... | [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... | 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 ... | 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... | 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
... | 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 ... | 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... | 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... | 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... | 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
... | 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|
... | 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... | 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|
... | 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: ... | 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:... | 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:... | 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... | 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|
... | 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... | 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... | 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... | 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:
... | 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|
... | 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... | 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):
... | 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.
... | 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... | 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| | 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... | 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... | 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|
... | :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... | 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|
... | :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... | 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:
... | :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... | 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... | 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... | 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... | 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|
:... | 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(... | :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... | 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:
... | :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:
... | 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:
... | :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:
... | 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:... | :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... | 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... | :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|
... | 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... | :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... | 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... | :param str table_name: Table name to drop.
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
:raises IOError: |raises_write_permission| | 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... | :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| | 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... | :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... | 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... | :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` | 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.
... | 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|/|... | 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|
... | 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` | 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... | 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.
... | 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... | 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... | 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... | 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... | 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... | .. seealso:: :py:meth:`sqlite3.Connection.rollback` | 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... | .. seealso:: :py:meth:`sqlite3.Connection.commit` | 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... | Commit and close the connection.
.. seealso:: :py:meth:`sqlite3.Connection.close` | 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... | :raises SimpleSQLite.OperationalError: If unable to open database file. | 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... | Extract data type name for each column as SQLite names.
:param tabledata.TableData table_data:
:return: { column_number : column_data_type }
:rtype: dictionary | 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... | :param str name: Table name to validate.
:raises NameValidationError: |raises_validate_table_name| | 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:... | :param str name: Name to validate.
:raises NameValidationError: |raises_validate_attr_name| | 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... | 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... | 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... | 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... | 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_... | :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... | 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... | :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... | 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: ... | 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... | 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... | 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. | 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... | 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:... | 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, ... | 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... | 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()... | Returns True if the given user is in given group | 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) | Returns True if the given user is in at least 1 of the given groups | 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) | Returns True if the given user is in all given groups | 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... | Return the list of handlers to use when receiving RPC requests. | 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 ... | 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 | 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 ... | Update context data with list of RPC methods of the current entry point.
Will be used to display methods documentation page | 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... | Look into each module listed in settings.MODERNRPC_METHODS_MODULES, import each module and register
functions annotated with @rpc_method decorator in the registry | 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... | 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) | 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... | Decorator. Use it to specify a RPC method is available only to logged users | 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)
... | Decorator. Use it to specify a RPC method is available only to logged superusers | 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... | Decorator. Use it to specify a RPC method is available only to logged users with given permissions | 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... | Decorator. Use it to specify a RPC method is available only to logged users with given permissions | 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... | 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... | 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) | For backward compatibility. Use registry.get_all_method_names() instead (with same arguments) | 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) | For backward compatibility. Use registry.get_all_methods() instead (with same arguments) | 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... | 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... | 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... | Methods docstring, as HTML | 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... | 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) | 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) | Check if the current function can be executed from a request defining the given protocol | 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) | Check if the current function can be executed from a request to the given entry point | 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) | Check if the current function can be executed from a request to the given entry point
and with the given protocol | 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'))) | Returns True if this method's return is documented | 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
... | 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 | 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... | Return the names of all RPC methods registered supported by the given entry_point / protocol pair | 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... | Return a list of all methods in the registry supported by the given entry_point / protocol pair | 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 | Retrieve a method from the given name | 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
... | 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. | 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... | Get a logger from default logging manager. If no handler is associated, add a default NullHandler | 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.