importargparsefromoffice365.sharepoint.client_contextimportClientContextfromtests.settingsimportcert_path,cert_thumbprint,client_id,site_url,tenantdefmain():parser=argparse.ArgumentParser(description="Promote or demote a site page as news")parser.add_argument("--file-name",required=True,help="page file name, e.g. Home.aspx")parser.add_argument("--demote",action="store_true",help="demote from news instead of promoting")args=parser.parse_args()ctx=ClientContext(site_url).with_client_certificate(tenant,client_id=client_id,thumbprint=cert_thumbprint,cert_path=cert_path)page=ctx.site_pages.pages.get_by_name(args.file_name).get().execute_query()ifargs.demote:page.demote_from_news().execute_query()print(f"Page demoted from news: {args.file_name}")else:page.promote_to_news().execute_query()print(f"Page promoted to news: {args.file_name}")if__name__=="__main__":main()