lib/bb/fetch/git.py: always use english here
[vuplus_bitbake] / lib / bb / parse / __init__.py
1 """
2 BitBake Parsers
3
4 File parsers for the BitBake build tools.
5
6 Copyright (C) 2003, 2004  Chris Larson
7 Copyright (C) 2003, 2004  Phil Blundell
8
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
12 version.
13
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.
17
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.
21
22 Based on functions from the base bb module, Copyright 2003 Holger Schurig
23 """
24
25 __all__ = [ 'ParseError', 'SkipPackage', 'cached_mtime', 'mark_dependency',
26             'supports', 'handle', 'init' ]
27 handlers = []
28
29 import bb, os
30
31 class ParseError(Exception):
32     """Exception raised when parsing fails"""
33
34 class SkipPackage(Exception):
35     """Exception raised to skip this package"""
36
37 __mtime_cache = {}
38 def cached_mtime(f):
39     if not __mtime_cache.has_key(f):
40         update_mtime(f)
41     return __mtime_cache[f]
42
43 def update_mtime(f):
44     __mtime_cache[f] = os.stat(f)[8]
45
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)
52
53 def supports(fn, data):
54     """Returns true if we have a handler for this file, false otherwise"""
55     for h in handlers:
56         if h['supports'](fn, data):
57             return 1
58     return 0
59
60 def handle(fn, data, include = 0):
61     """Call the handler that is appropriate for this file"""
62     for h in handlers:
63         if h['supports'](fn, data):
64             return h['handle'](fn, data, include)
65     raise ParseError("%s is not a BitBake file" % fn)
66
67 def init(fn, data):
68     for h in handlers:
69         if h['supports'](fn):
70             return h['init'](data)
71
72
73 from parse_py import __version__, ConfHandler, BBHandler