diff --git a/progit/lib/__init__.py b/progit/lib/__init__.py index c3aa458..c388cb8 100644 --- a/progit/lib/__init__.py +++ b/progit/lib/__init__.py @@ -11,9 +11,7 @@ import datetime import os -import random import shutil -import string import tempfile import uuid @@ -52,19 +50,6 @@ def create_session(db_url, debug=False, pool_recycle=3600): return scopedsession -def id_generator(size=15, chars=string.ascii_uppercase + string.digits): - """ Generates a random identifier for the given size and using the - specified characters. - If no size is specified, it uses 15 as default. - If no characters are specified, it uses ascii char upper case and - digits. - :arg size: the size of the identifier to return. - :arg chars: the list of characters that can be used in the - idenfitier. - """ - return ''.join(random.choice(chars) for x in range(size)) - - def get_next_id(session, projectid): """ Returns the next identifier of a project ticket or pull-request based on the identifier already in the database. diff --git a/progit/lib/login.py b/progit/lib/login.py index 646613c..30e288b 100644 --- a/progit/lib/login.py +++ b/progit/lib/login.py @@ -8,9 +8,26 @@ """ +import random +import string + from progit.lib import model +def id_generator(size=15, chars=string.ascii_uppercase + string.digits): + """ Generates a random identifier for the given size and using the + specified characters. + If no size is specified, it uses 15 as default. + If no characters are specified, it uses ascii char upper case and + digits. + :arg size: the size of the identifier to return. + :arg chars: the list of characters that can be used in the + idenfitier. + """ + return ''.join(random.choice(chars) for x in range(size)) + + + def get_session_by_visitkey(session, sessionid): ''' Return a specified VisitUser via its session identifier (visit_key).