Example #1
0
 def open(self, filename):
     from pyglossary.plugin_lib import slob
     self._filename = filename
     self._slobObj = slob.open(filename)
     tags = self._slobObj.tags
     name = tags.get("label")
     if name:
         self._glos.setInfo("name", name)
     creationTime = tags.get("created.at")
     if creationTime:
         self._glos.setInfo("creationTime", creationTime)
Example #2
0
    def open(self, filename):
        from pyglossary.plugin_lib import slob
        self._filename = filename
        self._slobObj = slob.open(filename)
        tags = dict(self._slobObj.tags.items())

        try:
            name = tags.pop("label")
        except KeyError:
            pass
        else:
            self._glos.setInfo("name", name)

        try:
            creationTime = tags.pop("created.at")
        except KeyError:
            pass
        else:
            self._glos.setInfo("creationTime", creationTime)

        try:
            createdBy = tags.pop("created.by")
        except KeyError:
            pass
        else:
            self._glos.setInfo("author", createdBy)

        copyrightLines = []
        for key in ("copyright", "license.name", "license.url"):
            try:
                value = tags.pop(key)
            except KeyError:
                continue
            copyrightLines.append(value)
        if copyrightLines:
            self._glos.setInfo("copyright", "\n".join(copyrightLines))

        try:
            uri = tags.pop("uri")
        except KeyError:
            pass
        else:
            self._glos.setInfo("website", uri)

        try:
            edition = tags.pop("edition")
        except KeyError:
            pass
        else:
            self._glos.setInfo("edition", edition)

        for key, value in tags.items():
            self._glos.setInfo(f"slob.{key}", value)
Example #3
0
 def open(self, filename):
     from pyglossary.plugin_lib import slob
     self._filename = filename
     self._slobObj = slob.open(filename)
Example #4
0
 def open(self, filename, encoding="utf-8"):
     from pyglossary.plugin_lib import slob
     self._filename = filename
     self._slobObj = slob.open(filename)