Xorn
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
slib.py
Go to the documentation of this file.
1 # xorn.geda.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-2016 Roland Lutz
5 #
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.
10 #
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.
15 #
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.
19 
20 ## \namespace xorn.geda.netlist.slib
21 ## Source library.
22 #
23 # slib stands for source (project/schematic/hdl/model source) library
24 
25 import os
26 
27 ## Search path.
28 
29 slib = []
30 
31 ## Search the source library for a particular file name substring.
32 #
33 # Search the source library for a directory, starting with the last
34 # one, which contains a file whose filename contains the substring \a
35 # basename.
36 #
37 # \returns the found directory plus \a basename, or \c None if \a
38 # basename was not found in the source library
39 #
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].
43 
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)
51 
52  return None
def s_slib_search_single
Search the source library for a particular file name substring.
Definition: slib.py:44