-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.py
49 lines (42 loc) · 1.88 KB
/
upload.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import subprocess
import logging
import argparse
import sys
import shutil
from fileprocessor import Fileprocessor
from model_wiki import Model_wiki
fileprocessor = Fileprocessor()
modelwiki = Model_wiki()
parser = argparse.ArgumentParser(
description="upload photos of object to Wikimedia Commons "
)
parser.add_argument("wikidata", type=str)
parser.add_argument("filepath")
parser.add_argument("-dry", "--dry-run", action="store_const",
required=False, default=False, const=True)
parser.add_argument("-l", "--later", action="store_const", required=False,
default=False, help='add to job list for upload later', const=True)
parser.add_argument("--verify", action="store_const",
required=False, default=False, const=True)
parser.add_argument("--country", type=str, required=False,
default='Russia', help='Country for {{Taken on}} template')
parser.add_argument('-s', "--secondary-objects", type=str, nargs='+', required=False,
help='secondary wikidata objects, used in category calc with country')
parser.add_argument("--rail", action="store_const", required=False, default=False, const=True,
help='add to https://commons.wikimedia.org/wiki/Category:Railway_photographs_by_date')
parser.add_argument("--progress", action="store_const", required=False, default=False, const=True,
help='display progressbar')
args = parser.parse_args()
desc_dict = dict()
desc_dict['mode'] = 'object'
desc_dict['wikidata'] = args.wikidata
desc_dict['country'] = args.country
desc_dict['secondary_objects'] = args.secondary_objects
desc_dict['rail'] = args.rail
desc_dict['later'] = args.later
desc_dict['dry_run'] = args.dry_run
desc_dict['progress'] = args.progress
fileprocessor.process_and_upload_files(args.filepath, desc_dict)