From d18f4e1579f725f607c5c81ba536522a7ae2c283 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Mon, 15 May 2023 23:51:45 +0200 Subject: [PATCH] Add clean --- import_export_canalblog.py | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/import_export_canalblog.py b/import_export_canalblog.py index 97a5bf3..6a2a3e3 100644 --- a/import_export_canalblog.py +++ b/import_export_canalblog.py @@ -12,7 +12,7 @@ from lib.WPRemove import WPRemove def remove(args, basic, logger): removeWp = WPRemove(basic=basic, wordpress="", logger=logger) - if args.remove: + if args.remove == True: for i in args.wordpress.split(","): removeWp.setUrl(i) removeWp.cleanPosts() @@ -22,13 +22,13 @@ def remove(args, basic, logger): else: for i in args.wordpress.split(","): removeWp.setUrl(i) - if args.posts: + if args.posts == True: removeWp.cleanPosts() - if args.categories: + if args.categories == True: removeWp.cleanCategories() - if args.tags: + if args.tags == True: removeWp.cleanTags() - if args.media: + if args.media == True: removeWp.cleanMedia() del removeWp @@ -136,10 +136,10 @@ if __name__ == '__main__': import_parser.add_argument("--wordpress", help="URL Wordpress", required=True) import_parser.add_argument("--serial", help="Serial execution", action="store_true") import_parser.add_argument("--remove-all", dest="remove", help="Remove all", action="store_true") - remove_parser.add_argument("--remove-posts", help="Remove all posts", dest="posts", action="store_true") - remove_parser.add_argument("--remove-categories", help="Remove all categories", dest="categories", action="store_true") - remove_parser.add_argument("--remove-tags", help="Remove all tags", dest="tags", action="store_true") - remove_parser.add_argument("--remove-media", help="Remove all media", dest="media", action="store_true") + import_parser.add_argument("--remove-posts", help="Remove all posts", dest="posts", action="store_true") + import_parser.add_argument("--remove-categories", help="Remove all categories", dest="categories", action="store_true") + import_parser.add_argument("--remove-tags", help="Remove all tags", dest="tags", action="store_true") + import_parser.add_argument("--remove-media", help="Remove all media", dest="media", action="store_true") remove_parser = subparsers.add_parser("remove") @@ -193,7 +193,7 @@ if __name__ == '__main__': fileHandler.setFormatter(formatter) logger.addHandler(fileHandler) - if args.command == "import": + if args.command == "import" or args.command == "remove": password = args.password if len(args.password) == 0: password = getpass() @@ -202,6 +202,7 @@ if __name__ == '__main__': exit(1) basic = HTTPBasicAuth(args.user, password) + if args.command == "import": wordpress = args.wordpress.split(",") importWp = WPimport(basic=basic, wordpress="", logger=logger, parser=args.parser) if len(args.file) > 0: @@ -261,16 +262,9 @@ if __name__ == '__main__': ] except Exception as err: logger.error("Threading error : {0}".format(err)) + exit(0) - if args.command == "remove": - password = args.password - if len(args.password) == 0: - password = getpass() - if len(password) == 0: - logger.error("No password error !!! ") - exit(1) - - basic = HTTPBasicAuth(args.user, password) - remove(args, basic, logger) + if args.command == "remove": + remove(args, basic, logger) exit(0) \ No newline at end of file