def write_post(blog): print(f"Writing post in blog: {blog['title']}\n") title = input("Insert post title: ") contents = input("Insert contents: ") date = input("Insert date (YYYYMMDD) or leave blank: ") if date != "": date = datetime.strptime(date, "%Y%m%d") post = Post(blog, title, contents, date) else: post = Post(blog, title, contents) post.save() print(f"Post {title} has been succesfully saved")
github_token=config["github_token"], github_repo=config["github_repo"]) git_mgr.update_master() git_mgr.create_new_branch() # Retrieve data meetup_retriever = Meetup("GCPUGSG") data = meetup_retriever.get_meetup_list() changes_detected = False for item in data: created_post_time = datetime.fromtimestamp(item['created'] / 1000) event_time = datetime.fromtimestamp(item["time"] / 1000) content = meetup_to_markdown(item["description"]) new_post = Post(item["name"], event_time, item["link"], created_post_time, content) filepath = os.path.join(os.curdir, 'gcpugsg', 'content', 'post', new_post.filename) previous_file_content = '' if os.path.exists(filepath): with open(filepath, 'r') as file: previous_file_content = file.read() if previous_file_content != new_post.render(): print( "Expected output is not the same, re-create blog and save once more" ) with open(filepath, 'w+') as file: file.write(new_post.render()) changes_detected = True