コード例 #1
0
def load_config(path=None):
    if path is None:
        try:
            path_dfl = BASE_PATH / '../server.yml'
            path = path_dfl.resolve(strict=True)
        except FileNotFoundError:
            raise FileNotFoundError(
                'The default config file "{}" does not exist. Specify one by --config.'.format(path_dfl.resolve()))

    with open(path, 'r') as f:
        d = yaml.safe_load(f)
    config = Config()
    config.load_from_dict(d)
    return config
コード例 #2
0
ファイル: client.py プロジェクト: zhangsdk/google-ads-python
    def load_from_dict(cls, config_dict):
        """Creates a GoogleAdsClient with data stored in the config_dict.

        Args:
            config_dict: a dict consisting of configuration data used to
                initialize a GoogleAdsClient.

        Returns:
            A GoogleAdsClient initialized with the values specified in the
                dict.

        Raises:
            ValueError: If the configuration lacks a required field.
        """
        config_data = config.load_from_dict(config_dict)
        kwargs = cls._get_client_kwargs(config_data)
        return cls(**kwargs)