https://bugzilla.wikimedia.org/show_bug.cgi?id=55149

--- Comment #13 from Kunal Mehta (Legoktm) <[email protected]> ---
There are two ways doing that task creating an item; i'll explain it with a
pseudocode:

1st:
repo = repository\(localpage\)
try: repo.createitem\(\)
except itemExistError: print repo.title\(\), 'already exist'

2st:
repo = repository\(localpage\)
if not repo.exists\(\): repo.createitem\(\)
else: print repo.title\(\), 'allready exits'

I prefer the last one. Look at this sample:
&gt;&gt;&gt; import wikipedia as wp
&gt;&gt;&gt; p = wp.Page\('de', 'Helium'\)
&gt;&gt;&gt; d = wp.DataPage\(p\)
&gt;&gt;&gt; d
DataPage\{\[\[wikidata:None\]\]\}
&gt;&gt;&gt; d.exists\(\)
True
&gt;&gt;&gt; d
DataPage\{\[\[wikidata:Q560\]\]\}
&gt;&gt;&gt; 

This means you does not need to call DataPage.get\(\) you may also use
DataPage.exists\(\) for this test.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to