GithubHelp home page GithubHelp logo

vbraun / exportsagenb Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 3.0 115 KB

Export SageNB Notebooks (to Jupyter)

License: GNU General Public License v3.0

Makefile 0.19% Python 32.65% HTML 63.30% CSS 2.29% JavaScript 1.57%

exportsagenb's People

Contributors

fchapoton avatar jdemeyer avatar minrk avatar nthiery avatar vbraun avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

exportsagenb's Issues

utf-8 in worksheet names

Unfortunately people use all possible strange charssets in worksheet names etc.

I have strange effect where:

sagenb-export --list

works and gives list with i18n chars

but
sagenb-export --list > file fails with

'ascii' codec can't encode character u'\u0142' in position 23: ordinal not in range(128)
btw: LC_ALL are set tu utf8

I have changes in sagenb_reader, open to io.open with utf-8 encoding explicitely, but it gave me:

UnicodeDecodeError: 'utf8' codec can't decode byte 0xf3 in position 368: invalid continuation byte

The problematic conf file contained indeen some junk:

VWDI projekt - R�\u017cankowski, Kie\u0142pi\u0144ski, Kozok

How is testing supposed to work

I have actually two issue with testing:

  1. how are we supposed to run the test?
  2. the test folder is currently listed for install which according to portage is a no-no and I can see why, considering it would be installed just under the site-packages folder. We can't have everyone test folder ending there.

Fails when LC_CTYPE is not explicitly UTF-8

$ LC_CTYPE="C.UTF-8" python2.7 -m unittest discover
......
----------------------------------------------------------------------
Ran 6 tests in 0.020s

OK

$ LC_CTYPE="POSIX" python2.7 -m unittest discover
.E....
======================================================================
ERROR: test_aleksandra_slapik_44 (test.test_sagenb_writer.ReadSageNB)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/infinity0/var/lib/sage/sagenb-export/test/test_sagenb_writer.py", line 39, in test_aleksandra_slapik_44
    ipynb.write(self.tmp_filename(u'WDI projekt - R\xf3\u017cankowski, Kie\u0142pi\u0144ski, Kozok.ipynb'))
  File "/home/infinity0/var/lib/sage/sagenb-export/sagenb_export/ipynb_writer.py", line 58, in write
    write(ipynb, filename)
  File "/usr/lib/python2.7/dist-packages/nbformat/__init__.py", line 163, in write
    with io.open(fp, 'w', encoding='utf-8') as f:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 41-42: ordinal not in range(128)

----------------------------------------------------------------------
Ran 6 tests in 0.020s

FAILED (errors=1)
1

This is because you pass a unicode string type as a filename. Python will implicitly try to encode this using LC_CTYPE, which doesn't support that particular value. You can fix this in several ways, I'm not sure which way you prefer:

  1. Say that IpynbWriter.write can only accept byte filenames, and do the encode('utf-8') in the test. This is probably the simplest.
  2. Say that IpynbWriter.write can accept unicode string filenames too, and do encode('utf-8') in there, if it's a string type.
  3. Add a filename_encoding param to IpynbWriter.write.

attached files (data "dir")

Files from "data dir attached to sagenb notebooks are not saved.

There is a solution in sws2rst, namely for each name there is a directory created with _files suffix and
internal links are also updated.

%FOO -> %%FOO

%time "magic" in sagenb works in fact as "cell magic" in sagenb.
However is not converted to %%time in ipynb ;-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.