Page MenuHomeDevCentral

D465.diff
No OneTemporary

D465.diff

diff --git a/create_given_name b/create_given_name
--- a/create_given_name
+++ b/create_given_name
@@ -9,27 +9,43 @@
import argparse
import sys
+import pywikibot
-#usage: create_givenname.py [-h] givenname
-parser = argparse.ArgumentParser(description='Creates a given name item on Wikidata.')
-parser.add_argument('givenname', metavar='givenname', nargs=1, help='the given name to create')
-parser.add_argument('genre', metavar='genre', nargs='?', default='D', help='M for a male, F for a female, U for an unisex given name', choices=['M','F','U','D'])
+# Usage: create_givenname.py [-h] givenname
+parser = argparse.ArgumentParser(
+ description='Creates a given name item on Wikidata.'
+)
+parser.add_argument(
+ 'givenname',
+ metavar='givenname', nargs=1,
+ help='the given name to create'
+)
+parser.add_argument(
+ 'genre',
+ metavar='genre', nargs='?', default='D',
+ help='M for a male, F for a female, U for an unisex given name',
+ choices=['M', 'F', 'U', 'D']
+)
args = parser.parse_args()
givenname = args.givenname[0]
genre = args.genre[0]
-#Consistency check
+# Consistency check
if givenname[0].islower():
- sys.stderr.write("Can't create a givenname with the first letter in lower case.\n")
- sys.exit(5);
+ sys.stderr.write(
+ "Can't create a givenname with the first letter in lower case.\n"
+ )
+ sys.exit(5)
-#Creates item on Wikidata
-import pywikibot
+# Creates item on Wikidata
site = pywikibot.Site("wikidata", "wikidata")
repo = site.data_repository()
data = {}
-result = repo.editEntity({}, {}, summary = "Creating empty item for given name " + givenname )
+result = repo.editEntity(
+ {}, {},
+ summary="Creating empty item for given name " + givenname
+)
title = result.get('entity').get('id')
item = pywikibot.ItemPage(repo, title=title)
item.get()
@@ -38,19 +54,19 @@
'fr': givenname,
'en': givenname
}
-item.editLabels(labels, summary = 'Adding given name labels')
+item.editLabels(labels, summary='Adding given name labels')
description = {
'en': 'given name',
'fr': 'prénom'
}
-item.editDescriptions(description, summary = 'Adding given name descriptions')
+item.editDescriptions(description, summary='Adding given name descriptions')
genre_items = {
- 'D': 'Q202444',
- 'M': 'Q12308941',
- 'F': 'Q11879590',
- 'U': 'Q3409032'
+ 'D': 'Q202444',
+ 'M': 'Q12308941',
+ 'F': 'Q11879590',
+ 'U': 'Q3409032'
}
claim = pywikibot.Claim(repo, 'P31')
diff --git a/create_surname b/create_surname
--- a/create_surname
+++ b/create_surname
@@ -7,26 +7,35 @@
"""
import argparse
-import sys
+import pywikibot
-#usage: create_surname.py [-h] surname
-parser = argparse.ArgumentParser(description='Creates a surname item on Wikidata.')
-parser.add_argument('surname', metavar='surname', nargs=1, help='the surname to create')
+# usage: create_surname.py [-h] surname
+parser = argparse.ArgumentParser(
+ description='Creates a surname item on Wikidata.'
+)
+parser.add_argument(
+ 'surname', metavar='surname',
+ nargs=1, help='the surname to create'
+)
args = parser.parse_args()
surname = args.surname[0]
-#Consistency check
-#if surname[0].islower():
-# sys.stderr.write("Can't create a surname with the first letter in lower case.\n")
+# Consistency check
+# if surname[0].islower():
+# sys.stderr.write(
+# "Can't create a surname with the first letter in lower case.\n"
+# )
# sys.exit(5);
-#Creates item on Wikidata
-import pywikibot
+# Creates item on Wikidata
site = pywikibot.Site("wikidata", "wikidata")
repo = site.data_repository()
data = {}
-result = repo.editEntity({}, {}, summary = "Creating empty item for surname " + surname)
+result = repo.editEntity(
+ {}, {},
+ summary="Creating empty item for surname " + surname
+)
title = result.get('entity').get('id')
item = pywikibot.ItemPage(repo, title=title)
item.get()
@@ -35,13 +44,13 @@
'fr': surname,
'en': surname
}
-item.editLabels(labels, summary = 'Adding surname labels')
+item.editLabels(labels, summary='Adding surname labels')
description = {
'en': 'family name',
'fr': 'nom de famille'
}
-item.editDescriptions(description, summary = 'Adding surname descriptions')
+item.editDescriptions(description, summary='Adding surname descriptions')
claim = pywikibot.Claim(repo, 'P31')
target = pywikibot.ItemPage(repo, 'Q101352')

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 06:28 (22 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2264131
Default Alt Text
D465.diff (4 KB)

Event Timeline