repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
opennode/waldur-core
waldur_core/cost_tracking/views.py
PriceListItemViewSet.create
def create(self, request, *args, **kwargs): """ Run **POST** request against */api/price-list-items/* to create new price list item. Customer owner and staff can create price items. Example of request: .. code-block:: http POST /api/price-list-items/ HTTP/1.1 ...
python
def create(self, request, *args, **kwargs): """ Run **POST** request against */api/price-list-items/* to create new price list item. Customer owner and staff can create price items. Example of request: .. code-block:: http POST /api/price-list-items/ HTTP/1.1 ...
[ "def", "create", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "PriceListItemViewSet", ",", "self", ")", ".", "create", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Run **POST** request against */api/price-list-items/* to create new price list item. Customer owner and staff can create price items. Example of request: .. code-block:: http POST /api/price-list-items/ HTTP/1.1 Content-Type: application/json Accept: applic...
[ "Run", "**", "POST", "**", "request", "against", "*", "/", "api", "/", "price", "-", "list", "-", "items", "/", "*", "to", "create", "new", "price", "list", "item", ".", "Customer", "owner", "and", "staff", "can", "create", "price", "items", "." ]
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L79-L101
opennode/waldur-core
waldur_core/cost_tracking/views.py
PriceListItemViewSet.update
def update(self, request, *args, **kwargs): """ Run **PATCH** request against */api/price-list-items/<uuid>/* to update price list item. Only item_type, key value and units can be updated. Only customer owner and staff can update price items. """ return super(PriceListIte...
python
def update(self, request, *args, **kwargs): """ Run **PATCH** request against */api/price-list-items/<uuid>/* to update price list item. Only item_type, key value and units can be updated. Only customer owner and staff can update price items. """ return super(PriceListIte...
[ "def", "update", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "PriceListItemViewSet", ",", "self", ")", ".", "update", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Run **PATCH** request against */api/price-list-items/<uuid>/* to update price list item. Only item_type, key value and units can be updated. Only customer owner and staff can update price items.
[ "Run", "**", "PATCH", "**", "request", "against", "*", "/", "api", "/", "price", "-", "list", "-", "items", "/", "<uuid", ">", "/", "*", "to", "update", "price", "list", "item", ".", "Only", "item_type", "key", "value", "and", "units", "can", "be", ...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L103-L109
opennode/waldur-core
waldur_core/cost_tracking/views.py
PriceListItemViewSet.destroy
def destroy(self, request, *args, **kwargs): """ Run **DELETE** request against */api/price-list-items/<uuid>/* to delete price list item. Only customer owner and staff can delete price items. """ return super(PriceListItemViewSet, self).destroy(request, *args, **kwargs)
python
def destroy(self, request, *args, **kwargs): """ Run **DELETE** request against */api/price-list-items/<uuid>/* to delete price list item. Only customer owner and staff can delete price items. """ return super(PriceListItemViewSet, self).destroy(request, *args, **kwargs)
[ "def", "destroy", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "PriceListItemViewSet", ",", "self", ")", ".", "destroy", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Run **DELETE** request against */api/price-list-items/<uuid>/* to delete price list item. Only customer owner and staff can delete price items.
[ "Run", "**", "DELETE", "**", "request", "against", "*", "/", "api", "/", "price", "-", "list", "-", "items", "/", "<uuid", ">", "/", "*", "to", "delete", "price", "list", "item", ".", "Only", "customer", "owner", "and", "staff", "can", "delete", "pri...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L111-L116
opennode/waldur-core
waldur_core/cost_tracking/views.py
DefaultPriceListItemViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of default price list items, run **GET** against */api/default-price-list-items/* as authenticated user. Price lists can be filtered by: - ?key=<string> - ?item_type=<string> has to be from list of available i...
python
def list(self, request, *args, **kwargs): """ To get a list of default price list items, run **GET** against */api/default-price-list-items/* as authenticated user. Price lists can be filtered by: - ?key=<string> - ?item_type=<string> has to be from list of available i...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "DefaultPriceListItemViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of default price list items, run **GET** against */api/default-price-list-items/* as authenticated user. Price lists can be filtered by: - ?key=<string> - ?item_type=<string> has to be from list of available item_types (available options: 'flavor', 'storage', ...
[ "To", "get", "a", "list", "of", "default", "price", "list", "items", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "default", "-", "price", "-", "list", "-", "items", "/", "*", "as", "authenticated", "user", "." ]
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L139-L150
opennode/waldur-core
waldur_core/cost_tracking/views.py
MergedPriceListItemViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of price list items, run **GET** against */api/merged-price-list-items/* as authenticated user. If service is not specified default price list items are displayed. Otherwise service specific price list items are display...
python
def list(self, request, *args, **kwargs): """ To get a list of price list items, run **GET** against */api/merged-price-list-items/* as authenticated user. If service is not specified default price list items are displayed. Otherwise service specific price list items are display...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "MergedPriceListItemViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of price list items, run **GET** against */api/merged-price-list-items/* as authenticated user. If service is not specified default price list items are displayed. Otherwise service specific price list items are displayed. In this case rendered object contains {"is_manuall...
[ "To", "get", "a", "list", "of", "price", "list", "items", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "merged", "-", "price", "-", "list", "-", "items", "/", "*", "as", "authenticated", "user", "." ]
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L158-L173
deathbeds/importnb
src/importnb/remote.py
Remote
def Remote(path=None, loader=Notebook, **globals): """A remote notebook finder. Place a `*` into a url to generalize the finder. It returns a context manager """ class Remote(RemoteMixin, loader): ... return Remote(path=path, **globals)
python
def Remote(path=None, loader=Notebook, **globals): """A remote notebook finder. Place a `*` into a url to generalize the finder. It returns a context manager """ class Remote(RemoteMixin, loader): ... return Remote(path=path, **globals)
[ "def", "Remote", "(", "path", "=", "None", ",", "loader", "=", "Notebook", ",", "*", "*", "globals", ")", ":", "class", "Remote", "(", "RemoteMixin", ",", "loader", ")", ":", "...", "return", "Remote", "(", "path", "=", "path", ",", "*", "*", "glob...
A remote notebook finder. Place a `*` into a url to generalize the finder. It returns a context manager
[ "A", "remote", "notebook", "finder", ".", "Place", "a", "*", "into", "a", "url", "to", "generalize", "the", "finder", ".", "It", "returns", "a", "context", "manager" ]
train
https://github.com/deathbeds/importnb/blob/ec870d1f8ab99fd5b363267f89787a3e442a779f/src/importnb/remote.py#L88-L96
opennode/waldur-core
waldur_core/core/permissions.py
ActionsPermission.get_permission_checks
def get_permission_checks(self, request, view): """ Get permission checks that will be executed for current action. """ if view.action is None: return [] # if permissions are defined for view directly - use them. if hasattr(view, view.action + '_permissions'):...
python
def get_permission_checks(self, request, view): """ Get permission checks that will be executed for current action. """ if view.action is None: return [] # if permissions are defined for view directly - use them. if hasattr(view, view.action + '_permissions'):...
[ "def", "get_permission_checks", "(", "self", ",", "request", ",", "view", ")", ":", "if", "view", ".", "action", "is", "None", ":", "return", "[", "]", "# if permissions are defined for view directly - use them.", "if", "hasattr", "(", "view", ",", "view", ".", ...
Get permission checks that will be executed for current action.
[ "Get", "permission", "checks", "that", "will", "be", "executed", "for", "current", "action", "." ]
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/permissions.py#L61-L75
stepank/pyws
src/pyws/server.py
Server.add_function
def add_function(self, function): """ Registers the function to the server's default fixed function manager. """ #noinspection PyTypeChecker if not len(self.settings.FUNCTION_MANAGERS): raise ConfigurationError( 'Where have the default function manager...
python
def add_function(self, function): """ Registers the function to the server's default fixed function manager. """ #noinspection PyTypeChecker if not len(self.settings.FUNCTION_MANAGERS): raise ConfigurationError( 'Where have the default function manager...
[ "def", "add_function", "(", "self", ",", "function", ")", ":", "#noinspection PyTypeChecker", "if", "not", "len", "(", "self", ".", "settings", ".", "FUNCTION_MANAGERS", ")", ":", "raise", "ConfigurationError", "(", "'Where have the default function manager gone?!'", ...
Registers the function to the server's default fixed function manager.
[ "Registers", "the", "function", "to", "the", "server", "s", "default", "fixed", "function", "manager", "." ]
train
https://github.com/stepank/pyws/blob/ff39133aabeb56bbb08d66286ac0cc8731eda7dd/src/pyws/server.py#L117-L125
opennode/waldur-core
waldur_core/logging/filters.py
format_raw_field
def format_raw_field(key): """ When ElasticSearch analyzes string, it breaks it into parts. In order make query for not-analyzed exact string values, we should use subfield instead. The index template for Elasticsearch 5.0 has been changed. The subfield for string multi-fields has changed from .raw...
python
def format_raw_field(key): """ When ElasticSearch analyzes string, it breaks it into parts. In order make query for not-analyzed exact string values, we should use subfield instead. The index template for Elasticsearch 5.0 has been changed. The subfield for string multi-fields has changed from .raw...
[ "def", "format_raw_field", "(", "key", ")", ":", "subfield", "=", "django_settings", ".", "WALDUR_CORE", ".", "get", "(", "'ELASTICSEARCH'", ",", "{", "}", ")", ".", "get", "(", "'raw_subfield'", ",", "'keyword'", ")", "return", "'%s.%s'", "%", "(", "camel...
When ElasticSearch analyzes string, it breaks it into parts. In order make query for not-analyzed exact string values, we should use subfield instead. The index template for Elasticsearch 5.0 has been changed. The subfield for string multi-fields has changed from .raw to .keyword Thus workaround for b...
[ "When", "ElasticSearch", "analyzes", "string", "it", "breaks", "it", "into", "parts", ".", "In", "order", "make", "query", "for", "not", "-", "analyzed", "exact", "string", "values", "we", "should", "use", "subfield", "instead", "." ]
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/filters.py#L20-L32
quora/qcore
qcore/decorators.py
decorate
def decorate(decorator_cls, *args, **kwargs): """Creates a decorator function that applies the decorator_cls that was passed in.""" global _wrappers wrapper_cls = _wrappers.get(decorator_cls, None) if wrapper_cls is None: class PythonWrapper(decorator_cls): pass wrapper_cl...
python
def decorate(decorator_cls, *args, **kwargs): """Creates a decorator function that applies the decorator_cls that was passed in.""" global _wrappers wrapper_cls = _wrappers.get(decorator_cls, None) if wrapper_cls is None: class PythonWrapper(decorator_cls): pass wrapper_cl...
[ "def", "decorate", "(", "decorator_cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "global", "_wrappers", "wrapper_cls", "=", "_wrappers", ".", "get", "(", "decorator_cls", ",", "None", ")", "if", "wrapper_cls", "is", "None", ":", "class", "Py...
Creates a decorator function that applies the decorator_cls that was passed in.
[ "Creates", "a", "decorator", "function", "that", "applies", "the", "decorator_cls", "that", "was", "passed", "in", "." ]
train
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L160-L179
quora/qcore
qcore/decorators.py
deprecated
def deprecated(replacement_description): """States that method is deprecated. :param replacement_description: Describes what must be used instead. :return: the original method with modified docstring. """ def decorate(fn_or_class): if isinstance(fn_or_class, type): pass # Can...
python
def deprecated(replacement_description): """States that method is deprecated. :param replacement_description: Describes what must be used instead. :return: the original method with modified docstring. """ def decorate(fn_or_class): if isinstance(fn_or_class, type): pass # Can...
[ "def", "deprecated", "(", "replacement_description", ")", ":", "def", "decorate", "(", "fn_or_class", ")", ":", "if", "isinstance", "(", "fn_or_class", ",", "type", ")", ":", "pass", "# Can't change __doc__ of type objects", "else", ":", "try", ":", "fn_or_class",...
States that method is deprecated. :param replacement_description: Describes what must be used instead. :return: the original method with modified docstring.
[ "States", "that", "method", "is", "deprecated", "." ]
train
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L182-L203
quora/qcore
qcore/decorators.py
convert_result
def convert_result(converter): """Decorator that can convert the result of a function call.""" def decorate(fn): @inspection.wraps(fn) def new_fn(*args, **kwargs): return converter(fn(*args, **kwargs)) return new_fn return decorate
python
def convert_result(converter): """Decorator that can convert the result of a function call.""" def decorate(fn): @inspection.wraps(fn) def new_fn(*args, **kwargs): return converter(fn(*args, **kwargs)) return new_fn return decorate
[ "def", "convert_result", "(", "converter", ")", ":", "def", "decorate", "(", "fn", ")", ":", "@", "inspection", ".", "wraps", "(", "fn", ")", "def", "new_fn", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "converter", "(", "fn", "(...
Decorator that can convert the result of a function call.
[ "Decorator", "that", "can", "convert", "the", "result", "of", "a", "function", "call", "." ]
train
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L206-L216
quora/qcore
qcore/decorators.py
retry
def retry(exception_cls, max_tries=10, sleep=0.05): """Decorator for retrying a function if it throws an exception. :param exception_cls: an exception type or a parenthesized tuple of exception types :param max_tries: maximum number of times this function can be executed. Must be at least 1. :param sle...
python
def retry(exception_cls, max_tries=10, sleep=0.05): """Decorator for retrying a function if it throws an exception. :param exception_cls: an exception type or a parenthesized tuple of exception types :param max_tries: maximum number of times this function can be executed. Must be at least 1. :param sle...
[ "def", "retry", "(", "exception_cls", ",", "max_tries", "=", "10", ",", "sleep", "=", "0.05", ")", ":", "assert", "max_tries", ">", "0", "def", "with_max_retries_call", "(", "delegate", ")", ":", "for", "i", "in", "xrange", "(", "0", ",", "max_tries", ...
Decorator for retrying a function if it throws an exception. :param exception_cls: an exception type or a parenthesized tuple of exception types :param max_tries: maximum number of times this function can be executed. Must be at least 1. :param sleep: number of seconds to sleep between function retries
[ "Decorator", "for", "retrying", "a", "function", "if", "it", "throws", "an", "exception", "." ]
train
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L219-L274
quora/qcore
qcore/decorators.py
decorator_of_context_manager
def decorator_of_context_manager(ctxt): """Converts a context manager into a decorator. This decorator will run the decorated function in the context of the manager. :param ctxt: Context to run the function in. :return: Wrapper around the original function. """ def decorator_fn(*outer_ar...
python
def decorator_of_context_manager(ctxt): """Converts a context manager into a decorator. This decorator will run the decorated function in the context of the manager. :param ctxt: Context to run the function in. :return: Wrapper around the original function. """ def decorator_fn(*outer_ar...
[ "def", "decorator_of_context_manager", "(", "ctxt", ")", ":", "def", "decorator_fn", "(", "*", "outer_args", ",", "*", "*", "outer_kwargs", ")", ":", "def", "decorator", "(", "fn", ")", ":", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "wrapper...
Converts a context manager into a decorator. This decorator will run the decorated function in the context of the manager. :param ctxt: Context to run the function in. :return: Wrapper around the original function.
[ "Converts", "a", "context", "manager", "into", "a", "decorator", "." ]
train
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L277-L304
stepank/pyws
src/pyws/protocols/base.py
Protocol.get_error
def get_error(self, error): """ A helper function, gets standard information from the error. """ error_type = type(error) if error.error_type == ET_CLIENT: error_type_name = 'Client' else: error_type_name = 'Server' return { 'ty...
python
def get_error(self, error): """ A helper function, gets standard information from the error. """ error_type = type(error) if error.error_type == ET_CLIENT: error_type_name = 'Client' else: error_type_name = 'Server' return { 'ty...
[ "def", "get_error", "(", "self", ",", "error", ")", ":", "error_type", "=", "type", "(", "error", ")", "if", "error", ".", "error_type", "==", "ET_CLIENT", ":", "error_type_name", "=", "'Client'", "else", ":", "error_type_name", "=", "'Server'", "return", ...
A helper function, gets standard information from the error.
[ "A", "helper", "function", "gets", "standard", "information", "from", "the", "error", "." ]
train
https://github.com/stepank/pyws/blob/ff39133aabeb56bbb08d66286ac0cc8731eda7dd/src/pyws/protocols/base.py#L66-L81
opennode/waldur-core
waldur_core/quotas/models.py
QuotaModelMixin.validate_quota_change
def validate_quota_change(self, quota_deltas, raise_exception=False): """ Get error messages about object and his ancestor quotas that will be exceeded if quota_delta will be added. raise_exception - if True QuotaExceededException will be raised if validation fails quota_deltas - dictio...
python
def validate_quota_change(self, quota_deltas, raise_exception=False): """ Get error messages about object and his ancestor quotas that will be exceeded if quota_delta will be added. raise_exception - if True QuotaExceededException will be raised if validation fails quota_deltas - dictio...
[ "def", "validate_quota_change", "(", "self", ",", "quota_deltas", ",", "raise_exception", "=", "False", ")", ":", "errors", "=", "[", "]", "for", "name", ",", "delta", "in", "six", ".", "iteritems", "(", "quota_deltas", ")", ":", "quota", "=", "self", "....
Get error messages about object and his ancestor quotas that will be exceeded if quota_delta will be added. raise_exception - if True QuotaExceededException will be raised if validation fails quota_deltas - dictionary of quotas deltas, example: { 'ram': 1024, 'storage': ...
[ "Get", "error", "messages", "about", "object", "and", "his", "ancestor", "quotas", "that", "will", "be", "exceeded", "if", "quota_delta", "will", "be", "added", "." ]
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/quotas/models.py#L186-L211
opennode/waldur-core
waldur_core/quotas/models.py
QuotaModelMixin.get_sum_of_quotas_as_dict
def get_sum_of_quotas_as_dict(cls, scopes, quota_names=None, fields=['usage', 'limit']): """ Return dictionary with sum of all scopes' quotas. Dictionary format: { 'quota_name1': 'sum of limits for quotas with such quota_name1', 'quota_name1_usage': 'sum of usage...
python
def get_sum_of_quotas_as_dict(cls, scopes, quota_names=None, fields=['usage', 'limit']): """ Return dictionary with sum of all scopes' quotas. Dictionary format: { 'quota_name1': 'sum of limits for quotas with such quota_name1', 'quota_name1_usage': 'sum of usage...
[ "def", "get_sum_of_quotas_as_dict", "(", "cls", ",", "scopes", ",", "quota_names", "=", "None", ",", "fields", "=", "[", "'usage'", ",", "'limit'", "]", ")", ":", "if", "not", "scopes", ":", "return", "{", "}", "if", "quota_names", "is", "None", ":", "...
Return dictionary with sum of all scopes' quotas. Dictionary format: { 'quota_name1': 'sum of limits for quotas with such quota_name1', 'quota_name1_usage': 'sum of usages for quotas with such quota_name1', ... } All `scopes` have to be instances of t...
[ "Return", "dictionary", "with", "sum", "of", "all", "scopes", "quotas", "." ]
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/quotas/models.py#L220-L270
opennode/waldur-core
waldur_core/logging/views.py
EventViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of events - run **GET** against */api/events/* as authenticated user. Note that a user can only see events connected to objects she is allowed to see. Sorting is supported in ascending and descending order by specifying a field...
python
def list(self, request, *args, **kwargs): """ To get a list of events - run **GET** against */api/events/* as authenticated user. Note that a user can only see events connected to objects she is allowed to see. Sorting is supported in ascending and descending order by specifying a field...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "queryset", "=", "self", ".", "filter_queryset", "(", "self", ".", "get_queryset", "(", ")", ")", "page", "=", "self", ".", "paginate_querys...
To get a list of events - run **GET** against */api/events/* as authenticated user. Note that a user can only see events connected to objects she is allowed to see. Sorting is supported in ascending and descending order by specifying a field to an **?o=** parameter. By default events are sorted...
[ "To", "get", "a", "list", "of", "events", "-", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "events", "/", "*", "as", "authenticated", "user", ".", "Note", "that", "a", "user", "can", "only", "see", "events", "connected", "to", "objects...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L23-L60
opennode/waldur-core
waldur_core/logging/views.py
EventViewSet.count
def count(self, request, *args, **kwargs): """ To get a count of events - run **GET** against */api/events/count/* as authenticated user. Endpoint support same filters as events list. Response example: .. code-block:: javascript {"count": 12321} """ ...
python
def count(self, request, *args, **kwargs): """ To get a count of events - run **GET** against */api/events/count/* as authenticated user. Endpoint support same filters as events list. Response example: .. code-block:: javascript {"count": 12321} """ ...
[ "def", "count", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "queryset", "=", "self", ".", "filter_queryset", "(", "self", ".", "get_queryset", "(", ")", ")", "return", "response", ".", "Response", "(...
To get a count of events - run **GET** against */api/events/count/* as authenticated user. Endpoint support same filters as events list. Response example: .. code-block:: javascript {"count": 12321}
[ "To", "get", "a", "count", "of", "events", "-", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "events", "/", "count", "/", "*", "as", "authenticated", "user", ".", "Endpoint", "support", "same", "filters", "as", "events", "list", "." ]
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L78-L91
opennode/waldur-core
waldur_core/logging/views.py
EventViewSet.count_history
def count_history(self, request, *args, **kwargs): """ To get a historical data of events amount - run **GET** against */api/events/count/history/*. Endpoint support same filters as events list. More about historical data - read at section *Historical data*. Response example: ...
python
def count_history(self, request, *args, **kwargs): """ To get a historical data of events amount - run **GET** against */api/events/count/history/*. Endpoint support same filters as events list. More about historical data - read at section *Historical data*. Response example: ...
[ "def", "count_history", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "queryset", "=", "self", ".", "filter_queryset", "(", "self", ".", "get_queryset", "(", ")", ")", "mapped", "=", "{", "'start'", ":", "request", ...
To get a historical data of events amount - run **GET** against */api/events/count/history/*. Endpoint support same filters as events list. More about historical data - read at section *Historical data*. Response example: .. code-block:: javascript [ { ...
[ "To", "get", "a", "historical", "data", "of", "events", "amount", "-", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "events", "/", "count", "/", "history", "/", "*", ".", "Endpoint", "support", "same", "filters", "as", "events", "list", ...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L94-L129
opennode/waldur-core
waldur_core/logging/views.py
EventViewSet.scope_types
def scope_types(self, request, *args, **kwargs): """ Returns a list of scope types acceptable by events filter. """ return response.Response(utils.get_scope_types_mapping().keys())
python
def scope_types(self, request, *args, **kwargs): """ Returns a list of scope types acceptable by events filter. """ return response.Response(utils.get_scope_types_mapping().keys())
[ "def", "scope_types", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "response", ".", "Response", "(", "utils", ".", "get_scope_types_mapping", "(", ")", ".", "keys", "(", ")", ")" ]
Returns a list of scope types acceptable by events filter.
[ "Returns", "a", "list", "of", "scope", "types", "acceptable", "by", "events", "filter", "." ]
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L132-L134
opennode/waldur-core
waldur_core/logging/views.py
AlertViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of alerts, run **GET** against */api/alerts/* as authenticated user. Alert severity field can take one of this values: "Error", "Warning", "Info", "Debug". Field scope will contain link to object that cause alert. Conte...
python
def list(self, request, *args, **kwargs): """ To get a list of alerts, run **GET** against */api/alerts/* as authenticated user. Alert severity field can take one of this values: "Error", "Warning", "Info", "Debug". Field scope will contain link to object that cause alert. Conte...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "AlertViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of alerts, run **GET** against */api/alerts/* as authenticated user. Alert severity field can take one of this values: "Error", "Warning", "Info", "Debug". Field scope will contain link to object that cause alert. Context - dictionary that contains information about all related to...
[ "To", "get", "a", "list", "of", "alerts", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "alerts", "/", "*", "as", "authenticated", "user", "." ]
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L161-L230
opennode/waldur-core
waldur_core/logging/views.py
AlertViewSet.create
def create(self, request, *args, **kwargs): """ Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and alert_type already exists - it will be updated. Only users with staff privileges can create alerts. Request example: .. code-block:: jav...
python
def create(self, request, *args, **kwargs): """ Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and alert_type already exists - it will be updated. Only users with staff privileges can create alerts. Request example: .. code-block:: jav...
[ "def", "create", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "AlertViewSet", ",", "self", ")", ".", "create", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and alert_type already exists - it will be updated. Only users with staff privileges can create alerts. Request example: .. code-block:: javascript POST /api/alerts/ Accept: appli...
[ "Run", "**", "POST", "**", "against", "*", "/", "api", "/", "alerts", "/", "*", "to", "create", "or", "update", "alert", ".", "If", "alert", "with", "posted", "scope", "and", "alert_type", "already", "exists", "-", "it", "will", "be", "updated", ".", ...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L232-L254
opennode/waldur-core
waldur_core/logging/views.py
AlertViewSet.close
def close(self, request, *args, **kwargs): """ To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required. Only users with staff privileges can close alerts. """ if not request.user.is_staff: raise PermissionDenied() alert = s...
python
def close(self, request, *args, **kwargs): """ To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required. Only users with staff privileges can close alerts. """ if not request.user.is_staff: raise PermissionDenied() alert = s...
[ "def", "close", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "request", ".", "user", ".", "is_staff", ":", "raise", "PermissionDenied", "(", ")", "alert", "=", "self", ".", "get_object", "(", ")", "...
To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required. Only users with staff privileges can close alerts.
[ "To", "close", "alert", "-", "run", "**", "POST", "**", "against", "*", "/", "api", "/", "alerts", "/", "<alert_uuid", ">", "/", "close", "/", "*", ".", "No", "data", "is", "required", ".", "Only", "users", "with", "staff", "privileges", "can", "clos...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L257-L267
opennode/waldur-core
waldur_core/logging/views.py
AlertViewSet.acknowledge
def acknowledge(self, request, *args, **kwargs): """ To acknowledge alert - run **POST** against */api/alerts/<alert_uuid>/acknowledge/*. No payload is required. All users that can see alerts can also acknowledge it. If alert is already acknowledged endpoint will return error with code 4...
python
def acknowledge(self, request, *args, **kwargs): """ To acknowledge alert - run **POST** against */api/alerts/<alert_uuid>/acknowledge/*. No payload is required. All users that can see alerts can also acknowledge it. If alert is already acknowledged endpoint will return error with code 4...
[ "def", "acknowledge", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "alert", "=", "self", ".", "get_object", "(", ")", "if", "not", "alert", ".", "acknowledged", ":", "alert", ".", "acknowledge", "(", ")", "return"...
To acknowledge alert - run **POST** against */api/alerts/<alert_uuid>/acknowledge/*. No payload is required. All users that can see alerts can also acknowledge it. If alert is already acknowledged endpoint will return error with code 409(conflict).
[ "To", "acknowledge", "alert", "-", "run", "**", "POST", "**", "against", "*", "/", "api", "/", "alerts", "/", "<alert_uuid", ">", "/", "acknowledge", "/", "*", ".", "No", "payload", "is", "required", ".", "All", "users", "that", "can", "see", "alerts",...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L270-L281
opennode/waldur-core
waldur_core/logging/views.py
AlertViewSet.stats
def stats(self, request, *args, **kwargs): """ To get count of alerts per severities - run **GET** request against */api/alerts/stats/*. This endpoint supports all filters that are available for alerts list (*/api/alerts/*). Response example: .. code-block:: javascript ...
python
def stats(self, request, *args, **kwargs): """ To get count of alerts per severities - run **GET** request against */api/alerts/stats/*. This endpoint supports all filters that are available for alerts list (*/api/alerts/*). Response example: .. code-block:: javascript ...
[ "def", "stats", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "queryset", "=", "self", ".", "filter_queryset", "(", "self", ".", "get_queryset", "(", ")", ")", "alerts_severities_count", "=", "queryset", ".", "values",...
To get count of alerts per severities - run **GET** request against */api/alerts/stats/*. This endpoint supports all filters that are available for alerts list (*/api/alerts/*). Response example: .. code-block:: javascript { "debug": 2, "error": 1, ...
[ "To", "get", "count", "of", "alerts", "per", "severities", "-", "run", "**", "GET", "**", "request", "against", "*", "/", "api", "/", "alerts", "/", "stats", "/", "*", ".", "This", "endpoint", "supports", "all", "filters", "that", "are", "available", "...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L298-L325
opennode/waldur-core
waldur_core/logging/views.py
WebHookViewSet.create
def create(self, request, *args, **kwargs): """ To create new web hook issue **POST** against */api/hooks-web/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-web/ HTTP/1....
python
def create(self, request, *args, **kwargs): """ To create new web hook issue **POST** against */api/hooks-web/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-web/ HTTP/1....
[ "def", "create", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "WebHookViewSet", ",", "self", ")", ".", "create", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To create new web hook issue **POST** against */api/hooks-web/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-web/ HTTP/1.1 Content-Type: application/json Accept:...
[ "To", "create", "new", "web", "hook", "issue", "**", "POST", "**", "against", "*", "/", "api", "/", "hooks", "-", "web", "/", "*", "as", "an", "authenticated", "user", ".", "You", "should", "specify", "list", "of", "event_types", "or", "event_groups", ...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L356-L401
opennode/waldur-core
waldur_core/logging/views.py
EmailHookViewSet.create
def create(self, request, *args, **kwargs): """ To create new email hook issue **POST** against */api/hooks-email/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-email/ H...
python
def create(self, request, *args, **kwargs): """ To create new email hook issue **POST** against */api/hooks-email/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-email/ H...
[ "def", "create", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "EmailHookViewSet", ",", "self", ")", ".", "create", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To create new email hook issue **POST** against */api/hooks-email/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-email/ HTTP/1.1 Content-Type: application/json A...
[ "To", "create", "new", "email", "hook", "issue", "**", "POST", "**", "against", "*", "/", "api", "/", "hooks", "-", "email", "/", "*", "as", "an", "authenticated", "user", ".", "You", "should", "specify", "list", "of", "event_types", "or", "event_groups"...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L409-L438
opennode/waldur-core
waldur_core/logging/views.py
PushHookViewSet.create
def create(self, request, *args, **kwargs): """ To create new push hook issue **POST** against */api/hooks-push/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-push/ HTTP...
python
def create(self, request, *args, **kwargs): """ To create new push hook issue **POST** against */api/hooks-push/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-push/ HTTP...
[ "def", "create", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "PushHookViewSet", ",", "self", ")", ".", "create", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To create new push hook issue **POST** against */api/hooks-push/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-push/ HTTP/1.1 Content-Type: application/json Acce...
[ "To", "create", "new", "push", "hook", "issue", "**", "POST", "**", "against", "*", "/", "api", "/", "hooks", "-", "push", "/", "*", "as", "an", "authenticated", "user", ".", "You", "should", "specify", "list", "of", "event_types", "or", "event_groups", ...
train
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L446-L475
alexras/pylsdj
pylsdj/instruments.py
Instruments.import_from_file
def import_from_file(self, index, filename): """Import this instrument's settings from the given file. Will automatically add the instrument's synth and table to the song's synths and tables if needed. Note that this may invalidate existing instrument accessor objects. :param i...
python
def import_from_file(self, index, filename): """Import this instrument's settings from the given file. Will automatically add the instrument's synth and table to the song's synths and tables if needed. Note that this may invalidate existing instrument accessor objects. :param i...
[ "def", "import_from_file", "(", "self", ",", "index", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "fp", ":", "self", ".", "_import_from_struct", "(", "index", ",", "json", ".", "load", "(", "fp", ")", ")" ]
Import this instrument's settings from the given file. Will automatically add the instrument's synth and table to the song's synths and tables if needed. Note that this may invalidate existing instrument accessor objects. :param index: the index into which to import :param fil...
[ "Import", "this", "instrument", "s", "settings", "from", "the", "given", "file", ".", "Will", "automatically", "add", "the", "instrument", "s", "synth", "and", "table", "to", "the", "song", "s", "synths", "and", "tables", "if", "needed", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instruments.py#L63-L80
alexras/pylsdj
pylsdj/project.py
load_lsdsng
def load_lsdsng(filename): """Load a Project from a ``.lsdsng`` file. :param filename: the name of the file from which to load :rtype: :py:class:`pylsdj.Project` """ # Load preamble data so that we know the name and version of the song with open(filename, 'rb') as fp: preamble_data = b...
python
def load_lsdsng(filename): """Load a Project from a ``.lsdsng`` file. :param filename: the name of the file from which to load :rtype: :py:class:`pylsdj.Project` """ # Load preamble data so that we know the name and version of the song with open(filename, 'rb') as fp: preamble_data = b...
[ "def", "load_lsdsng", "(", "filename", ")", ":", "# Load preamble data so that we know the name and version of the song", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "fp", ":", "preamble_data", "=", "bread", ".", "parse", "(", "fp", ",", "spec", ".", ...
Load a Project from a ``.lsdsng`` file. :param filename: the name of the file from which to load :rtype: :py:class:`pylsdj.Project`
[ "Load", "a", "Project", "from", "a", ".", "lsdsng", "file", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L10-L52
alexras/pylsdj
pylsdj/project.py
load_srm
def load_srm(filename): """Load a Project from an ``.srm`` file. :param filename: the name of the file from which to load :rtype: :py:class:`pylsdj.Project` """ # .srm files are just decompressed projects without headers # In order to determine the file's size in compressed blocks, we have to...
python
def load_srm(filename): """Load a Project from an ``.srm`` file. :param filename: the name of the file from which to load :rtype: :py:class:`pylsdj.Project` """ # .srm files are just decompressed projects without headers # In order to determine the file's size in compressed blocks, we have to...
[ "def", "load_srm", "(", "filename", ")", ":", "# .srm files are just decompressed projects without headers", "# In order to determine the file's size in compressed blocks, we have to", "# compress it first", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "fp", ":", "r...
Load a Project from an ``.srm`` file. :param filename: the name of the file from which to load :rtype: :py:class:`pylsdj.Project`
[ "Load", "a", "Project", "from", "an", ".", "srm", "file", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L55-L82
alexras/pylsdj
pylsdj/project.py
Project.song
def song(self): """the song associated with the project""" if self._song is None: self._song = Song(self._song_data) return self._song
python
def song(self): """the song associated with the project""" if self._song is None: self._song = Song(self._song_data) return self._song
[ "def", "song", "(", "self", ")", ":", "if", "self", ".", "_song", "is", "None", ":", "self", ".", "_song", "=", "Song", "(", "self", ".", "_song_data", ")", "return", "self", ".", "_song" ]
the song associated with the project
[ "the", "song", "associated", "with", "the", "project" ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L119-L124
alexras/pylsdj
pylsdj/project.py
Project.save
def save(self, filename): """Save a project in .lsdsng format to the target file. :param filename: the name of the file to which to save :deprecated: use ``save_lsdsng(filename)`` instead """ with open(filename, 'wb') as fp: writer = BlockWriter() factor...
python
def save(self, filename): """Save a project in .lsdsng format to the target file. :param filename: the name of the file to which to save :deprecated: use ``save_lsdsng(filename)`` instead """ with open(filename, 'wb') as fp: writer = BlockWriter() factor...
[ "def", "save", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "fp", ":", "writer", "=", "BlockWriter", "(", ")", "factory", "=", "BlockFactory", "(", ")", "preamble_dummy_bytes", "=", "bytearray", "(", ...
Save a project in .lsdsng format to the target file. :param filename: the name of the file to which to save :deprecated: use ``save_lsdsng(filename)`` instead
[ "Save", "a", "project", "in", ".", "lsdsng", "format", "to", "the", "target", "file", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L133-L159
alexras/pylsdj
pylsdj/project.py
Project.save_srm
def save_srm(self, filename): """Save a project in .srm format to the target file. :param filename: the name of the file to which to save """ with open(filename, 'wb') as fp: raw_data = bread.write(self._song_data, spec.song) fp.write(raw_data)
python
def save_srm(self, filename): """Save a project in .srm format to the target file. :param filename: the name of the file to which to save """ with open(filename, 'wb') as fp: raw_data = bread.write(self._song_data, spec.song) fp.write(raw_data)
[ "def", "save_srm", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "fp", ":", "raw_data", "=", "bread", ".", "write", "(", "self", ".", "_song_data", ",", "spec", ".", "song", ")", "fp", ".", "write"...
Save a project in .srm format to the target file. :param filename: the name of the file to which to save
[ "Save", "a", "project", "in", ".", "srm", "format", "to", "the", "target", "file", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L168-L175
alexras/pylsdj
pylsdj/synth.py
Synth.phase_type
def phase_type(self, value): '''compresses the waveform horizontally; one of ``"normal"``, ``"resync"``, ``"resync2"``''' self._params.phase_type = value self._overwrite_lock.disable()
python
def phase_type(self, value): '''compresses the waveform horizontally; one of ``"normal"``, ``"resync"``, ``"resync2"``''' self._params.phase_type = value self._overwrite_lock.disable()
[ "def", "phase_type", "(", "self", ",", "value", ")", ":", "self", ".", "_params", ".", "phase_type", "=", "value", "self", ".", "_overwrite_lock", ".", "disable", "(", ")" ]
compresses the waveform horizontally; one of ``"normal"``, ``"resync"``, ``"resync2"``
[ "compresses", "the", "waveform", "horizontally", ";", "one", "of", "normal", "resync", "resync2" ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/synth.py#L186-L190
alexras/pylsdj
pylsdj/savfile.py
SAVFile.project_list
def project_list(self): """The list of :py:class:`pylsdj.Project` s that the .sav file contains""" return [(i, self.projects[i]) for i in sorted(self.projects.keys())]
python
def project_list(self): """The list of :py:class:`pylsdj.Project` s that the .sav file contains""" return [(i, self.projects[i]) for i in sorted(self.projects.keys())]
[ "def", "project_list", "(", "self", ")", ":", "return", "[", "(", "i", ",", "self", ".", "projects", "[", "i", "]", ")", "for", "i", "in", "sorted", "(", "self", ".", "projects", ".", "keys", "(", ")", ")", "]" ]
The list of :py:class:`pylsdj.Project` s that the .sav file contains
[ "The", "list", "of", ":", "py", ":", "class", ":", "pylsdj", ".", "Project", "s", "that", "the", ".", "sav", "file", "contains" ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/savfile.py#L207-L210
alexras/pylsdj
pylsdj/savfile.py
SAVFile.save
def save(self, filename, callback=_noop_callback): """Save this file. :param filename: the file to which to save the .sav file :type filename: str :param callback: a progress callback function :type callback: function """ with open(filename, 'wb') as fp: ...
python
def save(self, filename, callback=_noop_callback): """Save this file. :param filename: the file to which to save the .sav file :type filename: str :param callback: a progress callback function :type callback: function """ with open(filename, 'wb') as fp: ...
[ "def", "save", "(", "self", ",", "filename", ",", "callback", "=", "_noop_callback", ")", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "fp", ":", "self", ".", "_save", "(", "fp", ",", "callback", ")" ]
Save this file. :param filename: the file to which to save the .sav file :type filename: str :param callback: a progress callback function :type callback: function
[ "Save", "this", "file", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/savfile.py#L312-L321
alexras/pylsdj
pylsdj/filepack.py
split
def split(compressed_data, segment_size, block_factory): """Splits compressed data into blocks. :param compressed_data: the compressed data to split :param segment_size: the size of a block in bytes :param block_factory: a BlockFactory used to construct the blocks :rtype: a list of block IDs of bl...
python
def split(compressed_data, segment_size, block_factory): """Splits compressed data into blocks. :param compressed_data: the compressed data to split :param segment_size: the size of a block in bytes :param block_factory: a BlockFactory used to construct the blocks :rtype: a list of block IDs of bl...
[ "def", "split", "(", "compressed_data", ",", "segment_size", ",", "block_factory", ")", ":", "# Split compressed data into blocks", "segments", "=", "[", "]", "current_segment_start", "=", "0", "index", "=", "0", "data_size", "=", "len", "(", "compressed_data", ")...
Splits compressed data into blocks. :param compressed_data: the compressed data to split :param segment_size: the size of a block in bytes :param block_factory: a BlockFactory used to construct the blocks :rtype: a list of block IDs of blocks that the block factory created while splitting
[ "Splits", "compressed", "data", "into", "blocks", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L46-L138
alexras/pylsdj
pylsdj/filepack.py
renumber_block_keys
def renumber_block_keys(blocks): """Renumber a block map's indices so that tehy match the blocks' block switch statements. :param blocks a block map to renumber :rtype: a renumbered copy of the block map """ # There is an implicit block switch to the 0th block at the start of the # file ...
python
def renumber_block_keys(blocks): """Renumber a block map's indices so that tehy match the blocks' block switch statements. :param blocks a block map to renumber :rtype: a renumbered copy of the block map """ # There is an implicit block switch to the 0th block at the start of the # file ...
[ "def", "renumber_block_keys", "(", "blocks", ")", ":", "# There is an implicit block switch to the 0th block at the start of the", "# file", "byte_switch_keys", "=", "[", "0", "]", "block_keys", "=", "list", "(", "blocks", ".", "keys", "(", ")", ")", "# Scan the blocks,...
Renumber a block map's indices so that tehy match the blocks' block switch statements. :param blocks a block map to renumber :rtype: a renumbered copy of the block map
[ "Renumber", "a", "block", "map", "s", "indices", "so", "that", "tehy", "match", "the", "blocks", "block", "switch", "statements", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L141-L201
alexras/pylsdj
pylsdj/filepack.py
merge
def merge(blocks): """Merge the given blocks into a contiguous block of compressed data. :param blocks: the list of blocks :rtype: a list of compressed bytes """ current_block = blocks[sorted(blocks.keys())[0]] compressed_data = [] eof = False while not eof: data_size_to_appe...
python
def merge(blocks): """Merge the given blocks into a contiguous block of compressed data. :param blocks: the list of blocks :rtype: a list of compressed bytes """ current_block = blocks[sorted(blocks.keys())[0]] compressed_data = [] eof = False while not eof: data_size_to_appe...
[ "def", "merge", "(", "blocks", ")", ":", "current_block", "=", "blocks", "[", "sorted", "(", "blocks", ".", "keys", "(", ")", ")", "[", "0", "]", "]", "compressed_data", "=", "[", "]", "eof", "=", "False", "while", "not", "eof", ":", "data_size_to_ap...
Merge the given blocks into a contiguous block of compressed data. :param blocks: the list of blocks :rtype: a list of compressed bytes
[ "Merge", "the", "given", "blocks", "into", "a", "contiguous", "block", "of", "compressed", "data", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L204-L259
alexras/pylsdj
pylsdj/filepack.py
pad
def pad(segment, size): """Add zeroes to a segment until it reaches a certain size. :param segment: the segment to pad :param size: the size to which to pad the segment """ for i in range(size - len(segment)): segment.append(0) assert len(segment) == size
python
def pad(segment, size): """Add zeroes to a segment until it reaches a certain size. :param segment: the segment to pad :param size: the size to which to pad the segment """ for i in range(size - len(segment)): segment.append(0) assert len(segment) == size
[ "def", "pad", "(", "segment", ",", "size", ")", ":", "for", "i", "in", "range", "(", "size", "-", "len", "(", "segment", ")", ")", ":", "segment", ".", "append", "(", "0", ")", "assert", "len", "(", "segment", ")", "==", "size" ]
Add zeroes to a segment until it reaches a certain size. :param segment: the segment to pad :param size: the size to which to pad the segment
[ "Add", "zeroes", "to", "a", "segment", "until", "it", "reaches", "a", "certain", "size", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L276-L285
alexras/pylsdj
pylsdj/filepack.py
decompress
def decompress(compressed_data): """Decompress data that has been compressed by the filepack algorithm. :param compressed_data: an array of compressed data bytes to decompress :rtype: an array of decompressed bytes""" raw_data = [] index = 0 while index < len(compressed_data): curren...
python
def decompress(compressed_data): """Decompress data that has been compressed by the filepack algorithm. :param compressed_data: an array of compressed data bytes to decompress :rtype: an array of decompressed bytes""" raw_data = [] index = 0 while index < len(compressed_data): curren...
[ "def", "decompress", "(", "compressed_data", ")", ":", "raw_data", "=", "[", "]", "index", "=", "0", "while", "index", "<", "len", "(", "compressed_data", ")", ":", "current", "=", "compressed_data", "[", "index", "]", "index", "+=", "1", "if", "current"...
Decompress data that has been compressed by the filepack algorithm. :param compressed_data: an array of compressed data bytes to decompress :rtype: an array of decompressed bytes
[ "Decompress", "data", "that", "has", "been", "compressed", "by", "the", "filepack", "algorithm", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L288-L338
alexras/pylsdj
pylsdj/filepack.py
compress
def compress(raw_data): """Compress raw bytes with the filepack algorithm. :param raw_data: an array of raw data bytes to compress :rtype: a list of compressed bytes """ raw_data = bytearray(raw_data) compressed_data = [] data_size = len(raw_data) index = 0 next_bytes = [-1, -1, ...
python
def compress(raw_data): """Compress raw bytes with the filepack algorithm. :param raw_data: an array of raw data bytes to compress :rtype: a list of compressed bytes """ raw_data = bytearray(raw_data) compressed_data = [] data_size = len(raw_data) index = 0 next_bytes = [-1, -1, ...
[ "def", "compress", "(", "raw_data", ")", ":", "raw_data", "=", "bytearray", "(", "raw_data", ")", "compressed_data", "=", "[", "]", "data_size", "=", "len", "(", "raw_data", ")", "index", "=", "0", "next_bytes", "=", "[", "-", "1", ",", "-", "1", ","...
Compress raw bytes with the filepack algorithm. :param raw_data: an array of raw data bytes to compress :rtype: a list of compressed bytes
[ "Compress", "raw", "bytes", "with", "the", "filepack", "algorithm", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L341-L433
alexras/pylsdj
pylsdj/utils.py
name_without_zeroes
def name_without_zeroes(name): """ Return a human-readable name without LSDJ's trailing zeroes. :param name: the name from which to strip zeroes :rtype: the name, without trailing zeroes """ first_zero = name.find(b'\0') if first_zero == -1: return name else: return str...
python
def name_without_zeroes(name): """ Return a human-readable name without LSDJ's trailing zeroes. :param name: the name from which to strip zeroes :rtype: the name, without trailing zeroes """ first_zero = name.find(b'\0') if first_zero == -1: return name else: return str...
[ "def", "name_without_zeroes", "(", "name", ")", ":", "first_zero", "=", "name", ".", "find", "(", "b'\\0'", ")", "if", "first_zero", "==", "-", "1", ":", "return", "name", "else", ":", "return", "str", "(", "name", "[", ":", "first_zero", "]", ")" ]
Return a human-readable name without LSDJ's trailing zeroes. :param name: the name from which to strip zeroes :rtype: the name, without trailing zeroes
[ "Return", "a", "human", "-", "readable", "name", "without", "LSDJ", "s", "trailing", "zeroes", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/utils.py#L32-L44
alexras/pylsdj
pylsdj/instrument.py
Instrument.name
def name(self): """the instrument's name (5 characters, zero-padded)""" instr_name = self.song.song_data.instrument_names[self.index] if type(instr_name) == bytes: instr_name = instr_name.decode('utf-8') return instr_name
python
def name(self): """the instrument's name (5 characters, zero-padded)""" instr_name = self.song.song_data.instrument_names[self.index] if type(instr_name) == bytes: instr_name = instr_name.decode('utf-8') return instr_name
[ "def", "name", "(", "self", ")", ":", "instr_name", "=", "self", ".", "song", ".", "song_data", ".", "instrument_names", "[", "self", ".", "index", "]", "if", "type", "(", "instr_name", ")", "==", "bytes", ":", "instr_name", "=", "instr_name", ".", "de...
the instrument's name (5 characters, zero-padded)
[ "the", "instrument", "s", "name", "(", "5", "characters", "zero", "-", "padded", ")" ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L21-L28
alexras/pylsdj
pylsdj/instrument.py
Instrument.table
def table(self): """a ```pylsdj.Table``` referencing the instrument's table, or None if the instrument doesn't have a table""" if hasattr(self.data, 'table_on') and self.data.table_on: assert_index_sane(self.data.table, len(self.song.tables)) return self.song.tables[self....
python
def table(self): """a ```pylsdj.Table``` referencing the instrument's table, or None if the instrument doesn't have a table""" if hasattr(self.data, 'table_on') and self.data.table_on: assert_index_sane(self.data.table, len(self.song.tables)) return self.song.tables[self....
[ "def", "table", "(", "self", ")", ":", "if", "hasattr", "(", "self", ".", "data", ",", "'table_on'", ")", "and", "self", ".", "data", ".", "table_on", ":", "assert_index_sane", "(", "self", ".", "data", ".", "table", ",", "len", "(", "self", ".", "...
a ```pylsdj.Table``` referencing the instrument's table, or None if the instrument doesn't have a table
[ "a", "pylsdj", ".", "Table", "referencing", "the", "instrument", "s", "table", "or", "None", "if", "the", "instrument", "doesn", "t", "have", "a", "table" ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L47-L52
alexras/pylsdj
pylsdj/instrument.py
Instrument.import_lsdinst
def import_lsdinst(self, struct_data): """import from an lsdinst struct""" self.name = struct_data['name'] self.automate = struct_data['data']['automate'] self.pan = struct_data['data']['pan'] if self.table is not None: self.table.import_lsdinst(struct_data)
python
def import_lsdinst(self, struct_data): """import from an lsdinst struct""" self.name = struct_data['name'] self.automate = struct_data['data']['automate'] self.pan = struct_data['data']['pan'] if self.table is not None: self.table.import_lsdinst(struct_data)
[ "def", "import_lsdinst", "(", "self", ",", "struct_data", ")", ":", "self", ".", "name", "=", "struct_data", "[", "'name'", "]", "self", ".", "automate", "=", "struct_data", "[", "'data'", "]", "[", "'automate'", "]", "self", ".", "pan", "=", "struct_dat...
import from an lsdinst struct
[ "import", "from", "an", "lsdinst", "struct" ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L79-L86
alexras/pylsdj
pylsdj/instrument.py
Instrument.export_to_file
def export_to_file(self, filename): """Export this instrument's settings to a file. :param filename: the name of the file """ instr_json = self.export_struct() with open(filename, 'w') as fp: json.dump(instr_json, fp, indent=2)
python
def export_to_file(self, filename): """Export this instrument's settings to a file. :param filename: the name of the file """ instr_json = self.export_struct() with open(filename, 'w') as fp: json.dump(instr_json, fp, indent=2)
[ "def", "export_to_file", "(", "self", ",", "filename", ")", ":", "instr_json", "=", "self", ".", "export_struct", "(", ")", "with", "open", "(", "filename", ",", "'w'", ")", "as", "fp", ":", "json", ".", "dump", "(", "instr_json", ",", "fp", ",", "in...
Export this instrument's settings to a file. :param filename: the name of the file
[ "Export", "this", "instrument", "s", "settings", "to", "a", "file", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L88-L96
alexras/pylsdj
pylsdj/kits.py
KitSample.write_wav
def write_wav(self, filename): """Write this sample to a WAV file. :param filename: the file to which to write """ wave_output = None try: wave_output = wave.open(filename, 'w') wave_output.setparams(WAVE_PARAMS) frames = bytearray([x << 4 ...
python
def write_wav(self, filename): """Write this sample to a WAV file. :param filename: the file to which to write """ wave_output = None try: wave_output = wave.open(filename, 'w') wave_output.setparams(WAVE_PARAMS) frames = bytearray([x << 4 ...
[ "def", "write_wav", "(", "self", ",", "filename", ")", ":", "wave_output", "=", "None", "try", ":", "wave_output", "=", "wave", ".", "open", "(", "filename", ",", "'w'", ")", "wave_output", ".", "setparams", "(", "WAVE_PARAMS", ")", "frames", "=", "bytea...
Write this sample to a WAV file. :param filename: the file to which to write
[ "Write", "this", "sample", "to", "a", "WAV", "file", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/kits.py#L229-L246
alexras/pylsdj
pylsdj/kits.py
KitSample.read_wav
def read_wav(self, filename): """Read sample data for this sample from a WAV file. :param filename: the file from which to read """ wave_input = None try: wave_input = wave.open(filename, 'r') wave_frames = bytearray( wave_input.readframe...
python
def read_wav(self, filename): """Read sample data for this sample from a WAV file. :param filename: the file from which to read """ wave_input = None try: wave_input = wave.open(filename, 'r') wave_frames = bytearray( wave_input.readframe...
[ "def", "read_wav", "(", "self", ",", "filename", ")", ":", "wave_input", "=", "None", "try", ":", "wave_input", "=", "wave", ".", "open", "(", "filename", ",", "'r'", ")", "wave_frames", "=", "bytearray", "(", "wave_input", ".", "readframes", "(", "wave_...
Read sample data for this sample from a WAV file. :param filename: the file from which to read
[ "Read", "sample", "data", "for", "this", "sample", "from", "a", "WAV", "file", "." ]
train
https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/kits.py#L248-L264
thusoy/headsup
headsup.py
get_device_address
def get_device_address(device): """ find the local ip address on the given device """ if device is None: return None command = ['ip', 'route', 'list', 'dev', device] ip_routes = subprocess.check_output(command).strip() for line in ip_routes.split('\n'): seen = '' for a in lin...
python
def get_device_address(device): """ find the local ip address on the given device """ if device is None: return None command = ['ip', 'route', 'list', 'dev', device] ip_routes = subprocess.check_output(command).strip() for line in ip_routes.split('\n'): seen = '' for a in lin...
[ "def", "get_device_address", "(", "device", ")", ":", "if", "device", "is", "None", ":", "return", "None", "command", "=", "[", "'ip'", ",", "'route'", ",", "'list'", ",", "'dev'", ",", "device", "]", "ip_routes", "=", "subprocess", ".", "check_output", ...
find the local ip address on the given device
[ "find", "the", "local", "ip", "address", "on", "the", "given", "device" ]
train
https://github.com/thusoy/headsup/blob/165a63cc6c987f664f2efd901d483ca07b7bc898/headsup.py#L68-L80
thusoy/headsup
headsup.py
get_default_net_device
def get_default_net_device(): """ Find the device where the default route is. """ with open('/proc/net/route') as fh: for line in fh: iface, dest, _ = line.split(None, 2) if dest == '00000000': return iface return None
python
def get_default_net_device(): """ Find the device where the default route is. """ with open('/proc/net/route') as fh: for line in fh: iface, dest, _ = line.split(None, 2) if dest == '00000000': return iface return None
[ "def", "get_default_net_device", "(", ")", ":", "with", "open", "(", "'/proc/net/route'", ")", "as", "fh", ":", "for", "line", "in", "fh", ":", "iface", ",", "dest", ",", "_", "=", "line", ".", "split", "(", "None", ",", "2", ")", "if", "dest", "==...
Find the device where the default route is.
[ "Find", "the", "device", "where", "the", "default", "route", "is", "." ]
train
https://github.com/thusoy/headsup/blob/165a63cc6c987f664f2efd901d483ca07b7bc898/headsup.py#L83-L90
EUDAT-B2SAFE/B2HANDLE
b2handle/util/argsutils.py
add_missing_optional_args_with_value_none
def add_missing_optional_args_with_value_none(args, optional_args): ''' Adds key-value pairs to the passed dictionary, so that afterwards, the dictionary can be used without needing to check for KeyErrors. If the keys passed as a second argument are not present, they are added with ...
python
def add_missing_optional_args_with_value_none(args, optional_args): ''' Adds key-value pairs to the passed dictionary, so that afterwards, the dictionary can be used without needing to check for KeyErrors. If the keys passed as a second argument are not present, they are added with ...
[ "def", "add_missing_optional_args_with_value_none", "(", "args", ",", "optional_args", ")", ":", "for", "name", "in", "optional_args", ":", "if", "not", "name", "in", "args", ".", "keys", "(", ")", ":", "args", "[", "name", "]", "=", "None", "return", "arg...
Adds key-value pairs to the passed dictionary, so that afterwards, the dictionary can be used without needing to check for KeyErrors. If the keys passed as a second argument are not present, they are added with None as a value. :args: The dictionary to be completed. :optional_args:...
[ "Adds", "key", "-", "value", "pairs", "to", "the", "passed", "dictionary", "so", "that", "afterwards", "the", "dictionary", "can", "be", "used", "without", "needing", "to", "check", "for", "KeyErrors", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/argsutils.py#L3-L21
EUDAT-B2SAFE/B2HANDLE
b2handle/util/argsutils.py
check_presence_of_mandatory_args
def check_presence_of_mandatory_args(args, mandatory_args): ''' Checks whether all mandatory arguments are passed. This function aims at methods with many arguments which are passed as kwargs so that the order in which the are passed does not matter. :args: The dictionary passed as arg...
python
def check_presence_of_mandatory_args(args, mandatory_args): ''' Checks whether all mandatory arguments are passed. This function aims at methods with many arguments which are passed as kwargs so that the order in which the are passed does not matter. :args: The dictionary passed as arg...
[ "def", "check_presence_of_mandatory_args", "(", "args", ",", "mandatory_args", ")", ":", "missing_args", "=", "[", "]", "for", "name", "in", "mandatory_args", ":", "if", "name", "not", "in", "args", ".", "keys", "(", ")", ":", "missing_args", ".", "append", ...
Checks whether all mandatory arguments are passed. This function aims at methods with many arguments which are passed as kwargs so that the order in which the are passed does not matter. :args: The dictionary passed as args. :mandatory_args: A list of keys that have to be present i...
[ "Checks", "whether", "all", "mandatory", "arguments", "are", "passed", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/argsutils.py#L24-L47
ipazc/pyzip
pyzip/__init__.py
PyZip.size
def size(self, store_hashes=True): """ Retrieves the size in bytes of this ZIP content. :return: Size of the zip content in bytes """ if self.modified: self.__cache_content(store_hashes) return len(self.cached_content)
python
def size(self, store_hashes=True): """ Retrieves the size in bytes of this ZIP content. :return: Size of the zip content in bytes """ if self.modified: self.__cache_content(store_hashes) return len(self.cached_content)
[ "def", "size", "(", "self", ",", "store_hashes", "=", "True", ")", ":", "if", "self", ".", "modified", ":", "self", ".", "__cache_content", "(", "store_hashes", ")", "return", "len", "(", "self", ".", "cached_content", ")" ]
Retrieves the size in bytes of this ZIP content. :return: Size of the zip content in bytes
[ "Retrieves", "the", "size", "in", "bytes", "of", "this", "ZIP", "content", ".", ":", "return", ":", "Size", "of", "the", "zip", "content", "in", "bytes" ]
train
https://github.com/ipazc/pyzip/blob/8680775ddba079a9a04ef3904252a9afb62cb7cc/pyzip/__init__.py#L171-L179
alexhayes/django-migration-fixture
django_migration_fixture/management/commands/create_initial_data_fixtures.py
Command.monkey_patch_migration_template
def monkey_patch_migration_template(self, app, fixture_path): """ Monkey patch the django.db.migrations.writer.MIGRATION_TEMPLATE Monkey patching django.db.migrations.writer.MIGRATION_TEMPLATE means that we don't have to do any complex regex or reflection. It's hacky... but wo...
python
def monkey_patch_migration_template(self, app, fixture_path): """ Monkey patch the django.db.migrations.writer.MIGRATION_TEMPLATE Monkey patching django.db.migrations.writer.MIGRATION_TEMPLATE means that we don't have to do any complex regex or reflection. It's hacky... but wo...
[ "def", "monkey_patch_migration_template", "(", "self", ",", "app", ",", "fixture_path", ")", ":", "self", ".", "_MIGRATION_TEMPLATE", "=", "writer", ".", "MIGRATION_TEMPLATE", "module_split", "=", "app", ".", "module", ".", "__name__", ".", "split", "(", "'.'", ...
Monkey patch the django.db.migrations.writer.MIGRATION_TEMPLATE Monkey patching django.db.migrations.writer.MIGRATION_TEMPLATE means that we don't have to do any complex regex or reflection. It's hacky... but works atm.
[ "Monkey", "patch", "the", "django", ".", "db", ".", "migrations", ".", "writer", ".", "MIGRATION_TEMPLATE" ]
train
https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/management/commands/create_initial_data_fixtures.py#L38-L69
alexhayes/django-migration-fixture
django_migration_fixture/management/commands/create_initial_data_fixtures.py
Command.migration_exists
def migration_exists(self, app, fixture_path): """ Return true if it looks like a migration already exists. """ base_name = os.path.basename(fixture_path) # Loop through all migrations for migration_path in glob.glob(os.path.join(app.path, 'migrations', '*.py')): ...
python
def migration_exists(self, app, fixture_path): """ Return true if it looks like a migration already exists. """ base_name = os.path.basename(fixture_path) # Loop through all migrations for migration_path in glob.glob(os.path.join(app.path, 'migrations', '*.py')): ...
[ "def", "migration_exists", "(", "self", ",", "app", ",", "fixture_path", ")", ":", "base_name", "=", "os", ".", "path", ".", "basename", "(", "fixture_path", ")", "# Loop through all migrations", "for", "migration_path", "in", "glob", ".", "glob", "(", "os", ...
Return true if it looks like a migration already exists.
[ "Return", "true", "if", "it", "looks", "like", "a", "migration", "already", "exists", "." ]
train
https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/management/commands/create_initial_data_fixtures.py#L77-L86
alexhayes/django-migration-fixture
django_migration_fixture/management/commands/create_initial_data_fixtures.py
Command.create_migration
def create_migration(self, app, fixture_path): """ Create a data migration for app that uses fixture_path. """ self.monkey_patch_migration_template(app, fixture_path) out = StringIO() management.call_command('makemigrations', app.label, empty=True, stdout=out) s...
python
def create_migration(self, app, fixture_path): """ Create a data migration for app that uses fixture_path. """ self.monkey_patch_migration_template(app, fixture_path) out = StringIO() management.call_command('makemigrations', app.label, empty=True, stdout=out) s...
[ "def", "create_migration", "(", "self", ",", "app", ",", "fixture_path", ")", ":", "self", ".", "monkey_patch_migration_template", "(", "app", ",", "fixture_path", ")", "out", "=", "StringIO", "(", ")", "management", ".", "call_command", "(", "'makemigrations'",...
Create a data migration for app that uses fixture_path.
[ "Create", "a", "data", "migration", "for", "app", "that", "uses", "fixture_path", "." ]
train
https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/management/commands/create_initial_data_fixtures.py#L88-L99
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.instantiate_for_read_and_search
def instantiate_for_read_and_search(handle_server_url, reverselookup_username, reverselookup_password, **config): ''' Initialize client with read access and with search function. :param handle_server_url: The URL of the Handle Server. May be None (then, the default 'https://hdl.hand...
python
def instantiate_for_read_and_search(handle_server_url, reverselookup_username, reverselookup_password, **config): ''' Initialize client with read access and with search function. :param handle_server_url: The URL of the Handle Server. May be None (then, the default 'https://hdl.hand...
[ "def", "instantiate_for_read_and_search", "(", "handle_server_url", ",", "reverselookup_username", ",", "reverselookup_password", ",", "*", "*", "config", ")", ":", "if", "handle_server_url", "is", "None", "and", "'reverselookup_baseuri'", "not", "in", "config", ".", ...
Initialize client with read access and with search function. :param handle_server_url: The URL of the Handle Server. May be None (then, the default 'https://hdl.handle.net' is used). :param reverselookup_username: The username to authenticate at the reverse lookup servlet. ...
[ "Initialize", "client", "with", "read", "access", "and", "with", "search", "function", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L183-L209
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.instantiate_with_username_and_password
def instantiate_with_username_and_password(handle_server_url, username, password, **config): ''' Initialize client against an HSv8 instance with full read/write access. The method will throw an exception upon bad syntax or non-existing Handle. The existence or validity of the password i...
python
def instantiate_with_username_and_password(handle_server_url, username, password, **config): ''' Initialize client against an HSv8 instance with full read/write access. The method will throw an exception upon bad syntax or non-existing Handle. The existence or validity of the password i...
[ "def", "instantiate_with_username_and_password", "(", "handle_server_url", ",", "username", ",", "password", ",", "*", "*", "config", ")", ":", "inst", "=", "EUDATHandleClient", "(", "handle_server_url", ",", "username", "=", "username", ",", "password", "=", "pas...
Initialize client against an HSv8 instance with full read/write access. The method will throw an exception upon bad syntax or non-existing Handle. The existence or validity of the password in the handle is not checked at this moment. :param handle_server_url: The URL of the Handle Syst...
[ "Initialize", "client", "against", "an", "HSv8", "instance", "with", "full", "read", "/", "write", "access", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L212-L233
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.instantiate_with_credentials
def instantiate_with_credentials(credentials, **config): ''' Initialize the client against an HSv8 instance with full read/write access. :param credentials: A credentials object, see separate class PIDClientCredentials. :param \**config: More key-value pairs may be p...
python
def instantiate_with_credentials(credentials, **config): ''' Initialize the client against an HSv8 instance with full read/write access. :param credentials: A credentials object, see separate class PIDClientCredentials. :param \**config: More key-value pairs may be p...
[ "def", "instantiate_with_credentials", "(", "credentials", ",", "*", "*", "config", ")", ":", "key_value_pairs", "=", "credentials", ".", "get_all_args", "(", ")", "if", "config", "is", "not", "None", ":", "key_value_pairs", ".", "update", "(", "*", "*", "co...
Initialize the client against an HSv8 instance with full read/write access. :param credentials: A credentials object, see separate class PIDClientCredentials. :param \**config: More key-value pairs may be passed that will be passed on to the constructor as config. Config...
[ "Initialize", "the", "client", "against", "an", "HSv8", "instance", "with", "full", "read", "/", "write", "access", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L236-L255
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.retrieve_handle_record_json
def retrieve_handle_record_json(self, handle): ''' Retrieve a handle record from the Handle server as a complete nested dict (including index, ttl, timestamp, ...) for later use. Note: For retrieving a simple dict with only the keys and values, please use :meth:`~b2handle.handle...
python
def retrieve_handle_record_json(self, handle): ''' Retrieve a handle record from the Handle server as a complete nested dict (including index, ttl, timestamp, ...) for later use. Note: For retrieving a simple dict with only the keys and values, please use :meth:`~b2handle.handle...
[ "def", "retrieve_handle_record_json", "(", "self", ",", "handle", ")", ":", "LOGGER", ".", "debug", "(", "'retrieve_handle_record_json...'", ")", "utilhandle", ".", "check_handle_syntax", "(", "handle", ")", "response", "=", "self", ".", "__send_handle_get_request", ...
Retrieve a handle record from the Handle server as a complete nested dict (including index, ttl, timestamp, ...) for later use. Note: For retrieving a simple dict with only the keys and values, please use :meth:`~b2handle.handleclient.EUDATHandleClient.retrieve_handle_record`. :param h...
[ "Retrieve", "a", "handle", "record", "from", "the", "Handle", "server", "as", "a", "complete", "nested", "dict", "(", "including", "index", "ttl", "timestamp", "...", ")", "for", "later", "use", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L259-L299
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.retrieve_handle_record
def retrieve_handle_record(self, handle, handlerecord_json=None): ''' Retrieve a handle record from the Handle server as a dict. If there is several entries of the same type, only the first one is returned. Values of complex types (such as HS_ADMIN) are transformed to strings. ...
python
def retrieve_handle_record(self, handle, handlerecord_json=None): ''' Retrieve a handle record from the Handle server as a dict. If there is several entries of the same type, only the first one is returned. Values of complex types (such as HS_ADMIN) are transformed to strings. ...
[ "def", "retrieve_handle_record", "(", "self", ",", "handle", ",", "handlerecord_json", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "'retrieve_handle_record...'", ")", "handlerecord_json", "=", "self", ".", "__get_handle_record_if_necessary", "(", "handle", "...
Retrieve a handle record from the Handle server as a dict. If there is several entries of the same type, only the first one is returned. Values of complex types (such as HS_ADMIN) are transformed to strings. :param handle: The handle whose record to retrieve. :param handlerecord...
[ "Retrieve", "a", "handle", "record", "from", "the", "Handle", "server", "as", "a", "dict", ".", "If", "there", "is", "several", "entries", "of", "the", "same", "type", "only", "the", "first", "one", "is", "returned", ".", "Values", "of", "complex", "type...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L302-L329
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.get_value_from_handle
def get_value_from_handle(self, handle, key, handlerecord_json=None): ''' Retrieve a single value from a single Handle. If several entries with this key exist, the methods returns the first one. If the handle does not exist, the method will raise a HandleNotFoundException. :para...
python
def get_value_from_handle(self, handle, key, handlerecord_json=None): ''' Retrieve a single value from a single Handle. If several entries with this key exist, the methods returns the first one. If the handle does not exist, the method will raise a HandleNotFoundException. :para...
[ "def", "get_value_from_handle", "(", "self", ",", "handle", ",", "key", ",", "handlerecord_json", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "'get_value_from_handle...'", ")", "handlerecord_json", "=", "self", ".", "__get_handle_record_if_necessary", "(", ...
Retrieve a single value from a single Handle. If several entries with this key exist, the methods returns the first one. If the handle does not exist, the method will raise a HandleNotFoundException. :param handle: The handle to take the value from. :param key: The key. :return:...
[ "Retrieve", "a", "single", "value", "from", "a", "single", "Handle", ".", "If", "several", "entries", "with", "this", "key", "exist", "the", "methods", "returns", "the", "first", "one", ".", "If", "the", "handle", "does", "not", "exist", "the", "method", ...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L331-L363
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.is_10320LOC_empty
def is_10320LOC_empty(self, handle, handlerecord_json=None): ''' Checks if there is a 10320/LOC entry in the handle record. *Note:* In the unlikely case that there is a 10320/LOC entry, but it does not contain any locations, it is treated as if there was none. :param handle: The...
python
def is_10320LOC_empty(self, handle, handlerecord_json=None): ''' Checks if there is a 10320/LOC entry in the handle record. *Note:* In the unlikely case that there is a 10320/LOC entry, but it does not contain any locations, it is treated as if there was none. :param handle: The...
[ "def", "is_10320LOC_empty", "(", "self", ",", "handle", ",", "handlerecord_json", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "'is_10320LOC_empty...'", ")", "handlerecord_json", "=", "self", ".", "__get_handle_record_if_necessary", "(", "handle", ",", "han...
Checks if there is a 10320/LOC entry in the handle record. *Note:* In the unlikely case that there is a 10320/LOC entry, but it does not contain any locations, it is treated as if there was none. :param handle: The handle. :param handlerecord_json: Optional. The content of the response ...
[ "Checks", "if", "there", "is", "a", "10320", "/", "LOC", "entry", "in", "the", "handle", "record", ".", "*", "Note", ":", "*", "In", "the", "unlikely", "case", "that", "there", "is", "a", "10320", "/", "LOC", "entry", "but", "it", "does", "not", "c...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L365-L402
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.generate_and_register_handle
def generate_and_register_handle(self, prefix, location, checksum=None, additional_URLs=None, **extratypes): ''' Register a new Handle with a unique random name (random UUID). :param prefix: The prefix of the handle to be registered. The method will generate a suffix. :param...
python
def generate_and_register_handle(self, prefix, location, checksum=None, additional_URLs=None, **extratypes): ''' Register a new Handle with a unique random name (random UUID). :param prefix: The prefix of the handle to be registered. The method will generate a suffix. :param...
[ "def", "generate_and_register_handle", "(", "self", ",", "prefix", ",", "location", ",", "checksum", "=", "None", ",", "additional_URLs", "=", "None", ",", "*", "*", "extratypes", ")", ":", "LOGGER", ".", "debug", "(", "'generate_and_register_handle...'", ")", ...
Register a new Handle with a unique random name (random UUID). :param prefix: The prefix of the handle to be registered. The method will generate a suffix. :param location: The URL of the data entity to be referenced. :param checksum: Optional. The checksum string. :param ex...
[ "Register", "a", "new", "Handle", "with", "a", "unique", "random", "name", "(", "random", "UUID", ")", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L445-L471
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.modify_handle_value
def modify_handle_value(self, handle, ttl=None, add_if_not_exist=True, **kvpairs): ''' Modify entries (key-value-pairs) in a handle record. If the key does not exist yet, it is created. *Note:* We assume that a key exists only once. In case a key exists several time, an exceptio...
python
def modify_handle_value(self, handle, ttl=None, add_if_not_exist=True, **kvpairs): ''' Modify entries (key-value-pairs) in a handle record. If the key does not exist yet, it is created. *Note:* We assume that a key exists only once. In case a key exists several time, an exceptio...
[ "def", "modify_handle_value", "(", "self", ",", "handle", ",", "ttl", "=", "None", ",", "add_if_not_exist", "=", "True", ",", "*", "*", "kvpairs", ")", ":", "LOGGER", ".", "debug", "(", "'modify_handle_value...'", ")", "# Read handle record:", "handlerecord_json...
Modify entries (key-value-pairs) in a handle record. If the key does not exist yet, it is created. *Note:* We assume that a key exists only once. In case a key exists several time, an exception will be raised. *Note:* To modify 10320/LOC, please use :meth:`~b2handle.handleclient.EUDATH...
[ "Modify", "entries", "(", "key", "-", "value", "-", "pairs", ")", "in", "a", "handle", "record", ".", "If", "the", "key", "does", "not", "exist", "yet", "it", "is", "created", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L473-L587
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.delete_handle_value
def delete_handle_value(self, handle, key): ''' Delete a key-value pair from a handle record. If the key exists more than once, all key-value pairs with this key are deleted. :param handle: Handle from whose record the entry should be deleted. :param key: Key to be deleted. Also...
python
def delete_handle_value(self, handle, key): ''' Delete a key-value pair from a handle record. If the key exists more than once, all key-value pairs with this key are deleted. :param handle: Handle from whose record the entry should be deleted. :param key: Key to be deleted. Also...
[ "def", "delete_handle_value", "(", "self", ",", "handle", ",", "key", ")", ":", "LOGGER", ".", "debug", "(", "'delete_handle_value...'", ")", "# read handle record:", "handlerecord_json", "=", "self", ".", "retrieve_handle_record_json", "(", "handle", ")", "if", "...
Delete a key-value pair from a handle record. If the key exists more than once, all key-value pairs with this key are deleted. :param handle: Handle from whose record the entry should be deleted. :param key: Key to be deleted. Also accepts a list of keys. :raises: :exc:`~b2handle.handle...
[ "Delete", "a", "key", "-", "value", "pair", "from", "a", "handle", "record", ".", "If", "the", "key", "exists", "more", "than", "once", "all", "key", "-", "value", "pairs", "with", "this", "key", "are", "deleted", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L589-L648
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.delete_handle
def delete_handle(self, handle, *other): '''Delete the handle and its handle record. If the Handle is not found, an Exception is raised. :param handle: Handle to be deleted. :param other: Deprecated. This only exists to catch wrong method usage by users who are used to delete handle...
python
def delete_handle(self, handle, *other): '''Delete the handle and its handle record. If the Handle is not found, an Exception is raised. :param handle: Handle to be deleted. :param other: Deprecated. This only exists to catch wrong method usage by users who are used to delete handle...
[ "def", "delete_handle", "(", "self", ",", "handle", ",", "*", "other", ")", ":", "LOGGER", ".", "debug", "(", "'delete_handle...'", ")", "utilhandle", ".", "check_handle_syntax", "(", "handle", ")", "# Safety check. In old epic client, the method could be used for", "...
Delete the handle and its handle record. If the Handle is not found, an Exception is raised. :param handle: Handle to be deleted. :param other: Deprecated. This only exists to catch wrong method usage by users who are used to delete handle VALUES with the method. :raises: :exc:`~b2h...
[ "Delete", "the", "handle", "and", "its", "handle", "record", ".", "If", "the", "Handle", "is", "not", "found", "an", "Exception", "is", "raised", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L650-L684
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.exchange_additional_URL
def exchange_additional_URL(self, handle, old, new): ''' Exchange an URL in the 10320/LOC entry against another, keeping the same id and other attributes. :param handle: The handle to modify. :param old: The URL to replace. :param new: The URL to set as new URL. ...
python
def exchange_additional_URL(self, handle, old, new): ''' Exchange an URL in the 10320/LOC entry against another, keeping the same id and other attributes. :param handle: The handle to modify. :param old: The URL to replace. :param new: The URL to set as new URL. ...
[ "def", "exchange_additional_URL", "(", "self", ",", "handle", ",", "old", ",", "new", ")", ":", "LOGGER", ".", "debug", "(", "'exchange_additional_URL...'", ")", "handlerecord_json", "=", "self", ".", "retrieve_handle_record_json", "(", "handle", ")", "if", "han...
Exchange an URL in the 10320/LOC entry against another, keeping the same id and other attributes. :param handle: The handle to modify. :param old: The URL to replace. :param new: The URL to set as new URL.
[ "Exchange", "an", "URL", "in", "the", "10320", "/", "LOC", "entry", "against", "another", "keeping", "the", "same", "id", "and", "other", "attributes", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L686-L729
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.add_additional_URL
def add_additional_URL(self, handle, *urls, **attributes): ''' Add a URL entry to the handle record's 10320/LOC entry. If 10320/LOC does not exist yet, it is created. If the 10320/LOC entry already contains the URL, it is not added a second time. :param handle: The handle to add...
python
def add_additional_URL(self, handle, *urls, **attributes): ''' Add a URL entry to the handle record's 10320/LOC entry. If 10320/LOC does not exist yet, it is created. If the 10320/LOC entry already contains the URL, it is not added a second time. :param handle: The handle to add...
[ "def", "add_additional_URL", "(", "self", ",", "handle", ",", "*", "urls", ",", "*", "*", "attributes", ")", ":", "LOGGER", ".", "debug", "(", "'add_additional_URL...'", ")", "handlerecord_json", "=", "self", ".", "retrieve_handle_record_json", "(", "handle", ...
Add a URL entry to the handle record's 10320/LOC entry. If 10320/LOC does not exist yet, it is created. If the 10320/LOC entry already contains the URL, it is not added a second time. :param handle: The handle to add the URL to. :param urls: The URL(s) to be added. Several URLs may be s...
[ "Add", "a", "URL", "entry", "to", "the", "handle", "record", "s", "10320", "/", "LOC", "entry", ".", "If", "10320", "/", "LOC", "does", "not", "exist", "yet", "it", "is", "created", ".", "If", "the", "10320", "/", "LOC", "entry", "already", "contains...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L731-L781
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.remove_additional_URL
def remove_additional_URL(self, handle, *urls): ''' Remove a URL from the handle record's 10320/LOC entry. :param handle: The handle to modify. :param urls: The URL(s) to be removed. Several URLs may be specified. :raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException...
python
def remove_additional_URL(self, handle, *urls): ''' Remove a URL from the handle record's 10320/LOC entry. :param handle: The handle to modify. :param urls: The URL(s) to be removed. Several URLs may be specified. :raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException...
[ "def", "remove_additional_URL", "(", "self", ",", "handle", ",", "*", "urls", ")", ":", "LOGGER", ".", "debug", "(", "'remove_additional_URL...'", ")", "handlerecord_json", "=", "self", ".", "retrieve_handle_record_json", "(", "handle", ")", "if", "handlerecord_js...
Remove a URL from the handle record's 10320/LOC entry. :param handle: The handle to modify. :param urls: The URL(s) to be removed. Several URLs may be specified. :raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException` :raises: :exc:`~b2handle.handleexceptions.HandleSyntaxErro...
[ "Remove", "a", "URL", "from", "the", "handle", "record", "s", "10320", "/", "LOC", "entry", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L783-L825
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.register_handle
def register_handle(self, handle, location, checksum=None, additional_URLs=None, overwrite=False, **extratypes): ''' Registers a new Handle with given name. If the handle already exists and overwrite is not set to True, the method will throw an exception. :param handle: The full...
python
def register_handle(self, handle, location, checksum=None, additional_URLs=None, overwrite=False, **extratypes): ''' Registers a new Handle with given name. If the handle already exists and overwrite is not set to True, the method will throw an exception. :param handle: The full...
[ "def", "register_handle", "(", "self", ",", "handle", ",", "location", ",", "checksum", "=", "None", ",", "additional_URLs", "=", "None", ",", "overwrite", "=", "False", ",", "*", "*", "extratypes", ")", ":", "LOGGER", ".", "debug", "(", "'register_handle....
Registers a new Handle with given name. If the handle already exists and overwrite is not set to True, the method will throw an exception. :param handle: The full name of the handle to be registered (prefix and suffix) :param location: The URL of the data entity to be refere...
[ "Registers", "a", "new", "Handle", "with", "given", "name", ".", "If", "the", "handle", "already", "exists", "and", "overwrite", "is", "not", "set", "to", "True", "the", "method", "will", "throw", "an", "exception", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L827-L930
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.search_handle
def search_handle(self, URL=None, prefix=None, **key_value_pairs): ''' Search for handles containing the specified key with the specified value. The search terms are passed on to the reverse lookup servlet as-is. The servlet is supposed to be case-insensitive, but if it isn't, th...
python
def search_handle(self, URL=None, prefix=None, **key_value_pairs): ''' Search for handles containing the specified key with the specified value. The search terms are passed on to the reverse lookup servlet as-is. The servlet is supposed to be case-insensitive, but if it isn't, th...
[ "def", "search_handle", "(", "self", ",", "URL", "=", "None", ",", "prefix", "=", "None", ",", "*", "*", "key_value_pairs", ")", ":", "LOGGER", ".", "debug", "(", "'search_handle...'", ")", "list_of_handles", "=", "self", ".", "__searcher", ".", "search_ha...
Search for handles containing the specified key with the specified value. The search terms are passed on to the reverse lookup servlet as-is. The servlet is supposed to be case-insensitive, but if it isn't, the wrong case will cause a :exc:`~b2handle.handleexceptions.ReverseLookupException`. ...
[ "Search", "for", "handles", "containing", "the", "specified", "key", "with", "the", "specified", "value", ".", "The", "search", "terms", "are", "passed", "on", "to", "the", "reverse", "lookup", "servlet", "as", "-", "is", ".", "The", "servlet", "is", "supp...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L934-L973
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.generate_PID_name
def generate_PID_name(self, prefix=None): ''' Generate a unique random Handle name (random UUID). The Handle is not registered. If a prefix is specified, the PID name has the syntax <prefix>/<generatedname>, otherwise it just returns the generated random name (suffix for the Hand...
python
def generate_PID_name(self, prefix=None): ''' Generate a unique random Handle name (random UUID). The Handle is not registered. If a prefix is specified, the PID name has the syntax <prefix>/<generatedname>, otherwise it just returns the generated random name (suffix for the Hand...
[ "def", "generate_PID_name", "(", "self", ",", "prefix", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "'generate_PID_name...'", ")", "randomuuid", "=", "uuid", ".", "uuid4", "(", ")", "if", "prefix", "is", "not", "None", ":", "return", "prefix", "+...
Generate a unique random Handle name (random UUID). The Handle is not registered. If a prefix is specified, the PID name has the syntax <prefix>/<generatedname>, otherwise it just returns the generated random name (suffix for the Handle). :param prefix: Optional. The prefix to be used f...
[ "Generate", "a", "unique", "random", "Handle", "name", "(", "random", "UUID", ")", ".", "The", "Handle", "is", "not", "registered", ".", "If", "a", "prefix", "is", "specified", "the", "PID", "name", "has", "the", "syntax", "<prefix", ">", "/", "<generate...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L975-L993
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.get_handlerecord_indices_for_key
def get_handlerecord_indices_for_key(self, key, list_of_entries): ''' Finds the Handle entry indices of all entries that have a specific type. *Important:* It finds the Handle System indices! These are not the python indices of the list, so they can not be used for itera...
python
def get_handlerecord_indices_for_key(self, key, list_of_entries): ''' Finds the Handle entry indices of all entries that have a specific type. *Important:* It finds the Handle System indices! These are not the python indices of the list, so they can not be used for itera...
[ "def", "get_handlerecord_indices_for_key", "(", "self", ",", "key", ",", "list_of_entries", ")", ":", "LOGGER", ".", "debug", "(", "'get_handlerecord_indices_for_key...'", ")", "indices", "=", "[", "]", "for", "entry", "in", "list_of_entries", ":", "if", "entry", ...
Finds the Handle entry indices of all entries that have a specific type. *Important:* It finds the Handle System indices! These are not the python indices of the list, so they can not be used for iteration. :param key: The key (Handle Record type) :param list_of_entries...
[ "Finds", "the", "Handle", "entry", "indices", "of", "all", "entries", "that", "have", "a", "specific", "type", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L997-L1019
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__send_handle_delete_request
def __send_handle_delete_request(self, handle, indices=None, op=None): ''' Send a HTTP DELETE request to the handle server to delete either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :p...
python
def __send_handle_delete_request(self, handle, indices=None, op=None): ''' Send a HTTP DELETE request to the handle server to delete either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :p...
[ "def", "__send_handle_delete_request", "(", "self", ",", "handle", ",", "indices", "=", "None", ",", "op", "=", "None", ")", ":", "resp", "=", "self", ".", "__handlesystemconnector", ".", "send_handle_delete_request", "(", "handle", "=", "handle", ",", "indice...
Send a HTTP DELETE request to the handle server to delete either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optional. A list of indices to delete. Defaults to None (i.e. the...
[ "Send", "a", "HTTP", "DELETE", "request", "to", "the", "handle", "server", "to", "delete", "either", "an", "entire", "handle", "or", "to", "some", "specified", "values", "from", "a", "handle", "record", "using", "the", "requests", "module", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1023-L1040
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__send_handle_put_request
def __send_handle_put_request(self, handle, list_of_entries, indices=None, overwrite=False, op=None): ''' Send a HTTP PUT request to the handle server to write either an entire handle or to some specified values to an handle record, using the requests module. :param hand...
python
def __send_handle_put_request(self, handle, list_of_entries, indices=None, overwrite=False, op=None): ''' Send a HTTP PUT request to the handle server to write either an entire handle or to some specified values to an handle record, using the requests module. :param hand...
[ "def", "__send_handle_put_request", "(", "self", ",", "handle", ",", "list_of_entries", ",", "indices", "=", "None", ",", "overwrite", "=", "False", ",", "op", "=", "None", ")", ":", "resp", ",", "payload", "=", "self", ".", "__handlesystemconnector", ".", ...
Send a HTTP PUT request to the handle server to write either an entire handle or to some specified values to an handle record, using the requests module. :param handle: The handle. :param list_of_entries: A list of handle record entries to be written, in the format [{"i...
[ "Send", "a", "HTTP", "PUT", "request", "to", "the", "handle", "server", "to", "write", "either", "an", "entire", "handle", "or", "to", "some", "specified", "values", "to", "an", "handle", "record", "using", "the", "requests", "module", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1042-L1066
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__send_handle_get_request
def __send_handle_get_request(self, handle, indices=None): ''' Send a HTTP GET request to the handle server to read either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Opt...
python
def __send_handle_get_request(self, handle, indices=None): ''' Send a HTTP GET request to the handle server to read either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Opt...
[ "def", "__send_handle_get_request", "(", "self", ",", "handle", ",", "indices", "=", "None", ")", ":", "resp", "=", "self", ".", "__handlesystemconnector", ".", "send_handle_get_request", "(", "handle", ",", "indices", ")", "return", "resp" ]
Send a HTTP GET request to the handle server to read either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optional. A list of indices to delete. Defaults to None (i.e. the enti...
[ "Send", "a", "HTTP", "GET", "request", "to", "the", "handle", "server", "to", "read", "either", "an", "entire", "handle", "or", "to", "some", "specified", "values", "from", "a", "handle", "record", "using", "the", "requests", "module", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1068-L1082
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__get_handle_record_if_necessary
def __get_handle_record_if_necessary(self, handle, handlerecord_json): ''' Returns the handle record if it is None or if its handle is not the same as the specified handle. ''' if handlerecord_json is None: handlerecord_json = self.retrieve_handle_record_json(han...
python
def __get_handle_record_if_necessary(self, handle, handlerecord_json): ''' Returns the handle record if it is None or if its handle is not the same as the specified handle. ''' if handlerecord_json is None: handlerecord_json = self.retrieve_handle_record_json(han...
[ "def", "__get_handle_record_if_necessary", "(", "self", ",", "handle", ",", "handlerecord_json", ")", ":", "if", "handlerecord_json", "is", "None", ":", "handlerecord_json", "=", "self", ".", "retrieve_handle_record_json", "(", "handle", ")", "else", ":", "if", "h...
Returns the handle record if it is None or if its handle is not the same as the specified handle.
[ "Returns", "the", "handle", "record", "if", "it", "is", "None", "or", "if", "its", "handle", "is", "not", "the", "same", "as", "the", "specified", "handle", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1084-L1095
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__make_another_index
def __make_another_index(self, list_of_entries, url=False, hs_admin=False): ''' Find an index not yet used in the handle record and not reserved for any (other) special type. :param: list_of_entries: List of all entries to find which indices are used already. :pa...
python
def __make_another_index(self, list_of_entries, url=False, hs_admin=False): ''' Find an index not yet used in the handle record and not reserved for any (other) special type. :param: list_of_entries: List of all entries to find which indices are used already. :pa...
[ "def", "__make_another_index", "(", "self", ",", "list_of_entries", ",", "url", "=", "False", ",", "hs_admin", "=", "False", ")", ":", "start", "=", "2", "# reserved indices:", "reserved_for_url", "=", "set", "(", "[", "1", "]", ")", "reserved_for_admin", "=...
Find an index not yet used in the handle record and not reserved for any (other) special type. :param: list_of_entries: List of all entries to find which indices are used already. :param url: If True, an index for an URL entry is returned (1, unless it is already in ...
[ "Find", "an", "index", "not", "yet", "used", "in", "the", "handle", "record", "and", "not", "reserved", "for", "any", "(", "other", ")", "special", "type", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1097-L1136
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__create_entry
def __create_entry(self, entrytype, data, index, ttl=None): ''' Create an entry of any type except HS_ADMIN. :param entrytype: THe type of entry to create, e.g. 'URL' or 'checksum' or ... Note: For entries of type 'HS_ADMIN', please use __create_admin_entry(). For type '...
python
def __create_entry(self, entrytype, data, index, ttl=None): ''' Create an entry of any type except HS_ADMIN. :param entrytype: THe type of entry to create, e.g. 'URL' or 'checksum' or ... Note: For entries of type 'HS_ADMIN', please use __create_admin_entry(). For type '...
[ "def", "__create_entry", "(", "self", ",", "entrytype", ",", "data", ",", "index", ",", "ttl", "=", "None", ")", ":", "if", "entrytype", "==", "'HS_ADMIN'", ":", "op", "=", "'creating HS_ADMIN entry'", "msg", "=", "'This method can not create HS_ADMIN entries.'", ...
Create an entry of any type except HS_ADMIN. :param entrytype: THe type of entry to create, e.g. 'URL' or 'checksum' or ... Note: For entries of type 'HS_ADMIN', please use __create_admin_entry(). For type '10320/LOC', please use 'add_additional_URL()' :param data: T...
[ "Create", "an", "entry", "of", "any", "type", "except", "HS_ADMIN", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1138-L1165
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__create_admin_entry
def __create_admin_entry(self, handleowner, permissions, index, handle, ttl=None): ''' Create an entry of type "HS_ADMIN". :param username: The username, i.e. a handle with an index (index:prefix/suffix). The value referenced by the index contains authentcation informati...
python
def __create_admin_entry(self, handleowner, permissions, index, handle, ttl=None): ''' Create an entry of type "HS_ADMIN". :param username: The username, i.e. a handle with an index (index:prefix/suffix). The value referenced by the index contains authentcation informati...
[ "def", "__create_admin_entry", "(", "self", ",", "handleowner", ",", "permissions", ",", "index", ",", "handle", ",", "ttl", "=", "None", ")", ":", "# If the handle owner is specified, use it. Otherwise, use 200:0.NA/prefix", "# With the prefix taken from the handle that is bei...
Create an entry of type "HS_ADMIN". :param username: The username, i.e. a handle with an index (index:prefix/suffix). The value referenced by the index contains authentcation information, e.g. a hidden entry containing a key. :param permissions: The permissions as a string of ze...
[ "Create", "an", "entry", "of", "type", "HS_ADMIN", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1167-L1206
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__get_python_indices_for_key
def __get_python_indices_for_key(self, key, list_of_entries): ''' Finds the indices of all entries that have a specific type. Important: This method finds the python indices of the list of entries! These are not the Handle System index values! :param key: The key (Handle...
python
def __get_python_indices_for_key(self, key, list_of_entries): ''' Finds the indices of all entries that have a specific type. Important: This method finds the python indices of the list of entries! These are not the Handle System index values! :param key: The key (Handle...
[ "def", "__get_python_indices_for_key", "(", "self", ",", "key", ",", "list_of_entries", ")", ":", "indices", "=", "[", "]", "for", "i", "in", "xrange", "(", "len", "(", "list_of_entries", ")", ")", ":", "if", "list_of_entries", "[", "i", "]", "[", "'type...
Finds the indices of all entries that have a specific type. Important: This method finds the python indices of the list of entries! These are not the Handle System index values! :param key: The key (Handle Record type) :param list_of_entries: A list of the existing entries in wh...
[ "Finds", "the", "indices", "of", "all", "entries", "that", "have", "a", "specific", "type", ".", "Important", ":", "This", "method", "finds", "the", "python", "indices", "of", "the", "list", "of", "entries!", "These", "are", "not", "the", "Handle", "System...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1208-L1224
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__exchange_URL_in_13020loc
def __exchange_URL_in_13020loc(self, oldurl, newurl, list_of_entries, handle): ''' Exchange every occurrence of oldurl against newurl in a 10320/LOC entry. This does not change the ids or other xml attributes of the <location> element. :param oldurl: The URL that will be...
python
def __exchange_URL_in_13020loc(self, oldurl, newurl, list_of_entries, handle): ''' Exchange every occurrence of oldurl against newurl in a 10320/LOC entry. This does not change the ids or other xml attributes of the <location> element. :param oldurl: The URL that will be...
[ "def", "__exchange_URL_in_13020loc", "(", "self", ",", "oldurl", ",", "newurl", ",", "list_of_entries", ",", "handle", ")", ":", "# Find existing 10320/LOC entries", "python_indices", "=", "self", ".", "__get_python_indices_for_key", "(", "'10320/LOC'", ",", "list_of_en...
Exchange every occurrence of oldurl against newurl in a 10320/LOC entry. This does not change the ids or other xml attributes of the <location> element. :param oldurl: The URL that will be overwritten. :param newurl: The URL to write into the entry. :param list_of_entrie...
[ "Exchange", "every", "occurrence", "of", "oldurl", "against", "newurl", "in", "a", "10320", "/", "LOC", "entry", ".", "This", "does", "not", "change", "the", "ids", "or", "other", "xml", "attributes", "of", "the", "<location", ">", "element", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1226-L1271
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__remove_URL_from_10320LOC
def __remove_URL_from_10320LOC(self, url, list_of_entries, handle): ''' Remove an URL from the handle record's "10320/LOC" entry. If it exists several times in the entry, all occurences are removed. If the URL is not present, nothing happens. If after removing, there is no more U...
python
def __remove_URL_from_10320LOC(self, url, list_of_entries, handle): ''' Remove an URL from the handle record's "10320/LOC" entry. If it exists several times in the entry, all occurences are removed. If the URL is not present, nothing happens. If after removing, there is no more U...
[ "def", "__remove_URL_from_10320LOC", "(", "self", ",", "url", ",", "list_of_entries", ",", "handle", ")", ":", "# Find existing 10320/LOC entries", "python_indices", "=", "self", ".", "__get_python_indices_for_key", "(", "'10320/LOC'", ",", "list_of_entries", ")", "num_...
Remove an URL from the handle record's "10320/LOC" entry. If it exists several times in the entry, all occurences are removed. If the URL is not present, nothing happens. If after removing, there is no more URLs in the entry, the entry is removed. :param url: The URL to be r...
[ "Remove", "an", "URL", "from", "the", "handle", "record", "s", "10320", "/", "LOC", "entry", ".", "If", "it", "exists", "several", "times", "in", "the", "entry", "all", "occurences", "are", "removed", ".", "If", "the", "URL", "is", "not", "present", "n...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1273-L1327
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__add_URL_to_10320LOC
def __add_URL_to_10320LOC(self, url, list_of_entries, handle=None, weight=None, http_role=None, **kvpairs): ''' Add a url to the handle record's "10320/LOC" entry. If no 10320/LOC entry exists, a new one is created (using the default "chooseby" attribute, if configured). ...
python
def __add_URL_to_10320LOC(self, url, list_of_entries, handle=None, weight=None, http_role=None, **kvpairs): ''' Add a url to the handle record's "10320/LOC" entry. If no 10320/LOC entry exists, a new one is created (using the default "chooseby" attribute, if configured). ...
[ "def", "__add_URL_to_10320LOC", "(", "self", ",", "url", ",", "list_of_entries", ",", "handle", "=", "None", ",", "weight", "=", "None", ",", "http_role", "=", "None", ",", "*", "*", "kvpairs", ")", ":", "# Find existing 10320/LOC entry or create new", "indices"...
Add a url to the handle record's "10320/LOC" entry. If no 10320/LOC entry exists, a new one is created (using the default "chooseby" attribute, if configured). If the URL is already present, it is not added again, but the attributes (e.g. weight) are updated/added. ...
[ "Add", "a", "url", "to", "the", "handle", "record", "s", "10320", "/", "LOC", "entry", ".", "If", "no", "10320", "/", "LOC", "entry", "exists", "a", "new", "one", "is", "created", "(", "using", "the", "default", "chooseby", "attribute", "if", "configur...
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1329-L1417
EUDAT-B2SAFE/B2HANDLE
b2handle/handleclient.py
EUDATHandleClient.__set_or_adapt_10320LOC_attributes
def __set_or_adapt_10320LOC_attributes(self, locelement, weight=None, http_role=None, **kvpairs): ''' Adds or updates attributes of a <location> element. Existing attributes are not removed! :param locelement: A location element as xml snippet (xml.etree.ElementTree.Elem...
python
def __set_or_adapt_10320LOC_attributes(self, locelement, weight=None, http_role=None, **kvpairs): ''' Adds or updates attributes of a <location> element. Existing attributes are not removed! :param locelement: A location element as xml snippet (xml.etree.ElementTree.Elem...
[ "def", "__set_or_adapt_10320LOC_attributes", "(", "self", ",", "locelement", ",", "weight", "=", "None", ",", "http_role", "=", "None", ",", "*", "*", "kvpairs", ")", ":", "if", "weight", "is", "not", "None", ":", "LOGGER", ".", "debug", "(", "'__set_or_ad...
Adds or updates attributes of a <location> element. Existing attributes are not removed! :param locelement: A location element as xml snippet (xml.etree.ElementTree.Element). :param weight: Optional. The weight to be set (integer between 0 and 1). If None, no weight ...
[ "Adds", "or", "updates", "attributes", "of", "a", "<location", ">", "element", ".", "Existing", "attributes", "are", "not", "removed!" ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1419-L1451
nooperpudd/weibopy
weibopy/auth.py
WeiboOauth2.authorize_url
def authorize_url(self): """ authorization url request weibo authorization url :return: code string 用于第二步调用oauth2/access_token接口,获取授权后的access token。 state string 如果传递参数,会回传该参数 """ if self.oauth2_params and self.oauth2_params.get("display") == ...
python
def authorize_url(self): """ authorization url request weibo authorization url :return: code string 用于第二步调用oauth2/access_token接口,获取授权后的access token。 state string 如果传递参数,会回传该参数 """ if self.oauth2_params and self.oauth2_params.get("display") == ...
[ "def", "authorize_url", "(", "self", ")", ":", "if", "self", ".", "oauth2_params", "and", "self", ".", "oauth2_params", ".", "get", "(", "\"display\"", ")", "==", "\"mobile\"", ":", "auth_url", "=", "self", ".", "mobile_url", "+", "\"authorize\"", "else", ...
authorization url request weibo authorization url :return: code string 用于第二步调用oauth2/access_token接口,获取授权后的access token。 state string 如果传递参数,会回传该参数
[ "authorization", "url", "request", "weibo", "authorization", "url", ":", "return", ":", "code", "string", "用于第二步调用oauth2", "/", "access_token接口,获取授权后的access", "token。", "state", "string", "如果传递参数,会回传该参数" ]
train
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L68-L90
nooperpudd/weibopy
weibopy/auth.py
WeiboOauth2.request
def request(self, method, suffix, data): """ :param method: str, http method ["GET","POST","PUT"] :param suffix: the url suffix :param data: :return: """ url = self.site_url + suffix response = self.session.request(method, url, data=data) if respo...
python
def request(self, method, suffix, data): """ :param method: str, http method ["GET","POST","PUT"] :param suffix: the url suffix :param data: :return: """ url = self.site_url + suffix response = self.session.request(method, url, data=data) if respo...
[ "def", "request", "(", "self", ",", "method", ",", "suffix", ",", "data", ")", ":", "url", "=", "self", ".", "site_url", "+", "suffix", "response", "=", "self", ".", "session", ".", "request", "(", "method", ",", "url", ",", "data", "=", "data", ")...
:param method: str, http method ["GET","POST","PUT"] :param suffix: the url suffix :param data: :return:
[ ":", "param", "method", ":", "str", "http", "method", "[", "GET", "POST", "PUT", "]", ":", "param", "suffix", ":", "the", "url", "suffix", ":", "param", "data", ":", ":", "return", ":" ]
train
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L92-L123
nooperpudd/weibopy
weibopy/auth.py
WeiboOauth2.auth_access
def auth_access(self, auth_code): """ verify the fist authorization response url code response data 返回值字段 字段类型 字段说明 access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据, 第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值...
python
def auth_access(self, auth_code): """ verify the fist authorization response url code response data 返回值字段 字段类型 字段说明 access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据, 第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值...
[ "def", "auth_access", "(", "self", ",", "auth_code", ")", ":", "data", "=", "{", "'client_id'", ":", "self", ".", "client_id", ",", "'client_secret'", ":", "self", ".", "client_secret", ",", "'grant_type'", ":", "'authorization_code'", ",", "'code'", ":", "a...
verify the fist authorization response url code response data 返回值字段 字段类型 字段说明 access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据, 第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值里的UID 字段来做登录识别。 ...
[ "verify", "the", "fist", "authorization", "response", "url", "code" ]
train
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L125-L166
nooperpudd/weibopy
weibopy/auth.py
WeiboOauth2.revoke_auth_access
def revoke_auth_access(self, access_token): """ 授权回收接口,帮助开发者主动取消用户的授权。 应用下线时,清空所有用户的授权 应用新上线了功能,需要取得用户scope权限,可以回收后重新引导用户授权 开发者调试应用,需要反复调试授权功能 应用内实现类似登出微博帐号的功能 并传递给你以下参数,source:应用appkey,uid :取消授权的用户,auth_end :取消授权的时间 :param access_token: :return...
python
def revoke_auth_access(self, access_token): """ 授权回收接口,帮助开发者主动取消用户的授权。 应用下线时,清空所有用户的授权 应用新上线了功能,需要取得用户scope权限,可以回收后重新引导用户授权 开发者调试应用,需要反复调试授权功能 应用内实现类似登出微博帐号的功能 并传递给你以下参数,source:应用appkey,uid :取消授权的用户,auth_end :取消授权的时间 :param access_token: :return...
[ "def", "revoke_auth_access", "(", "self", ",", "access_token", ")", ":", "result", "=", "self", ".", "request", "(", "\"post\"", ",", "\"revokeoauth2\"", ",", "data", "=", "{", "\"access_token\"", ":", "access_token", "}", ")", "return", "bool", "(", "result...
授权回收接口,帮助开发者主动取消用户的授权。 应用下线时,清空所有用户的授权 应用新上线了功能,需要取得用户scope权限,可以回收后重新引导用户授权 开发者调试应用,需要反复调试授权功能 应用内实现类似登出微博帐号的功能 并传递给你以下参数,source:应用appkey,uid :取消授权的用户,auth_end :取消授权的时间 :param access_token: :return: bool
[ "授权回收接口,帮助开发者主动取消用户的授权。" ]
train
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L168-L183
EUDAT-B2SAFE/B2HANDLE
b2handle/handlesystemconnector.py
HandleSystemConnector.__set_basic_auth_string
def __set_basic_auth_string(self, username, password): ''' Creates and sets the authentication string for (write-)accessing the Handle Server. No return, the string is set as an attribute to the client instance. :param username: Username handle with index: index:prefix/s...
python
def __set_basic_auth_string(self, username, password): ''' Creates and sets the authentication string for (write-)accessing the Handle Server. No return, the string is set as an attribute to the client instance. :param username: Username handle with index: index:prefix/s...
[ "def", "__set_basic_auth_string", "(", "self", ",", "username", ",", "password", ")", ":", "auth", "=", "b2handle", ".", "utilhandle", ".", "create_authentication_string", "(", "username", ",", "password", ")", "self", ".", "__basic_authentication_string", "=", "a...
Creates and sets the authentication string for (write-)accessing the Handle Server. No return, the string is set as an attribute to the client instance. :param username: Username handle with index: index:prefix/suffix. :param password: The password contained in the index of the ...
[ "Creates", "and", "sets", "the", "authentication", "string", "for", "(", "write", "-", ")", "accessing", "the", "Handle", "Server", ".", "No", "return", "the", "string", "is", "set", "as", "an", "attribute", "to", "the", "client", "instance", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L236-L247
EUDAT-B2SAFE/B2HANDLE
b2handle/handlesystemconnector.py
HandleSystemConnector.send_handle_get_request
def send_handle_get_request(self, handle, indices=None): ''' Send a HTTP GET request to the handle server to read either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optio...
python
def send_handle_get_request(self, handle, indices=None): ''' Send a HTTP GET request to the handle server to read either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optio...
[ "def", "send_handle_get_request", "(", "self", ",", "handle", ",", "indices", "=", "None", ")", ":", "# Assemble required info:", "url", "=", "self", ".", "make_handle_URL", "(", "handle", ",", "indices", ")", "LOGGER", ".", "debug", "(", "'GET Request to '", ...
Send a HTTP GET request to the handle server to read either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optional. A list of indices to delete. Defaults to None (i.e. the enti...
[ "Send", "a", "HTTP", "GET", "request", "to", "the", "handle", "server", "to", "read", "either", "an", "entire", "handle", "or", "to", "some", "specified", "values", "from", "a", "handle", "record", "using", "the", "requests", "module", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L252-L292
EUDAT-B2SAFE/B2HANDLE
b2handle/handlesystemconnector.py
HandleSystemConnector.send_handle_put_request
def send_handle_put_request(self, **args): ''' Send a HTTP PUT request to the handle server to write either an entire handle or to some specified values to an handle record, using the requests module. :param handle: The handle. :param list_of_entries: A list of h...
python
def send_handle_put_request(self, **args): ''' Send a HTTP PUT request to the handle server to write either an entire handle or to some specified values to an handle record, using the requests module. :param handle: The handle. :param list_of_entries: A list of h...
[ "def", "send_handle_put_request", "(", "self", ",", "*", "*", "args", ")", ":", "# Check if we have write access at all:", "if", "not", "self", ".", "__has_write_access", ":", "raise", "HandleAuthenticationError", "(", "msg", "=", "self", ".", "__no_auth_message", "...
Send a HTTP PUT request to the handle server to write either an entire handle or to some specified values to an handle record, using the requests module. :param handle: The handle. :param list_of_entries: A list of handle record entries to be written, in the format [{"i...
[ "Send", "a", "HTTP", "PUT", "request", "to", "the", "handle", "server", "to", "write", "either", "an", "entire", "handle", "or", "to", "some", "specified", "values", "to", "an", "handle", "record", "using", "the", "requests", "module", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L301-L356
EUDAT-B2SAFE/B2HANDLE
b2handle/handlesystemconnector.py
HandleSystemConnector.send_handle_delete_request
def send_handle_delete_request(self, **args): ''' Send a HTTP DELETE request to the handle server to delete either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optional. A...
python
def send_handle_delete_request(self, **args): ''' Send a HTTP DELETE request to the handle server to delete either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optional. A...
[ "def", "send_handle_delete_request", "(", "self", ",", "*", "*", "args", ")", ":", "# Check if we have write access at all:", "if", "not", "self", ".", "__has_write_access", ":", "raise", "HandleAuthenticationError", "(", "msg", "=", "self", ".", "__no_auth_message", ...
Send a HTTP DELETE request to the handle server to delete either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optional. A list of indices to delete. Defaults to None (i.e. the...
[ "Send", "a", "HTTP", "DELETE", "request", "to", "the", "handle", "server", "to", "delete", "either", "an", "entire", "handle", "or", "to", "some", "specified", "values", "from", "a", "handle", "record", "using", "the", "requests", "module", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L384-L445
EUDAT-B2SAFE/B2HANDLE
b2handle/handlesystemconnector.py
HandleSystemConnector.check_if_username_exists
def check_if_username_exists(self, username): ''' Check if the username handles exists. :param username: The username, in the form index:prefix/suffix :raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException` :raises: :exc:`~b2handle.handleexceptions.GenericHandleError`...
python
def check_if_username_exists(self, username): ''' Check if the username handles exists. :param username: The username, in the form index:prefix/suffix :raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException` :raises: :exc:`~b2handle.handleexceptions.GenericHandleError`...
[ "def", "check_if_username_exists", "(", "self", ",", "username", ")", ":", "LOGGER", ".", "debug", "(", "'check_if_username_exists...'", ")", "_", ",", "handle", "=", "b2handle", ".", "utilhandle", ".", "remove_index_from_handle", "(", "username", ")", "resp", "...
Check if the username handles exists. :param username: The username, in the form index:prefix/suffix :raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException` :raises: :exc:`~b2handle.handleexceptions.GenericHandleError` :return: True. If it does not exist, an exception is rais...
[ "Check", "if", "the", "username", "handles", "exists", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L447-L482
EUDAT-B2SAFE/B2HANDLE
b2handle/handlesystemconnector.py
HandleSystemConnector.__get_headers
def __get_headers(self, action): ''' Create HTTP headers for different HTTP requests. Content-type and Accept are 'application/json', as the library is interacting with a REST API. :param action: Action for which to create the header ('GET', 'PUT', 'DELETE', ...
python
def __get_headers(self, action): ''' Create HTTP headers for different HTTP requests. Content-type and Accept are 'application/json', as the library is interacting with a REST API. :param action: Action for which to create the header ('GET', 'PUT', 'DELETE', ...
[ "def", "__get_headers", "(", "self", ",", "action", ")", ":", "header", "=", "{", "}", "accept", "=", "'application/json'", "content_type", "=", "'application/json'", "if", "action", "is", "'GET'", ":", "header", "[", "'Accept'", "]", "=", "accept", "elif", ...
Create HTTP headers for different HTTP requests. Content-type and Accept are 'application/json', as the library is interacting with a REST API. :param action: Action for which to create the header ('GET', 'PUT', 'DELETE', 'SEARCH'). :return: dict containing key-value...
[ "Create", "HTTP", "headers", "for", "different", "HTTP", "requests", ".", "Content", "-", "type", "and", "Accept", "are", "application", "/", "json", "as", "the", "library", "is", "interacting", "with", "a", "REST", "API", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L484-L517
EUDAT-B2SAFE/B2HANDLE
b2handle/handlesystemconnector.py
HandleSystemConnector.make_handle_URL
def make_handle_URL(self, handle, indices=None, overwrite=None, other_url=None): ''' Create the URL for a HTTP request (URL + query string) to request a specific handle from the Handle Server. :param handle: The handle to access. :param indices: Optional. A list of integers or s...
python
def make_handle_URL(self, handle, indices=None, overwrite=None, other_url=None): ''' Create the URL for a HTTP request (URL + query string) to request a specific handle from the Handle Server. :param handle: The handle to access. :param indices: Optional. A list of integers or s...
[ "def", "make_handle_URL", "(", "self", ",", "handle", ",", "indices", "=", "None", ",", "overwrite", "=", "None", ",", "other_url", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "'make_handle_URL...'", ")", "separator", "=", "'?'", "if", "other_url",...
Create the URL for a HTTP request (URL + query string) to request a specific handle from the Handle Server. :param handle: The handle to access. :param indices: Optional. A list of integers or strings. Indices of the handle record entries to read or write. Defaults to None. ...
[ "Create", "the", "URL", "for", "a", "HTTP", "request", "(", "URL", "+", "query", "string", ")", "to", "request", "a", "specific", "handle", "from", "the", "Handle", "Server", "." ]
train
https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L519-L561