diff options
| author | Steven Knight <knight@baldmt.com> | 2001-09-17 04:57:00 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2001-09-17 04:57:00 (GMT) |
| commit | 3c81bb2bd0e009c0ee81570e17b0f87ad8d034ab (patch) | |
| tree | 1a08c189644909cdadc489cce0eaa487e2c6f578 /src/engine/SCons/Scanner/__init__.py | |
| parent | e2faf9c21bc7712fcdc547b7df0f12a6b2177601 (diff) | |
| download | SCons-3c81bb2bd0e009c0ee81570e17b0f87ad8d034ab.zip SCons-3c81bb2bd0e009c0ee81570e17b0f87ad8d034ab.tar.gz SCons-3c81bb2bd0e009c0ee81570e17b0f87ad8d034ab.tar.bz2 | |
Run setup.py on the unpacked .tar.gz for testing.
Diffstat (limited to 'src/engine/SCons/Scanner/__init__.py')
| -rw-r--r-- | src/engine/SCons/Scanner/__init__.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py new file mode 100644 index 0000000..225c7f3 --- /dev/null +++ b/src/engine/SCons/Scanner/__init__.py @@ -0,0 +1,69 @@ +"""SCons.Scanner + +The Scanner package for the SCons software construction utility. + +""" + +__revision__ = "Scanner/__init__.py __REVISION__ __DATE__ __DEVELOPER__" + +__version__ = "__VERSION__" + +class _Null: + pass + +# This is used instead of None as a default argument value so None can be +# used as an actual argument value. +_null = _Null + +class Scanner: + + def __init__(self, function, argument=_null): + """ + Construct a new scanner object given a scanner function. + + 'function' - a scanner function taking two or three arguments and + returning a list of strings. + + 'argument' - an optional argument that will be passed to the + scanner function if it is given. + + The scanner function's first argument will be the name of a file + that should be scanned for dependencies, the second argument will + be an Environment object, the third argument will be the value + passed into 'argument', and the returned list should contain the + file names of all the direct dependencies of the file. + + Examples: + + s = Scanner(my_scanner_function) + + s = Scanner(function = my_scanner_function) + + s = Scanner(function = my_scanner_function, argument = 'foo') + + """ + + # Note: this class could easily work with scanner functions that take + # something other than a filename as an argument (e.g. a database + # node) and a dependencies list that aren't file names. All that + # would need to be changed is the documentation. + + self.function = function + self.argument = argument + + def scan(self, filename, env): + """ + This method does the actually scanning. 'filename' is the filename + that will be passed to the scanner function, and 'env' is the + environment that will be passed to the scanner function. A list of + dependencies will be returned. + """ + + if not self.argument is _null: + return self.function(filename, env, self.argument) + else: + return self.function(filename, env) + + + + |
