<feed xmlns='http://www.w3.org/2005/Atom'>
<title>samba.git/python/samba/gp_parse, branch talloc-2.3.0</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/'/>
<entry>
<title>gp_inf: Read/write files with a UTF-16LE BOM in GptTmpl.inf</title>
<updated>2019-07-19T02:20:47+00:00</updated>
<author>
<name>Garming Sam</name>
<email>garming@catalyst.net.nz</email>
</author>
<published>2019-07-18T02:50:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/commit/?id=0bcfc550b1a902e3a6a766b06603ac9285d0ff63'/>
<id>0bcfc550b1a902e3a6a766b06603ac9285d0ff63</id>
<content type='text'>
Regression caused by 16596842a62bec0a9d974c48d64000e3c079254e

[MS-GPSB] 2.2 Message Syntax says that you have to write a BOM which I
didn't do up until this patch. UTF-16 as input encoding was marked much
higher up in the inheritance tree, which got overriden with the Python 3
fixes. I've now marked the encoding much more obviously for this file.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14004

Signed-off-by: Garming Sam &lt;garming@catalyst.net.nz&gt;
Reviewed-by: Gary Lockyer &lt;gary@catalyst.net.nz&gt;

Autobuild-User(master): Gary Lockyer &lt;gary@samba.org&gt;
Autobuild-Date(master): Fri Jul 19 02:20:47 UTC 2019 on sn-devel-184
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Regression caused by 16596842a62bec0a9d974c48d64000e3c079254e

[MS-GPSB] 2.2 Message Syntax says that you have to write a BOM which I
didn't do up until this patch. UTF-16 as input encoding was marked much
higher up in the inheritance tree, which got overriden with the Python 3
fixes. I've now marked the encoding much more obviously for this file.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14004

Signed-off-by: Garming Sam &lt;garming@catalyst.net.nz&gt;
Reviewed-by: Gary Lockyer &lt;gary@catalyst.net.nz&gt;

Autobuild-User(master): Gary Lockyer &lt;gary@samba.org&gt;
Autobuild-Date(master): Fri Jul 19 02:20:47 UTC 2019 on sn-devel-184
</pre>
</div>
</content>
</entry>
<entry>
<title>gpo: Parse GPT.INI with Latin-1</title>
<updated>2019-03-12T00:42:20+00:00</updated>
<author>
<name>Garming Sam</name>
<email>garming@catalyst.net.nz</email>
</author>
<published>2019-02-26T02:35:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/commit/?id=75cf728398421435186559306b0962c70f333c6e'/>
<id>75cf728398421435186559306b0962c70f333c6e</id>
<content type='text'>
For some reason the French version of RSAT turns accents into ISO-8859-1.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13806

Signed-off-by: Garming Sam &lt;garming@catalyst.net.nz&gt;
Reviewed-by: Andrew Bartlett &lt;abartlet@samba.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For some reason the French version of RSAT turns accents into ISO-8859-1.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13806

Signed-off-by: Garming Sam &lt;garming@catalyst.net.nz&gt;
Reviewed-by: Andrew Bartlett &lt;abartlet@samba.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>py3: io.open takes a numeric buffering argument at index 2</title>
<updated>2019-03-12T00:42:20+00:00</updated>
<author>
<name>Garming Sam</name>
<email>garming@catalyst.net.nz</email>
</author>
<published>2019-02-21T02:11:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/commit/?id=2e231541b48fc97ca013079585ef556efda6cb95'/>
<id>2e231541b48fc97ca013079585ef556efda6cb95</id>
<content type='text'>
It's unsure why this doesn't fail generically, but it fails on my machine sometimes...

Signed-off-by: Garming Sam &lt;garming@catalyst.net.nz&gt;
Reviewed-by: Andrew Bartlett &lt;abartlet@samba.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It's unsure why this doesn't fail generically, but it fails on my machine sometimes...

Signed-off-by: Garming Sam &lt;garming@catalyst.net.nz&gt;
Reviewed-by: Andrew Bartlett &lt;abartlet@samba.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python/samba/gp_parse: PY2/PY3 Decode only when necessary</title>
<updated>2018-11-05T19:05:24+00:00</updated>
<author>
<name>Noel Power</name>
<email>noel.power@suse.com</email>
</author>
<published>2018-09-05T16:01:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/commit/?id=fc047c2cf458e08e2689ff27677d8622f4507c82'/>
<id>fc047c2cf458e08e2689ff27677d8622f4507c82</id>
<content type='text'>
In python2 we decode str types in load_xml, in python3 these are
str class(s) which we cannot decode.

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In python2 we decode str types in load_xml, in python3 these are
str class(s) which we cannot decode.

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python/samba/gp_parse: Fix mulitple encode step with write_section</title>
<updated>2018-11-05T19:05:24+00:00</updated>
<author>
<name>Noel Power</name>
<email>noel.power@suse.com</email>
</author>
<published>2018-09-05T14:23:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/commit/?id=16596842a62bec0a9d974c48d64000e3c079254e'/>
<id>16596842a62bec0a9d974c48d64000e3c079254e</id>
<content type='text'>
In python2 as far as I can see GptTmplInfParser.write_binary more
or less works by accident.

write_binary creates a writer for the 'utf8' codec, such a writer
should consume unicode and emit utf8 encoded bytes. This writer
is passed to each of the sections managed by GptTmplInfParser as
follows

    def write_binary(self, filename):
        with codecs.open(filename, 'wb+',
                         self.encoding) as f:
            for s in self.sections:
                self.sections[s].write_section(s, f)

And each section type itself is encoding its result to 'utf-16-le'
e.g.
    class UnicodeParam(AbstractParam):
         def write_section(self, header, fp):
            fp.write(u'[Unicode]\r\nUnicode=yes\r\n'.encode(self.encoding)

But this makes little sense, it seems like sections are encoded to one
encoding but the total file is supposed to be encoded as ut8??? Also
having an encoding per ParamType doesn't seem correct.

Bizarely in PY2 this works and it actually encodes the whole file as utf-16le
In PY3 you can't do this as the writer wants to deal with strings not bytes
(after the extra encode phase in 'write_section'.

So, changes here are to remove the unnecessary encoding in each 'write_section'
method, additionally in GptTmplInfParser.write_binary the
codecs.open call now uses the correct codec (e.g. 'utf-16-le') to write

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In python2 as far as I can see GptTmplInfParser.write_binary more
or less works by accident.

write_binary creates a writer for the 'utf8' codec, such a writer
should consume unicode and emit utf8 encoded bytes. This writer
is passed to each of the sections managed by GptTmplInfParser as
follows

    def write_binary(self, filename):
        with codecs.open(filename, 'wb+',
                         self.encoding) as f:
            for s in self.sections:
                self.sections[s].write_section(s, f)

And each section type itself is encoding its result to 'utf-16-le'
e.g.
    class UnicodeParam(AbstractParam):
         def write_section(self, header, fp):
            fp.write(u'[Unicode]\r\nUnicode=yes\r\n'.encode(self.encoding)

But this makes little sense, it seems like sections are encoded to one
encoding but the total file is supposed to be encoded as ut8??? Also
having an encoding per ParamType doesn't seem correct.

Bizarely in PY2 this works and it actually encodes the whole file as utf-16le
In PY3 you can't do this as the writer wants to deal with strings not bytes
(after the extra encode phase in 'write_section'.

So, changes here are to remove the unnecessary encoding in each 'write_section'
method, additionally in GptTmplInfParser.write_binary the
codecs.open call now uses the correct codec (e.g. 'utf-16-le') to write

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python/samab/gp_parse: remove unused code</title>
<updated>2018-11-05T19:05:23+00:00</updated>
<author>
<name>Noel Power</name>
<email>noel.power@suse.com</email>
</author>
<published>2018-09-05T13:39:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/commit/?id=54e2bb707bc998e9017ab3818f8df45c95fad3ce'/>
<id>54e2bb707bc998e9017ab3818f8df45c95fad3ce</id>
<content type='text'>
Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python/samba/gp_parse: Use csv.reader for parsing cvs files</title>
<updated>2018-11-05T19:05:23+00:00</updated>
<author>
<name>Noel Power</name>
<email>noel.power@suse.com</email>
</author>
<published>2018-09-05T13:18:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/commit/?id=df578e1554630f6781d40d4820c9026bb7b01d2d'/>
<id>df578e1554630f6781d40d4820c9026bb7b01d2d</id>
<content type='text'>
The previous version here was using UnicodeReader which was
wrapping the UTF8Recoder class and passing that to csv.reader.
It looks like the intention was to read a bytestream in a
certain encoding and then reencode it to a different encoding.
And then UnicodeReader creates unicode from the newly encoded stream.
This is unnecssary, we know the encoding of the bytesstream and
codec.getreader will happily consume the bytstream and give back
unicode. The unicode can be fed directly into csv.writer.

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The previous version here was using UnicodeReader which was
wrapping the UTF8Recoder class and passing that to csv.reader.
It looks like the intention was to read a bytestream in a
certain encoding and then reencode it to a different encoding.
And then UnicodeReader creates unicode from the newly encoded stream.
This is unnecssary, we know the encoding of the bytesstream and
codec.getreader will happily consume the bytstream and give back
unicode. The unicode can be fed directly into csv.writer.

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python/samba/gp_parse: PY2/PY3 compat porting for gp_init.py</title>
<updated>2018-11-05T19:05:23+00:00</updated>
<author>
<name>Noel Power</name>
<email>noel.power@suse.com</email>
</author>
<published>2018-09-05T12:00:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/commit/?id=cf79e6ae1516a76cf8b7403a8372fbc6dc3a3a6a'/>
<id>cf79e6ae1516a76cf8b7403a8372fbc6dc3a3a6a</id>
<content type='text'>
Fixes
1) use compat versions of ConfigParser and StringIO
2) fix sort list of XML Elements
3) open file needs to be opened in binary mode as write_pretty_xml
   routing uses BytesIO() object.

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes
1) use compat versions of ConfigParser and StringIO
2) fix sort list of XML Elements
3) open file needs to be opened in binary mode as write_pretty_xml
   routing uses BytesIO() object.

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python/samba/gp_parse: PY3 open file non-binary mode for write_binary</title>
<updated>2018-11-05T19:05:23+00:00</updated>
<author>
<name>Noel Power</name>
<email>noel.power@suse.com</email>
</author>
<published>2018-09-05T11:52:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/commit/?id=d40ef736d5ee34ad5b575dc32f89d0f4cc1885b8'/>
<id>d40ef736d5ee34ad5b575dc32f89d0f4cc1885b8</id>
<content type='text'>
Although this is unintuitive it's because we are writing unicode
not bytes (both in PY2 &amp; PY3). using the 'b' mode causes an error in
PY3.

In PY3 we can define the encoding, but not in PY2.

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Although this is unintuitive it's because we are writing unicode
not bytes (both in PY2 &amp; PY3). using the 'b' mode causes an error in
PY3.

In PY3 we can define the encoding, but not in PY2.

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python/samba/gp_parse: PY3 file -&gt; open</title>
<updated>2018-11-05T19:05:23+00:00</updated>
<author>
<name>Noel Power</name>
<email>noel.power@suse.com</email>
</author>
<published>2018-09-05T11:46:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/samba.git/commit/?id=388bddf4a6471f17f32af209bec36713f0b75d20'/>
<id>388bddf4a6471f17f32af209bec36713f0b75d20</id>
<content type='text'>
'file' no longer exists in PY3 replace with 'open'

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
'file' no longer exists in PY3 replace with 'open'

Signed-off-by: Noel Power &lt;noel.power@suse.com&gt;
Reviewed-by: Douglas Bagnall &lt;douglas.bagnall@catalyst.net.nz&gt;
</pre>
</div>
</content>
</entry>
</feed>
