1 # gaf.netlist - gEDA Netlist Extraction and Generation
2 # Copyright (C) 1998-2010 Ales Hvezda
3 # Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
4 # Copyright (C) 2013-2020 Roland Lutz
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 ## \namespace gaf.netlist.slib
23 # slib stands for source (project/schematic/hdl/model source) library
31 ## Search the source library for a particular file name substring.
33 # Search the source library for a directory, starting with the last
34 # one, which contains a file whose filename contains the substring \a
37 # \returns the found directory plus \a basename, or \c None if \a
38 # basename was not found in the source library
40 # If, for example, the directory \c path/to is in the source library
41 # and contains the file \c myschematic.sch, then a search for \c
42 # "schematic" would return \c "path/to/schematic" [sic].
44 def s_slib_search_single(basename
):
45 # search slib paths backwards
46 for i
, dir_name
in reversed(list(enumerate(slib
))):
47 for d_name
in os
.listdir(dir_name
):
48 # Do a substring comp for a match
49 if basename
in d_name
:
50 return os
.path
.join(dir_name
, basename
)