def _get_and_update_article_content(self, afile, istxt=False):
        html, meta, txt, medias = self._get_article_content(afile)
        if not html:
            return  None, None, None, None
        # Update ATTACHMENTS in metadata.
        attach = 0
        if not meta.attachments:
            attach = 1
        elif meta.attachments[0] == '$ATTACHMENTS':
            attach = 2
        elif len(meta.attachments)>0:
            attach = 3

        if medias and attach>0:
            try:
                urls,attachids = self._update_medias(medias)
            except OSError as e:
                slog.error(e)
                return None, None, None, None
            idstxt = ','.join(attachids)
            if attach == 1:
                # Add attachments to the TOF.
                txt = 'Attachments: %s\n%s'%(idstxt, txt)
                slog.info(idstxt%'Fill attachments: %s.')
            elif attach == 2:
                txt = Template(txt).safe_substitute(ATTACHMENTS=idstxt)
                slog.info('Fill attachments: %s.'%idstxt)
            elif attach == 3:
                slog.info('Add new attachments: %s.'%idstxt)
                meta.attachments += attachids
                txt = re.sub(r'^Attachments: .*$', 
                        'Attachments: '+ ','.join(meta.attachments),
                        txt, 0, re.M)

            # Replace draft url to true url.
            i = 0
            for path, name in medias:
                txt = txt.replace(path, urls[i])
                i = i+1

            # Rewrite the text with modified metadata.
            write_file(afile, txt, newline='\n')
            medias = self._get_medias(txt)
            if medias:
                slog.error('Medias in the article are maybe wrong!')
                return None, None, None, None
            outputdir, baseurl, namepre = self._get_output_arg(afile)
            html, md, txt = wpcmd.md.convert(txt, outputdir, baseurl, namepre)
            meta = self._get_article_metadata(md.metadata)
        # medias is must be None
        return html, meta, txt, None
dataset/ETHPy150Open zrong/wpcmd/wpcmd/update.py/UpdateAction._get_and_update_article_content/swapped operands of `%`