#!/usr/bin/python3
# -*- coding: utf-8 -*-
########################################################################
#
# This file is part of python module <pySPC>.
# Copyright (C) 2013-2020 R. Marty
# (renaud.marty@developpement-durable.gouv.fr)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see COPYING.txt).
# If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
"""
Localiser tous les fichiers dans le dossier courant
et dans ses sous-repertoires
Locate all files matching supplied filename pattern in
and below supplied root directory.
"""
import os
import fnmatch
[docs]
def locate_file_in_tree(pattern, root=os.curdir):
"""
Localiser tous les fichiers dans le dossier courant
et dans ses sous-repertoires
Locate all files matching supplied filename pattern in
and below supplied root directory.
"""
for path, _, files in os.walk(os.path.abspath(root)):
for filename in fnmatch.filter(files, pattern):
yield os.path.join(path, filename)