diff --git a/src/Utils.py b/src/Utils.py index 156bda10d..ce4be08d3 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -37,6 +37,7 @@ import random import time import shutil import platform +import uuid #------------------------------------------------------------------------- # @@ -48,7 +49,7 @@ import gen.lib import Errors from GrampsLocale import codeset -from const import TEMP_DIR, USER_HOME, WINDOWS, MACOS, LINUX +from const import TEMP_DIR, USER_HOME, WINDOWS, MACOS, LINUX, GRAMPS_UUID from TransUtils import sgettext as _ #------------------------------------------------------------------------- @@ -444,6 +445,13 @@ def create_id(): return "%08x%08x" % ( int(time.time()*10000), rand.randint(0, sys.maxint)) +def create_uid(self, handle=None): + if handle: + uid = uuid.uuid5(GRAMPS_UUID, handle) + else: + uid = uuid.uuid4() + return uid.hex.upper() + #------------------------------------------------------------------------- # # probably_alive diff --git a/src/const.py.in b/src/const.py.in index ed5272281..adccb73b4 100644 --- a/src/const.py.in +++ b/src/const.py.in @@ -261,4 +261,4 @@ LONGOPTS = [ SHORTOPTS = "O:i:e:f:a:p:d:lLhu?" - +GRAMPS_UUID = uuid.UUID('516cd010-5a41-470f-99f8-eb22f1098ad6')