Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class ContentNode(BaseCClass):
TYPE_NAME = "content_node"
_iget = ConfigPrototype("char* config_content_node_iget( content_node , int)")
_size = ConfigPrototype("int config_content_node_get_size( content_node )")
_get_full_string = ConfigPrototype("char* config_content_node_get_full_string( content_node , char* )")
_iget_type = ConfigPrototype("config_content_type_enum config_content_node_iget_type( content_node , int)")
_iget_as_abspath = ConfigPrototype("char* config_content_node_iget_as_abspath( content_node , int)")
_iget_as_relpath = ConfigPrototype("char* config_content_node_iget_as_relpath( content_node , int)")
_iget_as_string = ConfigPrototype("char* config_content_node_iget( content_node , int)")
_iget_as_int = ConfigPrototype("int config_content_node_iget_as_int( content_node , int)")
_iget_as_double = ConfigPrototype("double config_content_node_iget_as_double( content_node , int)")
_iget_as_path = ConfigPrototype("char* config_content_node_iget_as_path( content_node , int)")
_iget_as_bool = ConfigPrototype("bool config_content_node_iget_as_bool( content_node , int)")
_iget_as_isodate = ConfigPrototype("time_t config_content_node_iget_as_isodate( content_node , int)")
typed_get = {
ContentTypeEnum.CONFIG_STRING: _iget_as_string,
ContentTypeEnum.CONFIG_INT: _iget_as_int,
ContentTypeEnum.CONFIG_FLOAT: _iget_as_double,
ContentTypeEnum.CONFIG_PATH: _iget_as_path,
ContentTypeEnum.CONFIG_EXISTING_PATH: _iget_as_path,
ContentTypeEnum.CONFIG_BOOL: _iget_as_bool,
ContentTypeEnum.CONFIG_ISODATE: _iget_as_isodate
}
def __init__(self):
raise NotImplementedError("Class can not be instantiated directly!")
import ctypes
from ert.util import UtilPrototype
from ert.config import ContentTypeEnum , ConfigPrototype
from cwrap import BaseCClass
class SchemaItem(BaseCClass):
TYPE_NAME = "schema_item"
_alloc = ConfigPrototype("void* config_schema_item_alloc( char* , bool )", bind=False)
_free = ConfigPrototype("void config_schema_item_free( schema_item )")
_iget_type = ConfigPrototype("config_content_type_enum config_schema_item_iget_type( schema_item, int)")
_iset_type = ConfigPrototype("void config_schema_item_iset_type( schema_item , int , config_content_type_enum)")
_set_argc_minmax = ConfigPrototype("void config_schema_item_set_argc_minmax( schema_item , int , int)")
_add_alternative = ConfigPrototype("void config_schema_item_add_indexed_alternative(schema_item , int , char*)")
_set_deprecated = ConfigPrototype("void config_schema_item_set_deprecated(schema_item , char*)")
_valid_string = ConfigPrototype("bool config_schema_item_valid_string(config_content_type_enum , char*)", bind = False)
_sscanf_bool = UtilPrototype("bool util_sscanf_bool( char* , bool*)", bind = False)
def __init__(self, keyword, required=False):
c_ptr = self._alloc(keyword, required)
super(SchemaItem, self).__init__(c_ptr)
@classmethod
def validString(cls , value_type, value):
return cls._valid_string( value_type , value )
@classmethod
def convert(cls, value_type, value_string):
# FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License at
# for more details.
import os.path
from ert.config import UnrecognizedEnum, ContentTypeEnum, ConfigError, ConfigPrototype, SchemaItem
from cwrap import BaseCClass
class ContentNode(BaseCClass):
TYPE_NAME = "content_node"
_iget = ConfigPrototype("char* config_content_node_iget( content_node , int)")
_size = ConfigPrototype("int config_content_node_get_size( content_node )")
_get_full_string = ConfigPrototype("char* config_content_node_get_full_string( content_node , char* )")
_iget_type = ConfigPrototype("config_content_type_enum config_content_node_iget_type( content_node , int)")
_iget_as_abspath = ConfigPrototype("char* config_content_node_iget_as_abspath( content_node , int)")
_iget_as_relpath = ConfigPrototype("char* config_content_node_iget_as_relpath( content_node , int)")
_iget_as_string = ConfigPrototype("char* config_content_node_iget( content_node , int)")
_iget_as_int = ConfigPrototype("int config_content_node_iget_as_int( content_node , int)")
_iget_as_double = ConfigPrototype("double config_content_node_iget_as_double( content_node , int)")
_iget_as_path = ConfigPrototype("char* config_content_node_iget_as_path( content_node , int)")
_iget_as_bool = ConfigPrototype("bool config_content_node_iget_as_bool( content_node , int)")
_iget_as_isodate = ConfigPrototype("time_t config_content_node_iget_as_isodate( content_node , int)")
typed_get = {
ContentTypeEnum.CONFIG_STRING: _iget_as_string,
ContentTypeEnum.CONFIG_INT: _iget_as_int,
ContentTypeEnum.CONFIG_FLOAT: _iget_as_double,
ContentTypeEnum.CONFIG_PATH: _iget_as_path,
node = self[item_index]
return node[node_index]
def free(self):
self._free( )
class ConfigContent(BaseCClass):
TYPE_NAME = "config_content"
_free = ConfigPrototype("void config_content_free( config_content )")
_is_valid = ConfigPrototype("bool config_content_is_valid( config_content )")
_has_key = ConfigPrototype("bool config_content_has_item( config_content , char*)")
_get_item = ConfigPrototype("content_item_ref config_content_get_item( config_content , char*)")
_get_errors = ConfigPrototype("config_error_ref config_content_get_errors( config_content )")
_get_warnings = ConfigPrototype("stringlist_ref config_content_get_warnings( config_content )")
def __init__(self):
raise NotImplementedError("Class can not be instantiated directly!")
def __contains__(self , key):
return self._has_key(key)
def setParser(self , parser):
self._parser = parser
def __getitem__(self , key):
if key in self:
item = self._get_item(key)
def set_argc_minmax(self, minimum, maximum):
self._set_argc_minmax(minimum, maximum)
def free(self):
self._free()
class ConfigParser(BaseCClass):
TYPE_NAME = "config_parser"
_alloc = ConfigPrototype("void* config_alloc( )", bind=False)
_add = ConfigPrototype("schema_item_ref config_add_schema_item( config_parser , char* , bool)")
_free = ConfigPrototype("void config_free( config_parser )")
_parse = ConfigPrototype("config_content_obj config_parse( config_parser , char* , char* , char* , char* , hash , config_unrecognized_enum , bool )")
_get_schema_item = ConfigPrototype("schema_item_ref config_get_schema_item( config_parser , char*)")
_has_schema_item = ConfigPrototype("bool config_has_schema_item( config_parser , char*)")
def __init__(self):
c_ptr = self._alloc()
super(ConfigParser, self).__init__(c_ptr)
def __contains__(self , keyword):
return self._has_schema_item( keyword )
def add(self, keyword, required=False , value_type = None):
item = self._add(keyword, required).setParent( self )
if value_type:
item.iset_type( 0 , value_type )
return item
# See the GNU General Public License at
# for more details.
import sys
import os.path
from ert.config import UnrecognizedEnum, ContentTypeEnum , ConfigContent, ConfigPrototype
from cwrap import BaseCClass
class ConfigParser(BaseCClass):
TYPE_NAME = "config_parser"
_alloc = ConfigPrototype("void* config_alloc( )", bind=False)
_add = ConfigPrototype("schema_item_ref config_add_schema_item( config_parser , char* , bool)")
_free = ConfigPrototype("void config_free( config_parser )")
_parse = ConfigPrototype("config_content_obj config_parse( config_parser , char* , char* , char* , char* , hash , config_unrecognized_enum , bool )")
_get_schema_item = ConfigPrototype("schema_item_ref config_get_schema_item( config_parser , char*)")
_has_schema_item = ConfigPrototype("bool config_has_schema_item( config_parser , char*)")
def __init__(self):
c_ptr = self._alloc()
super(ConfigParser, self).__init__(c_ptr)
def __contains__(self , keyword):
return self._has_schema_item( keyword )
def add(self, keyword, required=False , value_type = None):
item = self._add(keyword, required).setParent( self )
if value_type:
def igetString(self , index):
index = self.__assertIndex(index)
return self._iget(index )
def asList(self):
return [x for x in self]
class ContentItem(BaseCClass):
TYPE_NAME = "content_item"
_alloc = ConfigPrototype("void* config_content_item_alloc( schema_item , void* )" , bind = False )
_size = ConfigPrototype("int config_content_item_get_size( content_item )")
_iget_content_node = ConfigPrototype("content_node_ref config_content_item_iget_node( content_item , int)")
_free = ConfigPrototype("void config_content_item_free( content_item )")
def __init__(self , schema_item):
path_elm = None
c_ptr = self._alloc( schema_item , path_elm)
super( ContentItem, self).__init__(c_ptr)
def __len__(self):
return self._size()
def __getitem__(self, index):
if isinstance(index, int):
if index < 0:
index += len(self)
#
# See the GNU General Public License at
# for more details.
import sys
import os.path
from ert.config import UnrecognizedEnum, ContentTypeEnum , ConfigContent, ConfigPrototype
from ert.cwrap import BaseCClass
class SchemaItem(BaseCClass):
TYPE_NAME = "schema_item"
_alloc = ConfigPrototype("void* config_schema_item_alloc( char* , bool )", bind=False)
_free = ConfigPrototype("void config_schema_item_free( schema_item )")
_iget_type = ConfigPrototype("config_content_type_enum config_schema_item_iget_type( schema_item, int)")
_iset_type = ConfigPrototype("void config_schema_item_iset_type( schema_item , int , config_content_type_enum)")
_set_argc_minmax = ConfigPrototype("void config_schema_item_set_argc_minmax( schema_item , int , int)")
def __init__(self, keyword, required=False):
c_ptr = self._alloc(keyword, required)
super(SchemaItem, self).__init__(c_ptr)
def iget_type( self, index):
""" @rtype: ContentTypeEnum """
return self._iget_type(index)
def iset_type( self, index, schema_type ):
"""
@type schema_type: ContentTypeEnum
def last(self):
return self[-1]
def getValue(self , item_index = -1 , node_index = 0):
node = self[item_index]
return node[node_index]
class ConfigContent(BaseCClass):
TYPE_NAME = "config_content"
_free = ConfigPrototype("void config_content_free( config_content )")
_is_valid = ConfigPrototype("bool config_content_is_valid( config_content )")
_has_key = ConfigPrototype("bool config_content_has_item( config_content , char*)")
_get_item = ConfigPrototype("content_item_ref config_content_get_item( config_content , char*)")
_get_errors = ConfigPrototype("config_error_ref config_content_get_errors( content_node )")
def __init__(self):
raise NotImplementedError("Class can not be instantiated directly!")
def __contains__(self , key):
return self._has_key(key)
def __getitem__(self , key):
if key in self:
item = self._get_item(key)
item.setParent( self )
return item
else:
# (at your option) any later version.
#
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License at
# for more details.
from ert.config import ConfigPrototype
from ert.cwrap import BaseCClass
class ConfigError(BaseCClass):
TYPE_NAME = "config_error"
_free = ConfigPrototype("void config_error_free(config_error)")
_count = ConfigPrototype("int config_error_count(config_error)")
_iget = ConfigPrototype("char* config_error_iget(config_error, int)")
def __init__(self):
raise NotImplementedError("Class can not be instantiated directly!")
def __getitem__(self, index):
""" @rtype: str """
if not isinstance(index, int):
raise TypeError("Expected an integer")
size = len(self)
if index >= size:
raise IndexError("Index out of range: %d < %d" % (index, size))
return self._iget(index)