示例#1
0
    def __init__(self, path, base):
        """
        :param path: path of dated folder relative to base directory 
        :param base: directory 

        Reads json and ini files from the directory identified
        ito the d dict keyed on file stem names.
        """
        self.path = path
        self.base = base
         

        absdir = os.path.join(base, path) 
        self.absdir = absdir 

        self.datefold = os.path.basename(path)
        self.timestamp = dateparser(self.datefold)
        self.parentfold = os.path.basename(os.path.dirname(path))        
        assert self.timestamp is not None, "expected datedfolder argument %s " % path 

        self.d = {}
        for n in os.listdir(absdir):
            p = os.path.join(absdir,n)
            if not os.path.isfile(p): continue
            stem,ext = os.path.splitext(n) 
            if ext == ".json":
                self.d[stem] = json_(p)
            elif ext == ".ini":
                self.d[stem] = ini_(p)
            else:
                pass
            pass
        pass
示例#2
0
 def __init__(self, base, tag):
     path = os.path.join(base, self.NAME)
     log.info("path %s " % path)
     ini = ini_(path)
     itag = int(tag)
     key = self.PROPAGATE_OK if itag > 0 else self.PROPAGATE_G4
     propagate = ini.get(key, -1)
     self.propagate = propagate
     self.ini = ini
示例#3
0
 def loadpath_(cls, path, dbg=False):
     if os.path.exists(path):
         log.debug("loading %s " % path)
         if dbg:
             os.system("ls -l %s " % path)
         pass
         d = ini_(path)
     else:
         #log.warning("cannot load %s " % path)
         raise IOError("cannot load %s " % path)
         d = {}
     return d
示例#4
0
 def __init__(self, base, tag):
     path = os.path.join(base, self.NAME)
     if not os.path.exists(path):
         ini = None
         propagate = -99.
         log.info("path %s does not exist " % path)
     else:
         ini = ini_(path)
         itag = int(tag)
         propagate = ini.get(self.PROPAGATE_OK, -1) if itag > 0 else -1
     pass
     self.propagate = propagate
     self.ini = ini
示例#5
0
#!/usr/bin/env python
#
# Copyright (c) 2019 Opticks Team. All Rights Reserved.
#
# This file is part of Opticks
# (see https://bitbucket.org/simoncblyth/opticks).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import sys
from opticks.ana.base import ini_

if __name__ == '__main__':
    ini = ini_(sys.argv[1])
    for k, v in sorted(ini.items(), reverse=True, key=lambda kv: float(kv[1])):
        print(" %50s : %10.4f " % (k, float(v)))
    pass