コード例 #1
0
ファイル: wordpress.py プロジェクト: jgrynczewski/pisak
    def attach_text(self, post, text):
        """
        Attach plain text to the given post.
        Keep all the previously embedded images intact.

        :param post: post instance.
        :param text: new post text.
        """
        post.content = html_parsers.embed_images(
            text, html_parsers.list_images(post.content))
コード例 #2
0
ファイル: wordpress.py プロジェクト: BrainTech/pisak
    def attach_text(self, post, text):
        """
        Attach plain text to the given post.
        Keep all the previously embedded images intact.

        :param post: post instance.
        :param text: new post text.
        """
        post.content = html_parsers.embed_images(
            text, html_parsers.list_images(post.content))
コード例 #3
0
ファイル: wordpress.py プロジェクト: jgrynczewski/pisak
    def update_about_me_bio(self, text):
        """
        Update about me page with informations about the author.

        :param text: content of the page, eg. the author bio.
        """
        page = self.get_about_me_page()
        images = html_parsers.list_images(page.content)
        if len(images) > 0:
            text = html_parsers.embed_images(text, images[0])
        page.content = text
        self.publish_post(page)
コード例 #4
0
ファイル: wordpress.py プロジェクト: BrainTech/pisak
    def update_about_me_bio(self, text):
        """
        Update about me page with informations about the author.

        :param text: content of the page, eg. the author bio.
        """
        page = self.get_about_me_page()
        images = html_parsers.list_images(page.content)
        if len(images) > 0:
            text = html_parsers.embed_images(text, images[0])
        page.content = text
        self.publish_post(page)
コード例 #5
0
ファイル: wordpress.py プロジェクト: jgrynczewski/pisak
 def _cache_user_photo(self):
     images = html_parsers.list_images(self.get_about_me_page().content)
     if len(images) > 0:
         photo_url = images[0]
         try:
             photo_bytes = requests.get(photo_url).content
         except requests.exceptions.ConnectionError as e:
             _LOG.warning(e)
         else:
             if isinstance(photo_bytes, bytes):
                 photo_buffer = BytesIO(photo_bytes)
                 try:
                     image = Image.open(photo_buffer)
                     image.save(self.USER_PHOTO_PATH)
                 except OSError as e:
                     _LOG.error(e)
             else:
                 msg = "URL res with blog user photo does not contain" \
                       "proper bytes content."
                 _LOG.warning(msg)
コード例 #6
0
ファイル: wordpress.py プロジェクト: BrainTech/pisak
 def _cache_user_photo(self):
     images = html_parsers.list_images(self.get_about_me_page().content)
     if len(images) > 0:
         photo_url = images[0]
         try:
             photo_bytes = requests.get(photo_url).content
         except requests.exceptions.ConnectionError as e:
             _LOG.warning(e)
         else:
             if isinstance(photo_bytes, bytes):
                 photo_buffer = BytesIO(photo_bytes)
                 try:
                     image = Image.open(photo_buffer)
                     image.save(self.USER_PHOTO_PATH)
                 except OSError as e:
                     _LOG.error(e)
             else:
                 msg = "URL res with blog user photo does not contain" \
                       "proper bytes content."
                 _LOG.warning(msg)