"""

Objects
-------
    Settings :


Methods
-------
    getSettings :
    getParser : Get a standard argument parser for the settings.
    getArgs : Modify the ``Settings`` object to the command line arguments, return arguments.


"""

import argparse

__version__ = 0.1


class Settings(object):

    def __init__(self):

        ## Basic Parameters
        #  ----------------
        self.verbose = True
        self.debug = False

        ## Files and Directories
        #  ---------------------
        self.dir_log = "./log/"
        self.dir_data = "./data/"
        
        self.file_src = self.dir_data + "sources.json"
        

        ## Internal Parameters
        #  -------------------
        self.version = __version__
        


# } class Settings


def getSettings(sets=None):
    """
    Get a Settings object.
    """
    if( isinstance(sets, Settings) ): return sets
    else: sets = Settings()
    return sets
# } getSettings()



def getParser(sets):
    """
    Get a standard argument parser for the Settings associated with the ``Settings`` class.
    """

    parser = argparse.ArgumentParser()

    ## Create Arguments
    #  ----------------
    parser.add_argument("-v", "--verbose", 
                        action="store_true", dest="verbose", default=sets.verbose,
                        help="print verbose output to log")

    parser.add_argument("-d", "--debug", 
                        action="store_true", dest="debug", default=sets.debug,
                        help="print highly verbose output to log")

    parser.add_argument("-s", "--sources", 
                        dest="SRC_FILE", default=sets.file_src,
                        help="source file (json).")

    return parser

# } getParser()


def getArgs(parser, sets):
    """
    Modify the ``Settings`` object to the command line arguments, return arguments.
    """

    ## Parse and Store Arguments
    #  -------------------------
    args = parser.parse_args()

    sets.verbose = args.verbose
    sets.debug = args.debug
    sets.file_src = args.SRC_FILE

    return args, sets

# } getArgs()


@@ -268,16 +268,17 @@
 = 0.1%0A%0A%0A
+%0A
 class Se
@@ -297,33 +297,302 @@
 t):%0A
-%0A    def __init__(self):%0A
+    %22%22%22%0A%0A    %22%22%22%0A%0A    ## Implement as Singleton%0A    #  ----------------------%0A    __instance = None%0A    def __new__(cls):%0A        if cls.__instance == None:%0A            cls.__instance = object.__new__(cls)%0A        return cls.__instance%0A%0A%0A    def __init__(self):%0A        %22%22%22%0A        %22%22%22%0A        
 %0A   
@@ -844,24 +844,26 @@
     %0A       
+ #
  self.file_s
@@ -898,16 +898,75 @@
 s.json%22%0A
+        self.file_sources = self.dir_data + %22sources.conf%22%0A
         
@@ -1064,25 +1064,16 @@
 rsion__%0A
-        %0A
 %0A%0A# %7D cl
@@ -1091,193 +1091,8 @@
 s%0A%0A%0A
-def getSettings(sets=None):%0A    %22%22%22%0A    Get a Settings object.%0A    %22%22%22%0A    if( isinstance(sets, Settings) ): return sets%0A    else: sets = Settings()%0A    return sets%0A# %7D getSettings()%0A%0A%0A
 %0Adef

Implement 'Settings' class as a singleton