[GRASS-dev] usage of os.linesep (was: Re: [GRASS-SVN] r68240 - grass/trunk/scripts/v.report_
Vaclav Petras
wenzeslaus at gmail.com
Mon Apr 11 08:28:51 PDT 2016
On Mon, Apr 11, 2016 at 11:15 AM, Huidae Cho <grass4u at gmail.com> wrote:
> What about this then? For reading text files, use \r\n. For reading
> outputs from GRASS modules and writing, use os.linesep.
>
> I think this makes sense because it can handle cross platform files safely
> and it's very unlikely to have mixed newlines from modules compiled on the
> same platform.
>
> Or simply just use \r\n for reading and os.linesep for writing?
>
>
It seems to me that one of these is need and simple os.linesep is not
enough. I'm never sure how Python solves this for splitlines() and others.
I was quite struggling with it in the gunittest where sample data and code
usually have \n but on Windows you get \r\n in the created data. Now I'm
usually replacing \r\n everywhere and doing comparisons afterwards but
that's not really applicable for the normal code.
Vaclav
https://trac.osgeo.org/grass/changeset/64662
https://trac.osgeo.org/grass/changeset/64734
https://trac.osgeo.org/grass/changeset/64683
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20160411/8189a22c/attachment.html>
More information about the grass-dev
mailing list