maxlath / wikibase-cli

read and edit a Wikibase instance from the command line
MIT License
227 stars 24 forks source link

feature: read shapes #143

Open rwst opened 3 years ago

rwst commented 3 years ago

Wish for next year, make this more useful:

> wd d E233
/usr/lib/node_modules/wikibase-cli/lib/tolerant_id_parser.js:25
  throw errors_.new('invalid id', input)
  ^
maxlath commented 3 years ago

v15.11.0 now offers to download the text version from EntitySchema (via the /wiki/Special:EntitySchemaText, ex: https://www.wikidata.org/wiki/Special:EntitySchemaText/E233) by running wd data E233.

I played with bit with the shex module to see if that could be worth integrating or if there was a workflow to recommend, but I couldn't get this to work: shex-to-json -j https://www.wikidata.org/wiki/Special:EntitySchemaText/E233

aborting: Error: error parsing JSON https://www.wikidata.org/wiki/Special:EntitySchemaText/E233: SyntaxError: Unexpected token P in JSON at position 0
    at parseShExJ (/some/project/node_modules/shex/lib/ShExLoader.js:274:14)
    at /some/project/node_modules/shex/lib/ShExLoader.js:103:14
    at tryCatcher (/some/project/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/some/project/node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (/some/project/node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (/some/project/node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (/some/project/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/some/project/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues (/some/project/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate (internal/timers.js:461:21)

Any clue on what's wrong?

rwst commented 3 years ago

Using this script:

from pyshexc.parser_impl.generate_shexj import generate
generate(['-nr', './E233'])

the file parses successfully and generates JSONLD, so it seems your parser does not do its job.