Changeset 246 for pyyaml/trunk/lib/yaml/resolver.py
- Timestamp:
- 02/23/07 15:45:35 (6 years ago)
- File:
-
- 1 edited
-
pyyaml/trunk/lib/yaml/resolver.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pyyaml/trunk/lib/yaml/resolver.py
r226 r246 33 33 34 34 def add_path_resolver(cls, tag, path, kind=None): 35 # Note: `add_path_resolver` is experimental. The API could be changed. 36 # `new_path` is a pattern that is matched against the path from the 37 # root to the node that is being considered. `node_path` elements are 38 # tuples `(node_check, index_check)`. `node_check` is a node class: 39 # `ScalarNode`, `SequenceNode`, `MappingNode` or `None`. `None` 40 # matches any kind of a node. `index_check` could be `None`, a boolean 41 # value, a string value, or a number. `None` and `False` match against 42 # any _value_ of sequence and mapping nodes. `True` matches against 43 # any _key_ of a mapping node. A string `index_check` matches against 44 # a mapping value that corresponds to a scalar key which content is 45 # equal to the `index_check` value. An integer `index_check` matches 46 # against a sequence value with the index equal to `index_check`. 35 47 if not 'yaml_path_resolvers' in cls.__dict__: 36 48 cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() … … 114 126 if index_check is True and current_index is not None: 115 127 return 116 if index_check in [False, None] and current_index is None: 128 if (index_check is False or index_check is None) \ 129 and current_index is None: 117 130 return 118 131 if isinstance(index_check, basestring): … … 120 133 and index_check == current_index.value): 121 134 return 122 elif isinstance(index_check, int) :135 elif isinstance(index_check, int) and not isinstance(index_check, bool): 123 136 if index_check != current_index: 124 137 return
Note: See TracChangeset
for help on using the changeset viewer.
