text stringlengths 81 112k |
|---|
Gets a random alphanumeric value using both letters and numbers.
:param length: size of the random alphanumeric string.
:param lower_only: boolean indicating if only lower case letters should be
used.
:return: alphanumeric string size of length
This function uses all number except for:
* ... |
Gets a random alphanumeric key between low and high characters in
length.
def generate_key(low=7, high=10, lower_only=False):
"""Gets a random alphanumeric key between low and high characters in
length.
"""
return random_alphanum(length=randint(7, 10), lower_only=lower_only) |
Gets the html link for the object.
def get_absolute_url_link(self, text=None, cls=None, icon_class=None,
**attrs):
"""Gets the html link for the object."""
if text is None:
text = self.get_link_text()
return build_link(href=self.get_absolute_url(),
... |
Gets the html edit link for the object.
def get_edit_url_link(self, text=None, cls=None, icon_class=None,
**attrs):
"""Gets the html edit link for the object."""
if text is None:
text = 'Edit'
return build_link(href=self.get_edit_url(),
... |
Gets the html delete link for the object.
def get_delete_url_link(self, text=None, cls=None, icon_class=None,
**attrs):
"""Gets the html delete link for the object."""
if text is None:
text = 'Delete'
return build_link(href=self.get_delete_url(),
... |
Expires tokens for an email address or email addresses.
:param email_address: the string email address or emails addresses to
expire tokens for.
:param reason: the codified reason for the tokens. If explicitly set
to None, this will expire all tokens for the email provided.
de... |
Maps the GET query string params the the query_key_mapper dict and
updates the request's GET QueryDict with the mapped keys.
def map_query_string(self):
"""Maps the GET query string params the the query_key_mapper dict and
updates the request's GET QueryDict with the mapped keys.
"""
... |
Changes the pinned version number in the requirements files of all repos
which have the specified Python module as a dependency.
This script assumes that GITHUB_TOKEN is set for GitHub authentication.
def bump_repos_version(module_name, new_version, local_only):
"""
Changes the pinned version number i... |
Call an Slack Web API method
:param method: Slack Web API method to call
:param params: {str: object} parameters to method
:return: dict()
async def call(self, method, **params):
"""
Call an Slack Web API method
:param method: Slack Web API method to call
:para... |
Handle a message, processing it internally if required. If it's a message that should go outside the bot,
this function will return True
:param message:
:return: Boolean if message should be yielded
def rtm_handler(self, ws_message):
"""
Handle a message, processing it internal... |
r'[a-zA-Z_][a-zA-Z_0-9]*
def t_ATOM(self, t):
r'[a-zA-Z_][a-zA-Z_0-9]*'
t.type = LTLfLexer.reserved.get(t.value, 'ATOM') # Check for reserved words
return t |
formula : formula EQUIVALENCE formula
| formula IMPLIES formula
| formula OR formula
| formula AND formula
| formula UNTIL formula
| formula RELEASE formula
| EVENTUALLY formula
| ALWAYS ... |
Gets the prefix for this form.
:param instance: the form model instance. When calling this method
directly this should almost always stay None so it looks for
self.instance.
def get_default_prefix(self, instance=None):
"""Gets the prefix for this form.
:param instance... |
:param username: this is the email or username to check
def authenticate(self, username, password):
"""
:param username: this is the email or username to check
"""
# If username is an email address, then try to pull it up
user = self.get_by_username_or_email(username)
i... |
powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
def powerset(iterable) -> FrozenSet:
"powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
combs = _powerset(iterable)
res = frozenset(frozenset(x) for x in combs)
# res = map(frozenset, combs)
return res |
This method assumes that the "get_delete_url_link" method has been
implemented on the obj.
def edit_url_link(obj, **kwargs):
"""This method assumes that the "get_delete_url_link" method has been
implemented on the obj.
"""
if hasattr(obj, 'get_edit_url_link'):
return obj.get_edit_url_link(*... |
This method assumes that the "get_delete_url_link" method has been
implemented on the obj.
def delete_url_link(obj, **kwargs):
"""This method assumes that the "get_delete_url_link" method has been
implemented on the obj.
"""
if hasattr(obj, 'get_delete_url_link'):
return obj.get_delete_url_... |
Make the default formfield a CommaSeparatedListField.
def formfield(self, form_class=None, choices_form_class=None, **kwargs):
"""Make the default formfield a CommaSeparatedListField."""
defaults = {
'form_class': form_class or self.get_form_class()
}
defaults.update(kwargs)... |
This follows the validate rules for choices_form_class field used.
def validate(self, value, model_instance, **kwargs):
"""This follows the validate rules for choices_form_class field used.
"""
self.get_choices_form_class().validate(value, model_instance, **kwargs) |
Convert the input JSON value into python structures, raises
django.core.exceptions.ValidationError if the data can't be converted.
def to_python(self, value):
"""
Convert the input JSON value into python structures, raises
django.core.exceptions.ValidationError if the data can't be conv... |
Convert value to JSON string before save
def get_prep_value(self, value):
"""Convert value to JSON string before save"""
try:
return json.dumps(value, cls=DjangoJSONEncoder)
except Exception as e:
raise ValidationError(str(e)) |
Return the farthest origin of a generic class (internal helper).
def _gorg(a):
"""Return the farthest origin of a generic class (internal helper)."""
assert isinstance(a, GenericMeta)
while a.__origin__ is not None:
a = a.__origin__
return a |
Helper for Generic.__new__.
Returns the class after the last occurrence of Generic or
Generic[...] in cls.__mro__.
def _next_in_mro(cls):
"""Helper for Generic.__new__.
Returns the class after the last occurrence of Generic or
Generic[...] in cls.__mro__.
"""
next_in_mro = object
# Lo... |
Construct a __subclasshook__ callable that incorporates
the associated __extra__ class in subclass checks performed
against cls.
def _make_subclasshook(cls):
"""Construct a __subclasshook__ callable that incorporates
the associated __extra__ class in subclass checks performed
against cls.
"""
... |
Gets the authorization object for the view.
def get_authorization(self, **kwargs):
"""Gets the authorization object for the view."""
if self.authorization is not None:
return self.authorization
auth_class = self.get_authorization_class()
auth_user = self.get_authorization_u... |
Gets the user the authorization object is for.
def get_authorization_user(self, **kwargs):
"""Gets the user the authorization object is for."""
if self.authorization_user is not None:
return self.authorization_user
self.authorization_user = self.request.user
return self.req... |
Create a dictionary representation of object attributes
Returns:
OrderedDict serialised version of self
def to_dict(self, dict_cls=FrozenOrderedDict):
# type: (Type[dict]) -> Dict[str, Any]
"""Create a dictionary representation of object attributes
Returns:
Ord... |
Makes sure it's a legit site to redirect to.
:param default: this is the default url or named url to redirect to in the
event where next_url is not legit.
def safe_redirect(next_url, default=None):
"""Makes sure it's a legit site to redirect to.
:param default: this is the default url or named ur... |
Replace querystring values in a url string.
>>> url = 'http://helloworld.com/some/path?test=5'
>>> replace_vals = {'test': 10}
>>> replace_url_query_values(url=url, replace_vals=replace_vals)
'http://helloworld.com/some/path?test=10'
def replace_url_query_values(url, replace_vals):
"""Replace quer... |
Gets query string values from a url.
if a list of keys are provided, then a dict will be returned. If only a
single string key is provided, then only a single value will be returned.
>>> url = 'http://helloworld.com/some/path?test=5&hello=world&john=doe'
>>> get_query_values_from_url(url=url, keys='t... |
Returns a json response object.
def get_json_response(self, content, **kwargs):
"""Returns a json response object."""
# Don't care to return a django form or view in the response here.
# Remove those from the context.
if isinstance(content, dict):
response_content = {k: dee... |
Calls the delete() method on the fetched object and then
redirects to the success URL.
def delete(self, request, *args, **kwargs):
"""
Calls the delete() method on the fetched object and then
redirects to the success URL.
"""
self.object = self.get_object()
succe... |
Finds all the atomic formulas
def find_atomics(formula: Formula) -> Set[PLAtomic]:
"""Finds all the atomic formulas"""
f = formula
res = set()
if isinstance(formula, PLFormula):
res = formula.find_atomics()
# elif isinstance(f, PLNot):
# res = res.union(find_atomics(f.f))
# elif... |
From a Propositional Formula to a Propositional Formula
with non-propositional subformulas replaced with a "freezed" atomic formula.
def _transform_delta(f:Formula, formula2AtomicFormula):
"""From a Propositional Formula to a Propositional Formula
with non-propositional subformulas replaced with a "freezed... |
DEPRECATED
From a LDLfFormula, build the automaton.
:param f: a LDLfFormula;
:param labels: a set of Symbol, the fluents of our domain. If None, retrieve them from the formula;
:param determinize: True if you need to determinize the NFA, obtaining a DFA;
:param minimize: ... |
Gets a settings key or raises an improperly configured error.
:param key: the settings key to get.
:param default: the default value to return if no value is found
def get_setting(key, **kwargs):
"""Gets a settings key or raises an improperly configured error.
:param key: the settings key to get.
... |
Gets a class from a setting key. This will first check loaded models,
then look in installed apps, then fallback to import from lib.
:param settings_key: the key defined in settings to the value for
def get_class_from_settings(settings_key):
"""Gets a class from a setting key. This will first check load... |
Return the django model from a settings key.
This is the same pattern user for django's "get_user_model()" method. To
allow you to set the model instance to a different model subclass.
:param settings_key: the key defined in settings to the value for
def get_model_from_settings(settings_key):
"""Retu... |
Try and get a class from a settings path by lookin in installed apps.
def get_class_from_settings_from_apps(settings_key):
"""Try and get a class from a settings path by lookin in installed apps.
"""
cls_path = getattr(settings, settings_key, None)
if not cls_path:
raise NotImplementedError()
... |
Get a class from it's full path.
Example:
some.path.module.MyClass
def get_class_from_settings_full_path(settings_key):
"""Get a class from it's full path.
Example:
some.path.module.MyClass
"""
cls_path = getattr(settings, settings_key, None)
if not cls_path:
raise NotImple... |
Gets a function from the string path defined in a settings file.
Example:
# my_app/my_file.py
def some_function():
# do something
pass
# settings.py
SOME_FUNCTION = 'my_app.my_file.some_function'
> get_function_from_settings('SOME_FUNCTION')
<function my_app.my_file.some_... |
Return the frame object for the caller's stack frame.
def caller_locals():
# type: () -> Dict
"""Return the frame object for the caller's stack frame."""
try:
raise ValueError
except ValueError:
_, _, tb = sys.exc_info()
assert tb, "Can't get traceback, this shouldn't happen"
... |
Create a repr from an instance of a class
Args:
inst: The class instance we are generating a repr of
attrs: The attributes that should appear in the repr
def make_repr(inst, attrs):
# type: (object, Sequence[str]) -> str
"""Create a repr from an instance of a class
Args:
inst:... |
Default translation function for Fedora/RDO based systems
def default_rdo_tr(mod):
"""
Default translation function for Fedora/RDO based systems
"""
pkg = mod.rsplit('-python')[0]
pkg = pkg.replace('_', '-').replace('.', '-').lower()
if not pkg.startswith('python-'):
pkg = 'python-' + p... |
Default translation function for Ubuntu based systems
def default_ubuntu_tr(mod):
"""
Default translation function for Ubuntu based systems
"""
pkg = 'python-%s' % mod.lower()
py2pkg = pkg
py3pkg = 'python3-%s' % mod.lower()
return (pkg, py2pkg, py3pkg) |
Default translation function for openSUSE, SLES, and other
SUSE based systems
Returns a tuple of 3 elements - the unversioned name, the python2 versioned
name and the python3 versioned name.
def default_suse_tr(mod):
"""
Default translation function for openSUSE, SLES, and other
SUSE based sys... |
Return a corresponding package name for a python module.
mod: python module name
dist: a linux distribution as returned by
`platform.linux_distribution()[0]`
pkg_map: a custom package mapping. None means autodetected based on the
given dist parameter
py_vers: a list of python ver... |
Return a corresponding OpenStack upstream name for a python module.
mod -- python module name
def module2upstream(mod):
"""Return a corresponding OpenStack upstream name for a python module.
mod -- python module name
"""
for rule in OPENSTACK_UPSTREAM_PKG_MAP:
pkglist = rule(mod, dist=N... |
for resolving names from command line
def main():
"""for resolving names from command line"""
parser = argparse.ArgumentParser(description='Python module name to'
'package name')
group = parser.add_mutually_exclusive_group()
group.add_argument('--dist', help='distri... |
Gets the paging values passed through the query string params.
* "p" for "page number" and
* "ps" for "page size".
:returns: tuple with the page being the first part and the page size
being the second part.
def get_paging(self):
"""Gets the paging values passed thr... |
Make a call_types dictionary that describes what arguments to pass to f
Args:
f: The function to inspect for argument names (without self)
globals_d: A dictionary of globals to lookup annotation definitions in
def make_call_types(f, globals_d):
# type: (Callable, Dict) -> Tuple[Dict[str, Anno]... |
Create an annotations dictionary from Python2 type comments
http://mypy.readthedocs.io/en/latest/python2.html
Args:
f: The function to examine for type comments
globals_d: The globals dictionary to get type idents from. If not
specified then make the annotations dict contain string... |
Sometimes preprocessing of a view need to happen before the object
attribute has been set for a view. In this case, just return the
object if it has already been set when it's called down the road since
there's no need to make another query.
def get_object(self, **kwargs):
"""Sometimes... |
Converts hex timestamp to a datetime object.
>>> hex_timestamp_to_datetime('558BBCF9')
datetime.datetime(2015, 6, 25, 8, 34, 1)
>>> hex_timestamp_to_datetime('0x558BBCF9')
datetime.datetime(2015, 6, 25, 8, 34, 1)
>>> datetime.fromtimestamp(0x558BBCF9)
datetime.datetime(2015, 6, 25, 8, 34, 1)
d... |
Gets the current datetime object by timezone.
:param tz: is the timezone to get the date for. tz can be passed as a
string or as a timezone object. (i.e. 'US/Central' or
pytz.timezone('US/Central'), etc)
:param ignoretz: will ignore the timezone portion of the datetime object and
tzinf... |
Converts a datetime object from the specified timezone to a UTC datetime.
:param tz: the timezone the datetime is currently in. tz can be passed
as a string or as a timezone object. (i.e. 'US/Central' or
pytz.timezone('US/Central'), etc)
:param ignoretz: will ignore the timezone portion of the... |
Converts UTC datetime object to the specific timezone.
:param dt: the UTC datetime object to convert.
:param tz: the timezone to convert the UTC datetime object info. tz can be
passed as a string or as a timezone object. (i.e. 'US/Central' or
pytz.timezone('US/Central'), etc)
... |
:param dt: string datetime to convert into datetime object.
:return: date object if the string can be parsed into a date. Otherwise,
return None.
:see: http://labix.org/python-dateutil
Examples:
>>> parse_date('2011-12-30')
datetime.date(2011, 12, 30)
>>> parse_date('12/30/2011')
... |
:param dt: string datetime to convert into datetime object.
:return: datetime object if the string can be parsed into a datetime.
Otherwise, return None.
:see: http://labix.org/python-dateutil
Examples:
>>> parse_datetime('2011-12-30 13:45:12 CDT')
2011-12-30 13:45:12
>>> parse_dateti... |
Turns emails off so no emails will be sent.
def turn_emails_off(view_func):
"""Turns emails off so no emails will be sent."""
# Dummy email backend so no emails are sent.
EMAIL_BACKEND_DUMMY = 'django.core.mail.backends.dummy.EmailBackend'
def decorated(request, *args, **kwargs):
orig_email_b... |
Get the md5 hash for a file.
:param file: the file to get the md5 hash for
def get_md5_for_file(file):
"""Get the md5 hash for a file.
:param file: the file to get the md5 hash for
"""
md5 = hashlib.md5()
while True:
data = file.read(md5.block_size)
if not data:
... |
Gets a dict of data form a json file.
:param path: the absolute path to the file
:param encoding: the encoding the file is in
def get_dict_from_json_file(path, encoding='utf-8'):
"""Gets a dict of data form a json file.
:param path: the absolute path to the file
:param encoding: the encoding the ... |
Adds linebreaks only for text that has a newline character.
def linebreaks_safe(value, autoescape=True):
"""
Adds linebreaks only for text that has a newline character.
"""
if isinstance(value, string_types) and '\n' in value:
return linebreaks_filter(value, autoescape=autoescape)
return v... |
Kendall' tau (Rank) Correlation Matrix (for ordinal data)
Parameters
----------
x : ndarray
data set
axis : int, optional
Variables as columns is the default (axis=0). If variables are
in the rows use axis=1
Returns
-------
r : ndarray
Correlation Matrix (K... |
Add sub resource
def add_sub_resource(self, relative_id, sub_resource):
"""Add sub resource"""
existing_sub_resources = self.resources.get(sub_resource.RELATIVE_PATH_TEMPLATE, defaultdict(list))
existing_sub_resources[relative_id].append(sub_resource)
self.resources.update({sub_resource... |
Return the name of the CloudShell model
def cloudshell_model_name(self):
"""Return the name of the CloudShell model"""
if self.shell_name:
return "{shell_name}.{resource_model}".format(shell_name=self.shell_name,
resource_model=self.... |
slice a correlation and p-value matrix of a (y,X) dataset
into a (y,x_i) vector and (x_j, x_k) matrices
Parameters
----------
r : ndarray
Correlation Matrix of a (y,X) dataset
pval : ndarray
p-values
ydim : int
Number of target variables y, i.e. the first ydim-th colum... |
Returns tuple with expression type and expression body
def parse_expression(source: str) -> ExpressionSource:
'''Returns tuple with expression type and expression body'''
if not is_expression(source):
msg = 'Expression is not valid. Expression should be matched with regular expression: {0}'\
... |
Returns list of servers that have not errored in the last five minutes.
If all servers have errored in the last five minutes, returns list with
one item, the server that errored least recently.
def _server_whitelist(self):
'''
Returns list of servers that have not errored in the last fi... |
Creates an instance of Networking Resource by given context
:param shell_name: Shell Name
:type shell_name: str
:param supported_os: list of supported OS
:type supported_os: list
:param context: cloudshell.shell.core.driver_context.ResourceCommandContext
:type context: cloudshell.shell.core.driv... |
Find the N "worst", i.e. insignificant/random and low, correlations
Parameters
----------
rho : ndarray, list
1D array with correlation coefficients
pval : ndarray, list
1D array with p-values
m : int
The desired number of indicies to return
(How many "worst" corre... |
Coerce value into an list.
:param str value: Value to parse.
:returns: list or None if the value is not a JSON array
:raises: TypeError or ValueError if value appears to be an array but can't
be parsed as JSON.
def _parse_array(value):
"""Coerce value into an list.
:param str value: Value... |
Coerce value into an bool.
:param str value: Value to parse.
:returns: bool or None if the value is not a boolean string.
def _parse_boolean(value):
"""Coerce value into an bool.
:param str value: Value to parse.
:returns: bool or None if the value is not a boolean string.
"""
value = val... |
Coerce value into a dict.
:param str value: Value to parse.
:returns: dict or None if the value is not a JSON object
:raises: TypeError or ValueError if value appears to be an object but can't
be parsed as JSON.
def _parse_object(value):
"""Coerce value into a dict.
:param str value: Valu... |
Parse a value into one of a number of types.
This function is used to coerce untyped HTTP parameter strings into an
appropriate type. It tries to coerce the value into each of the allowed
types, and uses the first that evaluates properly.
Because this is coercing a string into multiple, potentially am... |
Parse a value as JSON.
This is just a wrapper around json.loads which re-raises any errors as a
ParseError instead.
:param str value: JSON string.
:param dict sig_params: The logic function's signature parameters.
:returns: the parsed JSON value
def parse_json(value: str, sig_params: List[inspect... |
Maps request param names to match logic function param names.
If a doctor type defined a `param_name` attribute for the name of the
parameter in the request, we should use that as the key when looking up
the value for the request parameter.
When we declare a type we can specify what the parameter name... |
Uses the parameter annotations to coerce string params.
This is used for HTTP requests, in which the form parameters are all
strings, but need to be converted to the appropriate types before
validating them.
:param dict req_params: The parameters specified in the request.
:param dict sig_params: T... |
Pass request info to the async framework.
def _handle_task(self):
"""Pass request info to the async framework."""
headers = self.request.headers
message = None
try:
status_code, output = process_async_task(
headers, self.request.body)
except AbortAnd... |
Migrate autoload details. Add namespace for attributes
:param autoload_details:
:param shell_name:
:param shell_type:
:return:
def migrate_autoload_details(autoload_details, shell_name, shell_type):
""" Migrate autoload details. Add namespace for attributes
:param autoload_details:
:param... |
Creates an instance of Firewall Resource by given context
:param shell_name: Shell Name
:type shell_name: str
:param supported_os: list of supported OS
:type supported_os: list
:param context: cloudshell.shell.core.driver_context.ResourceCommandContext
:type context: cloudshell.shell.core.driver... |
Get right method to convert of the value.
def _get_convert_method(self):
"""
Get right method to convert of the value.
"""
for type_, method in self._map.items():
if type(self.value) is bool and type_ is not bool:
continue
if isinstance(self.value... |
Flatten correlation and p-value matrix
Parameters:
-----------
rho : ndarray
Correlation Matrix
pval : ndarray
Matrix with p-values
sortby : str
sort the output table by
- "cor" the highest absolute correlation coefficient
- "pval" the lowest p-value
... |
Get the maximum value this immediate can have
:return: Maximum value of this immediate
def max(self) -> int:
"""
Get the maximum value this immediate can have
:return: Maximum value of this immediate
"""
if self.signed:
v = (1 << (self.bits - 1)) - 1
... |
Set the immediate to a value. This function checks if the value is valid and will raise an
:class:`InvalidImmediateException` if it doesn't.
:param value: Value to set the immediate to
:type value: int
:raises InvalidImmediateException: value does not match immediate
def set(self, val... |
Set the immediate value from machine code bits. Those are not sign extended, so it will take care of the
proper handling.
:param value: Value to set the immediate to
:type value: int
def set_from_bits(self, value: int):
"""
Set the immediate value from machine code bits. Those ... |
Randomize this immediate to a legal value
def randomize(self):
"""
Randomize this immediate to a legal value
"""
self.value = randint(self.min(), self.max())
if self.lsb0:
self.value = self.value - (self.value % 2) |
Initialize the furious context and registry.
NOTE: Do not directly run this method.
def _init():
"""Initialize the furious context and registry.
NOTE: Do not directly run this method.
"""
# If there is a context and it is initialized to this request,
# return, otherwise reinitialize the _loca... |
Takes an async object and executes its job.
def run_job():
"""Takes an async object and executes its job."""
async = get_current_async()
async_options = async.get_options()
job = async_options.get('job')
if not job:
raise Exception('This async contains no job to execute!')
__, args, k... |
Process the results of executing the Async's target.
def _handle_results(options):
"""Process the results of executing the Async's target."""
results_processor = options.get('_process_results')
if not results_processor:
results_processor = _process_results
processor_result = results_processor(... |
Encode exception to a form that can be passed around and serialized.
This will grab the stack, then strip off the last two calls which are
encode_exception and the function that called it.
def encode_exception(exception):
"""Encode exception to a form that can be passed around and serialized.
This wi... |
Process the results from an Async job.
def _process_results():
"""Process the results from an Async job."""
async = get_current_async()
callbacks = async.get_callbacks()
if not isinstance(async.result.payload, AsyncException):
callback = callbacks.get('success')
else:
callback = ca... |
Execute the given callback or insert the Async callback, or if no
callback is given return the async.result.
def _execute_callback(async, callback):
"""Execute the given callback or insert the Async callback, or if no
callback is given return the async.result.
"""
from furious.async import Async
... |
Pick a state.
def complex_state_generator_bravo(last_state=''):
"""Pick a state."""
from random import choice
states = ['ALPHA', 'BRAVO', 'BRAVO', 'DONE']
if last_state:
states.remove(last_state) # Slightly lower chances of previous state.
state = choice(states)
logging.info('Genera... |
A positive result! Iterate!
def state_machine_success():
"""A positive result! Iterate!"""
from furious.async import Async
from furious.context import get_current_async
result = get_current_async().result
if result == 'ALPHA':
logging.info('Inserting continuation for state %s.', result)... |
Render a cURL command for the given request.
:param str method: HTTP request method (e.g. "GET").
:param str url: HTTP request URL.
:param dict params: JSON body, for POST and PUT requests.
:param dict headers: A dict of HTTP headers.
:returns: list
def get_example_curl_lines(method: str, url: str... |
Render a reStructuredText example for the given request and response.
:param dict headers: A dict of HTTP headers.
:param str method: HTTP request method (e.g. "GET").
:param str url: HTTP request URL.
:param dict params: Form parameters, for POST and PUT requests.
:param str response: Text respons... |
Gets an object reference string from the obj instance.
This adds the object type to ALL_RESOURCES so that it gets documented and
returns a str which contains a sphinx reference to the documented object.
:param obj: The Object instance.
:returns: A sphinx docs reference str.
def get_object_reference(o... |
Returns a description for an array's items.
:param item: The Array type whose items should be documented.
:returns: A string documenting what type the array's items should be.
def get_array_items_description(item: Array) -> str:
"""Returns a description for an array's items.
:param item: The Array ty... |
Returns the json types for the provided annotated type.
This handles special cases for when we encounter UnionType and an Array.
UnionType's will have all valid types returned. An Array will document
what the items type is by placing that value in brackets, e.g. `list[str]`.
:param annotated_type: A ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.