diff python/storage.py @ 1003:75af46516b2b

work in progress
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 01 Jun 2018 17:19:31 -0400
parents 933670761a57
children 75601be6019f
line wrap: on
line diff
--- a/python/storage.py	Fri Jun 01 17:19:24 2018 -0400
+++ b/python/storage.py	Fri Jun 01 17:19:31 2018 -0400
@@ -5,7 +5,7 @@
 import utils, moving, events, indicators, shutil
 from base import VideoFilenameAddable
 
-from os import path
+from pathlib import Path
 from copy import copy
 import sqlite3, logging
 from numpy import log, min as npmin, max as npmax, round as npround, array, sum as npsum, loadtxt, floor as npfloor, ceil as npceil, linalg
@@ -43,7 +43,7 @@
 
 def deleteFromSqlite(filename, dataType):
     'Deletes (drops) some tables in the filename depending on type of data'
-    if path.isfile(filename):
+    if Path(filename).is_file():
         with sqlite3.connect(filename) as connection:
             if dataType == 'object':
                 dropTables(connection, ['objects', 'objects_features'])
@@ -1307,7 +1307,7 @@
         self.stdVehicleSpeed = config.getfloat(self.sectionHeader, 'std-veh-speed')
 
     def __init__(self, filename = None):
-        if filename is not None and path.exists(filename):
+        if filename is not None and Path(filename).exists():
             self.loadConfigFile(filename)
         else:
             print('Configuration filename {} could not be loaded.'.format(filename))
@@ -1350,12 +1350,12 @@
         self.videoFilename = config.get(self.sectionHeader, 'video-filename')
         self.databaseFilename = config.get(self.sectionHeader, 'database-filename')
         self.homographyFilename = config.get(self.sectionHeader, 'homography-filename')
-        if path.exists(self.homographyFilename):
+        if Path(self.homographyFilename).exists():
             self.homography = loadtxt(self.homographyFilename)
         else:
             self.homography = None
         self.intrinsicCameraFilename = config.get(self.sectionHeader, 'intrinsic-camera-filename')
-        if path.exists(self.intrinsicCameraFilename):
+        if Path(self.intrinsicCameraFilename).exists():
             self.intrinsicCameraMatrix = loadtxt(self.intrinsicCameraFilename)
         else:
             self.intrinsicCameraMatrix = None
@@ -1389,7 +1389,7 @@
         self.minLcssSimilarity = config.getfloat(self.sectionHeader, 'min-lcss-similarity')
 
     def __init__(self, filename = None):
-        if filename is not None and path.exists(filename):
+        if filename is not None and Path(filename).exists():
             self.loadConfigFile(filename)
         else:
             print('Configuration filename {} could not be loaded.'.format(filename))