Search is not available for this dataset
text stringlengths 75 104k |
|---|
def set_base_url(self, platform: str = "prod"):
"""Set Isogeo base URLs according to platform.
:param str platform: platform to use. Options:
* prod [DEFAULT]
* qa
* int
"""
platform = platform.lower()
self.platform = platform
if platform =... |
def convert_uuid(self, in_uuid: str = str, mode: bool = 0):
"""Convert a metadata UUID to its URI equivalent. And conversely.
:param str in_uuid: UUID or URI to convert
:param int mode: conversion direction. Options:
* 0 to HEX
* 1 to URN (RFC4122)
* 2 to URN (Iso... |
def encoded_words_to_text(self, in_encoded_words: str):
"""Pull out the character set, encoding, and encoded text from the input
encoded words. Next, it decodes the encoded words into a byte string,
using either the quopri module or base64 module as determined by the
encoding. Finally, i... |
def get_isogeo_version(self, component: str = "api", prot: str = "https"):
"""Get Isogeo components versions. Authentication not required.
:param str component: which platform component. Options:
* api [default]
* db
* app
"""
# which component
if... |
def get_edit_url(
self,
md_id: str = None,
md_type: str = None,
owner_id: str = None,
tab: str = "identification",
):
"""Constructs the edition URL of a metadata.
:param str md_id: metadata/resource UUID
:param str owner_id: owner UUID
:param ... |
def get_view_url(self, webapp: str = "oc", **kwargs):
"""Constructs the view URL of a metadata.
:param str webapp: web app destination
:param dict kwargs: web app specific parameters. For example see WEBAPPS
"""
# build wbeapp URL depending on choosen webapp
if webapp in... |
def register_webapp(self, webapp_name: str, webapp_args: list, webapp_url: str):
"""Register a new WEBAPP to use with the view URL builder.
:param str webapp_name: name of the web app to register
:param list webapp_args: dynamic arguments to complete the URL.
Typically 'md_id'.
... |
def get_url_base_from_url_token(
self, url_api_token: str = "https://id.api.isogeo.com/oauth/token"
):
"""Returns the Isogeo API root URL (which is not included into
credentials file) from the token URL (which is always included).
:param url_api_token str: url to Isogeo API ID token... |
def pages_counter(self, total: int, page_size: int = 100) -> int:
"""Simple helper to handle pagination. Returns the number of pages for a
given number of results.
:param int total: count of metadata in a search request
:param int page_size: count of metadata to display in each page
... |
def tags_to_dict(self, tags=dict, prev_query=dict, duplicated: str = "rename"):
"""Reverse search tags dictionary to values as keys.
Useful to populate filters comboboxes for example.
:param dict tags: tags dictionary from a search request
:param dict prev_query: query parameters return... |
def share_extender(self, share: dict, results_filtered: dict):
"""Extend share model with additional informations.
:param dict share: share returned by API
:param dict results_filtered: filtered search result
"""
# add share administration URL
creator_id = share.get("_cr... |
def credentials_loader(self, in_credentials: str = "client_secrets.json") -> dict:
"""Loads API credentials from a file, JSON or INI.
:param str in_credentials: path to the credentials file. By default,
look for a client_secrets.json file.
"""
accepted_extensions = (".ini", ".... |
def configure(username, password):
# type: (str, str) -> None
"""
Generate .pypirc config with the given credentials.
Example:
$ peltak pypi configure my_pypi_user my_pypi_pass
"""
from peltak.extra.pypi import logic
logic.gen_pypirc(username, password) |
def tr(self, subdomain: str, string_to_translate: str = "") -> str:
"""Returns translation of string passed.
:param str subdomain: subpart of strings dictionary.
Must be one of self.translations.keys() i.e. 'restrictions'
:param str string_to_translate: string you want to translate
... |
def optout_saved(sender, instance, **kwargs):
"""
This is a duplicte of the view code for DRF to stop future
internal Django implementations breaking.
"""
if instance.identity is None:
# look up using the address_type and address
identities = Identity.objects.filter_by_addr(
... |
def get_ec2_client(region_name=None, aws_access_key_id=None, aws_secret_access_key=None):
"""Gets an EC2 client
:return: boto3.client object
:raises: AWSAPIError
"""
log = logging.getLogger(mod_logger + '.get_ec2_client')
# Connect to EC2 API
try:
client = boto3.client('ec2', region... |
def get_vpc_id(self):
"""Gets the VPC ID for this EC2 instance
:return: String instance ID or None
"""
log = logging.getLogger(self.cls_logger + '.get_vpc_id')
# Exit if not running on AWS
if not self.is_aws:
log.info('This machine is not running in AWS, exi... |
def get_eni_id(self, interface=1):
"""Given an interface number, gets the AWS elastic network
interface associated with the interface.
:param interface: Integer associated to the interface/device number
:return: String Elastic Network Interface ID or None if not found
:raises OS... |
def add_secondary_ip(self, ip_address, interface=1):
"""Adds an IP address as a secondary IP address
:param ip_address: String IP address to add as a secondary IP
:param interface: Integer associated to the interface/device number
:return: None
:raises: AWSAPIError, EC2UtilError... |
def associate_elastic_ip(self, allocation_id, interface=1, private_ip=None):
"""Given an elastic IP address and an interface number, associates the
elastic IP to the interface number on this host.
:param allocation_id: String ID for the elastic IP
:param interface: Integer associated to... |
def allocate_elastic_ip(self):
"""Allocates an elastic IP address
:return: Dict with allocation ID and Public IP that were created
:raises: AWSAPIError, EC2UtilError
"""
log = logging.getLogger(self.cls_logger + '.allocate_elastic_ip')
# Attempt to allocate a new elasti... |
def attach_new_eni(self, subnet_name, security_group_ids, device_index=2, allocation_id=None, description=''):
"""Creates a new Elastic Network Interface on the Subnet
matching the subnet_name, with Security Group identified by
the security_group_name, then attaches an Elastic IP address
... |
def get_elastic_ips(self):
"""Returns the elastic IP info for this instance any are
attached
:return: (dict) Info about the Elastic IPs
:raises AWSAPIError
"""
log = logging.getLogger(self.cls_logger + '.get_elastic_ips')
instance_id = get_instance_id()
i... |
def disassociate_elastic_ips(self):
"""For each attached Elastic IP, disassociate it
:return: None
:raises AWSAPIError
"""
log = logging.getLogger(self.cls_logger + '.disassociate_elastic_ips')
try:
address_info = self.get_elastic_ips()
except AWSAPI... |
def create_security_group(self, name, description='', vpc_id=None):
"""Creates a new Security Group with the specified name,
description, in the specified vpc_id if provided. If
vpc_id is not provided, use self.vpc_id
:param name: (str) Security Group Name
:param description: (... |
def list_security_groups_in_vpc(self, vpc_id=None):
"""Lists security groups in the VPC. If vpc_id is not provided, use self.vpc_id
:param vpc_id: (str) VPC ID to list security groups for
:return: (list) Security Group info
:raises: AWSAPIError, EC2UtilError
"""
log = l... |
def configure_security_group_ingress(self, security_group_id, port, desired_cidr_blocks):
"""Configures the security group ID allowing access
only to the specified CIDR blocks, for the specified
port number.
:param security_group_id: (str) Security Group ID
:param port: (str) TC... |
def revoke_security_group_ingress(self, security_group_id, ingress_rules):
"""Revokes all ingress rules for a security group bu ID
:param security_group_id: (str) Security Group ID
:param port: (str) TCP Port number
:param ingress_rules: (list) List of IP permissions (see AWS API docs r... |
def launch_instance(self, ami_id, key_name, subnet_id, security_group_id=None, security_group_list=None,
user_data_script_path=None, instance_type='t2.small', root_device_name='/dev/xvda'):
"""Launches an EC2 instance with the specified parameters, intended to launch
an instance ... |
def get_ec2_instances(self):
"""Describes the EC2 instances
:return: dict containing EC2 instance data
:raises: EC2UtilError
"""
log = logging.getLogger(self.cls_logger + '.get_ec2_instances')
log.info('Describing EC2 instances...')
try:
response = se... |
def docs_cli(ctx, recreate, gen_index, run_doctests):
# type: (click.Context, bool, bool, bool) -> None
""" Build project documentation.
This command will run sphinx-refdoc first to generate the reference
documentation for the code base. Then it will run sphinx to generate the
final docs. You can c... |
def as_string(value):
"""Convert a value to a Unicode object for matching with a query.
None becomes the empty string. Bytestrings are silently decoded.
"""
if six.PY2:
buffer_types = buffer, memoryview # noqa: F821
else:
buffer_types = memoryview
if value is None:
retu... |
def displayable_path(path, separator=u'; '):
"""Attempts to decode a bytestring path to a unicode object for the
purpose of displaying it to the user. If the `path` argument is a
list or a tuple, the elements are joined with `separator`.
"""
if isinstance(path, (list, tuple)):
return separat... |
def syspath(path, prefix=True):
"""Convert a path for use by the operating system. In particular,
paths on Windows must receive a magic prefix and must be converted
to Unicode before they are sent to the OS. To disable the magic
prefix on Windows, set `prefix` to False---but only do this if you
*rea... |
def on_new(self, button):
'''
Copy selected notebook template to notebook directory.
## Notes ##
- An exception is raised if the parent of the selected file is the
notebook directory.
- If notebook with same name already exists in notebook directory,
off... |
def se_iban_load_map(filename: str) -> list:
"""
Loads Swedish monetary institution codes in CSV format.
:param filename: CSV file name of the BIC definitions.
Columns: Institution Name, Range Begin-Range End (inclusive), Account digits count
:return: List of (bank name, clearing code begin, clearin... |
def admin_log(instances, msg: str, who: User=None, **kw):
"""
Logs an entry to admin logs of model(s).
:param instances: Model instance or list of instances
:param msg: Message to log
:param who: Who did the change
:param kw: Optional key-value attributes to append to message
:return: None
... |
def kw_changelist_view(self, request: HttpRequest, extra_context=None, **kw):
"""
Changelist view which allow key-value arguments.
:param request: HttpRequest
:param extra_context: Extra context dict
:param kw: Key-value dict
:return: See changelist_view()
"""
... |
def history_view(self, request, object_id, extra_context=None):
from django.template.response import TemplateResponse
from django.contrib.admin.options import get_content_type_for_model
from django.contrib.admin.utils import unquote
from django.core.exceptions import PermissionDenied
... |
def get_object_by_filename(self, request, filename):
"""
Returns owner object by filename (to be downloaded).
This can be used to implement custom permission checks.
:param request: HttpRequest
:param filename: File name of the downloaded object.
:return: owner object
... |
def get_download_urls(self):
"""
Use like this:
def get_urls(self):
return self.get_download_urls() + super().get_urls()
Returns: File download URLs for this model.
"""
info = self.model._meta.app_label, self.model._meta.model_name
return [
... |
def write(version):
# type: (str) -> None
""" Write the given version to the VERSION_FILE """
if not is_valid(version):
raise ValueError("Invalid version: ".format(version))
storage = get_version_storage()
storage.write(version) |
def bump(component='patch', exact=None):
# type: (str, str) -> Tuple[str, str]
""" Bump the given version component.
Args:
component (str):
What part of the version should be bumped. Can be one of:
- major
- minor
- patch
exact (str):
... |
def _bump_version(version, component='patch'):
# type: (str, str) -> str
""" Bump the given version component.
Args:
version (str):
The current version. The format is: MAJOR.MINOR[.PATCH].
component (str):
What part of the version should be bumped. Can be one of:
... |
def get_version_storage():
# type: () -> VersionStorage
""" Get version storage for the given version file.
The storage engine used depends on the extension of the *version_file*.
"""
version_file = conf.get_path('version_file', 'VERSION')
if version_file.endswith('.py'):
return PyVersi... |
def read(self):
# type: () -> Optional[str]
""" Read the project version from .py file.
This will regex search in the file for a
``__version__ = VERSION_STRING`` and read the version string.
"""
with open(self.version_file) as fp:
content = fp.read()
... |
def write(self, version):
# type: (str) -> None
""" Write the project version to .py file.
This will regex search in the file for a
``__version__ = VERSION_STRING`` and substitute the version string
for the new version.
"""
with open(self.version_file) as fp:
... |
def read(self):
# type: () -> Optional[str]
""" Read the project version from .py file.
This will regex search in the file for a
``__version__ = VERSION_STRING`` and read the version string.
"""
with open(self.version_file) as fp:
version = fp.read().strip()
... |
def loggray(x, a, b):
"""Auxiliary function that specifies the logarithmic gray scale.
a and b are the cutoffs."""
linval = 10.0 + 990.0 * (x-float(a))/(b-a)
return (np.log10(linval)-1.0)*0.5 * 255.0 |
def fromfits(infile, hdu = 0, verbose = True):
"""
Factory function that reads a FITS file and returns a f2nimage object.
Use hdu to specify which HDU you want (primary = 0)
"""
pixelarray, hdr = ft.getdata(infile, hdu, header=True)
pixelarray = np.asarray(pixelarray).transpose()
#print... |
def rebin(a, newshape):
"""
Auxiliary function to rebin ndarray data.
Source : http://www.scipy.org/Cookbook/Rebinning
example usage:
>>> a=rand(6,4); b=rebin(a,(3,2))
"""
shape = a.shape
lenShape = len(shape)
factor = np.asarray(shape)/np.asarray(newshape)
... |
def compose(f2nimages, outfile):
"""
Takes f2nimages and writes them into one single png file, side by side.
f2nimages is a list of horizontal lines, where each line is a list of f2nimages.
For instance :
[
[image1, image2],
[image3, image4]
]
The sizes of these images have to "match... |
def setzscale(self, z1="auto", z2="auto", nsig=3, samplesizelimit = 10000, border=300):
"""
We set z1 and z2, according to different algorithms or arguments.
For both z1 and z2, give either :
- "auto" (default automatic, different between z1 and z2)
- "e... |
def crop(self, xa, xb, ya, yb):
"""
Crops the image. Two points :
- We use numpy conventions
xa = 200 and xb = 400 will give you a width of 200 pixels !
- We crop relative to the current array (i.e. not necessarily to the original array !)
... |
def irafcrop(self, irafcropstring):
"""
This is a wrapper around crop(), similar to iraf imcopy,
using iraf conventions (100:199 will be 100 pixels, not 99).
"""
irafcropstring = irafcropstring[1:-1] # removing the [ ]
ranges = irafcropstring.split(",")
xr = range... |
def rebin(self, factor):
"""
I robustly rebin your image by a given factor.
You simply specify a factor, and I will eventually take care of a crop to bring
the image to interger-multiple-of-your-factor dimensions.
Note that if you crop your image before, you must directly crop to... |
def makepilimage(self, scale = "log", negative = False):
"""
Makes a PIL image out of the array, respecting the z1 and z2 cutoffs.
By default we use a log scaling identical to iraf's, and produce an image of mode "L", i.e. grayscale.
But some drawings or colourscales will change the mode... |
def drawmask(self, maskarray, colour = 128):
"""
I draw a mask on the image.
Give me a numpy "maskarray" of same size as mine, and I draw on the pilimage all pixels
of the maskarray that are True in the maskcolour.
By default, colour is gray, to avoid switching to RGB.
Bu... |
def showcutoffs(self, redblue = False):
"""
We use drawmask to visualize pixels above and below the z cutoffs.
By default this is done in black (above) and white (below) (and adapts to negative images).
But if you choose redblue = True, I use red for above z2 and blue for below z1.
... |
def makedraw(self):
"""Auxiliary method to make a draw object if not yet done.
This is also called by changecolourmode, when we go from L to RGB, to get a new draw object.
"""
if self.draw == None:
self.draw = imdw.Draw(self.pilimage) |
def defaultcolour(self, colour):
"""
Auxiliary method to choose a default colour.
Give me a user provided colour : if it is None, I change it to the default colour, respecting negative.
Plus, if the image is in RGB mode and you give me 128 for a gray, I translate this to the expected (12... |
def loadtitlefont(self):
"""Auxiliary method to load font if not yet done."""
if self.titlefont == None:
# print 'the bloody fonts dir is????', fontsdir
# print 'pero esto que hace??', os.path.join(fontsdir, "courR18.pil")
# /home/vital/Workspace/pyResources/Scientifi... |
def loadinfofont(self):
"""Auxiliary method to load font if not yet done."""
if self.infofont == None:
self.infofont = imft.load_path(os.path.join(fontsdir, "courR10.pil")) |
def loadlabelfont(self):
"""Auxiliary method to load font if not yet done."""
if self.labelfont == None:
self.labelfont = imft.load_path(os.path.join(fontsdir, "courR10.pil")) |
def changecolourmode(self, newcolour):
"""Auxiliary method to change the colour mode.
Give me a colour (either an int, or a 3-tuple, values 0 to 255) and I decide if the image mode has to
be switched from "L" to "RGB".
"""
if type(newcolour) != type(0) and self.pilimage.mode != "... |
def upsample(self, factor):
"""
The inverse operation of rebin, applied on the PIL image.
Do this before writing text or drawing on the image !
The coordinates will be automatically converted for you
"""
self.checkforpilimage()
if type(factor) !=... |
def pilcoords(self, (x,y)):
"""
Converts the coordinates (x,y) of the original array or FITS file to the current coordinates of the PIL image,
respecting cropping, rebinning, and upsampling.
This is only used once the PIL image is available, for drawing.
Note that we also have to... |
def pilscale(self, r):
"""
Converts a "scale" (like an aperture radius) of the original array or FITS file to the current PIL coordinates.
"""
return r * float(self.upsamplefactor) / float(self.binfactor) |
def drawpoint(self, x, y, colour = None):
"""
Most elementary drawing, single pixel, used mainly for testing purposes.
Coordinates are those of your initial image !
"""
self.checkforpilimage()
colour = self.defaultcolour(colour)
self.changecolourmode(colour)
... |
def drawcircle(self, x, y, r = 10, colour = None, label = None):
"""
Draws a circle centered on (x, y) with radius r. All these are in the coordinates of your initial image !
You give these x and y in the usual ds9 pixels, (0,0) is bottom left.
I will convert this into the right PIL coor... |
def drawrectangle(self, xa, xb, ya, yb, colour=None, label = None):
"""
Draws a 1-pixel wide frame AROUND the region you specify. Same convention as for crop().
"""
self.checkforpilimage()
colour = self.defaultcolour(colour)
self.changecolourmode(colour)
... |
def writetitle(self, titlestring, colour = None):
"""
We write a title, centered below the image.
"""
self.checkforpilimage()
colour = self.defaultcolour(colour)
self.changecolourmode(colour)
self.makedraw()
self.loadtitlefont()
... |
def writeinfo(self, linelist, colour = None):
"""
We add a longer chunk of text on the upper left corner of the image.
Provide linelist, a list of strings that will be written one below the other.
"""
self.checkforpilimage()
colour = self.defaultcolour(colour)
... |
def drawstarslist(self, dictlist, r = 10, colour = None):
"""
Calls drawcircle and writelable for an list of stars.
Provide a list of dictionnaries, where each dictionnary contains "name", "x", and "y".
"""
self.checkforpilimage()
colour = self.defaultco... |
def drawstarsfile(self, filename, r = 10, colour = None):
"""
Same as drawstarlist but we read the stars from a file.
Here we read a text file of hand picked stars. Same format as for cosmouline, that is :
# comment
starA 23.4 45.6 [other stuff...]
Then we pass t... |
def tonet(self, outfile):
"""
Writes the PIL image into a png.
We do not want to flip the image at this stage, as you might have written on it !
"""
self.checkforpilimage()
if self.verbose :
print "Writing image to %s...\n%i x %i pixels, mode %s" % (o... |
def cors_setup(self, request):
"""
Sets up the CORS headers response based on the settings used for the API.
:param request: <pyramid.request.Request>
"""
def cors_headers(request, response):
if request.method.lower() == 'options':
response.headers.up... |
def factory(self, request, parent=None, name=None):
"""
Returns a new service for the given request.
:param request | <pyramid.request.Request>
:return <pyramid_restful.services.AbstractService>
"""
traverse = request.matchdict['traverse']
# show docum... |
def register(self, service, name=''):
"""
Exposes a given service to this API.
"""
# expose a sub-factory
if isinstance(service, ApiFactory):
self.services[name] = (service.factory, None)
# expose a module dynamically as a service
elif inspect.ismodul... |
def serve(self, config, path, route_name=None, permission=None, **view_options):
"""
Serves this API from the inputted root path
"""
route_name = route_name or path.replace('/', '.').strip('.')
path = path.strip('/') + '*traverse'
self.route_name = route_name
sel... |
def line(separator="-·-", color=None, padding=None, num=1):
""" Prints a line separator the full width of the terminal.
@separator: the #str chars to create the line from
@color: line color from :mod:vital.debug.colors
@padding: adds extra lines to either the top, bottom or both
... |
def padd(text, padding="top", size=1):
""" Adds extra new lines to the top, bottom or both of a String
@text: #str text to pad
@padding: #str 'top', 'bottom' or 'all'
@size: #int number of new lines
-> #str padded @text
..
from vital.debug import *
... |
def colorize(text, color="BLUE", close=True):
""" Colorizes text for terminal outputs
@text: #str to colorize
@color: #str color from :mod:colors
@close: #bool whether or not to reset the color
-> #str colorized @text
..
from vital.debug import colorize
... |
def bold(text, close=True):
""" Bolds text for terminal outputs
@text: #str to bold
@close: #bool whether or not to reset the bold flag
-> #str bolded @text
..
from vital.debug import bold
bold("Hello world")
# -> '\x1b[1mHello world\x1b[1;m'
... |
def cut(text, length=50, replace_with="…"):
""" Shortens text to @length, appends @replace_with to end of string
if the string length is > @length
@text: #str text to shortens
@length: #int max length of string
@replace_with: #str to replace chars beyond @length with
..
... |
def flag(text=None, color=None, padding=None, show=True, brackets='⸨⸩'):
""" Wraps @text in parentheses (), optionally colors and pads and
prints the text.
@text: #str text to (flag)
@color: #str color to :func:colorize the text within
@padding: #str location of padding from :func:p... |
def table_mapping(data, padding=1, separator=" "):
""" Pretty prints a one-dimensional key: value mapping
@data: #dict data to pretty print
@padding: #int number of spaces to pad the left side of the key with
@separator: #str chars to separate the key and value pair with
-> #str pr... |
def gen_rand_str(*size, use=None, keyspace=None):
""" Generates a random string using random module specified in @use within
the @keyspace
@*size: #int size range for the length of the string
@use: the random module to use
@keyspace: #str chars allowed in the random string
.... |
def get_parent_name(obj):
""" Gets the name of the object containing @obj and returns as a string
@obj: any python object
-> #str parent object name or None
..
from vital.debug import get_parent_name
get_parent_name(get_parent_name)
# -> 'vital.debug'
... |
def get_class_that_defined_method(meth):
""" Gets the class object which defined a given method
@meth: a class method
-> owner class object
"""
if inspect.ismethod(meth):
for cls in inspect.getmro(meth.__self__.__class__):
if cls.__dict__.get(meth.__name__) is meth:
... |
def get_parent_obj(obj):
""" Gets the name of the object containing @obj and returns as a string
@obj: any python object
-> #str parent object name or None
..
from vital.debug import get_parent_obj
get_parent_obj(get_parent_obj)
# -> <module 'vital.debu... |
def format_obj_name(obj, delim="<>"):
""" Formats the object name in a pretty way
@obj: any python object
@delim: the characters to wrap a parent object name in
-> #str formatted name
..
from vital.debug import format_obj_name
format_obj_name(vital.debug.Ti... |
def preprX(*attributes, address=True, full_name=False,
pretty=False, keyless=False, **kwargs):
""" `Creates prettier object representations`
@*attributes: (#str) instance attributes within the object you
wish to display. Attributes can be recursive
e.g. |one.two.three| fo... |
def add_attrs(self, *args, _order=[], **kwargs):
""" Adds attributes to the __repr__ string
@order: optional #list containing order to display kwargs
"""
for arg in args:
if isinstance(arg, (tuple, list)):
key, color = arg
self.attrs[key] =... |
def _format_attrs(self):
""" Formats the self.attrs #OrderedDict """
_bold = bold
_colorize = colorize
if not self.pretty:
_bold = lambda x: x
_colorize = lambda x, c: x
attrs = []
add_attr = attrs.append
if self.doc and hasattr(self.obj, "... |
def format(self):
""" Formats the __repr__ string
-> #str containing __repr__ output
"""
_bold = bold
_break = "\n "
if not self.pretty:
_bold = lambda x: x
# Attach memory address and return
_attrs = self._format_attrs()
parent_... |
def randstr(self):
""" -> #str result of :func:gen_rand_str """
return gen_rand_str(
4, 10, use=self.random, keyspace=list(string.ascii_letters)) |
def randbytes(self):
""" -> #bytes result of bytes-encoded :func:gen_rand_str """
return gen_rand_str(
10, 30, use=self.random, keyspace=list(self.keyspace)
).encode("utf-8") |
def randdomain(self):
""" -> a randomized domain-like name """
return '.'.join(
rand_readable(3, 6, use=self.random, density=3)
for _ in range(self.random.randint(1, 2))
).lower() |
def randpath(self):
""" -> a random URI-like #str path """
return '/'.join(
gen_rand_str(3, 10, use=self.random, keyspace=list(self.keyspace))
for _ in range(self.random.randint(0, 3))) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.