get_flagged_args

Collects from the execution statement the arguments provided to this script.
The items are then interpretted and returned.  The object expected are the
KvP's:
    --os_type - the operating system type to be built
    --os_version - the operating system version to be built
NOTE: by not using these options, both Debian .deb and Redhat .rpm files are
generated for the operating systems and versions natively as set by a global
variable at the top of this script.
FURTHER NOTE: there should be a
    dist_dir/Docker/<os_type>/<os_version>/DockerFile*
Present for this script to work.
CONFIGURATION:  It is part of the standard for this script to run its own
configuration parameters to generate a:
    dist_dir/scripts/config.JSON
This is a part of a separate script and is executed by this one in an effort
to make this code as translatable from project segment to segment.

def get_flagged_args():
    """get_flagged_args

Collects from the execution statement the arguments provided to this script.
The items are then interpretted and returned.  The object expected are the
KvP's:
    --os_type - the operating system type to be built
    --os_version - the operating system version to be built
NOTE: by not using these options, both Debian .deb and Redhat .rpm files are
generated for the operating systems and versions natively as set by a global
variable at the top of this script.
FURTHER NOTE: there should be a
    dist_dir/Docker/<os_type>/<os_version>/DockerFile*
Present for this script to work.
CONFIGURATION:  It is part of the standard for this script to run its own
configuration parameters to generate a:
    dist_dir/scripts/config.JSON
This is a part of a separate script and is executed by this one in an effort
to make this code as translatable from project segment to segment.
    """
    expected = ['os_type', 'os_version']
    arguments = {}
    try:
        opts, adds = \
            getopt.getopt(sys.argv, '', map(lambda x: x + "=", expected))
    except getopt.GetoptError as Error:
        print(str(Error))
        print("Defaulting to standard run...")
        return arguments
    for o, a in opts:
        opt = re.sub('^-+', '', o)
        if opt in expected:
            arguments[opt] = a
    if arguments:
        if 'os_type' not in arguments:
            print("Unsupported means of operation!")
            print("You can either specify both os_type and os_version " +
                  "or just os_type")
            arguments = {}
    return arguments