コード例 #1
0
ファイル: other.py プロジェクト: quiquinSP/vaex
	def close_files(self):
		for name, file in self.file_map.items():
			file.close()
		# on osx and linux this will give random bus errors (osx) or segfaults (linux)
		# on win32 however, we'll run out of file handles
		if vaex.utils.osname not in ["osx", "linux"]:
			for name, memmap in self.mapping_map.items():
				memmap.close()
コード例 #2
0
ファイル: dataset_mmap.py プロジェクト: maartenbreddels/vaex
 def close_files(self):
     for name, file in self.file_map.items():
         file.close()
     # on osx and linux this will give random bus errors (osx) or segfaults (linux)
     # on win32 however, we'll run out of file handles
     if vaex.utils.osname not in ["osx", "linux"]:
         for name, memmap in self.mapping_map.items():
             memmap.close()
コード例 #3
0
def read_json_or_yaml(file, fs_options={}, fs=None, old_style=True):
    file, path = vaex.file.file_and_path(file, fs_options=fs_options, fs=fs)
    try:
        if path:
            base, ext = os.path.splitext(path)
        else:
            ext = '.json'  # default
        if ext == ".json":
            return json.load(file, cls=VaexJsonDecoder if old_style else None) or {}
        elif ext == ".yaml":
            return yaml_load(file) or {}
        else:
            raise ValueError("file should end in .json or .yaml (not %s)" % ext)
    finally:
        file.close()
コード例 #4
0
def write_json_or_yaml(file, data, fs_options={}, fs=None, old_style=True):
    file, path = vaex.file.file_and_path(file, mode='w', fs_options=fs_options, fs=fs)
    try:
        if path:
            base, ext = os.path.splitext(path)
        else:
            ext = '.json'  # default
        if ext == ".json":
            json.dump(data, file, indent=2, cls=VaexJsonEncoder if old_style else None)
        elif ext == ".yaml":
            yaml_dump(file, data)
        else:
            raise ValueError("file should end in .json or .yaml (not %s)" % ext)
    finally:
        file.close()
コード例 #5
0
 def close(self):
     for name, memmap in self.mapping_map.items():
         memmap.close()
     for name, file in self.file_map.items():
         file.close()