diff options
Diffstat (limited to 'bitbake-dev/lib/bb/parse/__init__.py')
-rw-r--r-- | bitbake-dev/lib/bb/parse/__init__.py | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/bitbake-dev/lib/bb/parse/__init__.py b/bitbake-dev/lib/bb/parse/__init__.py deleted file mode 100644 index 5dd96c4136..0000000000 --- a/bitbake-dev/lib/bb/parse/__init__.py +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | """ | ||
2 | BitBake Parsers | ||
3 | |||
4 | File parsers for the BitBake build tools. | ||
5 | |||
6 | """ | ||
7 | |||
8 | |||
9 | # Copyright (C) 2003, 2004 Chris Larson | ||
10 | # Copyright (C) 2003, 2004 Phil Blundell | ||
11 | # | ||
12 | # This program is free software; you can redistribute it and/or modify | ||
13 | # it under the terms of the GNU General Public License version 2 as | ||
14 | # published by the Free Software Foundation. | ||
15 | # | ||
16 | # This program is distributed in the hope that it will be useful, | ||
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | # GNU General Public License for more details. | ||
20 | # | ||
21 | # You should have received a copy of the GNU General Public License along | ||
22 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
23 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
24 | # | ||
25 | # Based on functions from the base bb module, Copyright 2003 Holger Schurig | ||
26 | |||
27 | __all__ = [ 'ParseError', 'SkipPackage', 'cached_mtime', 'mark_dependency', | ||
28 | 'supports', 'handle', 'init' ] | ||
29 | handlers = [] | ||
30 | |||
31 | import bb, os | ||
32 | |||
33 | class ParseError(Exception): | ||
34 | """Exception raised when parsing fails""" | ||
35 | |||
36 | class SkipPackage(Exception): | ||
37 | """Exception raised to skip this package""" | ||
38 | |||
39 | __mtime_cache = {} | ||
40 | def cached_mtime(f): | ||
41 | if not __mtime_cache.has_key(f): | ||
42 | __mtime_cache[f] = os.stat(f)[8] | ||
43 | return __mtime_cache[f] | ||
44 | |||
45 | def cached_mtime_noerror(f): | ||
46 | if not __mtime_cache.has_key(f): | ||
47 | try: | ||
48 | __mtime_cache[f] = os.stat(f)[8] | ||
49 | except OSError: | ||
50 | return 0 | ||
51 | return __mtime_cache[f] | ||
52 | |||
53 | def update_mtime(f): | ||
54 | __mtime_cache[f] = os.stat(f)[8] | ||
55 | return __mtime_cache[f] | ||
56 | |||
57 | def mark_dependency(d, f): | ||
58 | if f.startswith('./'): | ||
59 | f = "%s/%s" % (os.getcwd(), f[2:]) | ||
60 | deps = bb.data.getVar('__depends', d) or [] | ||
61 | deps.append( (f, cached_mtime(f)) ) | ||
62 | bb.data.setVar('__depends', deps, d) | ||
63 | |||
64 | def supports(fn, data): | ||
65 | """Returns true if we have a handler for this file, false otherwise""" | ||
66 | for h in handlers: | ||
67 | if h['supports'](fn, data): | ||
68 | return 1 | ||
69 | return 0 | ||
70 | |||
71 | def handle(fn, data, include = 0): | ||
72 | """Call the handler that is appropriate for this file""" | ||
73 | for h in handlers: | ||
74 | if h['supports'](fn, data): | ||
75 | return h['handle'](fn, data, include) | ||
76 | raise ParseError("%s is not a BitBake file" % fn) | ||
77 | |||
78 | def init(fn, data): | ||
79 | for h in handlers: | ||
80 | if h['supports'](fn): | ||
81 | return h['init'](data) | ||
82 | |||
83 | |||
84 | from parse_py import __version__, ConfHandler, BBHandler | ||