Namespace branch unification#26
Merged
chisholm merged 18 commits intomixbox_namespaces_revampfrom Mar 4, 2016
Merged
Conversation
I use it to enable one-pass namespace collection in mixbox's Entity.to_xml method.
methods, since it turned out there are some python-cybox tests which use them. They don't seem to be used anywhere else; makes me think maybe the tests should be rewritten...
checks only entity subclasses. This is to avoid having to import anything from stix (in particular, stix.Entity). Also, some tests are moved from python-stix to this library, since they were tests of its NamespaceInfo class (now, mixbox's NamespaceCollector).
* Added __contains__ to NamespaceSet. * _NamespaceInfo.prefixes is an OrderedSet now. This reduces issues that can arise when determining the preferred_prefix for a namespace when ``next(iter(namespaceinfo.prefixes))`` is used. * Added docstrings to lookup_prefix and lookup_namespace functions.
* Some code-style changes: guard clauses used to reduce if/elif/else block nesting in loops; kwargs used when passing in literals to multi-parameter functions; use parens for multi-line conditions rather than backslashes; etc. * Removed Entity._get_children() and Entity._get_namespaces() as they are no longer used outside of two python-cybox tests and are no longer a part of the namespace collection/generation workflow.
Looks like he was trying to add more container emulation to NamespaceSet. He'd only got so far as adding __contains__(), but it also suggests possibly defining __iter__() too. Looks like he'd allowed __contains__() to work on a _NamespaceInfo, but I don't agree that public functions should work with that internal type. Someone might think it's okay to do that... So I removed that functionality. Now, it's essentially equivalent to the existing contains_namespace() function, supporting only a namespace URI string.
OrderedSet instead of the built-in python set. I think he didn't finish: he changed __default_construct() but never changed __construct_from_components(). So I updated the latter method.
Bw one pass namespaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There have been two namespace-related branches. The first was about factoring out XML namespace handling into mixbox and making other projects use mixbox's capabilities instead of each reinventing it separately. The second was about making sure the projects were collecting namespace data and generating binding object graphs in the same pass, to improve performance. I wanted the latter task to be based on the new code introduced in the former task, so the latter branched off the former.
I need to merge this whole namespace-related ball of changes together, in preparation for another merge with another out-standing branch. I'm going to merge one_pass into the namespace_revamp branch, to create one big namespace-related change branch.