.. _exampleaboutfilesrst: =================== Helpers about files =================== .. only:: html **Links:** :download:`notebook `, :downloadlink:`html `, :download:`PDF `, :download:`python `, :downloadlink:`slides `, :githublink:`GitHub|_doc/notebooks/example_about_files.ipynb|*` How to compress, encrypt, decrypt files with pyquickhelper. compress -------- .. code:: ipython3 from pyquickhelper.filehelper import download, gzip_files, zip7_files, zip_files .. code:: ipython3 download("https://docs.python.org/3.4/library/urllib.request.html") .. parsed-literal:: '.\\urllib.request.html' .. code:: ipython3 gzip_files("request.html.gz", ["urllib.request.html"]) .. code:: ipython3 import os os.listdir(".") .. parsed-literal:: ['.ipynb_checkpoints', 'autosavetime2', 'check_matplotlib_backend.ipynb', 'compare_python_distribution.ipynb', 'example_about_files.ipynb', 'example_completion.ipynb', 'example_documentation.ipynb', 'example_pyquickhelper.ipynb', 'example_with_comments.ipynb', 'exemple_of_fix_menu.ipynb', 'git_dataframes.ipynb', 'having_a_form_in_a_notebook.ipynb', 'javascript_extension.ipynb', 'nbimage.png', 'notebook_with_svg.ipynb', 'README.txt', 'request.html.gz', 'simple_example.ipynb', 'urllib.request.html'] .. code:: ipython3 ipy = [ _ for _ in os.listdir(".") if ".ipynb" in _ ] if os.path.exists("request.html.zip"): os.remove("notebooks.zip") zip_files("notebooks.zip", ipy) .. parsed-literal:: 14 The following example get all files registered in a repository GIT or SVN. .. code:: ipython3 from pyquickhelper.filehelper import explore_folder_iterfile_repo .. code:: ipython3 files = list ( explore_folder_iterfile_repo(".") ) .. code:: ipython3 files .. parsed-literal:: ['README.txt', 'check_matplotlib_backend.ipynb', 'compare_python_distribution.ipynb', 'example_about_files.ipynb', 'example_completion.ipynb', 'example_documentation.ipynb', 'example_pyquickhelper.ipynb', 'example_with_comments.ipynb', 'exemple_of_fix_menu.ipynb', 'git_dataframes.ipynb', 'having_a_form_in_a_notebook.ipynb', 'javascript_extension.ipynb', 'nbimage.png', 'notebook_with_svg.ipynb', 'simple_example.ipynb'] encrypt, decrypt ---------------- .. code:: ipython3 %load_ext pyquickhelper .. code:: ipython3 %encrypt_file notebooks.zip notebooks.enc passwordpassword .. code:: ipython3 %decrypt_file notebooks.enc notebooks2.zip passwordpassword