Rev 522890 simplifies g.readFileIntoString. The 'mode', 'raw' and 'silent' 
keyword args are gone.

The changes seem straightforward, I have run all possible tests, and I have 
been eating my own dog food without problems.  I saw no reason to create a 
git branch, and imo, nothing would be gained by delaying public testing.

Having said that, any errors in the new would be extremely serious. Please 
report any problems immediately.

Otoh, g.readFileIntoString is Leo's most important helper for reading 
files. Imo, simplifying it (and how it is used) was worth the risk:

- Most calls (almost 20) now contain only the single required argument, a 
file name.

- Only four calls use either the 'encoding' or 'kind' keyword arguments. 
These special cases are clearly unavoidable.

- Perhaps most importantly, g.readFileIntoString is no longer a catch-all 
function. Here is its new docstring:

   '''Return the contents of the file whose full path is fn.

    Return (s,e)
    s is the string, converted to unicode, or None if there was an error.
    e is the encoding of s, computed in the following order:
    - The BOM encoding if the file starts with a BOM mark.
    - The encoding given in the # -*- coding: utf-8 -*- line for python 
files.
    - The encoding given by the 'encoding' keyword arg.
    - None, which typically means 'utf-8'.
    '''

Edward

P. S. Leo has a new method relating to encoding: g.getEncodingAt(p). At 
present, only the bibtex plugin uses it. It computes encodings in this 
order:

    - The BOM, if it exists,
    - Any @encoding directive in p or p's ancestors.
    - For windows, locale.getpreferredencoding() if the string is not 
'utf-8'.

I'm not convinced that using locale.getpreferredencoding() is *ever *the 
right thing to do.  This is an ongoing investigation relating to Character 
encoding problem importing bibtex 
<https://github.com/leo-editor/leo-editor/issues/381>.

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to