Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, file_path):
assert HAVE_NIXIO, self.installation_mesg
RecordingExtractor.__init__(self)
self._file = nix.File.open(file_path, nix.FileMode.ReadOnly)
self._load_properties()
self._kwargs = {'file_path': str(Path(file_path).absolute())}
check_nix_version()
BaseIO.__init__(self, filename)
self.filename = filename
if mode == "ro":
filemode = nix.FileMode.ReadOnly
elif mode == "rw":
filemode = nix.FileMode.ReadWrite
elif mode == "ow":
filemode = nix.FileMode.Overwrite
else:
raise ValueError("Invalid mode specified '{}'. "
"Valid modes: 'ro' (ReadOnly)', 'rw' (ReadWrite),"
" 'ow' (Overwrite).".format(mode))
self.nix_file = nix.File.open(self.filename, filemode)
if self.nix_file.mode == nix.FileMode.ReadOnly:
self._file_version = '0.5.2'
if "neo" in self.nix_file.sections:
self._file_version = self.nix_file.sections["neo"]["version"]
elif self.nix_file.mode == nix.FileMode.ReadWrite:
if "neo" in self.nix_file.sections:
self._file_version = self.nix_file.sections["neo"]["version"]
else:
self._file_version = '0.5.2'
filemd = self.nix_file.create_section("neo", "neo.metadata")
filemd["version"] = self._file_version
else:
# new file
filemd = self.nix_file.create_section("neo", "neo.metadata")
filemd["version"] = neover
self._file_version = neover
def __init__(self, filename, mode="rw"):
"""
Initialise IO instance and NIX file.
:param filename: Full path to the file
"""
check_nix_version()
BaseIO.__init__(self, filename)
self.filename = filename
if mode == "ro":
filemode = nix.FileMode.ReadOnly
elif mode == "rw":
filemode = nix.FileMode.ReadWrite
elif mode == "ow":
filemode = nix.FileMode.Overwrite
else:
raise ValueError("Invalid mode specified '{}'. "
"Valid modes: 'ro' (ReadOnly)', 'rw' (ReadWrite),"
" 'ow' (Overwrite).".format(mode))
self.nix_file = nix.File.open(self.filename, filemode)
if self.nix_file.mode == nix.FileMode.ReadOnly:
self._file_version = '0.5.2'
if "neo" in self.nix_file.sections:
self._file_version = self.nix_file.sections["neo"]["version"]
elif self.nix_file.mode == nix.FileMode.ReadWrite:
if "neo" in self.nix_file.sections: