Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
} catch (err) { /* ignore */ }
// what to fetch
let _brands = fileTree.read('brands');
let _wikidata = gatherQIDs(_brands);
let _qids = Object.keys(_wikidata);
let _total = _qids.length;
if (!_total) {
console.log('Nothing to fetch');
process.exit();
}
// split into several wikidata requests
let _urls = wdk.getManyEntities({
ids: _qids,
languages: ['en'],
props: ['info', 'labels', 'descriptions', 'claims'],
format: 'json'
});
let _errors = [];
doFetch().then(finish);
function gatherQIDs(brands) {
let wikidata = {};
Object.keys(brands).forEach(kvnd => {
['brand:wikidata', 'operator:wikidata'].forEach(t => {
let qid = brands[kvnd].tags[t];
if (qid && /^Q\d+$/.test(qid)) {
let _brands = fileTree.read('brands');
let _errors = [];
let _wrongFormat = [];
let _deletedWikidata = [];
let _deletedWikipedia = [];
let _foundSitelink = [];
let _wrongLink = [];
let _wrongEntity = [];
let _missingInstance = [];
let _missingReferences = [];
let _data = gatherData(_brands);
let _urls = {
wikidata: wdk.getManyEntities({
ids: Object.keys(_data.wikidata),
languages: ['en'],
props: ['info', 'claims', 'sitelinks'],
format: 'json',
redirects: false
}),
wikipedia: getWikipediaUrls(
Object.keys(_data.wikipedia)
)
};
process.stdout.write('\nchecking and validating');
doFetch(null, _urls.wikidata, checkWikidata)
.then(doFetch(null, _urls.wikipedia, checkWikipedia))
.then(finish);