text
stringlengths
81
112k
Helper function that saves the token on disk def _save_token_on_disk(self): """Helper function that saves the token on disk""" token = self._token.copy() # Client secret is needed for token refreshing and isn't returned # as a pared of OAuth token by default token.update(client...
Get Monzo access token via OAuth2 `authorization code` grant type. Official docs: https://monzo.com/docs/#acquire-an-access-token :returns: OAuth 2 access token :rtype: dict def _get_oauth_token(self): """ Get Monzo access token via OAuth2 `authorization code` gran...
Refresh Monzo OAuth 2 token. Official docs: https://monzo.com/docs/#refreshing-access :raises UnableToRefreshTokenException: when token couldn't be refreshed def _refresh_oath_token(self): """ Refresh Monzo OAuth 2 token. Official docs: https://monzo.c...
Helper method to handle HTTP requests and catch API errors :param method: valid HTTP method :type method: str :param endpoint: API endpoint :type endpoint: str :param params: extra parameters passed with the request :type params: dict :returns: API response ...
Get information about the access token. Official docs: https://monzo.com/docs/#authenticating-requests :returns: access token details :rtype: dict def whoami(self): """ Get information about the access token. Official docs: https://monzo.com/do...
Returns a list of accounts owned by the currently authorised user. It's often used when deciding whether to require explicit account ID or use the only available one, so we cache the response by default. Official docs: https://monzo.com/docs/#list-accounts :param refresh: d...
Returns balance information for a specific account. Official docs: https://monzo.com/docs/#read-balance :param account_id: Monzo account ID :type account_id: str :raises: ValueError :returns: Monzo balance instance :rtype: MonzoBalance def balance(self, acc...
Returns a list of pots owned by the currently authorised user. Official docs: https://monzo.com/docs/#pots :param refresh: decides if the pots information should be refreshed. :type refresh: bool :returns: list of Monzo pots :rtype: list of MonzoPot def pots(self, ...
Returns a list of transactions on the user's account. Official docs: https://monzo.com/docs/#list-transactions :param account_id: Monzo account ID :type account_id: str :param reverse: whether transactions should be in in descending order :type reverse: bool ...
Returns an individual transaction, fetched by its id. Official docs: https://monzo.com/docs/#retrieve-transaction :param transaction_id: Monzo transaction ID :type transaction_id: str :param expand_merchant: whether merchant data should be included :type expand_merc...
Launch it. def launcher(): """Launch it.""" parser = OptionParser() parser.add_option( '-f', '--file', dest='filename', default='agents.csv', help='snmposter configuration file' ) options, args = parser.parse_args() factory = SNMPosterFactory() snmp...
Create auth string from credentials. def get_auth_string(self): """Create auth string from credentials.""" auth_info = '{}:{}'.format(self.sauce_username, self.sauce_access_key) return base64.b64encode(auth_info.encode('utf-8')).decode('utf-8')
Add authorization header. def make_auth_headers(self, content_type): """Add authorization header.""" headers = self.make_headers(content_type) headers['Authorization'] = 'Basic {}'.format(self.get_auth_string()) return headers
Send http request. def request(self, method, url, body=None, content_type='application/json'): """Send http request.""" headers = self.make_auth_headers(content_type) connection = http_client.HTTPSConnection(self.apibase) connection.request(method, url, body, headers=headers) re...
Access basic account information. def get_user(self): """Access basic account information.""" method = 'GET' endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username) return self.client.request(method, endpoint)
Create a sub account. def create_user(self, username, password, name, email): """Create a sub account.""" method = 'POST' endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username) body = json.dumps({'username': username, 'password': password, 'name': n...
Check account concurrency limits. def get_concurrency(self): """Check account concurrency limits.""" method = 'GET' endpoint = '/rest/v1.1/users/{}/concurrency'.format( self.client.sauce_username) return self.client.request(method, endpoint)
Get a list of sub accounts associated with a parent account. def get_subaccounts(self): """Get a list of sub accounts associated with a parent account.""" method = 'GET' endpoint = '/rest/v1/users/{}/list-subaccounts'.format( self.client.sauce_username) return self.client.re...
Get a list of sibling accounts associated with provided account. def get_siblings(self): """Get a list of sibling accounts associated with provided account.""" method = 'GET' endpoint = '/rest/v1.1/users/{}/siblings'.format( self.client.sauce_username) return self.client.req...
Get information about a sub account. def get_subaccount_info(self): """Get information about a sub account.""" method = 'GET' endpoint = '/rest/v1/users/{}/subaccounts'.format( self.client.sauce_username) return self.client.request(method, endpoint)
Change access key of your account. def change_access_key(self): """Change access key of your account.""" method = 'POST' endpoint = '/rest/v1/users/{}/accesskey/change'.format( self.client.sauce_username) return self.client.request(method, endpoint)
Check account concurrency limits. def get_activity(self): """Check account concurrency limits.""" method = 'GET' endpoint = '/rest/v1/{}/activity'.format(self.client.sauce_username) return self.client.request(method, endpoint)
Access historical account usage data. def get_usage(self, start=None, end=None): """Access historical account usage data.""" method = 'GET' endpoint = '/rest/v1/users/{}/usage'.format(self.client.sauce_username) data = {} if start: data['start'] = start if en...
Get a list of objects describing all the OS and browser platforms currently supported on Sauce Labs. def get_platforms(self, automation_api='all'): """Get a list of objects describing all the OS and browser platforms currently supported on Sauce Labs.""" method = 'GET' endpoint ...
List jobs belonging to a specific user. def get_jobs(self, full=None, limit=None, skip=None, start=None, end=None, output_format=None): """List jobs belonging to a specific user.""" method = 'GET' endpoint = '/rest/v1/{}/jobs'.format(self.client.sauce_username) data = {...
Edit an existing job. def update_job(self, job_id, build=None, custom_data=None, name=None, passed=None, public=None, tags=None): """Edit an existing job.""" method = 'PUT' endpoint = '/rest/v1/{}/jobs/{}'.format(self.client.sauce_username, ...
Terminates a running job. def stop_job(self, job_id): """Terminates a running job.""" method = 'PUT' endpoint = '/rest/v1/{}/jobs/{}/stop'.format( self.client.sauce_username, job_id) return self.client.request(method, endpoint)
Get details about the static assets collected for a specific job. def get_job_asset_url(self, job_id, filename): """Get details about the static assets collected for a specific job.""" return 'https://saucelabs.com/rest/v1/{}/jobs/{}/assets/{}'.format( self.client.sauce_username, job_id, fi...
Get an auth token to access protected job resources. https://wiki.saucelabs.com/display/DOCS/Building+Links+to+Test+Results def get_auth_token(self, job_id, date_range=None): """Get an auth token to access protected job resources. https://wiki.saucelabs.com/display/DOCS/Building+Links+to+Test...
Uploads a file to the temporary sauce storage. def upload_file(self, filepath, overwrite=True): """Uploads a file to the temporary sauce storage.""" method = 'POST' filename = os.path.split(filepath)[1] endpoint = '/rest/v1/storage/{}/{}?overwrite={}'.format( self.client.sau...
Check which files are in your temporary storage. def get_stored_files(self): """Check which files are in your temporary storage.""" method = 'GET' endpoint = '/rest/v1/storage/{}'.format(self.client.sauce_username) return self.client.request(method, endpoint)
Retrieves all running tunnels for a specific user. def get_tunnels(self): """Retrieves all running tunnels for a specific user.""" method = 'GET' endpoint = '/rest/v1/{}/tunnels'.format(self.client.sauce_username) return self.client.request(method, endpoint)
Get information for a tunnel given its ID. def get_tunnel(self, tunnel_id): """Get information for a tunnel given its ID.""" method = 'GET' endpoint = '/rest/v1/{}/tunnels/{}'.format( self.client.sauce_username, tunnel_id) return self.client.request(method, endpoint)
Apply a patch. The patch's :attr:`~Patch.obj` attribute is injected into the patch's :attr:`~Patch.destination` under the patch's :attr:`~Patch.name`. This is a wrapper around calling ``setattr(patch.destination, patch.name, patch.obj)``. Parameters ---------- patch : gorilla.Patch ...
Decorator to create a patch. The object being decorated becomes the :attr:`~Patch.obj` attribute of the patch. Parameters ---------- destination : object Patch destination. name : str Name of the attribute at the destination. settings : gorilla.Settings Settings. ...
Decorator to create a patch for each member of a module or a class. Parameters ---------- destination : object Patch destination. settings : gorilla.Settings Settings. traverse_bases : bool If the object is a class, the base classes are also traversed. filter : function ...
Modifier decorator to update a patch's destination. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- value : object Patch destination. ...
Modifier decorator to update a patch's settings. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- kwargs Settings to update. See :class:`Set...
Modifier decorator to force the inclusion or exclusion of an attribute. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- value : bool ``True...
Create a patch for each member of a module or a class. Parameters ---------- destination : object Patch destination. root : object Root object, either a module or a class. settings : gorilla.Settings Settings. traverse_bases : bool If the object is a class, the b...
Find all the patches created through decorators. Parameters ---------- modules : list of module Modules and/or packages to search the patches in. recursive : bool ``True`` to search recursively in subpackages. Returns ------- list of gorilla.Patch Patches found. ...
Retrieve an attribute while bypassing the descriptor protocol. As per the built-in |getattr()|_ function, if the input object is a class then its base classes might also be searched until the attribute is found. Parameters ---------- obj : object Object to search the attribute in. name...
Retrieve any decorator data from an object. Parameters ---------- obj : object Object. set_default : bool If no data is found, a default one is set on the object and returned, otherwise ``None`` is returned. Returns ------- gorilla.DecoratorData The decorato...
Unwrap decorators to retrieve the base object. def _get_base(obj): """Unwrap decorators to retrieve the base object.""" if hasattr(obj, '__func__'): obj = obj.__func__ elif isinstance(obj, property): obj = obj.fget elif isinstance(obj, (classmethod, staticmethod)): # Fallback fo...
Retrieve the member attributes of a module or a class. The descriptor protocol is bypassed. def _get_members(obj, traverse_bases=True, filter=default_filter, recursive=True): """Retrieve the member attributes of a module or a class. The descriptor protocol is bypassed.""" if filter i...
Iterate over modules. def _module_iterator(root, recursive=True): """Iterate over modules.""" yield root stack = collections.deque((root,)) while stack: package = stack.popleft() # The '__path__' attribute of a package might return a list of paths if # the package is referenced...
Update some attributes. If a 'settings' attribute is passed as a dict, then it updates the content of the settings, if any, instead of completely overwriting it. def _update(self, **kwargs): """Update some attributes. If a 'settings' attribute is passed as a dict, then it updates the ...
To make a request to the API. def request(self, path, action, data=''): """To make a request to the API.""" # Check if the path includes URL or not. head = self.base_url if path.startswith(head): path = path[len(head):] path = quote_plus(path, safe='/') i...
To get pagewise data. def get_collection(self, path): """To get pagewise data.""" while True: items = self.get(path) req = self.req for item in items: yield item if req.links and req.links['next'] and\ req.links['next']...
To return all items generated by get collection. def collection(self, path): """To return all items generated by get collection.""" data = [] for item in self.get_collection(path): data.append(item) return data
List projects with searchstring. def list_projects_search(self, searchstring): """List projects with searchstring.""" log.debug('List all projects with: %s' % searchstring) return self.collection('projects/search/%s.json' % quote_plus(searchstring))
Create a project. def create_project(self, data): """Create a project.""" # http://teampasswordmanager.com/docs/api-projects/#create_project log.info('Create project: %s' % data) NewID = self.post('projects.json', data).get('id') log.info('Project has been created with ID %s' % ...
Update a project. def update_project(self, ID, data): """Update a project.""" # http://teampasswordmanager.com/docs/api-projects/#update_project log.info('Update project %s with %s' % (ID, data)) self.put('projects/%s.json' % ID, data)
Change parent of project. def change_parent_of_project(self, ID, NewParrentID): """Change parent of project.""" # http://teampasswordmanager.com/docs/api-projects/#change_parent log.info('Change parrent for project %s to %s' % (ID, NewParrentID)) data = {'parent_id': NewParrentID} ...
Update security of project. def update_security_of_project(self, ID, data): """Update security of project.""" # http://teampasswordmanager.com/docs/api-projects/#update_project_security log.info('Update project %s security %s' % (ID, data)) self.put('projects/%s/security.json' % ID, dat...
List passwords with searchstring. def list_passwords_search(self, searchstring): """List passwords with searchstring.""" log.debug('List all passwords with: %s' % searchstring) return self.collection('passwords/search/%s.json' % quote_plus(searchstring))
Create a password. def create_password(self, data): """Create a password.""" # http://teampasswordmanager.com/docs/api-passwords/#create_password log.info('Create new password %s' % data) NewID = self.post('passwords.json', data).get('id') log.info('Password has been created wit...
Update a password. def update_password(self, ID, data): """Update a password.""" # http://teampasswordmanager.com/docs/api-passwords/#update_password log.info('Update Password %s with %s' % (ID, data)) self.put('passwords/%s.json' % ID, data)
Update security of a password. def update_security_of_password(self, ID, data): """Update security of a password.""" # http://teampasswordmanager.com/docs/api-passwords/#update_security_password log.info('Update security of password %s with %s' % (ID, data)) self.put('passwords/%s/secur...
Update custom fields definitions of a password. def update_custom_fields_of_password(self, ID, data): """Update custom fields definitions of a password.""" # http://teampasswordmanager.com/docs/api-passwords/#update_cf_password log.info('Update custom fields of password %s with %s' % (ID, data)...
Unlock a password. def unlock_password(self, ID, reason): """Unlock a password.""" # http://teampasswordmanager.com/docs/api-passwords/#unlock_password log.info('Unlock password %s, Reason: %s' % (ID, reason)) self.unlock_reason = reason self.put('passwords/%s/unlock.json' % ID)
List my passwords with searchstring. def list_mypasswords_search(self, searchstring): """List my passwords with searchstring.""" # http://teampasswordmanager.com/docs/api-my-passwords/#list_passwords log.debug('List MyPasswords with %s' % searchstring) return self.collection('my_passwor...
Create my password. def create_mypassword(self, data): """Create my password.""" # http://teampasswordmanager.com/docs/api-my-passwords/#create_password log.info('Create MyPassword with %s' % data) NewID = self.post('my_passwords.json', data).get('id') log.info('MyPassword has b...
Update my password. def update_mypassword(self, ID, data): """Update my password.""" # http://teampasswordmanager.com/docs/api-my-passwords/#update_password log.info('Update MyPassword %s with %s' % (ID, data)) self.put('my_passwords/%s.json' % ID, data)
Create a User. def create_user(self, data): """Create a User.""" # http://teampasswordmanager.com/docs/api-users/#create_user log.info('Create user with %s' % data) NewID = self.post('users.json', data).get('id') log.info('User has been created with ID %s' % NewID) retur...
Update a User. def update_user(self, ID, data): """Update a User.""" # http://teampasswordmanager.com/docs/api-users/#update_user log.info('Update user %s with %s' % (ID, data)) self.put('users/%s.json' % ID, data)
Change password of a User. def change_user_password(self, ID, data): """Change password of a User.""" # http://teampasswordmanager.com/docs/api-users/#change_password log.info('Change user %s password' % ID) self.put('users/%s/change_password.json' % ID, data)
Convert a normal user to a LDAP user. def convert_user_to_ldap(self, ID, DN): """Convert a normal user to a LDAP user.""" # http://teampasswordmanager.com/docs/api-users/#convert_to_ldap data = {'login_dn': DN} log.info('Convert User %s to LDAP DN %s' % (ID, DN)) self.put('users...
Create a Group. def create_group(self, data): """Create a Group.""" # http://teampasswordmanager.com/docs/api-groups/#create_group log.info('Create group with %s' % data) NewID = self.post('groups.json', data).get('id') log.info('Group has been created with ID %s' % NewID) ...
Update a Group. def update_group(self, ID, data): """Update a Group.""" # http://teampasswordmanager.com/docs/api-groups/#update_group log.info('Update group %s with %s' % (ID, data)) self.put('groups/%s.json' % ID, data)
Add a user to a group. def add_user_to_group(self, GroupID, UserID): """Add a user to a group.""" # http://teampasswordmanager.com/docs/api-groups/#add_user log.info('Add User %s to Group %s' % (UserID, GroupID)) self.put('groups/%s/add_user/%s.json' % (GroupID, UserID))
Delete a user from a group. def delete_user_from_group(self, GroupID, UserID): """Delete a user from a group.""" # http://teampasswordmanager.com/docs/api-groups/#del_user log.info('Delete user %s from group %s' % (UserID, GroupID)) self.put('groups/%s/delete_user/%s.json' % (GroupID, U...
Check if Team Password Manager is up to date. def up_to_date(self): """Check if Team Password Manager is up to date.""" VersionInfo = self.get_latest_version() CurrentVersion = VersionInfo.get('version') LatestVersion = VersionInfo.get('latest_version') if CurrentVersion == Lat...
Decorator: Catch exception ``from_exception`` and instead raise ``to_exception(*to_args, **to_kw)``. Useful when modules you're using in a method throw their own errors that you want to convert to your own exceptions that you handle higher in the stack. Example: :: class FooError(Exception): ...
Convert (date, value) sorted lists into contiguous value-per-day data sets. Great for sparklines. Example:: [(datetime.date(2011, 1, 1), 1), (datetime.date(2011, 1, 4), 2)] -> [1, 0, 0, 2] def iterate_date_values(d, start_date=None, stop_date=None, default=0): """ Convert (date, value) sorted lis...
Given a datetime ``t`` and a ``resolution``, flatten the precision beyond the given resolution. ``resolution`` can be one of: year, month, day, hour, minute, second, microsecond Example:: >>> t = datetime.datetime(2000, 1, 2, 3, 4, 5, 6000) # Or, 2000-01-02 03:04:05.006000 >>> truncate_datet...
Return an aware datetime which is ``dt`` converted to ``timezone``. If ``dt`` is naive, it is assumed to be UTC. For example, if ``dt`` is "06:00 UTC+0000" and ``timezone`` is "EDT-0400", then the result will be "02:00 EDT-0400". This method follows the guidelines in http://pytz.sourceforge.net/ def...
Return a naive datetime object for the given ``timezone``. A ``timezone`` is any pytz- like or datetime.tzinfo-like timezone object. If no timezone is given, then UTC is assumed. This method is best used with pytz installed:: pip install pytz def now(timezone=None): """ Return a naive dat...
Enumerate over SQLAlchemy query object ``q`` and yield individual results fetched in batches of size ``limit`` using SQL LIMIT and OFFSET. def enumerate_query_by_limit(q, limit=1000): """ Enumerate over SQLAlchemy query object ``q`` and yield individual results fetched in batches of size ``limit`` usin...
Validate a dictionary of data against the provided schema. Returns a list of values positioned in the same order as given in ``schema``, each value is validated with the corresponding validator. Raises formencode.Invalid if validation failed. Similar to get_many but using formencode validation. :...
Verify that each argument is hashable. Passes silently if successful. Raises descriptive TypeError otherwise. Example:: >>> assert_hashable(1, 'foo', bar='baz') >>> assert_hashable(1, [], baz='baz') Traceback (most recent call last): ... TypeError: Argument in positi...
Memoize a function into an optionally-specificed cache container. If the `cache` container is not specified, then the instance container is accessible from the wrapped function's `memoize_cache` property. Example:: >>> @memoized ... def foo(bar): ... print("Not cached.") ...
Memoize a class's method. Arguments are similar to to `memoized`, except that the cache container is specified with `cache_factory`: a function called with no arguments to create the caching container for the instance. Note that, unlike `memoized`, the result cache will be stored on the instance, ...
Throw a warning when a function/method will be soon deprecated Supports passing a ``message`` and an ``exception`` class (uses ``PendingDeprecationWarning`` by default). This is useful if you want to alternatively pass a ``DeprecationWarning`` exception for already deprecated functions/methods. Ex...
Aggregate iterator values into buckets based on how frequently the values appear. Example:: >>> list(groupby_count([1, 1, 1, 2, 3])) [(1, 3), (2, 1), (3, 1)] def groupby_count(i, key=None, force_keys=None): """ Aggregate iterator values into buckets based on how frequently the values ...
Return whether ``maybe_iter`` is an iterable, unless it's an instance of one of the base class, or tuple of base classes, given in ``unless``. Example:: >>> is_iterable('foo') False >>> is_iterable(['foo']) True >>> is_iterable(['foo'], unless=list) False ...
Always return an iterable. Returns ``maybe_iter`` if it is an iterable, otherwise it returns a single element iterable containing ``maybe_iter``. By default, strings and dicts are treated as non-iterable. This can be overridden by passing in a type or tuple of types for ``unless``. :param maybe_it...
Return a consistent (key, value) iterable on dict-like objects, including lists of tuple pairs. Example: >>> list(iterate_items({'a': 1})) [('a', 1)] >>> list(iterate_items([('a', 1), ('b', 2)])) [('a', 1), ('b', 2)] def iterate_items(dictish): """ Return a consistent (key...
Iterate over an iterator ``i`` in ``size`` chunks, yield chunks. Similar to pagination. Example:: >>> list(iterate_chunks([1, 2, 3, 4], size=2)) [[1, 2], [3, 4]] def iterate_chunks(i, size=10): """ Iterate over an iterator ``i`` in ``size`` chunks, yield chunks. Similar to paginat...
A decorator which wraps a function's return value in ``list(...)``. Useful when an algorithm can be expressed more cleanly as a generator but the function should return an list. Example:: >>> @listify ... def get_lengths(iterable): ... for i in iterable: ... yi...
Similar to the ``issubclass`` builtin, but does not raise a ``TypeError`` if either ``o`` or ``bases`` is not an instance of ``type``. Example:: >>> is_subclass(IOError, Exception) True >>> is_subclass(Exception, None) False >>> is_subclass(None, Exception) Fals...
Returns a predictable number of elements out of ``d`` in a list for auto-expanding. Keys in ``required`` will raise KeyError if not found in ``d``. Keys in ``optional`` will return None if not found in ``d``. Keys in ``one_of`` will raise KeyError if none exist, otherwise return the first in ``d``. Ex...
Return a random string of given length and alphabet. Default alphabet is url-friendly (base62). def random_string(length=6, alphabet=string.ascii_letters+string.digits): """ Return a random string of given length and alphabet. Default alphabet is url-friendly (base62). """ return ''.join([ran...
Given an non-negative integer ``n``, convert it to a string composed of the given ``alphabet`` mapping, where the position of each element in ``alphabet`` is its radix value. Examples:: >>> number_to_string(12345678, '01') '101111000110000101001110' >>> number_to_string(12345678, ...
Given a string ``s``, convert it to an integer composed of the given ``alphabet`` mapping, where the position of each element in ``alphabet`` is its radix value. Examples:: >>> string_to_number('101111000110000101001110', '01') 12345678 >>> string_to_number('babbbbaaabbaaaababaabb...
Convert a string to an integer. :param b: String or bytearray to convert. :param endian: Byte order to convert into ('big' or 'little' endian-ness, default 'big') Assumes bytes are 8 bits. This is a special-case version of string_to_number with a full base-256 ASCII alpha...
Convert an integer to a corresponding string of bytes.. :param n: Integer to convert. :param endian: Byte order to convert into ('big' or 'little' endian-ness, default 'big') Assumes bytes are 8 bits. This is a special-case version of number_to_string with a full base-256 ...
r""" Returns a ``str`` of ``obj``, encoding using ``encoding`` if necessary. For example:: >>> some_str = b"\xff" >>> some_unicode = u"\u1234" >>> some_exception = Exception(u'Error: ' + some_unicode) >>> r(to_str(some_str)) b'\xff' >>> r(to_str(some_unicode)) ...
r""" Returns a ``unicode`` of ``obj``, decoding using ``encoding`` if necessary. If decoding fails, the ``fallback`` encoding (default ``latin1``) is used. Examples:: >>> r(to_unicode(b'\xe1\x88\xb4')) u'\u1234' >>> r(to_unicode(b'\xff')) u'\xff' >>> r(to_unicode(u'...
Return input converted into a float. If failed, then return ``default``. Note that, by default, ``allow_nan=False``, so ``to_float`` will not return ``nan``, ``inf``, or ``-inf``. Examples:: >>> to_float('1.5') 1.5 >>> to_float(1) 1.0 >>> to_float('') 0.0 ...