How to use the shortuuid.set_alphabet function in shortuuid

To help you get started, we’ve selected a few shortuuid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ourresearch / total-impact-webapp / totalimpactwebapp / product.py View on Github external
def __init__(self, **kwargs):
        if "tiid" in kwargs:
            self.tiid = kwargs["tiid"]
        else:
            shortuuid.set_alphabet('abcdefghijklmnopqrstuvwxyz1234567890')
            self.tiid = shortuuid.uuid()[0:24]
       
        now = datetime.datetime.utcnow()

        if "created" not in kwargs:
            self.created = now
        if "last_modified" not in kwargs:
            self.last_modified = now
        if "last_update_run" not in kwargs:
            self.last_update_run = now

        super(Product, self).__init__(**kwargs)
github ourresearch / total-impact-webapp / totalimpactwebapp / reference_set.py View on Github external
def __init__(self, **kwargs):
        if not "refset_id" in kwargs:
            shortuuid.set_alphabet('abcdefghijklmnopqrstuvwxyz1234567890')
            self.refset_id = shortuuid.uuid()[0:24]

        if not "created" in kwargs:
            self.created = datetime.datetime.utcnow()
        super(ReferenceSetList, self).__init__(**kwargs)
github ourresearch / total-impact-core / totalimpact / collection.py View on Github external
def make(collection_id=None):
    shortuuid.set_alphabet('abcdefghijklmnopqrstuvwxyz1234567890')
    key = shortuuid.uuid()[0:10]

    if collection_id is None:
        collection_id = _make_id()

    now = datetime.datetime.utcnow().isoformat()
    collection = {}

    collection["_id"] = collection_id
    collection["created"] = now
    collection["last_modified"] = now
    collection["type"] = "collection"
    collection["owner"] = None
    collection["key"] = key  # using the hash was needless complexity...

    return collection, key
github CenterForOpenScience / SHARE / api / filters.py View on Github external
def filter(self, qs, value):
        if value:
            shortuuid.set_alphabet('23456789abcdefghjkmnpqrstuvwxyz')
            value = shortuuid.decode(value)
        return super(ObjectIDFilter, self).filter(qs, value)
github joway / Block / utils / helpers.py View on Github external
import random
import string
from datetime import timedelta, datetime

import pytz
import shortuuid

shortuuid.set_alphabet(string.ascii_uppercase + string.digits)


def get_random_string(length):
    # 0123456789ABCDEFGHJKLMNPQRSTUVWXYZ
    return ''.join([random.choice(string.ascii_uppercase + string.digits)
                    for n in range(length)])


def get_uuid(length):
    return shortuuid.uuid()[:length]


def format_url(url):
    return url
github MycroftAI / mycroft-core / mycroft / pairing / client.py View on Github external
def generate_pairing_code():
    shortuuid.set_alphabet("0123456789ABCDEF")
    return shortuuid.random(length=6)
github ourresearch / total-impact-core / totalimpact / item.py View on Github external
def make():
    now = datetime.datetime.utcnow().isoformat()
    shortuuid.set_alphabet('abcdefghijklmnopqrstuvwxyz1234567890')

    item = {}
    item["_id"] = shortuuid.uuid()[0:24]
    item["aliases"] = {}
    item["biblio"] = {}
    item["last_modified"] = now
    item["created"] = now
    item["type"] = "item"
    return item
github ourresearch / total-impact-webapp / totalimpact / item.py View on Github external
def make():
    now = datetime.datetime.utcnow().isoformat()
    shortuuid.set_alphabet('abcdefghijklmnopqrstuvwxyz1234567890')

    item = {}
    item["_id"] = shortuuid.uuid()[0:24]
    item["aliases"] = {}
    item["biblio"] = {}
    item["last_modified"] = now
    item["created"] = now
    item["type"] = "item"
    return item
github ourresearch / total-impact-core / totalimpact / item.py View on Github external
def __init__(self, **kwargs):
        # logger.debug(u"new Item {kwargs}".format(
        #     kwargs=kwargs))                

        if "tiid" in kwargs:
            self.tiid = kwargs["tiid"]
        else:
            shortuuid.set_alphabet('abcdefghijklmnopqrstuvwxyz1234567890')
            self.tiid = shortuuid.uuid()[0:24]
       
        now = datetime.datetime.utcnow()
        if "created" in kwargs:
            self.created = kwargs["created"]
        else:   
            self.created = now
        if "last_modified" in kwargs:
            self.last_modified = kwargs["last_modified"]
        else:   
            self.last_modified = now
        if "last_update_run" in kwargs:
            self.last_update_run = kwargs["last_update_run"]
        else:   
            self.last_update_run = now