File: Path.py

package info (click to toggle)
atheist 0.20110402-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,348 kB
  • sloc: python: 4,764; xml: 626; makefile: 113; cpp: 54; ansic: 5; sh: 5
file content (18 lines) | stat: -rw-r--r-- 466 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# -*- mode:python; coding:utf-8 -*-

import os

def resolve_path(fname, paths, find_all=False):
    '''Busca fname en las rutas indicadas y devuelve la primera ruta
    completa dónde lo encuentre. Todas si se indica find_all'''

    retval = []
    for p in paths:
        path = os.path.join(p, fname)
        if os.path.exists(path):
            if find_all:
                retval.append(path)
            else:
                return [path]

    return retval