From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,NO_DNS_FOR_FROM, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from [10.7.7.5] (unknown [182.253.183.247]) by gnuweeb.org (Postfix) with ESMTPSA id 24ED480908; Fri, 21 Oct 2022 14:06:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666361212; bh=GCYpqTx+jivaYKvuXSZj4ysZ7VvFPNfo4LIGg2K5kPk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=QqxIzXvn3BKzkKY5jLWWelfhuoP8wz1WbBQQOu7li8gTU2e6GPtEaq+7WrWtxcDM7 t6/ch2EqPpUmpU4OBz2BdlZIfSsVNFRr199gxsS4b7fvYD0f42O9Gx1zUcZ0YYT6Fy iET6ZHyHML3rprcL3oUyk6/1uznFwLouGhKK8INXnqOuUaFN0vWlRfZebmOHlHA9iD mEkrunL0b+tmyF/cBIpRoG3qv8HW4+Mov9N6MSSANSpzl7u7FKiKWh0TGNFnf+Wg/B vdsguZ3GnNmurBoKqXxR9GZIGIA20eUjUNLeZX2/dbbQY7n0OVoVO3BBzvKzjLrGij YxT+kEWBdKkSA== Message-ID: <473f96db-cc7a-f867-bb6f-aa2acbea3677@gnuweeb.org> Date: Fri, 21 Oct 2022 21:06:48 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v3 5/9] atom: add manage_payload() Content-Language: en-US To: Muhammad Rizki Cc: Alviro Iskandar Setiawan , GNU/Weeb Mailing List References: <20221021134520.701-1-kiizuha@gnuweeb.org> <20221021134520.701-6-kiizuha@gnuweeb.org> <6a9ebeeb-9227-96bb-a8d5-caceb54e54ca@gnuweeb.org> From: Ammar Faizi In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: On 10/21/22 9:02 PM, Muhammad Rizki wrote: > On 21/10/2022 21.01, Ammar Faizi wrote: >> On 10/21/22 8:45 PM, Muhammad Rizki wrote: >>> +def manage_payload(payload: Message): >>> +    p = str(payload.get_payload()) >>> +    tf_encode = payload.get("Content-Transfer-Encoding") >>> + >>> +    if tf_encode == "base64": >>> +        return b64decode(p).decode("utf-8") >>> +    if tf_encode == "quoted-printable": >>> +        return quopri.decodestring(p.encode()).decode() >>> + >>> +    return p.encode().decode("utf-8", errors="replace") >> >> I don't feel strongly about this helper name. What about name it >> with get_decoded_paylaod()? >> > > Sure, or just decode_payload()? Since you pass a Message object and it contains headers and body, I prefer to emphasize the "get". So I still prefer the name get_decoded_paylaod() for this function. What we call payload is the body anyway. -- Ammar Faizi