U afm@sJddlmZddlmZmZmZmZmZGdddZGdddeZ dS)) ConfigParser)AnyCallableDictListOptionalc@sleZdZdZd eeedddZd eeeedddZ deee e ddd Z deee e dd d Z dS)ConfigzBase configuration object.NkeydefaultreturncCsttddS)z Get the config option as a string :param key: config option name :param default: default value if no value exists in the config :return: option value z.get()N)NotImplementedError__name__selfr r rB/opt/nydus/tmp/pip-target-53d1vnqk/lib/python/primordial/config.pyget sz Config.getcCst|||S)z Get the config option as a boolean :param key: config option name :param default: default value if no value exists in the config :return: option value )boolrrrrrget_boolszConfig.get_boolcCst|||S)z Get the config option as an integer :param key: config option name :param default: default value if no value exists in the config :return: option value )intrrrrrget_intszConfig.get_intcCst|||S)z Get the config option as a float :param key: config option name :param default: default value if no value exists in the config :return: option value )floatrrrrr get_float(szConfig.get_float)N)N)N)N)r __module__ __qualname____doc__strrrrrrrrrrrrrrrs    rc@seZdZdZdZdZgZdeeeeee ee fddddZ ee dd d Z de ee e d d d Zdee e dddZdeeeedddZdeeeedddZdeeeedddZdS) FileConfigzVConfig class that loads configuration options from the locally-cached ZooKeeper configz/var/cache/hfs/config.inizconfig-defaultN)service_prefixfilenamedefaultsr cCsx|dkr|j}t|jdd|_|j|g|_|rb|d}|rb|jd|d| q>|jd||_ dS)N)default_section interpolation.) DEFAULT_FILENAMErr"configreadprefixessplitappendjoinpopr!)rrr r!Z prefix_partsrrr__init__9s    zFileConfig.__init__)r r cCs ||S)z Get a config key value as a direct attribute of this class. :param key: The config key name :return: The config key value, if it exists, or None )r)rr rrr __getattr__KszFileConfig.__getattr__)getfuncr r r cCsN|dkr|jr|j|}|jD]$}||}||j|dd}|r qJq |}|S)N)fallback)r!rr)r")rr0r r prefixZ prefixed_keyvalrrr_getTs  zFileConfig._getr cCs||jj||SN)r4r'rrrrrraszFileConfig.getcCs||jj||Sr5)r4r' getbooleanrrrrrdszFileConfig.get_boolcCs||jj||Sr5)r4r'getintrrrrrgszFileConfig.get_intcCs||jj||Sr5)r4r'getfloatrrrrrjszFileConfig.get_float)NNN)N)N)N)N)N)rrrrr&r"r)rrrrr.r/rr4rrrrrrrrrrrr3s&   rN) configparserrtypingrrrrrrrrrrrs ,