def update_config(self, incremental=False): if not self.account: return domain = self._get_domain() organization = BLOG_ORGANIZATION logo = BLOG_AVATAR favicon = BLOG_FAVICON language = settings.get_env_var("LANGUAGE") or "en" a = SteemAccount(self.account) author = self.account name = self._yaml_compatible(a.get_profile("name"), "") avatar = self._yaml_compatible(a.avatar(), "") # about = a.get_profile("about") or "" location = self._yaml_compatible(a.get_profile("location"), "") website = self._yaml_compatible(a.get_profile("website"), "''") incremental = "true" if incremental else "false" # build config file with template template = get_message("config") config = template.format(organization=organization, domain=domain, language=language, name=name, author=author, incremental=incremental) filename = CONFIG_FILE with open(filename, "w", encoding="utf-8") as f: f.write(config) logger.info("{} file has been updated for the account @{}".format( filename, author)) # build config theme file with template template = get_message("config.theme") config = template.format(organization=organization, favicon=favicon, logo=logo, author=author, name=name, location=location, avatar=avatar, website=website) filename = CONFIG_THEME_FILE with open(filename, "w", encoding="utf-8") as f: f.write(config) logger.info("{} file has been updated for the account @{}".format( filename, author))
def _write_content(self, post): folder = self._get_content_folder() c = SteemComment(comment=post) # retrieve necessary data from steem title = self._yaml_compatible(post.title, "''") # permlink = post["permlink"] permlink = self.permalink_filtering(post.title) body = c.get_compatible_markdown() position = self._get_position(body) date_str = post.json()["created"] date = date_str.replace('T', ' ') tags = "\n".join(["- {}".format(tag) for tag in c.get_tags()]) category = "\n".join(["- {}".format(c) for c in c.get_category()]) thumbnail = self._yaml_compatible(c.get_pic_url(), "") url = c.get_url() # build content with template template = get_message("blog", footer=True) content = template.format(title=title, permlink=permlink, position=position, date=date, tags=tags, category=category, thumbnail=thumbnail, body=body, url=url) # write into MD files filename = os.path.join(folder, "{}_{}.md".format(date_str.split('T')[0], permlink)) with open(filename, "w", encoding="utf-8") as f: f.write(content) logger.info("Download post [{}] into file {}".format(title, filename))