[Mesa-dev] [PATCH 01/14] util/gen_xmlpool: use argparse for argument handling

Dylan Baker dylan at pnwbakers.com
Fri Oct 26 15:33:04 UTC 2018


I don't really understand what happened, but the rest of the series sent as
blank emails, mailman got very grumpy with me and gave me a temp ban for it :/

I'll resend the whole series with your rb on this patch.

Dylan

Quoting Eric Engestrom (2018-10-26 04:30:01)
> On Thursday, 2018-10-25 13:12:04 -0700, Dylan Baker wrote:
> > This is a little cleaner than just looking at sys.argv, but it's also
> > going to allow us to handle the differences in the way meson and
> > autotools handle translations more cleanly.
> 
> Can't see the rest of this series (it's not in the mailman archive
> either), but this patch is:
> Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>
> 
> > ---
> >  src/util/xmlpool/gen_xmlpool.py | 20 +++++++++-----------
> >  1 file changed, 9 insertions(+), 11 deletions(-)
> > 
> > diff --git a/src/util/xmlpool/gen_xmlpool.py b/src/util/xmlpool/gen_xmlpool.py
> > index 56a67bcab55..b40f295738e 100644
> > --- a/src/util/xmlpool/gen_xmlpool.py
> > +++ b/src/util/xmlpool/gen_xmlpool.py
> > @@ -9,25 +9,23 @@
> >  
> >  from __future__ import print_function
> >  
> > +import argparse
> >  import io
> >  import sys
> >  import gettext
> >  import re
> >  
> > +parser = argparse.ArgumentParser()
> > +parser.add_argument('template')
> > +parser.add_argument('localedir')
> > +parser.add_argument('languages', nargs='*')
> > +args = parser.parse_args()
> >  
> >  if sys.version_info < (3, 0):
> >      gettext_method = 'ugettext'
> >  else:
> >      gettext_method = 'gettext'
> >  
> > -# Path to t_options.h
> > -template_header_path = sys.argv[1]
> > -
> > -localedir = sys.argv[2]
> > -
> > -# List of supported languages
> > -languages = sys.argv[3:]
> > -
> >  # Escape special characters in C strings
> >  def escapeCString (s):
> >      escapeSeqs = {'\a' : '\\a', '\b' : '\\b', '\f' : '\\f', '\n' : '\\n',
> > @@ -166,9 +164,9 @@ def expandMatches (matches, translations, end=None):
> >  # Compile a list of translation classes to all supported languages.
> >  # The first translation is always a NullTranslations.
> >  translations = [("en", gettext.NullTranslations())]
> > -for lang in languages:
> > +for lang in args.languages:
> >      try:
> > -        trans = gettext.translation ("options", localedir, [lang])
> > +        trans = gettext.translation ("options", args.localedir, [lang])
> >      except IOError:
> >          sys.stderr.write ("Warning: language '%s' not found.\n" % lang)
> >          continue
> > @@ -188,7 +186,7 @@ print("/***********************************************************************\
> >  
> >  # Process the options template and generate options.h with all
> >  # translations.
> > -template = io.open (template_header_path, mode="rt", encoding='utf-8')
> > +template = io.open (args.template, mode="rt", encoding='utf-8')
> >  descMatches = []
> >  for line in template:
> >      if len(descMatches) > 0:
> > -- 
> > 2.19.1
> > 
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181026/197d0067/attachment.sig>


More information about the mesa-dev mailing list