Helpers about files

Links: notebook, html ., PDF, python, slides ., presentation .

compress

from pyquickhelper.filehelper import download, gzip_files, zip7_files, zip_files
download("https://docs.python.org/3.4/library/urllib.request.html")
'.\urllib.request.html'
gzip_files("request.html.gz", ["urllib.request.html"])
1
import os
os.listdir(".")
['.ipynb_checkpoints',
 'example_about_files.ipynb',
 'example_completion.ipynb',
 'example_documentation.ipynb',
 'example_pyquickhelper.ipynb',
 'example_with_comments.ipynb',
 'exemple_of_fix_menu.ipynb',
 'having_a_form_in_a_notebook.ipynb',
 'javascript_extension.ipynb',
 'nbimage.png',
 'notebooks.7z',
 'notebooks.enc',
 'notebooks2.7z',
 'notebook_with_svg.ipynb',
 'request.html.gz',
 'simple_example.ipynb',
 'urllib.request.html']
ipy = [ _ for _ in os.listdir(".") if ".ipynb" in _ ]
if os.path.exists("request.html.zip"):
    os.remove("notebooks.zip")
zip_files("notebooks.zip", ipy)
11

The following example get all files registered in a repository GIT or SVN.

from pyquickhelper.filehelper import explore_folder_iterfile_repo
files = list ( explore_folder_iterfile_repo(".") )
files
['javascript_extension.ipynb',
 'having_a_form_in_a_notebook.ipynb',
 'nbimage.png',
 'example_with_comments.ipynb',
 'example_documentation.ipynb',
 'example_completion.ipynb',
 'example_pyquickhelper.ipynb',
 'example_about_files.ipynb',
 'notebook_with_svg.ipynb',
 'exemple_of_fix_menu.ipynb',
 'simple_example.ipynb']

encrypt, decrypt

%load_ext pyquickhelper
%encrypt_file notebooks.zip notebooks.enc passwordpassword
%decrypt_file notebooks.enc notebooks2.zip passwordpassword