From f06516adbe05f9b67af7b28e3822b6461b441a0b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 24 Mar 2016 09:42:49 +1700 Subject: [PATCH] Re: [PATCH v2 2/4] nmbug-status: Add meta.message-url config setting --- 8d/2c2a1c138caf9515449549d1639d33b71ee63f | 188 ++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 8d/2c2a1c138caf9515449549d1639d33b71ee63f diff --git a/8d/2c2a1c138caf9515449549d1639d33b71ee63f b/8d/2c2a1c138caf9515449549d1639d33b71ee63f new file mode 100644 index 000000000..b993b7950 --- /dev/null +++ b/8d/2c2a1c138caf9515449549d1639d33b71ee63f @@ -0,0 +1,188 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 6C0E06DE02A6 + for ; Wed, 23 Mar 2016 09:51:11 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.811 +X-Spam-Level: +X-Spam-Status: No, score=0.811 tagged_above=-999 required=5 tests=[AWL=-0.704, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_BL=0.01, RCVD_IN_MSPIKE_L3=1.606, + SPF_PASS=-0.001] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id E1ydrqsWphv9 for ; + Wed, 23 Mar 2016 09:51:02 -0700 (PDT) +X-Greylist: delayed 490 seconds by postgrey-1.35 at arlo; + Wed, 23 Mar 2016 09:51:02 PDT +Received: from resqmta-po-11v.sys.comcast.net (resqmta-po-11v.sys.comcast.net + [96.114.154.170]) + by arlo.cworth.org (Postfix) with ESMTPS id 983A46DE02A5 + for ; Wed, 23 Mar 2016 09:51:02 -0700 (PDT) +Received: from resomta-po-02v.sys.comcast.net ([96.114.154.226]) + by resqmta-po-11v.sys.comcast.net with comcast + id ZUi71s0084tLnxL01UiqUg; Wed, 23 Mar 2016 16:42:50 +0000 +Received: from mail.tremily.us ([73.221.72.168]) + by resomta-po-02v.sys.comcast.net with comcast + id ZUip1s00P3dr3C901Uiqs6; Wed, 23 Mar 2016 16:42:50 +0000 +Received: by mail.tremily.us (Postfix, from userid 1000) + id 52AB11C64427; Wed, 23 Mar 2016 09:42:49 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin; + t=1458751369; bh=zHdBDBknJzNt+DttTwj1XzIRpS5Vcux0iQHEP/SkkYY=; + h=Date:From:To:Cc:Subject:References:In-Reply-To; + b=anRQRiM3n4whau53/cq/AmxaiGu2zJoIhXIkdJ/6gwBpUEbtRuYl5mjzmZO5OEA9R + L/F+kJWJrt+b28JyfXhOj3awTJ2yeQnuwLTqYHG9/P9hYjG+V9f6Z1DpBTF81ckcqd + kG56u9nMv9uhHjn6rngWchF4/Qyy7K45jBOCe5Tc= +Date: Wed, 23 Mar 2016 09:42:49 -0700 +From: "W. Trevor King" +To: David Bremner +Cc: notmuch@notmuchmail.org +Subject: Re: [PATCH v2 2/4] nmbug-status: Add meta.message-url config setting +Message-ID: <20160323164249.GX10674@odin.tremily.us> +References: + <9377a4c1265b13f9588d21ec0ea591ea9f61a05f.1451683912.git.wking@tremily.us> + <87zitpjvax.fsf@zancas.localnet> +MIME-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="9/9WPmgm2v60RN0g" +Content-Disposition: inline +In-Reply-To: <87zitpjvax.fsf@zancas.localnet> +OpenPGP: id=39A2F3FA2AB17E5D8764F388FC29BDCDF15F5BE8; + url=http://tremily.us/pubkey.txt +User-Agent: Mutt/1.5.23 (2014-03-12) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; + s=q20140121; t=1458751370; + bh=zmcCFXuSs8E8fqN/SiCc+DjWIQnZgAf0ytAfbfeiYPE=; + h=Received:Received:Received:Date:From:To:Subject:Message-ID: + MIME-Version:Content-Type; + b=OBzzC7oZelfJ7WMO1a7F/GUN/firdUYuZd6t4osyPWhrtWNPBkNmnzDMX6mzb9mX0 + vQDzVovisnLsS9JDHat6MNyOqjFq+n7Vd5pnCjy6C1a7cty0gbwf/3XMdqHYztEczd + A5Qaj70bzlddFvIaliwnaBmbd7i2xDT3osxutzvMPyb3+yPHC6cGXgx+aVA5onv3mJ + oEOZndu42XHnTUBeaxC8BC3Clav4WfHfbVpgUJ9zM9UZhNMRjGUgwJ/FofTtPFileS + 5z37FfXqrr+93vGssYCniWxPS2oWCQtZMufgFxeLnXcCtPSu8AzkBFUYFB1FQMXFRg + mUKt8I0k2VdYg== +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 23 Mar 2016 16:51:11 -0000 + + +--9/9WPmgm2v60RN0g +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Wed, Mar 23, 2016 at 08:19:34AM -0300, David Bremner wrote: +> W. Trevor King writes: +> > from __future__ import print_function +> > @@ -232,6 +232,10 @@ class Page (object): +> > class HtmlPage (Page): +> > _slug_regexp =3D re.compile('\W+') +> > +> > + def __init__(self, message_url_template, **kwargs): +> > + self.message_url_template =3D message_url_template +> > + super(HtmlPage, self).__init__(**kwargs) +> > + +> +> > @@ -395,6 +400,8 @@ _PAGES['text'] =3D Page() +> > _PAGES['html'] =3D HtmlPage( +> > header=3Dheader_template.format(**context), +> > footer=3Dfooter_template.format(**context), +> > + message_url_template=3Dconfig['meta'].get( +> > + 'message-url', 'http://mid.gmane.org/{message-id}'), +> > ) +> > +> +> Maybe I'm missing some python knowledged, but it looks the +> constructor is defined to take a regular argument for +> message_url_template, but only passed in as a keyword. Does this +> really work? + +Yup. From [1]: + + positional-only: specifies an argument that can be supplied only by + position. Python has no syntax for defining positional-only + parameters. However, some built-in functions have positional-only + parameters (e.g. abs()). + +I can't find a similar Python 3 glossary, but see [2]. Whether we use: + + def __init__(self, message_url_template, **kwargs): + =E2=80=A6 + +or: + + def __init__(self, message_url_template=3D'foobar', **kwargs): + =E2=80=A6 + +just controls whether the message_url_template has a default or not, +and not whether it can be set via positional or keyword arguments. + +There is Python syntax for keyword-only arguments, and it would look +like [2]: + + def __init__(self, *, message_url_template, **kwargs): + =E2=80=A6 + +or: + + def __init__(self, *, message_url_template=3D'foobar', **kwargs): + =E2=80=A6 + +in the former case, you'd have to call __init__ with a +message_url_template=3D=E2=80=A6 keyword argument or you'd get: + + TypeError: __init__() missing 1 required keyword-only argument: 'message_= +url_template' + +With the latter case, calling __init__ without a message_url_template +argument would just get you the default value (=E2=80=98foobar=E2=80=99 in = +these +examples). + +Cheers, +Trevor + +[1]: https://docs.python.org/2/glossary.html#term-parameter +[2]: https://docs.python.org/3/reference/compound_stmts.html#function-defin= +itions + +--=20 +This email may be signed or encrypted with GnuPG (http://www.gnupg.org). +For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy + +--9/9WPmgm2v60RN0g +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v2 + +iQIcBAEBAgAGBQJW8seHAAoJEAPqygegUbGs/eAQAJCBVzmrcY+PboKhJP5atwtT +yq3WrENws2uvXLmB9+h7B7NJBRJk6xvefbpWWIsY003lqv0IVDt6c7a8L2JPPfgL +VGr94elPkVCWNu74zYuRVxvHWURqo8167szslI40Fm7fB0d7V7lOFk8soaBEa4lV +jOS6y2zkTubk7o0u92DdmtyiBnOTylbCym8ZhZ7S8sBysoWqr5I7Rh1YXRh7jvfP +/GUIE6ZgbLNCWKA99Z4YMCX1glMLrLedU2SLQM+X2x6IsuIHVMVD8oj6FCj5A2VH +CSjeWNMsMqIaEUinuM5BxKL7Z+N6+W8AuGpd2AQbhEpxGnXUb40JuwRc+F/tDn09 +T+oMdSj7x66Ik2bl3Ns0U/YMTOqSl7wL7kzufsm6X7sR6sA75fehSIkFo39hXziQ +rp6lSjZLSgX/seiUs5icXy0G6acKaIT3DEalouA+HdNbc2Tyolp6U+wGX2JJO2/O +WGudLN2bFtUc26VivkKf7FV/QS9XWP6X+VSZ2flWZSpeZQkVIGIca4QSsEcqS3dm +p3eDHi9vdRYGWvsP3HA7YryI+NiIU0FHEIz329M8L9oqpEjB7TzPJsb+iUHcK1q0 +Vez4CVXLUEEbumgy4IhPOo7e1cUQh/OEDImr7PrP4naMAreRoFtvVWHywFWziQu3 +YDJ/hV9Y1qlxhKb2JIFW +=o4kq +-----END PGP SIGNATURE----- + +--9/9WPmgm2v60RN0g-- -- 2.26.2