summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* plugin: remove 'node_get_provenance', use the Node API directlybschubert/node-provenance-2Benjamin Schubert2019-07-094-25/+10
|
* _yaml: Remove 'node_get_provenance' and add 'Node.get_provenance'Benjamin Schubert2019-07-0924-121/+115
| | | | | | | | This replaces the helper method by adding a 'get_provenance' on the node directly - Adapt all call sites - Delay getting provenance wherever possible without major refactor
* _yaml: rework 'assert_symbol_names' to not require provenanceBenjamin Schubert2019-07-095-11/+11
| | | | | Now that we get scalar Nodes, it is easier to just give the node and extract the provenance as needed.
* _project: remove 'key' argument from 'get_path_from_node'Benjamin Schubert2019-07-094-13/+17
| | | | | | | Now that we have scalar nodes, we can directly give the scalar to the method. - Adapt the plugin method to also not access via the key
* _yaml: Remove 'indices' from 'node_get_provenance'Benjamin Schubert2019-07-095-29/+29
| | | | | | | | | With nodes being propagated better, we now don't need to extract provenance beforehand. Therefore removing the ability to provide indiced when getting provenance. - Also add 'scalar_at' on 'SequenceNode', in order to fetch a scalar node at a specific indice
* types: rework dependency to always get a 'Node' as dep and remove provenanceBenjamin Schubert2019-07-091-9/+4
| | | | | The provenance can be constructed afterwards, so we don't need to pre-calculate it.
* _yaml: Use __cinit__ and __new__ to create node more effectivelyBenjamin Schubert2019-07-091-27/+34
| | | | | | | Cython can bypass the normal python mechanism to create new objects, which makes their instantation faster. See https://cython.readthedocs.io/en/latest/src/userguide/extension_types.html#fast-instantiation for more details.
* _yaml: Move 'value' of Node in each sub nodeBenjamin Schubert2019-07-093-39/+71
| | | | | | | | This allows us to type its value more strictly, allowing for more efficient access. - Also implement 'node_at' on 'SequenceNode', to allow some tests to test some internals generically.
* _yaml: Mark attributes on 'Node' as private (only c-accessible)Benjamin Schubert2019-07-092-4/+6
| | | | | This ensures that we are not breaking our encapsulation and that the modules accessing 'Node' from C are correctly typed.
* _yaml: Remove 'is_node', which is not used in the codebase anymoreBenjamin Schubert2019-07-091-20/+0
| | | | | A direct replacement would be isinstance(obj, MappingNode) if someone really needs it.
* _yaml: Remove 'node_validate' and replace by 'MappingNode.validate_keys'Benjamin Schubert2019-07-0930-103/+71
| | | | - adapt all call sites to use the new API
* _yaml: Create 'from_dict' on Node and remove node creation methodsBenjamin Schubert2019-07-099-54/+18
| | | | | | | Using 'Node.from_dict({})' can replace new_empty_node, and the rest is not needed anymore. - Adapt all call sites
* _yaml: Remove 'node_extend_list' and add 'SequenceNode.append'Benjamin Schubert2019-07-094-80/+16
| | | | | | | There was a single place using 'node_extend_list', which we can replace more easily with 'SequenceNode.append'. Also rewrite _projectrefs.py:_lookup to use the new API more effectively
* _yaml: Refer new synthetic nodes to their parentsBenjamin Schubert2019-07-091-19/+22
| | | | | | | | | This changes how we were handling synthetic nodes. Previously, we would have them as coming from a 'SYNTHETIC_FILE'. This is not correct when we need the position in the real file when adding new information to a file we will end up writing to disk (like project_ref). This is a prerequisite for further work on cleaning how it is done.
* _yaml: Add a 'from_dict' on Node to create new nodes from dictsBenjamin Schubert2019-07-094-18/+22
| | | | | | | This new methods is here to replace the previous 'new_node_from_dict' that will be moved to a private method. Adapt all call sites to use the new 'from_dict' method.
* _yaml: Move 'node_composite' to a method on 'MappingNode'Benjamin Schubert2019-07-0910-68/+64
| | | | | - Also take care of node_composite_move in the same way. - Adapt all calling places
* _yaml: move 'composite_dict' to 'MappingNode' as '_composite'Benjamin Schubert2019-07-092-18/+14
|
* _yaml: Extract parts of 'composite_dict' to each type of 'Node'Benjamin Schubert2019-07-092-49/+62
| | | | | | We had a large if-else clause in 'composite_dict' that was looking at the type of the source and acting based on that. This is easier to handle once split on each type of 'Node'
* _yaml: Move actual composition logic to MappingNodeBenjamin Schubert2019-07-092-67/+51
|
* _yaml: move 'is_composite_list' as a Node memberBenjamin Schubert2019-07-092-44/+48
|
* tests/yaml: Stop using 'composite_dict' and use 'composite' insteadBenjamin Schubert2019-07-092-8/+8
| | | | | 'composite_dict' is a more internal method and we don't really need to access it there
* _yaml: Move 'node_final_assertions' to 'Node._assert_fully_composited'Benjamin Schubert2019-07-096-58/+47
|
* _yaml: remove node_sanitizeBenjamin Schubert2019-07-097-71/+20
| | | | | | | | | Some call places do not need calls to 'node_sanitize' anymore, therefore removing the call entirely. Other still use it for convenience, but that doesn't seem the right way to do it for consistency. Those places have been replaced by calls to 'Node.strip_node_info()'.
* _yaml: Decomission 'dump()'. 'roundtrip_dump' is an equivalent function nowBenjamin Schubert2019-07-096-22/+7
| | | | | Remove completely '_yaml.dump()' and replace all notions and call by 'roundtrip_dump'
* tests: Change all calls to _yaml.dump to _yaml.rountrip_dumpBenjamin Schubert2019-07-0966-312/+293
| | | | | Now that both are equivalent, we can skip the sanitization part before the yaml call.
* _yaml: Automatically represent Yaml nodes into yamlBenjamin Schubert2019-07-091-2/+16
| | | | | This removes the need of calling _yaml.dump(), as roundtrip_dump is now equivalent.
* _yaml: Stop stringifying manually in roundtrip_dumpBenjamin Schubert2019-07-091-27/+14
| | | | | | This removes the need of manually stringifying the values in roundtrip_dump by registering special Ruamel representer for each value we might expect.
* _cachekey: Remove the 'node_sanitization' done before the json stringBenjamin Schubert2019-07-097-7/+26
| | | | | | | | Since ujson already sorts the keys, we just need to be able to jsonify Nodes sensibly. This is done by implementing __json__ on the 'Node' base class. This does not break the cache keys.
* _yaml: Remove 'node_find_target' and replace by 'MappingNode.find'Benjamin Schubert2019-07-094-68/+70
|
* _yaml: Remove 'key' from node_find_targetBenjamin Schubert2019-07-093-12/+7
| | | | | | | - node_find_target with 'key' is only used once in the codebase. We can remove and simplify this function - Allow 'MappingNode.get_node()' to be called without any 'expected_types'
* _yaml: Remove 'node_set'. Now use __setitem__Benjamin Schubert2019-07-0915-98/+98
| | | | | | - Implement __setitem__ on 'MappingNode' - Implement __setitem__ on 'SequenceNode' - Adapt all call sites to use the new calling way.
* _yaml: Remove 'node_items' and add 'MappingNode.items()'Benjamin Schubert2019-07-0910-86/+32
| | | | | | One difference is that 'MappingNode.items()' does not strip the provenance from scalars and lists, which ends up not affecting the code much.
* _yaml: Introduce 'MappingNode.values()'Benjamin Schubert2019-07-095-9/+17
| | | | | | | This is to mimic the 'dict.values()' interface. - Adapt parts of the code calling 'node_items' but ignoring the first value to use this instead
* _yaml: Remove 'node_keys' and add 'MappingNode.keys' to replace itBenjamin Schubert2019-07-097-29/+15
| | | | | This mimics the dict.keys() method but returns a list instead of a dict_keys, for cython performance reasons
* _yaml: Remove 'node_del' and support `del mapping[key]`Benjamin Schubert2019-07-098-28/+20
| | | | | - Also add a convenience method 'safe_del' catching the exception when we don't care if the value was there or not.
* _yaml: Remove 'node_copy' and add 'Node.copy()'Benjamin Schubert2019-07-097-85/+51
| | | | Also adaprt every part of the code calling it
* _yaml: Add a 'get_node' on Mapping, when return type can be of multiple typesBenjamin Schubert2019-07-093-12/+27
| | | | | | | | | | | Sometimes, we might want to have a list or a string, in which case, we can now use 'get_node', which can return multiple types. This method doesn't contain a 'default' value, as building a 'Node' from it would be hard. We therefore just have a 'allow_none' flag that allows returning 'None' when the value is not found. - includes: use the new 'get_node' instead of trying multiple versions
* _yaml: Never create base 'Node' directlyBenjamin Schubert2019-07-092-5/+8
| | | | We shouldn't have to create normal nodes ever. Let's ensure we don't
* _yaml: Remove 'node_get' and migrate all remaining calls to new APIBenjamin Schubert2019-07-0919-167/+67
|
* doc/bst2html: Remove usage of 'node_get' and use new APIBenjamin Schubert2019-07-091-13/+11
|
* element: Remove `node_get_member` and all references to itBenjamin Schubert2019-07-094-47/+3
| | | | This can now be done more easily with the Node api
* plugin: remove 'node_get_list_element'Benjamin Schubert2019-07-091-37/+1
| | | | | | | The new yaml API is able of getting these access with the same error messages handling. Having this helper is therefore not useful anymore.
* element: remove 'node_subst_list_element'Benjamin Schubert2019-07-092-43/+1
| | | | | This method is unused and can be easily reimplemented with the new Node API by looping over nodes.
* tests: remove 'node_get_yaml_provenance()' helper and replace with the new APIBenjamin Schubert2019-07-096-62/+19
| | | | | | This function is hard to make generic and, with the new API, the access is simplified. Therefore, removing this function and migrating all its usages
* _yaml: Introduce 'get_sequence()' and 'sequence_at()'/'mapping_at()'Benjamin Schubert2019-07-0919-70/+123
| | | | | | | | | - Adding 'get_sequence' on MappingNode to access sequences in a mapping - Adding 'sequence_at' on SequenceNode to access sequences in a sequence - Adding 'mapping_at' on SequenceNode to access mappings in a sequence Using "*_at" in sequences allows us to quickly understand if we are dealing with a sequence or a mapping.
* _yaml: Remove use of expected_type=None in 'node_get()'Benjamin Schubert2019-07-093-13/+11
| | | | | | | In a strongly typed API with Node, having a 'None' as expected type is hard to make nice. Moreover, this is rarely used in the codebase. Thus, adapting the call sites to not use 'None' as an expected type.
* _yaml: Add 'as_int()' on ScalarNodeBenjamin Schubert2019-07-098-15/+32
| | | | | | - Add the 'as_int()' method on 'ScalarNode' to replace 'node_get(mapping, key, int)' - Adapt all call sites to use the new API
* _yaml: Add 'as_bool()' and 'is_none()' to ScalarNodeBenjamin Schubert2019-07-0916-34/+57
| | | | | | | | | | | - 'as_bool()' casts a ScalarNode into a boolean, understanding both 'True' and 'False' as truthy-falsy values, as per node_get(type=bool) behavior - 'is_none()' allwos checking whether the scalar node contains a 'None' value. Since 'None' cannot be used when working with booleans, we need to have a way of checking for 'None' when we actually need the information of whether the value is unset. - Adapt all call places to use the new API
* _yaml: Add 'as_str()' on ScalarNode and 'get_scalar()' on MappingNodeBenjamin Schubert2019-07-0946-160/+191
| | | | | | | | | | - 'get_scalar()' allows retrieving a scalar node from a mapping. - 'as_str()' casts a ScalarNode into a string (thus removing the node information). Both together, those replace 'node_get(mapping, key, type=str)' but also allow retrieving the 'Node' itself, which will allow in the future lazier provenance computation.
* _yaml: add 'get_mapping()' to MappingNodeBenjamin Schubert2019-07-0919-77/+101
| | | | | | | | This allows to get a mapping node from another 'MappingNode', replacing 'node_get(my_mapping, key, type=dict)' Also changes all places where 'node_get' was called like that by the new API.