Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ID Namespace Example causes warning #209

Closed
MarkDavidson opened this issue Sep 30, 2014 · 4 comments
Closed

ID Namespace Example causes warning #209

MarkDavidson opened this issue Sep 30, 2014 · 4 comments

Comments

@MarkDavidson
Copy link
Contributor

When running the example for ID Namespaces [1], I get the following warning: site-packages\stix\utils\nsparser.py:161: UserWarning: Unable to map namespace 'http://MY-NAMESPACE.com' to schemaLocation "schemaLocation" % ns)

Valid XML is produced, so I'm really just filing this issue about the warning. My guess is that ID namespaces don't really need to be present in the schemaLocation element.

This is probably a pretty low priority.
-Mark

[1] http://stix.readthedocs.org/en/latest/examples/index.html#id-namespaces

@MarkDavidson
Copy link
Contributor Author

Another comment: The stix.utils.set_id_namespace and cybox.utils.set_id_namespace collide on function names. While the examples show using them separately, they will probably be used together frequently.

My interim solution is to import them with separate names:

from stix.utils import set_id_namespace as stix_sin
from cybox.utils import set_id_namespace as cybox_sin

@bworrell
Copy link
Contributor

The warning issue was fixed in bd831c0. Also, warnings can be filtered such that you can ignore them if you want [1][2][3]. I felt it was important to raise a potential issue to producers about their output without actually aborting on the process so I chose warnings as a solution, with the knowledge that developers can ignore them. They also print to stderr so redirecting stdout to a file doesn't cause problems.

[1] https://docs.python.org/2/library/warnings.html#available-context-managers
[2] https://docs.python.org/2/library/warnings.html#temporarily-suppressing-warnings
[3] https://docs.python.org/2/library/warnings.html#the-warnings-filter

@bworrell
Copy link
Contributor

As for function names, I don't see a need to rename them as they are namespaced/packaged appropriately. There are a number of ways you could have addressed this via import statements, including your own.

import cybox.utils
import stix.utils

cybox.utils.set_id_namespace(...)
stix.utils.set_id_namespace(...)
import cybox.utils as cybox_utils
import stix.utils as stix_utils

cybox_utils.set_id_namespace(...)
stix_utils.set_id_namespace(...)

I am going to close this out since there are fixes already in place for your specific warning, and workarounds available for those who want to filter Python warnings.

@MarkDavidson
Copy link
Contributor Author

Agree with the close. The warning was the issue, which seems to have been fixed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants