- Speed up the internal find_file() function (used for searching
CPPPATH, LIBPATH, etc.).
+ - Add support for using the Python "in" keyword on construction
+ environments (for example, if "CPPPATH" in env: ...).
+
From Rob Managan:
- Scan for TeX files in the paths specified in the $TEXINPUTS
def has_key(self, key):
return self._dict.has_key(key)
+ def __contains__(self, key):
+ return self._dict.__contains__(key)
+
def items(self):
return self._dict.items()
return 1
except KeyError:
return self.__dict__['__subject'].has_key(key)
+ def __contains__(self, key):
+ if self.__dict__['overrides'].__contains__(key):
+ return 1
+ return self.__dict__['__subject'].__contains__(key)
def Dictionary(self):
"""Emulates the items() method of dictionaries."""
d = self.__dict__['__subject'].Dictionary().copy()
assert env.has_key('XXX')
assert not env.has_key('YYY')
+ def test_contains(self):
+ """Test the SubstitutionEnvironment __contains__() method
+ """
+ try:
+ 'x' in {'x':1}
+ except TypeError:
+ # TODO(1.5)
+ # An early version of Python that doesn't support "in"
+ # on dictionaries. Just pass the test.
+ pass
+ else:
+ env = SubstitutionEnvironment(XXX = 'x')
+ assert 'XXX' in env
+ assert not 'YYY' in env
+
def test_items(self):
"""Test the SubstitutionEnvironment items() method
"""
assert not env2.has_key('ZZZ'), env2.has_key('ZZZ')
assert env3.has_key('ZZZ'), env3.has_key('ZZZ')
+ def test_contains(self):
+ """Test the OverrideEnvironment __contains__() method"""
+ try:
+ 'x' in {'x':1}
+ except TypeError:
+ # TODO(1.5)
+ # An early version of Python that doesn't support "in"
+ # on dictionaries. Just pass the test.
+ pass
+ else:
+ env, env2, env3 = self.envs
+ assert 'XXX' in env
+ assert 'XXX' in env2
+ assert 'XXX' in env3
+ assert 'YYY' in env
+ assert 'YYY' in env2
+ assert 'YYY' in env3
+ assert not 'ZZZ' in env
+ assert not 'ZZZ' in env2
+ assert 'ZZZ' in env3
+
def test_items(self):
"""Test the OverrideEnvironment Dictionary() method"""
env, env2, env3 = self.envs