add serial for url

This commit is contained in:
Valentin CZERYBA 2023-04-10 16:36:49 +02:00
parent 7c75116c5b
commit 05a3a28c6f

View File

@ -21,6 +21,8 @@ if __name__ == '__main__':
import_parser.add_argument("--directory", help="HTML directory", default="") import_parser.add_argument("--directory", help="HTML directory", default="")
import_parser.add_argument("--canalblog", help="URL Canalblog", default="") import_parser.add_argument("--canalblog", help="URL Canalblog", default="")
import_parser.add_argument("--wordpress", help="URL Wordpress", required=True) import_parser.add_argument("--wordpress", help="URL Wordpress", required=True)
import_parser.add_argument("--serial", help="Serial execution", action="store_true")
export_parser = subparsers.add_parser("export") export_parser = subparsers.add_parser("export")
@ -76,24 +78,56 @@ if __name__ == '__main__':
importWp.fromFile(args.file.split(",")) importWp.fromFile(args.file.split(","))
exit(0) exit(0)
if len(args.directory) > 0: if len(args.directory) > 0:
for i in wordpress: directory = args.directory.split(",")
importWp.setUrl(i) if args.serial is False:
importWp.fromDirectory(args.directory) for i in wordpress:
importWp.setUrl(i)
for j in directory:
importWp.fromDirectory(j)
else:
if len(directory) != len(wordpress):
logger.error("ERREUR : Le nombre de dossier n'est pas equivalent au nombre d'URL wordpress")
exit(1)
for i in range(0, len(wordpress)-1):
importWp.setUrl(wordpress[i])
importWp.fromDirectory(directory[i])
exit(0) exit(0)
if len(args.canalblog) > 0: if len(args.canalblog) > 0:
exportWp = WPExport.WPExport("", logger, args.parser, args.directory) exportWp = WPExport.WPExport("", logger, args.parser, args.directory)
canalblog = args.canalblog.split(",") canalblog = args.canalblog.split(",")
for canal in canalblog: wordpress = args.wordpress.split(",")
try:
o = urlparse(canal) if serial is False:
o = o._replace(scheme="https") for canal in canalblog:
url = o.geturl().replace(":///", "://") try:
except Exception as err: o = urlparse(canal)
logger.error("parsing error : {0}".format(err)) o = o._replace(scheme="https")
url = o.geturl().replace(":///", "://")
except Exception as err:
logger.error("parsing error : {0}".format(err))
exit(1)
exportWp.setUrl(url)
webpage = exportWp.getUrlPage()
for j in wordpress:
importWp.setUrl(j)
importWp.fromUrl(webpage)
else:
if len(canalblog) != len(wordpress):
logger.error("ERREUR : Le nombre de dossier n'est pas equivalent au nombre d'URL wordpress")
exit(1) exit(1)
exportWp.setUrl(url) for i in range(0, len(canalblog)-1):
webpage = exportWp.getUrlPage() try:
importWp.fromUrl(webpage) o = urlparse(canalblog[i])
o = o._replace(scheme="https")
url = o.geturl().replace(":///", "://")
except Exception as err:
logger.error("parsing error : {0}".format(err))
exit(1)
exportWp.setUrl(url)
webpage = exportWp.getUrlPage()
importWp.setUrl(wordpress[i])
importWp.fromUrl(webpage)
if args.command == "export": if args.command == "export":