|
|
|
@ -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)
|
|
|
|
|
|
|
|
|
|