fileutils
Module¶
File operations¶
-
gluon.fileutils.
read_file
(filename, mode='r')[source]¶ Returns content from filename, making sure to close the file explicitly on exit.
-
gluon.fileutils.
write_file
(filename, value, mode='w')[source]¶ Writes <value> to filename, making sure to close the file explicitly on exit.
-
gluon.fileutils.
readlines_file
(filename, mode='r')[source]¶ Applies .split(‘ ‘) to the output of read_file()
-
gluon.fileutils.
abspath
(*relpath, **base)[source]¶ Converts relative path to absolute path based (by default) on applications_parent
-
gluon.fileutils.
listdir
(path, expression='^.+$', drop=True, add_dirs=False, sort=True, maxnum=None, exclude_content_from=None)[source]¶ Like os.listdir() but you can specify a regex pattern to filter files. If add_dirs is True, the returned items will have the full path.
-
gluon.fileutils.
recursive_unlink
(f)[source]¶ Deletes f. If it’s a folder, also its contents will be deleted
-
gluon.fileutils.
cleanpath
(path)[source]¶ Turns any expression/path into a valid filename. replaces / with _ and removes special characters.
-
gluon.fileutils.
tar
(file, dir, expression='^.+$', filenames=None, exclude_content_from=None)[source]¶ Tars dir into file, only tars file that match expression
-
gluon.fileutils.
tar_compiled
(file, dir, expression='^.+$', exclude_content_from=None)[source]¶ Used to tar a compiled application. The content of models, views, controllers is not stored in the tar file.
-
gluon.fileutils.
get_session
(request, other_application='admin')[source]¶ Checks that user is authorized to access other_application
-
gluon.fileutils.
check_credentials
(request, other_application='admin', expiration=3600, gae_login=True)[source]¶ Checks that user is authorized to access other_application
-
gluon.fileutils.
w2p_pack
(filename, path, compiled=False, filenames=None)[source]¶ Packs a web2py application.
Parameters: - filename (str) – path to the resulting archive
- path (str) – path to the application
- compiled (bool) – if True packs the compiled version
- filenames (list) – adds filenames to the archive