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

Serialisation warning in CDAO with Windows paths #320

Open
peterjc opened this issue May 2, 2014 · 3 comments
Open

Serialisation warning in CDAO with Windows paths #320

peterjc opened this issue May 2, 2014 · 3 comments

Comments

@peterjc
Copy link
Member

peterjc commented May 2, 2014

See http://lists.open-bio.org/pipermail/biopython-dev/2014-April/011294.html - the test output for CDAO reports a series of slightly messages (more than an hundred) that looks like this:

file://C:\WinPython3.3\3.3 - Biopythontest\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\biopython\Test\CDAO\test.cdao/tree0000001#node0000001 does not look like a valid URI, trying to serialize this will break.

According to the RDFLib docstring for their URI class they issue this warning if the URI contains a Windows-style forward slash: http://rdflib.readthedocs.org/en/latest/_modules/rdflib/term.html

The relevant snippet of their code is:

_invalid_uri_chars = '<>" {}|\\^`'

def _is_valid_uri(uri):
    for c in _invalid_uri_chars:
        if c in uri: return False
    return True

My suggestion would be to switch all the \ into / to avoid these warnings under Windows:

@peterjc
Copy link
Member Author

peterjc commented May 2, 2014

@bendmorris - any comment? Does this seem like a sensible solution?

@MCalvi
Copy link

MCalvi commented May 28, 2014

I did a bit of exploration on this error starting to the snippet Peter posted. I found out the problem started with RDFlib behaviour under Windows is legit, it put out the more compatible forward slashes. only one indeed, the one after the test.cdao file. The rest is handled by another parser and by the os.path library in the test callings, those modules actively converts forward slashes in backward slashes when used in Windows so when the path get passed to RDFlib it complains.

The only way out I could think of is using regular expression module before handling the path to RDFlib and change the backward slashes to forwards. I don't know the inner gut of Biopython so well, maybe there is another way to do it.

@peterjc
Copy link
Member Author

peterjc commented May 28, 2014

Is there no point in our code were we give the path to RDFlib (after os.path has been called), where we can just add a .replace(r"\", "/") or similar?

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