Python click.UUID Examples
The following are 3
code examples of click.UUID().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
click
, or try the search function
.
Example #1
Source File: commands.py From notifications-api with MIT License | 5 votes |
def purge_functional_test_data(user_email_prefix): """ Remove non-seeded functional test data users, services, etc. Give an email prefix. Probably "notify-tests-preview". """ users = User.query.filter(User.email_address.like("{}%".format(user_email_prefix))).all() for usr in users: # Make sure the full email includes a uuid in it # Just in case someone decides to use a similar email address. try: uuid.UUID(usr.email_address.split("@")[0].split('+')[1]) except ValueError: print("Skipping {} as the user email doesn't contain a UUID.".format(usr.email_address)) else: services = dao_fetch_all_services_by_user(usr.id) if services: print(f"Deleting user {usr.id} which is part of services") for service in services: delete_service_and_all_associated_db_objects(service) else: services_created_by_this_user = dao_fetch_all_services_created_by_user(usr.id) if services_created_by_this_user: # user is not part of any services but may still have been the one to create the service # sometimes things get in this state if the tests fail half way through # Remove the service they created (but are not a part of) so we can then remove the user print(f"Deleting services created by {usr.id}") for service in services_created_by_this_user: delete_service_and_all_associated_db_objects(service) print(f"Deleting user {usr.id} which is not part of any services") delete_user_verify_codes(usr) delete_model_user(usr)
Example #2
Source File: shared_options.py From globus-cli with Apache License 2.0 | 5 votes |
def endpoint_id_arg(*args, **kwargs): """ This is the `ENDPOINT_ID` argument consumed by many Transfer endpoint related operations. It accepts alternate metavars for cases when another name is desirable (e.x. `SHARE_ID`, `HOST_ENDPOINT_ID`), but can also be applied as a direct decorator if no specialized metavar is being passed. Usage: >>> @endpoint_id_arg >>> def command_func(endpoint_id): >>> ... or >>> @endpoint_id_arg(metavar='HOST_ENDPOINT_ID') >>> def command_func(endpoint_id): >>> ... """ def decorate(f, **kwargs): """ Work of actually decorating a function -- wrapped in here because we want to dispatch depending on how this is invoked """ metavar = kwargs.get("metavar", "ENDPOINT_ID") f = click.argument("endpoint_id", metavar=metavar, type=click.UUID)(f) return f return detect_and_decorate(decorate, args, kwargs)
Example #3
Source File: endpoint_plus_path.py From globus-cli with Apache License 2.0 | 5 votes |
def convert(self, value, param, ctx): """ ParamType.convert() is the actual processing method that takes a provided parameter and parses it. """ # passthrough conditions: None or already processed if value is None or isinstance(value, tuple): return value # split the value on the first colon, leave the rest intact splitval = value.split(":", 1) # first element is the endpoint_id endpoint_id = click.UUID(splitval[0]) # get the second element, defaulting to `None` if there was no colon in # the original value try: path = splitval[1] except IndexError: path = None # coerce path="" to path=None # means that we treat "enpdoint_id" and "endpoint_id:" equivalently path = path or None if path is None and self.path_required: self.fail("The path component is required", param=param) return (endpoint_id, path)