예제 #1
0
    def __init__(self, limit=None, **kwargs):
        super().__init__(**kwargs)
        try:
            config = PyFileConfigLoader(os.path.expanduser(
                self.config_file)).load_config()
            config.merge(self.config)
            self.update_config(config)
        except ConfigFileNotFound:
            pass

        self.paths = [p for p in self.paths if os.path.isdir(p)]

        dirs = []
        for p in self.paths:
            for d in glob(os.path.join(p, self.directory_pattern)):
                if (os.path.isdir(d) and not os.path.islink(d)) \
                and len(glob(os.path.join(d, self.file_glob))) > 0:
                    dirs.append(d)
                    if limit is not None and len(dirs) == limit:
                        break
        if self.hour != -1:
            dirs = [d for d in dirs if d[-2:] == '{:02}'.format(self.hour)]
        if self.from_date != '':
            dirs = [d for d in dirs if d[-10:-2] >= self.from_date]
        if self.to_date != '':
            dirs = [d for d in dirs if d[-10:-2] <= self.to_date]
        self.dirs = sorted(dirs, key=lambda s: s[-10:])

        assert len(self.dirs) > 0, "no directories added"
        self.log.info("WuRFiles initialized with %s directories.",
                      len(self.dirs))
예제 #2
0
 def __init__(self, config={}, **kwargs):
     try:
         cfg = PyFileConfigLoader(self.config_file).load_config()
         cfg.merge(config)
         super().__init__(config=cfg, **kwargs)
     except ConfigFileNotFound:
         print('not found')
         super().__init__(config=Config(config), **kwargs)
예제 #3
0
 def __init__(self, *args, config={}, **kwargs):
     try:
         cfg = PyFileConfigLoader(os.path.expanduser(
             self.config_file)).load_config()
         cfg.merge(config)
     except ConfigFileNotFound:
         cfg = Config(config)
     super().__init__(config=cfg, **kwargs)
예제 #4
0
파일: GSHHS.py 프로젝트: betaplane/cezanne
    def __init__(self, filename, *args, config={}, **kwargs):
        try:
            cfg = PyFileConfigLoader(os.path.expanduser(
                self.config_file)).load_config()
            cfg.merge(config)
        except ConfigFileNotFound:
            pass
        super().__init__(config=cfg, **kwargs)

        z = ZipFile(self.path)

        self._reader = shapereader(**{
            k: z.open('{}.{}'.format(filename, k))
            for k in ['shp', 'shx', 'dbf']
        })
        self._geometry_factory = GEOMETRY_FACTORIES.get(self._reader.shapeType)
        self._fields = self._reader.fields
        z.close()
예제 #5
0
        help=
        'disable extent based provenance for event mentions to use trigger based provenance',
        default_value=True).tag(config=True)

    evt_merge_level = Integer(
        help='How much level of type level to consider when merge events',
        default_value=0).tag(config=True)


if __name__ == '__main__':
    from event import util
    import sys

    conf = PyFileConfigLoader(sys.argv[1]).load_config()

    cl_conf = util.load_command_line_config(sys.argv[2:])
    conf.merge(cl_conf)

    params = CombineParams(config=conf)

    log_file = os.path.join(params.output_folder, 'combiner.log')
    if os.path.exists(log_file):
        os.remove(log_file)

    print("Logs will be output at {}".format(log_file))
    util.set_file_log(log_file)

    # util.set_basic_log()

    main(params)
예제 #6
0
파일: util.py 프로젝트: zzsfornlp/csr
def load_all_config(args):
    cl_conf = load_command_line_config(args[2:])
    conf = PyFileConfigLoader(args[1]).load_config()
    conf.merge(cl_conf)
    return conf