campy.io.filelib module¶
This file exports a standardized set of tools for working with files. The library offers at least some portability across the file systems used in the three supported platforms: Mac OSX, Windows, and Linux. Directory and search paths are allowed to contain separators in any of the supported styles, which usually makes it possible to use the same code on different platforms.
Note: Several of the functions that lived in CPP’s version of this library are removed, to force students to learn the proper builtin pathlib library. The compatability is listed here:
def create_directory(path):
_Path(path).mkdir()
def create_directory_path(path):
_Path(path).mkdir(path, parents=True)
def default_extension(path, ext):
p = _Path(path)
if ext.startswith('*') or not p.suffix:
return p.with_suffix(ext)
def delete_file(path):
return os.remove(path)
TODO more
-
campy.io.filelib.
open_file_dialog
(title='Open File', mode='load', path='', binary=False)[source]¶ Opens a dialog that allows the user to choose the file. The title parameter is displayed in the dialog title. The path parameter is used to set the working directory; if path does not appear, openFileDialog uses the current directory.
@type title: string @param title: title of dialog box @type mode: string @param mode: mode of dialog box @type binary: boolean @param binary: open file in binary mode on windows @rtype: file