本文整理汇总了Python中CIME.XML.files.Files.get_schema方法的典型用法代码示例。如果您正苦于以下问题:Python Files.get_schema方法的具体用法?Python Files.get_schema怎么用?Python Files.get_schema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIME.XML.files.Files
的用法示例。
在下文中一共展示了Files.get_schema方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, batch_system=None, machine=None, infile=None, files=None):
"""
initialize an object
"""
if files is None:
files = Files()
if infile is None:
infile = files.get_value("BATCH_SPEC_FILE")
schema = files.get_schema("BATCH_SPEC_FILE")
GenericXML.__init__(self, infile, schema=schema)
self.batch_system_node = None
self.machine_node = None
self.batch_system = batch_system
self.machine = machine
#Append the contents of $HOME/.cime/config_batch.xml if it exists
#This could cause problems if node matchs are repeated when only one is expected
infile = os.path.join(os.environ.get("HOME"),".cime","config_batch.xml")
if os.path.exists(infile):
GenericXML.read(self, infile)
if self.batch_system is not None:
self.set_batch_system(self.batch_system, machine=machine)
示例2: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, infile, files=None):
"""
initialize a files object given input pes specification file
"""
if files is None:
files = Files()
schema = files.get_schema("PES_SPEC_FILE")
logger.debug("DEBUG: infile is {}".format(infile))
GenericXML.__init__(self, infile, schema=schema)
示例3: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self,infile, files=None):
"""
initialize an object
"""
schema = None
if files is None:
files = Files()
schema = files.get_schema("TESTS_SPEC_FILE")
GenericXML.__init__(self, infile, schema=schema)
示例4: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self,infile, files=None):
"""
initialize an object
"""
schema = None
if files is None:
files = Files()
schema = files.get_schema("TESTS_SPEC_FILE")
GenericXML.__init__(self, infile, schema=schema)
expect(self.get_version() >= 2.0,
"{} is an unsupported version of the testfile format and will be ignored".format(infile))
示例5: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, infile=None, files=None):
if files is None:
files = Files()
if infile is None:
infile = files.get_value("GRIDS_SPEC_FILE")
logger.debug(" Grid specification file is %s" % infile)
schema = files.get_schema("GRIDS_SPEC_FILE")
GenericXML.__init__(self, infile, schema)
self._version = self.get_version()
self._comp_gridnames = self._get_grid_names()
示例6: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, infile):
"""
initialize an object
"""
files = Files()
schema = None
# not checking schema on external components yet
cimeroot = get_cime_root()
if cimeroot in os.path.abspath(infile):
schema = files.get_schema("CONFIG_DRV_FILE")
EntryID.__init__(self, infile, schema=schema)
示例7: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, infile=None, files=None):
"""
initialize a files object given input pes specification file
"""
if files is None:
files = Files()
if infile is None:
infile = files.get_value("INPUTDATA_SPEC_FILE")
schema = files.get_schema("INPUTDATA_SPEC_FILE")
logger.debug("DEBUG: infile is {}".format(infile))
GenericXML.__init__(self, infile, schema=schema)
self._servernode = None
示例8: test_st_archive
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def test_st_archive(self, testdir="st_archive_test"):
archive = Archive()
files = Files()
components = []
# expect(not self.get_value("MULTI_DRIVER"),"Test not configured for multi-driver cases")
config_archive_files = archive.get_all_config_archive_files(files)
# create the run directory testdir and populate it with rest_file and hist_file from
# config_archive.xml test_file_names
if os.path.exists(testdir):
logger.info("Removing existing test directory {}".format(testdir))
shutil.rmtree(testdir)
dout_s_root=os.path.join(testdir,"archive")
archive = Archive()
schema = files.get_schema("ARCHIVE_SPEC_FILE")
for config_archive_file in config_archive_files:
archive.read(config_archive_file, schema)
comp_archive_specs = archive.get_children("comp_archive_spec")
for comp_archive_spec in comp_archive_specs:
components.append(archive.get(comp_archive_spec, 'compname'))
test_file_names = archive.get_optional_child("test_file_names", root=comp_archive_spec)
if test_file_names is not None:
if not os.path.exists(testdir):
os.makedirs(os.path.join(testdir,"archive"))
for file_node in archive.get_children("tfile", root=test_file_names):
fname = os.path.join(testdir,archive.text(file_node))
disposition = archive.get(file_node, "disposition")
logger.info("Create file {} with disposition {}".
format(fname, disposition))
with open(fname, 'w') as fd:
fd.write(disposition+"\n")
logger.info("testing components: {} ".format(list(set(components))))
_archive_process(self, archive, None, False, False,components=list(set(components)),
dout_s_root=dout_s_root,
casename="casename", rundir=testdir, testonly=True)
_check_disposition(testdir)
# Now test the restore capability
testdir2 = os.path.join(testdir,"run2")
os.makedirs(testdir2)
restore_from_archive(self, rundir=testdir2, dout_s_root=dout_s_root)
restfiles = [f for f in os.listdir(os.path.join(testdir,"archive","rest","1976-01-01-00000"))]
for _file in restfiles:
expect(os.path.isfile(os.path.join(testdir2,_file)), "Expected file {} to be restored from rest dir".format(_file))
return True
示例9: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, infile, comp_class):
"""
initialize a Component obect from the component xml file in infile
associate the component class with comp_class if provided.
"""
self._comp_class = comp_class
if infile == 'testingonly':
self.filename = infile
return
files = Files()
schema = None
EntryID.__init__(self, infile)
schema = files.get_schema("CONFIG_{}_FILE".format(comp_class), attributes={"version":"{}".format(self.get_version())})
if schema is not None:
self.validate_xml_file(infile, schema)
示例10: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, machobj, infile=None, compiler=None, mpilib=None, files=None, version=None):
"""
initialize an object
"""
if infile is None:
if files is None:
files = Files()
infile = files.get_value("COMPILERS_SPEC_FILE")
schema = files.get_schema("COMPILERS_SPEC_FILE")
GenericXML.__init__(self, infile, schema)
self._machobj = machobj
if version is not None:
# this is used in scripts_regression_tests to force version 2, it should not be used otherwise
self._version = version
else:
self._version = self.get_version()
self.machine = machobj.get_machine_name()
self.os = machobj.get_value("OS")
if compiler is None:
compiler = machobj.get_default_compiler()
self.compiler = compiler
if mpilib is None:
if compiler is None:
mpilib = machobj.get_default_MPIlib()
else:
mpilib = machobj.get_default_MPIlib(attributes={'compiler':compiler})
self.mpilib = mpilib
self.compiler_nodes = None # Listed from last to first
#Append the contents of $HOME/.cime/config_compilers.xml if it exists
#This could cause problems if node matchs are repeated when only one is expected
infile = os.path.join(os.environ.get("HOME"),".cime","config_compilers.xml")
if os.path.exists(infile):
GenericXML.read(self, infile)
if self.compiler is not None:
self.set_compiler(compiler)
if self._version > 1.0:
schema_db = GenericXML(infile=schema)
compiler_vars = schema_db.get_child("{http://www.w3.org/2001/XMLSchema}group", attributes={"name":"compilerVars"})
choice = schema_db.get_child(name="{http://www.w3.org/2001/XMLSchema}choice", root=compiler_vars)
self.flag_vars = set(schema_db.get(elem, "name") for elem in schema_db.get_children(root=choice, attributes={"type":"flagsVar"}))
示例11: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, machobj, infile=None, compiler=None, mpilib=None, files=None, version=None):
"""
initialize an object
"""
if infile is None:
if files is None:
files = Files()
infile = files.get_value("COMPILERS_SPEC_FILE")
schema = files.get_schema("COMPILERS_SPEC_FILE")
GenericXML.__init__(self, infile, schema)
self._machobj = machobj
if version is not None:
# this is used in scripts_regression_tests to force version 2, it should not be used otherwise
self._version = version
else:
self._version = self.get_version()
self.machine = machobj.get_machine_name()
self.os = machobj.get_value("OS")
if mpilib is None:
mpilib = machobj.get_default_MPIlib()
self.mpilib = mpilib
if compiler is None:
compiler = machobj.get_default_compiler()
self.compiler = compiler
self.compiler_nodes = None # Listed from last to first
#Append the contents of $HOME/.cime/config_compilers.xml if it exists
#This could cause problems if node matchs are repeated when only one is expected
infile = os.path.join(os.environ.get("HOME"),".cime","config_compilers.xml")
if os.path.exists(infile):
GenericXML.read(self, infile)
if self.compiler is not None:
self.set_compiler(compiler)
if self._version > 1.0:
# Run an XPath query to extract the list of flag variable names.
ns = {"xs": "http://www.w3.org/2001/XMLSchema"}
flag_xpath = ".//xs:group[@name='compilerVars']/xs:choice/xs:element[@type='flagsVar']"
flag_elems = ET.parse(schema).getroot().findall(flag_xpath, ns)
self.flag_vars = set(elem.get('name') for elem in flag_elems)
示例12: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, infile, files=None):
"""Construct a `NamelistDefinition` from an XML file."""
# if the file is invalid we may not be able to check the version
# but we need to do it this way until we remove the version 1 files
schema = None
if files is None:
files = Files()
schema = files.get_schema("NAMELIST_DEFINITION_FILE")
expect(os.path.isfile(infile), "File {} does not exist".format(infile))
super(NamelistDefinition, self).__init__(infile, schema=schema)
self._attributes = {}
self._entry_nodes = []
self._entry_ids = []
self._valid_values = {}
self._entry_types = {}
self._group_names = {}
self._nodes = {}
示例13: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, infile=None, files=None, machine=None):
"""
initialize an object
if a filename is provided it will be used,
otherwise if a files object is provided it will be used
otherwise create a files object from default values
"""
self.machine_node = None
self.machine = None
self.machines_dir = None
schema = None
if files is None:
files = Files()
if infile is None:
infile = files.get_value("MACHINES_SPEC_FILE")
schema = files.get_schema("MACHINES_SPEC_FILE")
logger.debug("Verifying using schema {}".format(schema))
self.machines_dir = os.path.dirname(infile)
GenericXML.__init__(self, infile, schema)
# Append the contents of $HOME/.cime/config_machines.xml if it exists
# This could cause problems if node matchs are repeated when only one is expected
local_infile = os.path.join(os.environ.get("HOME"),".cime","config_machines.xml")
logger.debug("Infile: {}".format(local_infile))
if os.path.exists(local_infile):
GenericXML.read(self, local_infile, schema)
if machine is None:
if "CIME_MACHINE" in os.environ:
machine = os.environ["CIME_MACHINE"]
else:
cime_config = get_cime_config()
if cime_config.has_option("main", "machine"):
machine = cime_config.get("main", "machine")
if machine is None:
machine = self.probe_machine_name()
expect(machine is not None, "Could not initialize machine object from {} or {}".format(infile, local_infile))
self.set_machine(machine)
示例14: __init__
# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_schema [as 别名]
def __init__(self, infile=None, files=None):
if files is None:
files = Files()
schema = files.get_schema("COMPSETS_SPEC_FILE")
GenericXML.__init__(self, infile, schema=schema)