[{"id":14342,"web_url":"https://patchwork.libcamera.org/comment/14342/","msgid":"<X+hjZtfSoFdf4Jjy@wyvern>","date":"2020-12-27T10:35:18","subject":"Re: [libcamera-devel] [PATCH 4/8] utils: checkstyle.py: Make title\n\tand files properties of commit class","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-12-24 14:28:51 +0200, Laurent Pinchart wrote:\n> Make the API of the Commit class more explicit by exposing the title and\n> files as properties instead of through a get_info() method.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  utils/checkstyle.py | 34 +++++++++++++++++++++-------------\n>  1 file changed, 21 insertions(+), 13 deletions(-)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 4ba65e5a4ff1..77e635dc5154 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -197,15 +197,24 @@ def parse_diff(diff):\n>  class Commit:\n>      def __init__(self, commit):\n>          self.commit = commit\n> +        self.__parse()\n>  \n> -    def get_info(self):\n> +    def __parse(self):\n>          # Get the commit title and list of files.\n>          ret = subprocess.run(['git', 'show', '--pretty=oneline', '--name-only',\n>                                self.commit],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n>          files = ret.splitlines()\n> -        # Returning title and files list as a tuple\n> -        return files[0], files[1:]\n> +        self.__files = files[1:]\n> +        self.__title = files[0]\n> +\n> +    @property\n> +    def files(self):\n> +        return self.__files\n> +\n> +    @property\n> +    def title(self):\n> +        return self.__title\n>  \n>      def get_diff(self, top_level, filename):\n>          return subprocess.run(['git', 'diff', '%s~..%s' % (self.commit, self.commit),\n> @@ -221,10 +230,11 @@ class StagedChanges(Commit):\n>      def __init__(self):\n>          Commit.__init__(self, '')\n>  \n> -    def get_info(self):\n> +    def __parse(self):\n>          ret = subprocess.run(['git', 'diff', '--staged', '--name-only'],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        return \"Staged changes\", ret.splitlines()\n> +        self.__title = \"Staged changes\"\n> +        self.__files = ret.splitlines()\n>  \n>      def get_diff(self, top_level, filename):\n>          return subprocess.run(['git', 'diff', '--staged', '--',\n> @@ -236,15 +246,15 @@ class Amendment(StagedChanges):\n>      def __init__(self):\n>          StagedChanges.__init__(self)\n>  \n> -    def get_info(self):\n> +    def __parse(self):\n>          # Create a title using HEAD commit\n>          ret = subprocess.run(['git', 'show', '--pretty=oneline', '--no-patch'],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        title = 'Amendment of ' + ret.strip()\n> +        self.__title = 'Amendment of ' + ret.strip()\n>          # Extract the list of modified files\n>          ret = subprocess.run(['git', 'diff', '--staged', '--name-only', 'HEAD~'],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        return title, ret.splitlines()\n> +        self.__files = ret.splitlines()\n>  \n>      def get_diff(self, top_level, filename):\n>          return subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--',\n> @@ -686,18 +696,16 @@ def check_file(top_level, commit, filename):\n>  \n>  \n>  def check_style(top_level, commit):\n> -    title, files = commit.get_info()\n> -\n> -    separator = '-' * len(title)\n> +    separator = '-' * len(commit.title)\n>      print(separator)\n> -    print(title)\n> +    print(commit.title)\n>      print(separator)\n>  \n>      # Filter out files we have no checker for.\n>      patterns = set()\n>      patterns.update(StyleChecker.all_patterns())\n>      patterns.update(Formatter.all_patterns())\n> -    files = [f for f in files if len([p for p in patterns if fnmatch.fnmatch(os.path.basename(f), p)])]\n> +    files = [f for f in commit.files if len([p for p in patterns if fnmatch.fnmatch(os.path.basename(f), p)])]\n>      if len(files) == 0:\n>          print(\"Commit doesn't touch source files, skipping\")\n>          return 0\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 55AF4C0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 27 Dec 2020 10:35:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B1A35615B4;\n\tSun, 27 Dec 2020 11:35:22 +0100 (CET)","from mail-lf1-x144.google.com (mail-lf1-x144.google.com\n\t[IPv6:2a00:1450:4864:20::144])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 84265615AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Dec 2020 11:35:21 +0100 (CET)","by mail-lf1-x144.google.com with SMTP id m12so17968509lfo.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Dec 2020 02:35:21 -0800 (PST)","from localhost ([185.224.57.161]) by smtp.gmail.com with ESMTPSA id\n\ti18sm5800315lja.102.2020.12.27.02.35.19\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 27 Dec 2020 02:35:20 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"sMBufK1C\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=HZbIT3yT6TwuvzMFsH2MMz8oRX/DpRjsYLEAhMeDzfY=;\n\tb=sMBufK1Cxdc3KpuMbd0PsQbRve0eSM8DqL1rmv23XHPsMcZHhZWWvVU56biden1kbX\n\tcyCjc7xRObgWYRkr2rb1SFLoge06BGoClJiHRDWUff4GkM9FWg246KFyZz3FSSlQh6qg\n\t90KZfw/ZGGUUOCbg83ddTWciT3XfA2yNZyKjt1/bmWcdVcA7UARtsu5cgwFCoMAamCs9\n\tfprEoOKw93w633Oy66pLmkmiswi0JmYL8goQN0gjGXNyvwoJjekaT4MBEcTtb5QnXs8s\n\t7AFlnCN9JIY+eMC41iV39ZKvxP/fCuw5G6tLZBBQF6OVD3+KZfSjKM/8zagvmkKh+rlQ\n\tZNYA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=HZbIT3yT6TwuvzMFsH2MMz8oRX/DpRjsYLEAhMeDzfY=;\n\tb=o/igh9zMNg/2FAOon+ghQiBK74n+ecMKTcxnhGGtlONqHr+wgktaczLKxDHFqdeGli\n\tGCkn7WLwJtjGdZyuUpFqKlkPWprDHNwbAWzSdDijnDx9SE7/4AOKfE0WDXkzZDkKuCPJ\n\teQZq46rPK7W/m2Cq0VCSxesVIZ8tPJlKnpk4hKHl6gyzaZA8ewLvvYGA6GkWSXUaXwfW\n\tBQuK77BW0wZnD2ff9eHclEGwBEeetza5fTlkx4yv2RIXsG6sgw+bXrmeEnGIyZx4/bXt\n\tYU3SX6r6swvk7dgCOJlrf1PZxwXrP9cO8AKPsEenNYH/RVBdTRgI8/eF3doNbtnaoVAY\n\tcsxg==","X-Gm-Message-State":"AOAM533vY/7q7FU8qhsi2SGeRVh56xwrY+esURZ6BlHs1bTE/7rbL5vU\n\tNha7v0pP4QghSp0bUgf8/UYW0Q==","X-Google-Smtp-Source":"ABdhPJy3sbDINMW5YJmrtJAXxvihVImyPSAnKUgfl5yknCT+nvAt6qr8XyFMD83Gbjokqm2fd3WIoQ==","X-Received":"by 2002:a19:4ad8:: with SMTP id\n\tx207mr18561742lfa.9.1609065320986; \n\tSun, 27 Dec 2020 02:35:20 -0800 (PST)","Date":"Sun, 27 Dec 2020 11:35:18 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<X+hjZtfSoFdf4Jjy@wyvern>","References":"<20201224122855.22200-1-laurent.pinchart@ideasonboard.com>\n\t<20201224122855.22200-5-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201224122855.22200-5-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 4/8] utils: checkstyle.py: Make title\n\tand files properties of commit class","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":14363,"web_url":"https://patchwork.libcamera.org/comment/14363/","msgid":"<20201228051420.GB1933@pyrite.rasen.tech>","date":"2020-12-28T05:14:20","subject":"Re: [libcamera-devel] [PATCH 4/8] utils: checkstyle.py: Make title\n\tand files properties of commit class","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nOn Thu, Dec 24, 2020 at 02:28:51PM +0200, Laurent Pinchart wrote:\n> Make the API of the Commit class more explicit by exposing the title and\n> files as properties instead of through a get_info() method.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  utils/checkstyle.py | 34 +++++++++++++++++++++-------------\n>  1 file changed, 21 insertions(+), 13 deletions(-)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 4ba65e5a4ff1..77e635dc5154 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -197,15 +197,24 @@ def parse_diff(diff):\n>  class Commit:\n>      def __init__(self, commit):\n>          self.commit = commit\n> +        self.__parse()\n>  \n> -    def get_info(self):\n> +    def __parse(self):\n>          # Get the commit title and list of files.\n>          ret = subprocess.run(['git', 'show', '--pretty=oneline', '--name-only',\n>                                self.commit],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n>          files = ret.splitlines()\n> -        # Returning title and files list as a tuple\n> -        return files[0], files[1:]\n> +        self.__files = files[1:]\n> +        self.__title = files[0]\n> +\n> +    @property\n> +    def files(self):\n> +        return self.__files\n> +\n> +    @property\n> +    def title(self):\n> +        return self.__title\n>  \n>      def get_diff(self, top_level, filename):\n>          return subprocess.run(['git', 'diff', '%s~..%s' % (self.commit, self.commit),\n> @@ -221,10 +230,11 @@ class StagedChanges(Commit):\n>      def __init__(self):\n>          Commit.__init__(self, '')\n>  \n> -    def get_info(self):\n> +    def __parse(self):\n>          ret = subprocess.run(['git', 'diff', '--staged', '--name-only'],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        return \"Staged changes\", ret.splitlines()\n> +        self.__title = \"Staged changes\"\n> +        self.__files = ret.splitlines()\n>  \n>      def get_diff(self, top_level, filename):\n>          return subprocess.run(['git', 'diff', '--staged', '--',\n> @@ -236,15 +246,15 @@ class Amendment(StagedChanges):\n>      def __init__(self):\n>          StagedChanges.__init__(self)\n>  \n> -    def get_info(self):\n> +    def __parse(self):\n>          # Create a title using HEAD commit\n>          ret = subprocess.run(['git', 'show', '--pretty=oneline', '--no-patch'],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        title = 'Amendment of ' + ret.strip()\n> +        self.__title = 'Amendment of ' + ret.strip()\n>          # Extract the list of modified files\n>          ret = subprocess.run(['git', 'diff', '--staged', '--name-only', 'HEAD~'],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        return title, ret.splitlines()\n> +        self.__files = ret.splitlines()\n>  \n>      def get_diff(self, top_level, filename):\n>          return subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--',\n> @@ -686,18 +696,16 @@ def check_file(top_level, commit, filename):\n>  \n>  \n>  def check_style(top_level, commit):\n> -    title, files = commit.get_info()\n> -\n> -    separator = '-' * len(title)\n> +    separator = '-' * len(commit.title)\n>      print(separator)\n> -    print(title)\n> +    print(commit.title)\n>      print(separator)\n>  \n>      # Filter out files we have no checker for.\n>      patterns = set()\n>      patterns.update(StyleChecker.all_patterns())\n>      patterns.update(Formatter.all_patterns())\n> -    files = [f for f in files if len([p for p in patterns if fnmatch.fnmatch(os.path.basename(f), p)])]\n> +    files = [f for f in commit.files if len([p for p in patterns if fnmatch.fnmatch(os.path.basename(f), p)])]\n>      if len(files) == 0:\n>          print(\"Commit doesn't touch source files, skipping\")\n>          return 0\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A6E03C0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Dec 2020 05:14:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2B2056159A;\n\tMon, 28 Dec 2020 06:14:29 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 65BA46031B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Dec 2020 06:14:28 +0100 (CET)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C453025C;\n\tMon, 28 Dec 2020 06:14:26 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"aGo1OhWz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1609132468;\n\tbh=+TPIUeYmofQO2r7GbInrJCub7mLAs/DaSkPXC0AdY7M=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=aGo1OhWz+gMk3A8U1y7zvtIh5sB01Vg0LIP6UWw/iAnplxc2zNxjBEo8lUfAYOyyc\n\tHKt3RiMIND4XXLC/uyvzVX7P2wm4+RZGrZ2LmiYQCFfb6Yo0krjbOQ4N96Ndzkes/M\n\tYQxG2wZkAPNbzs5ujtujQuu6E6+y9bgWBUl8Hzxw=","Date":"Mon, 28 Dec 2020 14:14:20 +0900","From":"paul.elder@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20201228051420.GB1933@pyrite.rasen.tech>","References":"<20201224122855.22200-1-laurent.pinchart@ideasonboard.com>\n\t<20201224122855.22200-5-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201224122855.22200-5-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 4/8] utils: checkstyle.py: Make title\n\tand files properties of commit class","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]