From: Oleg Broytman Date: Mon, 30 May 2016 22:53:48 +0000 (+0300) Subject: Check if DB pathname starts with the current directory X-Git-Tag: 0.0.11~14 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=2aec5f3920d5ba9f7add67a1980e4321f5b7689b;p=m_librarian.git Check if DB pathname starts with the current directory --- diff --git a/m_librarian/db.py b/m_librarian/db.py index 0da18a4..56b194d 100755 --- a/m_librarian/db.py +++ b/m_librarian/db.py @@ -142,13 +142,13 @@ def open_db(db_uri=None): except: db_uri = find_sqlite_dburi() - if db_uri.startswith(os.sep) or os.altsep and db_uri.startswith(os.altsep) \ + if db_uri.startswith(os.sep) \ + or os.altsep and db_uri.startswith(os.altsep) \ or db_uri.startswith(os.pardir + os.sep) \ - or os.altsep and db_uri.startswith(os.pardir + os.altsep): - if db_uri.startswith(os.pardir + os.sep) \ - or os.altsep and db_uri.startswith(os.pardir + os.altsep): - db_uri = os.path.abspath(db_uri) - db_uri = 'sqlite://' + db_uri.replace(os.sep, '/') + or os.altsep and db_uri.startswith(os.pardir + os.altsep) \ + or db_uri.startswith(os.curdir + os.sep) \ + or os.altsep and db_uri.startswith(os.curdir + os.altsep): + db_uri = 'sqlite://' + os.path.abspath(db_uri).replace(os.sep, '/') sqlhub.processConnection = connection = connectionForURI(db_uri)