]> git.phdru.name Git - m_librarian.git/commitdiff
Check if DB pathname starts with the current directory
authorOleg Broytman <phd@phdru.name>
Mon, 30 May 2016 22:53:48 +0000 (01:53 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 30 May 2016 22:53:48 +0000 (01:53 +0300)
m_librarian/db.py

index 0da18a4676ab8679bcc99664705a252ea50c043b..56b194d0ac5621145d935d4343468249e7174adf 100755 (executable)
@@ -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)