Juha, Could you look in the file `einvoice11.py`, for a line something like this:
ExternalEncoding = 'XXXX' If it says: ExternalEncoding = 'ascii' Then change it to this: ExternalEncoding = 'utf-8' And, see if that works. If that works, then you can avoid having to modify the generated modules by hand and can generate modules containing that value by using the following command line option: $ generateDS.py --external-encoding="utf-8" ... If that does not fix your problem, please give me a little more information on how to reproduce it. By the way, I believe that your print statement throws an exception because you need to encode the string before printing it. You'd use: print instring.encode('utf-8') If, instead, you used: instring.encode('ascii') You would get a similar error. And, that's why we need to set ExternalEncoding to 'utf-8' (or whatever handles your character set. I guess I'm saying that I believe we have a fix, even though it's a mysterious and hidden fix. Can you think of anything I could do so that users could find the answer to this problem by themselves? Perhaps a FAQ would help, but when I think of that and think of all the other weird and mysterious things that would have to be in it, my mind freezes. Maybe someday when I'm feeling more energized, or maybe after the second cup of coffee, or after the third glass of beer, ... then maybe I'll start a FAQ. Dave On Tue, Feb 06, 2018 at 12:07:08PM +0200, Juha Tuomala wrote: > > > On tiistaina 6. helmikuuta 2018 0.15.24 EET you wrote: > > Thanks for your fix. I've added it to my repository, and I've > > pushed that change to Bitbucket -- > > https://bitbucket.org/dkuhlman/generateds > > That's great! I think i updated everything (hg pull, hg update) and > re-created > my classes. > > > And, to test this change, I also added a pattern containing > > multi-byte characters to the `tests/validate_simpletypes*` unit > > test. That meant that I had to change the ExternalEncoding for that > > test from the default encoding (ascii) to utf-8. Since your use > > case apparently has xs:simpleType validation patterns that contain > > multi-byte characters, you might want to be aware of this. You can > > use the "--external-encoding" command line option to control this. > > For example, I used: > > > > $ generateDS.py --external-encoding="utf-8" ... some_schema.xsd > > > > In the case of the unit test, the resulting command line is: > > > > $ python generateDS.py \ > > --no-dates --no-versions --member-specs=list \ > > -f \ > > -o tests/validate_simpletypes2_sup.py \ > > -s tests/validate_simpletypes2_sub.py \ > > --super=validate_simpletypes2_sup \ > > --external-encoding="utf-8" \ > > tests/validate_simpletypes.xsd > > > > Hope this helps. Thanks again for your help. I appreciate it. > > I changed my company names into real local characters and tried if that > change > would allow 'em: > > NetNix Estonia OÜ > Traceback (most recent call last): > File "./send.py", line 144, in <module> > r = client.service.sendSaleInvoice( "%s" % (str(einvoice) ) ) > File "/net/alca/srv/sys/lib/python2.6/estonia/centralbank/__init__.py", > line > 133, in __str__ > pretty_print=True, > File "/net/alca/srv/sys/lib/python2.6/estonia/centralbank/einvoice11.py", > line 776, in export > self.exportChildren(outfile, level + 1, namespace_='', name_='E_Invoice', > pretty_print=pretty_print) > File "/net/alca/srv/sys/lib/python2.6/estonia/centralbank/einvoice11.py", > line 791, in exportChildren > Invoice_.export(outfile, level, namespace_, name_='Invoice', > pretty_print=pretty_print) > File "/net/alca/srv/sys/lib/python2.6/estonia/centralbank/einvoice11.py", > line 1183, in export > self.exportChildren(outfile, level + 1, namespace_='', name_='Invoice', > pretty_print=pretty_print) > File "/net/alca/srv/sys/lib/python2.6/estonia/centralbank/einvoice11.py", > line 1231, in exportChildren > self.InvoiceParties.export(outfile, level, namespace_, > name_='InvoiceParties', pretty_print=pretty_print) > File "/net/alca/srv/sys/lib/python2.6/estonia/centralbank/einvoice11.py", > line 1402, in export > self.exportChildren(outfile, level + 1, namespace_='', > name_='InvoiceParties', pretty_print=pretty_print) > File "/net/alca/srv/sys/lib/python2.6/estonia/centralbank/einvoice11.py", > line 1415, in exportChildren > self.SellerParty.export(outfile, level, namespace_, name_='SellerParty', > pretty_print=pretty_print) > File "/net/alca/srv/sys/lib/python2.6/estonia/centralbank/einvoice11.py", > line 4219, in export > self.exportChildren(outfile, level + 1, namespace_='', > name_='BillPartyRecord', pretty_print=pretty_print) > File "/net/alca/srv/sys/lib/python2.6/estonia/centralbank/einvoice11.py", > line 4236, in exportChildren > outfile.write('<Name>%s</Name>%s' % > (self.gds_encode(self.gds_format_string(quote_xml(self.Name), > input_name='Name')), eol_)) > File "/net/alca/srv/sys/lib/python2.6/estonia/centralbank/einvoice11.py", > line 402, in gds_encode > return instring.encode(ExternalEncoding) > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 16: > ordinal not in range(128) > > > particular piece of code is: > > def gds_encode(instring): > print(instring) > if sys.version_info.major == 2: > return instring.encode(ExternalEncoding) > else: > return instring > > And that print that I added, prints 'NetNix Estonia OÜ' - and it still blows > something. :) > > But I can change that Ü to U, it's common here. Just if you're interested to > improve that, I'm happy to help. > > -- > t...@iki.ee | http://tuju.ee | sip:t...@iki.ee | +3726311345 | +3725025337 > Better to have one, and not need it, than to need one and not have it. > > -- Dave Kuhlman http://www.davekuhlman.org ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users