Skip to content

Utilities and Convenience Functions

make_reader(args)

  1. Receives an argparse argument containing command-line arguments
  2. Identifies the subtype required using the attr which must match an entry in the reader_type_map
  3. Translates the argparse arguments into the specific form required by the constructor for the type identified in (2) above
  4. Returns an instance of that type constructed using these arguments
Source code in dsprofile/lib/reader.py
def make_reader(args):
    """
      1. Receives an argparse <args> argument containing command-line
         arguments
      2. Identifies the subtype required using the <command> attr which
         must match an entry in the reader_type_map
      3. Translates the argparse arguments into the specific form required
         by the constructor for the type identified in (2) above
      4. Returns an instance of that type constructed using these
         arguments
    """
    cls = reader_type_map[args.command]
    ctor_args, ctor_kwargs = cls.handle_args(args)
    return cls(*ctor_args, **ctor_kwargs)