Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert user nicely when docDate does not have required attribute #492

Closed
johnfelipe opened this issue Jun 10, 2015 · 8 comments
Closed

Alert user nicely when docDate does not have required attribute #492

johnfelipe opened this issue Jun 10, 2015 · 8 comments

Comments

@johnfelipe
Copy link

(virtualenv-sayit)notroot@felipeurrego:~/sayit/sayit.mysociety.org$ ./manage.py load_akomantoso --file=/home/notroot/camara/actas-consejo-medellin/xml/acta-20-12-noviembre-20-de-2012.xml --instance=camara --commit
An exception of type AttributeError occurred, arguments:
'NoneType' object has no attribute 'read'
Traceback (most recent call last):
  File "/home/notroot/sayit/virtualenv-sayit/src/django-sayit/speeches/management/import_commands.py", line 120, in import_document
    importer.import_document(path)
  File "/home/notroot/sayit/virtualenv-sayit/src/django-sayit/speeches/importers/import_akomantoso.py", line 25, in import_document
    return self.parse_document()
  File "/home/notroot/sayit/virtualenv-sayit/src/django-sayit/speeches/importers/import_akomantoso.py", line 62, in parse_document
    self.start_date = dateutil.parse(docDate.get('date'))
  File "/home/notroot/sayit/virtualenv-sayit/local/lib/python2.7/site-packages/dateutil/parser.py", line 1008, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
  File "/home/notroot/sayit/virtualenv-sayit/local/lib/python2.7/site-packages/dateutil/parser.py", line 392, in parse
    res = self._parse(timestr, **kwargs)
  File "/home/notroot/sayit/virtualenv-sayit/local/lib/python2.7/site-packages/dateutil/parser.py", line 492, in _parse
    l = _timelex.split(timestr)         # Splits the timestr into tokens
  File "/home/notroot/sayit/virtualenv-sayit/local/lib/python2.7/site-packages/dateutil/parser.py", line 174, in split
    return list(cls(s))
  File "/home/notroot/sayit/virtualenv-sayit/local/lib/python2.7/site-packages/dateutil/parser.py", line 171, in next
    return self.__next__()  # Python 2.x support
  File "/home/notroot/sayit/virtualenv-sayit/local/lib/python2.7/site-packages/dateutil/parser.py", line 164, in __next__
    token = self.get_token()
  File "/home/notroot/sayit/virtualenv-sayit/local/lib/python2.7/site-packages/dateutil/parser.py", line 82, in get_token
    nextchar = self.instream.read(1)
AttributeError: 'NoneType' object has no attribute 'read'

This is xml generated

https://github.com/johnfelipe/camarakomantoso

<questions>....</questions>
and
<narrative>....</narrative>

Are included

@dracos
Copy link
Member

dracos commented Jun 10, 2015

If you wish to use docDate, you must give it a date attribute, <docDate date="2000-01-01">1st Janary 2000</docDate> or similar, like your other XML files used to do. It could give a better error message, I'll rename the ticket for that.

@dracos dracos changed the title AttributeError: 'NoneType' object has no attribute 'read' Alert user nicely when docDate does not have required attribute Jun 10, 2015
@johnfelipe
Copy link
Author

<questions>

are good?
Place are good to?

@dracos
Copy link
Member

dracos commented Jun 10, 2015

From a quick look, it looks okay, I guess the test is if it imports okay.
I don't know what you mean by Place are good to?.

@johnfelipe
Copy link
Author

<docDate date="11-09-2012"/>

Is visible for all hansard, its better docDate or startTime in each speech?

Url is not visible to: #491

@dracos
Copy link
Member

dracos commented Jun 10, 2015

I don't understand your question.

@johnfelipe
Copy link
Author

Is betther have a startime like this in each speech:

 <speech by="#nicolasalbeiroecheverrialvaran" startTime="2013-06-25T00:00:00">

Or

 <docDate date="2013-06-25"/>

For give date to all hansard

@dracos
Copy link
Member

dracos commented Jun 10, 2015

If a startTime attribute is not given on a speech and a docDate has been given, then the speech will default to using the docDate date.

@johnfelipe
Copy link
Author

Tnks so much, pls close

@dracos dracos closed this as completed in 5422a8b Jun 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants