RDFLib / pyrdfa3

RDFa 1.1 distiller/parser library: can extract RDFa 1.1 (and RDFa 1.0, if properly set via a @version attribute) from (X)HTML, SVG, or XML in general. The module can be used to produce serialized versions of the extracted graph, or simply an RDFLib Graph.
http://www.w3.org/2012/pyRdfa/
Other
67 stars 22 forks source link

Error simple rdfa #27

Closed RichDijk closed 5 years ago

RichDijk commented 5 years ago

I just want to start to have a running configuration of pyrdfa. But running Python 3.7 and rdfa3 ==3.5 gives the following error.

from pyRdfa import pyRdfa
import rdflib
print(pyRdfa().rdf_from_source('pyrdfa.xml'))

Input file pyrdfa.xml

<html xmlns="http://www.w3.org/1999/xhtml"
      prefix="cal: http://www.w3.org/2002/12/cal/ical#">
  <head>
    <title>Jo's Friends and Family Blog</title>
    <link rel="foaf:primaryTopic" href="#bbq" />
    <meta property="dc:creator" content="Jo" />
  </head>
  <body>
    <p about="#bbq" typeof="cal:Vevent">
      I'm holding
      <span property="cal:summary">
        one last summer barbecue
      </span>,
      on
      <span property="cal:dtstart" content="2015-09-16T16:00:00-05:00" 
            datatype="xsd:dateTime">
        September 16th at 4pm
      </span>.
    </p>
  </body>
</html>

error:

> NameError                                 Traceback (most recent call last)
> c:\users\dijkstrr\appdata\local\programs\python\python37-32\lib\site-packages\pyRdfa\__init__.py in _get_input(self, name)
>     448                                                 self.options.set_host_language(self.media_type)
> --> 449                                         return file(name)
>     450                         else :
> 
> NameError: name 'file' is not defined

What is going wrong?

iherman commented 5 years ago

@RichDijk, this was a leftover from the old times, and is not a problem in python2. The file built-in is not available in Python3 anymore, open should be used instead.

I have made an update of the code in this repository as well as on PyPI. I think this should work now.

Thanks for reporting!

RichDijk commented 5 years ago

Using pyrdfa3-3.5.1 works fine now. Thank you.