def _construct_argparser(<EOL>self, meths_to_inspect, locscale_in, locscale_out):
if self.shapes:<EOL><INDENT>if not isinstance(self.shapes, string_types):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>shapes = self.shapes.replace('<STR_LIT:U+002C>', '<STR_LIT:U+0020>').split()<EOL>for field in shapes:<EOL><INDENT>if keyword.iskeyword(field):<EOL><INDENT>raise SyntaxError('<STR_LIT>')<EOL><DEDENT>if not re.match('<STR_LIT>', field):<EOL><INDENT>raise SyntaxError(<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>shapes_list = []<EOL>for meth in meths_to_inspect:<EOL><INDENT>shapes_args = inspect.getargspec(meth)<EOL>shapes_list.append(shapes_args.args)<EOL>if len(shapes_args.args) > <NUM_LIT:2>:<EOL><INDENT>if shapes_args.varargs is not None:<EOL><INDENT>raise TypeError(<EOL>'<STR_LIT>')<EOL><DEDENT>if shapes_args.keywords is not None:<EOL><INDENT>raise TypeError(<EOL>'<STR_LIT>')<EOL><DEDENT>if shapes_args.defaults is not None:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>shapes = max(shapes_list, key=lambda x: len(x))<EOL>shapes = shapes[<NUM_LIT:2>:]  <EOL>for item in shapes_list:<EOL><INDENT>if len(item) > <NUM_LIT:2> and item[<NUM_LIT:2>:] != shapes:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>shapes_str = '<STR_LIT:U+002CU+0020>'.join(shapes) + '<STR_LIT:U+002CU+0020>' if shapes else '<STR_LIT>'  <EOL>dct = dict(shape_arg_str=shapes_str,<EOL>locscale_in=locscale_in,<EOL>locscale_out=locscale_out,<EOL>)<EOL>ns = {}<EOL>exec_(parse_arg_template % dct, ns)<EOL>for name in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>setattr(self, name,<EOL>instancemethod(ns[name], self, self.__class__)<EOL>)<EOL><DEDENT>self.shapes = '<STR_LIT:U+002CU+0020>'.join(shapes) if shapes else None<EOL>if not hasattr(self, '<STR_LIT>'):<EOL><INDENT>self.numargs = len(shapes)<EOL><DEDENT>
Construct the parser for the shape arguments.

        Generates the argument-parsing functions dynamically and attaches
        them to the instance.
        Is supposed to be called in __init__ of a class for each distribution.

        If self.shapes is a non-empty string, interprets it as a
        comma-separated list of shape parameters.

        Otherwise inspects the call signatures of `meths_to_inspect`
        and constructs the argument-parsing functions from these.
        In this case also sets `shapes` and `numargs`.