本文整理汇总了Python中drslib.drs_tree.DRSTree.set_move_cmd方法的典型用法代码示例。如果您正苦于以下问题:Python DRSTree.set_move_cmd方法的具体用法?Python DRSTree.set_move_cmd怎么用?Python DRSTree.set_move_cmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类drslib.drs_tree.DRSTree
的用法示例。
在下文中一共展示了DRSTree.set_move_cmd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Command
# 需要导入模块: from drslib.drs_tree import DRSTree [as 别名]
# 或者: from drslib.drs_tree.DRSTree import set_move_cmd [as 别名]
class Command(object):
def __init__(self, op, opts, args):
self.op = op
self.opts = opts
self.args = args
self.shelve_dir = None
self.p_cmip5_config = None
self.drs_root = None
self.drs_tree = None
self.make_drs_tree()
def _config_p_cmip5(self):
"""
Ensure self.shelve_dir is set. This is required for InitCommand
and any command that uses p_cmip5.
"""
self.shelve_dir = self.opts.shelve_dir
if self.shelve_dir is None:
try:
self.shelve_dir = config.config.get("p_cmip5", "shelve-dir")
except NoSectionError:
raise Exception(
"Shelve directory not specified. Please use --shelve-dir or set shelve_dir via metaconfig"
)
def _setup_p_cmip5(self):
"""
Instantiate the p_cmip5.cmip5_product object ready for deducing
the product component.
"""
shelves = p_cmip5.init._find_shelves(self.shelve_dir)
self.p_cmip5_config = self.opts.p_cmip5_config
if self.p_cmip5_config is None:
try:
self.p_cmip5_config = config.config.get("p_cmip5", "config")
except (NoSectionError, NoOptionError):
raise Exception(
"p_cmip5 configuration file not specified. Please use --p-cmip5-config or set via metaconfig"
)
self.drs_tree.set_p_cmip5(
p_cmip5.product.cmip5_product(
mip_table_shelve=shelves["stdo_mip"],
template=shelves["template"],
stdo=shelves["stdo"],
config=self.p_cmip5_config,
not_ok_excpt=True,
)
)
def make_drs_tree(self):
if self.opts.root:
self.drs_root = self.opts.root
else:
try:
self.drs_root = config.drs_defaults["root"]
except KeyError:
raise Exception("drs-root not defined")
if self.opts.incoming:
incoming = self.opts.incoming
else:
try:
incoming = config.drs_defaults["incoming"]
except KeyError:
incoming = os.path.join(self.drs_root, config.DEFAULT_INCOMING)
if self.opts.json_drs:
json_drs = self.opts.json_drs
else:
json_drs = None
drs_root = os.path.normpath(os.path.abspath(self.drs_root))
if self.opts.scheme:
scheme = self.opts.scheme
else:
scheme = config.default_drs_scheme
try:
fs_cls = config.get_drs_scheme(scheme)
except KeyError:
raise ValueError("Unrecognised DRS scheme %s" % scheme)
self.drs_fs = fs_cls(drs_root)
self.drs_tree = DRSTree(self.drs_fs)
if self.opts.move_cmd:
self.drs_tree.set_move_cmd(self.opts.move_cmd)
# This code is specifically for the deprecated DRS setting options
# Generic DRS component setting is handled below
kwargs = {}
for attr in ["activity", "product", "institute", "model", "experiment", "frequency", "realm", "ensemble"]:
try:
#.........这里部分代码省略.........
示例2: Command
# 需要导入模块: from drslib.drs_tree import DRSTree [as 别名]
# 或者: from drslib.drs_tree.DRSTree import set_move_cmd [as 别名]
class Command(object):
def __init__(self, opts, args):
self.opts = opts
self.args = args
self.shelve_dir = None
self.p_cmip5_config = None
self.drs_root = None
self.drs_tree = None
self.make_drs_tree()
def _config_p_cmip5(self):
"""
Ensure self.shelve_dir is set. This is required for InitCommand
and any command that uses p_cmip5.
"""
self.shelve_dir = self.opts.shelve_dir
if self.shelve_dir is None:
try:
self.shelve_dir = config.config.get('p_cmip5', 'shelve-dir')
except NoSectionError:
raise Exception("Shelve directory not specified. Please use --shelve-dir or set shelve_dir via metaconfig")
def _setup_p_cmip5(self):
"""
Instantiate the p_cmip5.cmip5_product object ready for deducing
the product component.
"""
shelves = p_cmip5.init._find_shelves(self.shelve_dir)
self.p_cmip5_config = self.opts.p_cmip5_config
if self.p_cmip5_config is None:
try:
self.p_cmip5_config = config.config.get('p_cmip5', 'config')
except (NoSectionError, NoOptionError):
raise Exception("p_cmip5 configuration file not specified. Please use --p-cmip5-config or set via metaconfig")
self.drs_tree.set_p_cmip5(p_cmip5.product.cmip5_product(
mip_table_shelve=shelves['stdo_mip'],
template=shelves['template'],
stdo=shelves['stdo'],
config=self.p_cmip5_config,
not_ok_excpt=True))
def make_drs_tree(self):
if self.opts.root:
self.drs_root = self.opts.root
else:
try:
self.drs_root = config.drs_defaults['root']
except KeyError:
raise Exception('drs-root not defined')
if self.opts.incoming:
incoming = self.opts.incoming
else:
try:
incoming = config.drs_defaults['incoming']
except KeyError:
incoming = os.path.join(self.drs_root, config.DEFAULT_INCOMING)
self.drs_tree = DRSTree(self.drs_root)
if self.opts.move_cmd:
self.drs_tree.set_move_cmd(self.opts.move_cmd)
kwargs = {}
for attr in ['activity', 'product', 'institute', 'model', 'experiment',
'frequency', 'realm', 'ensemble']:
try:
val = getattr(self.opts, attr)
# val may be there but None
if val is None:
raise AttributeError
except AttributeError:
val = config.drs_defaults.get(attr)
kwargs[attr] = val
# Get the template DRS from args
if self.args:
dataset_id = self.args[0]
drs = DRS.from_dataset_id(dataset_id, **kwargs)
else:
drs = DRS(**kwargs)
# Product detection
if self.opts.detect_product:
self._config_p_cmip5()
self._setup_p_cmip5()
self.drs_tree.discover(incoming, **drs)
def do(self):
raise NotImplementedError("Unimplemented command")
#.........这里部分代码省略.........