Skip to content

Instantly share code, notes, and snippets.

@CeriseGoutPelican
Last active September 20, 2018 13:24
Show Gist options
  • Save CeriseGoutPelican/417d529329debf2daeed7645c7f35fa3 to your computer and use it in GitHub Desktop.
Save CeriseGoutPelican/417d529329debf2daeed7645c7f35fa3 to your computer and use it in GitHub Desktop.
Python - Projet 1
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="W29" />
<option value="E501" />
</list>
</option>
</inspection_tool>
</profile>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Séance 2.iml" filepath="$PROJECT_DIR$/.idea/Séance 2.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
import logging
import os
def walk(path = None, depth = 5, debug = False):
"""
La fonction Walk permet de lister les fichiers et sous dossiers présents dans un dossier donné.
La fonction renvoie une liste contenant tous les fichiers
:param str path: le document racine où commencer la récursivité
:param int depth: le nombre de récursivité maximal
:param bool debug: active les logs de debug ou non
:return: une liste sous la forme {{"dossier 1", "fichier 1", "fichier 2"}, {"dossier 2", "fichier 1"}}
"""
try:
os.chdir(path)
except Exception as e:
logging.warning("Le chemin de début n'a pas été correctement spécifié")
# Tests
walk("../", 5, False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment