Closed edigiacomo closed 9 years ago
Auto detection of encoding is done only on the first byte of the input, but there are examples in extra/bufr that have other leading data at the beginning of the file, which confuses autodetection.
I have committed the option to specify the encoding from python explicitly:
In [3]: db.load?
Type: builtin_function_or_method
String form: <built-in method load of dballe.DB object at 0x7f7aaa6d2290>
Docstring:
load(fp, encoding=None)
Load a file object in the database. An encoding can optionally be
provided as a string ("BUFR", "CREX", "AOF"). If encoding is None then
load will try to autodetect based on the first byte of the file.
So now you can do this and it should work:
db.load(r, "BUFR")
Thank you! But when encoding is None
, then BUFR
encoding is set (the docstring should be updated)
Should be fixed now. Rather than documenting that BUFR is set when encoding is None, I fixed the behaviour so that autodetect is attempted when encoding is None
Starting a web server from top src dir:
The code sometimes raise
KeyError: 'could not detect the encoding of '
orOSError: reading a 5505024-bytes record from : Illegal seek
.Inspecting with gdb, it seems that sometimes the encoding is not dected the line int c = getc(stream); return 255 (encoding not detected) or 0 (create a AOF file):