/usr/share/pyshared/drslib/config.py is in python-drslib 0.3.0a3-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | # BSD Licence
# Copyright (c) 2010, Science & Technology Facilities Council (STFC)
# All rights reserved.
#
# See the LICENSE file in the source distribution of this software for
# the full license text.
"""
"""
#!TODO: tidy this up and review what needs documenting.
import os
import metaconfig
config = metaconfig.get_config('drslib')
##############################################################################
# Configure the location of MIP tables.
#
# This can be configured with the MIP_TABLE_PATH environment varliable
# or in the drslib metaconfig as
# [drslib:tables]
# path = $MIP_TABLE_PATH
#
# You can override the location of CSV versions of the tables with the
# "path_csv" option in metaconfig. You can override the prefix of tables
# with the "prefix" option.
#
if 'MIP_TABLE_PATH' in os.environ:
table_path = os.environ['MIP_TABLE_PATH']
else:
try:
table_path = config.get('tables', 'path')
except:
# On Debian, the user may have cmip5-cmor-tables installed. Fall back to these.
if os.path.exists('/usr/share/cmor'):
table_path ='/usr/share/cmor'
else:
raise Exception("Please configure your MIP table path using MIP_TABLE_PATH or a config file")
try:
table_path_csv = config.get('tables', 'path_csv')
except:
table_path_csv = '%s_csv' % os.path.normpath(table_path)
# Check both paths exist
if not os.path.exists(table_path):
raise Exception("The configured mip-table path %s does not exist" % table_path)
if not os.path.exists(table_path_csv):
raise Exception("The mip-table CSV directory %s could not be found" % table_path_csv)
if config.has_option('tables', 'prefix'):
table_prefix = config.get('tables', 'prefix')
else:
table_prefix = 'CMIP5_'
##############################################################################
# Configure site-specific drs vocabulary behaviour
#
#
# Configure default values of the drs attributes
#
#!TODO: this should probably be drs_defaults. Requires major version change.
if config.has_section('drs'):
drs_defaults = dict(config.items('drs'))
else:
drs_defaults = {}
#
# Configure the model table. You shouldn't need to change this from the
# internal default.
#
#!TODO: Check whether this is used.
try:
model_table = config.get('tables', 'model_table')
except:
model_table = os.path.join(os.path.dirname(__file__), 'data',
'CMIP5_models.csv')
#
# Allow backward compatibility with the original version system
# Original behaviour is default
#
try:
version_by_date = config.getboolean('versioning', 'version_by_date')
except:
version_by_date = True
#
# Allow override of experiment names.
# These are merged with names in the MIP tables
#
try:
experiments = config.get('vocabularies', 'experiments').split()
except:
experiments = []
##############################################################################
# drs_tree command defaults
#
# Default subdirectory of drs-root to scan for incoming files
DEFAULT_INCOMING = 'output'
DEFAULT_MOVE_CMD = 'mv'
try:
move_cmd = config.get('DEFAULT', 'move-cmd')
except:
move_cmd = DEFAULT_MOVE_CMD
#
# CMIP3 component to file/path position mapping
#
class CMIP3_DRS:
PATH_INSTMODEL = 4
PATH_EXPERIMENT = 0
PATH_FREQUENCY = 2
PATH_REALM = 1
PATH_VARIABLE = 3
PATH_ENSEMBLE = 5
FILE_VARIABLE = 0
FILE_TABLE = 1
#FILE_SUBSET = 2
FILE_EXTENDED = 6
#
# CMIP5 component to file/path position mapping
#
class CMIP5_DRS:
PATH_PRODUCT = 0
PATH_INSTITUTE = 1
PATH_MODEL = 2
PATH_EXPERIMENT = 3
PATH_FREQUENCY = 4
PATH_REALM = 5
PATH_TABLE = 6
PATH_ENSEMBLE = 7
PATH_VERSION = 8
PATH_VARIABLE = 9
FILE_VARIABLE = 0
FILE_TABLE = 1
FILE_MODEL = 2
FILE_EXPERIMENT = 3
FILE_ENSEMBLE = 4
FILE_SUBSET = 5
FILE_EXTENDED = 6
#
# CMIP5 component to file/path position mappings for DRS <= v0.27
#
class CMIP5_DRS_OLD:
PATH_PRODUCT = 0
PATH_INSTITUTE = 1
PATH_MODEL = 2
PATH_EXPERIMENT = 3
PATH_FREQUENCY = 4
PATH_REALM = 5
PATH_VERSION = 6
PATH_VARIABLE = 7
PATH_ENSEMBLE = 8
FILE_VARIABLE = 0
FILE_TABLE = 1
FILE_MODEL = 2
FILE_EXPERIMENT = 3
FILE_ENSEMBLE = 4
FILE_SUBSET = 5
FILE_EXTENDED = 6
# Without version!
class CMIP5_CMOR_DRS:
PATH_PRODUCT = 0
PATH_INSTITUTE = 1
PATH_MODEL = 2
PATH_EXPERIMENT = 3
PATH_FREQUENCY = 4
PATH_REALM = 5
PATH_VARIABLE = 6
PATH_ENSEMBLE = 7
FILE_VARIABLE = 0
FILE_TABLE = 1
FILE_MODEL = 2
FILE_EXPERIMENT = 3
FILE_ENSEMBLE = 4
FILE_SUBSET = 5
FILE_EXTENDED = 6
|