4 File parsers for the BitBake build tools.
6 Copyright (C) 2003, 2004 Chris Larson
7 Copyright (C) 2003, 2004 Phil Blundell
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along with
19 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20 Place, Suite 330, Boston, MA 02111-1307 USA.
22 Based on functions from the base bb module, Copyright 2003 Holger Schurig
25 __all__ = [ 'ParseError', 'SkipPackage', 'cached_mtime', 'mark_dependency',
26 'supports', 'handle', 'init' ]
31 class ParseError(Exception):
32 """Exception raised when parsing fails"""
34 class SkipPackage(Exception):
35 """Exception raised to skip this package"""
39 if not __mtime_cache.has_key(f):
41 return __mtime_cache[f]
44 __mtime_cache[f] = os.stat(f)[8]
46 def mark_dependency(d, f):
47 if f.startswith('./'):
48 f = "%s/%s" % (os.getcwd(), f[2:])
49 deps = bb.data.getVar('__depends', d) or []
50 deps.append( (f, cached_mtime(f)) )
51 bb.data.setVar('__depends', deps, d)
53 def supports(fn, data):
54 """Returns true if we have a handler for this file, false otherwise"""
56 if h['supports'](fn, data):
60 def handle(fn, data, include = 0):
61 """Call the handler that is appropriate for this file"""
63 if h['supports'](fn, data):
64 return h['handle'](fn, data, include)
65 raise ParseError("%s is not a BitBake file" % fn)
70 return h['init'](data)
73 from parse_py import __version__, ConfHandler, BBHandler