Ejemplo n.º 1
0
    def __init__(self, projectName, path, Session, validate=True, offline=False):

        ProjectHandler.__init__(self, projectName, path, Session, validate=validate, offline=offline)
        if not offline:
            try:
#                 f = NetCDF.NetCDFFile(path)
                f = Cdunif.CdunifFile(path)
            except:
                raise ESGPublishError('Error opening %s. Is the data offline?'%path)
            if not self.validateProject(f):
                raise ESGInvalidMetadataFormat("Not a %s datafile"%projectName)
            f.close()

        self.fieldNames = {
            'project': (ENUM, True, 0),
            'experiment': (ENUM, True, 1),
            'model': (ENUM, True, 2),
            'product': (ENUM, True, 3),
            'submodel': (ENUM, False, 4),
            'run_name': (STRING, True, 5),
            }
        self.context = {}
        self.validValues = {}

        if validate:
            self.initValidValues(Session)
Ejemplo n.º 2
0
 def getContext(self, **context):
     ProjectHandler.getContext(self, **context)
     if self.context.get('creation_time', '')=='':
         self.context['creation_time'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     if self.context.get('format', '')=='':
         self.context['format'] = self.formatHandlerClass.getFormatDescription()
         conventions = self.context.get('Conventions')
         if conventions is not None:
             self.context['format'] += ', %s'%conventions
     return self.context
Ejemplo n.º 3
0
 def getContext(self, **context):
     ProjectHandler.getContext(self, **context)
     if self.context.get('creation_time', '') == '':
         self.context['creation_time'] = datetime.datetime.now().strftime(
             "%Y-%m-%d %H:%M:%S")
     if self.context.get('format', '') == '':
         self.context[
             'format'] = self.formatHandlerClass.getFormatDescription()
         conventions = self.context.get('Conventions')
         if conventions is not None:
             self.context['format'] += ', %s' % conventions
     return self.context
Ejemplo n.º 4
0
    def __init__(self,
                 projectName,
                 path,
                 Session,
                 validate=True,
                 offline=False):

        ProjectHandler.__init__(self,
                                projectName,
                                path,
                                Session,
                                validate=validate,
                                offline=offline)
        if not offline:
            try:
                #                 f = NetCDF.NetCDFFile(path)
                f = Cdunif.CdunifFile(path)
            except:
                raise ESGPublishError(
                    'Error opening %s. Is the data offline?' % path)
            if not self.validateProject(f):
                raise ESGInvalidMetadataFormat("Not a %s datafile" %
                                               projectName)
            f.close()

        self.fieldNames = {
            'project': (ENUM, True, 0),
            'experiment': (ENUM, True, 1),
            'model': (ENUM, True, 2),
            'product': (ENUM, True, 3),
            'submodel': (ENUM, False, 4),
            'run_name': (STRING, True, 5),
        }
        self.context = {}
        self.validValues = {}

        if validate:
            self.initValidValues(Session)