upload working. But template formating nees % notation

docker
Castro0o 5 years ago
parent c996cb98b6
commit 29f569346e

@ -155,7 +155,7 @@ def reorder_imgs(dir, dry):
return listimgs(dir) # update list w/ renamed imgs
smw_propval_template = '''
{{ImageMetadata
\{\{ImageMetadata
|Title={title}
|Date={date}
|Part={part}
@ -165,6 +165,6 @@ smw_propval_template = '''
|Format={format}
|Event={event}
|Topic={topic}
}}
\}\}
[[Template:ImageMetadata]]
'''

@ -64,8 +64,6 @@ elif len(list(site.ask(f'[[Title::{args.title}]]'))) > 0:
print_colormsg(f'Error: --title "{args.title}" already exists in wiki. Provide a different one', level='fail')
sys.exit()
lsimgs = reorder_imgs(dir=args.dir, dry=args.dry)
dirname = os.path.split(args.dir)[-1].replace(' ', '_')
dirname = re.sub(r'[\W]', '', dirname) #remove non letters or digits
@ -94,24 +92,16 @@ for n, _file in enumerate(lsimgs):
topic=(', ').join(args.topic[1:])
)
print(img_smw_prop_val)
if args.dry == True:
print(args)
sys.exit()
_file_path = os.path.join(args.dir, _file)
print(_file_path)
if not args.dry:
with open(_file_path, 'rb') as _f:
site.upload(file=_file_path,
filename=pagename,
description=img_smw_prop_val,
ignore=True)
print(img_smw_prop_val)
print(f'https://{args.host}{args.path}index.php/File:{pagename}')
filename = 'cat2.jpg'
page = site.images[filename]
img_url = f'https://{args.host}{args.path}/index.php/File:{filename}'
if page.exists is True:
print(f'{filename} is already upload it, you can see it at {img_url}' )
print('The upload process wont proceed. Please upload all images in folder by hand')
else:
with open(filename, 'rb') as _file:
dirname = (os.path.split(dir)[-1])
site.upload(file=_file, filename=f'{dirname}_{filename}',
description='img_smw_prop_val', ignore=True)

Loading…
Cancel
Save