def _set_config(self, config): if config: try: self.spacing = afconfig.get_config_value( config, 'grid', 'spacing') self.swLat = afconfig.get_config_value(config, 'grid', 'boundary', 'sw', 'lat') self.swLng = afconfig.get_config_value(config, 'grid', 'boundary', 'sw', 'lng') self.neLat = afconfig.get_config_value(config, 'grid', 'boundary', 'ne', 'lat') self.neLng = afconfig.get_config_value(config, 'grid', 'boundary', 'ne', 'lng') if (self.spacing and self.swLat and self.swLng and self.neLat and self.neLng): return except Exception as e: pass # The config wasn't defined at all, or one of the required fields # wasn't defined, or the config was otherwise invalid raise BlueSkyConfigurationError( "Missing or invalid plume_merge configuration")
def get(cls, *keys, **kwargs): if 'default' in kwargs: raise DeprecationWarning("config defaults are specified in " "bluesky.config.defaults module") if keys: keys = [k.lower() for k in keys] # default behavior is to fail if key isn't in user's config # or in default config return afconfig.get_config_value( cls._IM_CONFIG, *keys, fail_on_missing_key=not kwargs.get('allow_missing')) else: return cls._IM_CONFIG
def _get_config_options(self, output_directory): """Creates config options dict to be pass into BlueSkyKml This method supports specifying old BSF / blueskykml ini settings under the blueskykml_config config key, which (if defined) is expected to contain nested dicts (each dict representing a config section). e.g. "visualization": { "targets": ["dispersion"], "dispersion": { "hysplit": { "output_dir": "/sdf/sdf/", ..., "blueskykml_config": { "SmokeDispersionKMLInput": { "FIRE_EVENT_ICON" : "http://maps.google.com/mapfiles/ms/micons/firedept.png" } ... } } } } The config_options dict returned by this method is initialized with whatever is specified under blueskykml_config. Then, specific config options are set if not already defined. - 'SmokeDispersionKMLInput' > 'FIRE_EVENT_ICON' -- set to "http://maps.google.com/mapfiles/ms/micons/firedept.png" - 'DispersionGridOutput' > 'OUTPUT_DIR' """ # we don't want to modify the central Config, so we use # afconfig on deep-copied blueskykml config # TODO: is there a valid reason for not modifying the central Config ? config_options = copy.deepcopy(vis_hysplit_config('blueskykml_config')) # set output directory if not already specified if afconfig.get_config_value(config_options, 'DispersionGridOutput', 'OUTPUT_DIR') is None: images_dir = str(os.path.join(output_directory, vis_hysplit_config('images_dir') or '')) afconfig.set_config_value(config_options, images_dir, 'DispersionGridOutput', 'OUTPUT_DIR') return config_options
def getter(*keys, **kwargs): keys = [k.lower() for k in keys] return afconfig.get_config_value( config, *keys, fail_on_missing_key=not kwargs.get('allow_missing'))
def get(*args): return copy.deepcopy( afconfig.get_config_value(ConfigManagerSingleton().config, *args))
def get(*args): return copy.deepcopy(afconfig.get_config_value(config, *args))