Erlang with Erlsom and DTD - erlang

I am trying to work with 1 GB XML and DTD file with Erlsom.
The problem is that parse_sax throws an exception becuase it cannot work with DTD file.
Basically i don't need this information so my question is how i tell the
sax_parser to just ignore this?
or even to use try and catch and when the error got catches then to skip this place on the file and continue from there.
This the exception:
** exception throw: {error,"Malformed: unknown reference: uuml"}
in function erlsom_sax_latin1:nowFinalyTranslate/3 (src/erlsom_sax_latin1.erl, line 1051)
in call from erlsom_sax_latin1:translateReferenceNonCharacter/4 (src/erlsom_sax_latin1.erl, line 1024)
in call from erlsom_sax_latin1:parseTextNoIgnore/3 (src/erlsom_sax_latin1.erl, line 922)
in call from erlsom_sax_latin1:parseContent/2 (src/erlsom_sax_latin1.erl, line 898)
in call from erlsom_sax_latin1:parse/2 (src/erlsom_sax_latin1.erl, line 172)
in call from mapReduce:run/0 (/home/alon/workspace/mapReduce/src/mapReduce.erl, line 26)(mapReduce#alon-Vostro-3300)2>
The problem is with "uuml" because in the XML file its apear with &uuml
Thanks for your help.

Hit the same error and found this in the ErlSom docs under limitations of the sax parser:
It doesn’t support entities, apart from the predefined ones (< etc.) and character references (&#nnn; and &#xhhh;).

Related

SeqIO.parse throwing error in genbank files

I'm working with some genbank seq files and have the following code:
for seq_record in SeqIO.parse("datafile_location, "genbank"):
And while it can run through most of the seqs in the seq file (which contains multiple seqs) I get the following error. Any thoughts about how to fix this?
Maybe delete the offending seq? It gets to record 92126 of 93145 and then throws the error.
I have tried re-downloading the seq file, but that doesn't fix the problem.
File "C:\python38\lib\site-packages\Bio\GenBank\Scanner.py", line 516,
in parse_records record = self.parse(handle, do_features) File
"C:\python38\lib\site-packages\Bio\GenBank\Scanner.py", line 499, in
parse if self.feed(handle, consumer, do_features): File
"C:\python38\lib\site-packages\Bio\GenBank\Scanner.py", line 466, in
feed self._feed_header_lines(consumer, self.parse_header()) File
"C:\python38\lib\site-packages\Bio\GenBank\Scanner.py", line 1801, in
feed_header_lines previous_value_line = structured_comment_dict[ KeyError: 'Assembly-Data'
Seems similar like BioPython issue #2844.
A pull request was recently merged to address this.

Service __len__ not found Unexpected error, recovered safely

python3.8
My code:
from googleads import adwords
def execute_request():
adwords_client = adwords.AdWordsClient.LoadFromStorage(path="google_general/googleads.yaml")
campaign_service = adwords_client.GetService('CampaignService', version='v201809')
pass
context["dict_list"] = execute_request()
Traceback:
Traceback (most recent call last):
File "/home/michael/pycharm-community-2019.3.2/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_xml.py", line 282, in frame_vars_to_xml
xml += var_to_xml(v, str(k), evaluate_full_value=eval_full_val)
File "/home/michael/pycharm-community-2019.3.2/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_xml.py", line 369, in var_to_xml
elif hasattr(v, "__len__") and not is_string(v):
File "/home/michael/PycharmProjects/ads3/venv/lib/python3.8/site-packages/googleads/common.py", line 694, in __getattr__
raise googleads.errors.GoogleAdsValueError('Service %s not found' % attr)
googleads.errors.GoogleAdsValueError: Service __len__ not found
Unexpected error, recovered safely.
googleads.yaml about logging
logging:
version: 1
disable_existing_loggers: False
formatters:
default_fmt:
format: ext://googleads.util.LOGGER_FORMAT
handlers:
default_handler:
class: logging.StreamHandler
formatter: default_fmt
level: DEBUG
loggers:
# Configure root logger
"":
handlers: [default_handler]
level: DEBUG
I've just started studying the API.
Namely, I'm trying to execute my first request (https://developers.google.com/adwords/api/docs/guides/first-api-call#make_your_first_api_call)
Could you help me with this problem? At least how to localize it more precisely.
This seems to be a problem which results from the way the PyCharm debugger inspects live objects during debugging.
Specifically, it checks if a given object has the __len__ attribute/method in the code of var_to_xml, most likely to determine an appropriate representation of the object for the debugger interface (which seems to require constructing an XML representation).
googleads service objects such as your campaign_service, however, use some magic to be able to call the defined SOAP methods on them without requiring to hard-code all of them. The code looks like this:
def __getattr__(self, attr):
"""Support service.method() syntax."""
if self._WsdlHasMethod(attr):
if attr not in self._method_proxies:
self._method_proxies[attr] = self._CreateMethod(attr)
return self._method_proxies[attr]
else:
raise googleads.errors.GoogleAdsValueError('Service %s not found' % attr)
This means that the debugger's check for a potential __len__ attribute is intercepted, and because the CampaignService does not have a SOAP operation called __len__, an exception is raised.
You can validate this by running your snippet in the regular way (i.e. not debugging it) and checking if that works.
An actual fix would seem to either require that PyCharm's debugger changes the way it inspects objects (not calling hasattr(v, "__len__")) or that googleads modifies the way it implements __getattr__, for example by actually implementing a __len__ method that just raises AttributeError.

Parse error: syntax error, unexpected ''supplier_rule'' (T_CONSTANT_ENCAPSED_STRING), expecting function (T_FUNCTION)

Resetting CleanURL Prestashop Module has lead to HTTP ERROR.
Parse error: syntax error, unexpected ''supplier_rule''
(T_CONSTANT_ENCAPSED_STRING), expecting function (T_FUNCTION) in
/home/mbawithf/public_html/mbawithfun.cu.cc/override/classes/Dispatcher.php
on line 4
Now I can not even access backend. I just tried to deleting module from FTP... still didn't work. Any solution?
Delete the Dispatcher file in override folder, or comment the function that includes that line.
Don't forget to delete the cache/class_index.php so Prestashop recreates that file.
PrestaShop tries to manually copy class methods to \override\classes* files, and sometimes the lines miss-match or the line break are wrong, and the end result is incorrectly copied lines which cause syntax errors. That happens both on installation and uninstallation. Basically, you then have to manually fix/remove syntax errors from overridden class files.
What you need is to log on to FTP server and edit this files - fix syntax error.
EDIT:
If you had uninstalled the module, then you should replace the contents of this file with:
class Dispatcher extends DispatcherCore
{
}
Please check that the are no public function ... because if there is, it means that other modules may have inserted their functions here. If there isn't any, then it's safe to reset the file with the code above.

Lua Compiling Error 'do' expected near '['

I have a Lua file that I decompiled using unluac. When I try to recompile the files without any changes I get the following error:
lua: main.lua:647: 'do' expected near '['
I really do not know the problem here, as the while do statement follows the correct format.
The error is on line 647 as stated above.
Source is here:
Full Pastebin Source
Expressions like while {}[1] do and if {}[1].parentFolderName then are invalid because of {}[1] reference. It needs to be ({})[1]. It's probably a result of some sort of automated processing, but you should be able to fix it manually.

NSXMLParser fails with NSXMLParserErrorDomain error 111; error 111 isn't defined?

A few people seem to have run into NSXMLParser error 111 before, but it's not defined in the constants. This answer seems to have mistaken 111 with 11: NSXMLParserErrorDomain 111
As far as I can tell, I have no illegal characters in my final xml:
<?xml version="1.0" encoding="utf-16"?><wsse:BinarySecurityToken wsu:Id="uuid:383b6148-1c27-45ab-963b-30e14af8154e" ValueType="http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">aHR0cCUzYSUyZiUyZnNjaGVtYXMueG1sc29hcC5vcmclMmZ3cyUyZjIwMDUlMmYwNSUyZmlkZW50aXR5JTJmY2xhaW1zJTJmbmFtZWlkZW50aWZpZXI9V3dEM2ozRzBobjE0MWFndkNWJTJmWERadmgwJTJiQ0xHV1hBblRLTmM4Qjc3N1UlM2QmaHR0cCUzYSUyZiUyZnNjaGVtYXMubWljcm9zb2Z0LmNvbSUyZmFjY2Vzc2NvbnRyb2xzZXJ2aWNlJTJmMjAxMCUyZjA3JTJmY2xhaW1zJTJmaWRlbnRpdHlwcm92aWRlcj11cmklM2FXaW5kb3dzTGl2ZUlEJkF1ZGllbmNlPWh0dHBzJTNhJTJmJTJma21haW4ta2RzLWV1czItMC5jbG91ZGFwcC5uZXQlMmYmRXhwaXJlc09uPTEzOTQ3NjExODEmSXNzdWVyPWh0dHBzJTNhJTJmJTJmdG9sZWRvLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQlMmYmSE1BQ1NIQTI1Nj1iVTg4cWs2OFc3bmFxOEZFam1EVUFWSlQySzZ5cCUyYkxmdGR4SlFlWDhsYXclM2Q=</wsse:BinarySecurityToken>
I've also tried changing the encoding to utf-8, but it made no difference. What causes a parser to fail with error 111? Is the parser not set up correctly, or is the XML killing it?
In NSXMLParserError docs, it says:
The following error codes are defined by NSXMLParser. For error codes not listed here, see the <libxml/xmlerror.h> header file.
The number 111 isn't mentioned in this list, so we go to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2/libxml/xmlerror.h, and find the value:
XML_ERR_USER_STOP, /* 111 */
There isn't a lot of documentation on XML_ERR_USER_STOP in libxml2, but from reading the changeset, it looks like it's a fast-fail when the parser sees an unexpected EOF.
Referred DebugCN and Internet.
Turns out I was simply passing in an entirely wrong string. The XML chunk came from a larger JSON structure, which I then processed down to get the only XML part; yet when inited the parser, I used the wrong string to create the NSData. So make sure you aren't mixing variables up. I'm still not sure why error 111 isn't defined in the documentation, though.

Resources