Ejemplo n.º 1
0
 def __init__(self, f=None):
     if f is None: f = '.ccrawlrc'
     self.f = f
     cl = PyFileConfigLoader(filename=f, path=('.', os.getenv('HOME')))
     try:
         c = cl.load_config()
     except:
         c = None
     self.Terminal = Terminal(config=c)
     self.Database = Database(config=c)
     self.Collect = Collect(config=c)
     self.Formats = Formats(config=c)
     self.src = c
     clang.cindex.Config.library_file = self.Collect.lib
Ejemplo n.º 2
0
    def __init__(self, f=None):

        if f is not None:
            f = os.path.expanduser(f)
            self._locations = [f]
        for f in self._locations:
            cl = PyFileConfigLoader(filename=f, path=(".", os.getenv("HOME")))
            try:
                c = cl.load_config()
            except Exception:
                c = None
                self.f = None
            else:
                self.f = f
                break
        self.setup(c)
Ejemplo n.º 3
0
 def __init__(self, f=None):
     if f is None:
         f = ".ccrawlrc"
     self.f = f
     cl = PyFileConfigLoader(filename=f, path=(".", os.getenv("HOME")))
     try:
         c = cl.load_config()
     except Exception:
         c = None
     self.Terminal = Terminal(config=c)
     self.Database = Database(config=c)
     self.Collect = Collect(config=c)
     self.Formats = Formats(config=c)
     self.Ghidra = Ghidra(config=c)
     self.src = c
     if self.Collect.lib:
         clang.cindex.Config.library_file = self.Collect.lib
Ejemplo n.º 4
0
 def __init__(self, f=None):
     if f is None:
         from os import getenv
         from traitlets.config import PyFileConfigLoader
         for f in self._locations:
             cl = PyFileConfigLoader(filename=f, path=('.', getenv('HOME')))
             try:
                 c = cl.load_config()
             except:
                 c = None
                 self.f = None
             else:
                 self.f = f
                 break
     self.UI = UI(config=c)
     self.DB = DB(config=c)
     self.Code = Code(config=c)
     self.Arch = Arch(config=c)
     self.Log = Log(config=c)
     self.Cas = Cas(config=c)
     self.System = System(config=c)
     self.src = c
Ejemplo n.º 5
0
def load_config(path=None):
    """Load a Python or JSON config file."""
    if not path or not op.exists(path):
        return Config()
    path = op.realpath(path)
    dirpath, filename = op.split(path)
    file_ext = op.splitext(path)[1]
    logger.debug("Load config file `%s`.", path)
    if file_ext == '.py':
        config = PyFileConfigLoader(filename, dirpath,
                                    log=logger).load_config()
    elif file_ext == '.json':
        config = JSONFileConfigLoader(filename, dirpath,
                                      log=logger).load_config()
    return config
Ejemplo n.º 6
0
def load_config(path=None):
    """Load a Python or JSON config file and return a `Config` instance."""
    if not path:
        return Config()
    path = Path(path)
    if not path.exists():  # pragma: no cover
        return Config()
    file_ext = path.suffix
    logger.debug("Load config file `%s`.", path)
    if file_ext == '.py':
        config = PyFileConfigLoader(path.name, str(path.parent),
                                    log=logger).load_config()
    elif file_ext == '.json':
        config = JSONFileConfigLoader(path.name, str(path.parent),
                                      log=logger).load_config()
    return config
Ejemplo n.º 7
0
 def __init__(self, **kwargs):
     loader = PyFileConfigLoader('igitconfig.py',
                                 path='/home/gilad/.config/igit')
     config = loader.load_config()
     super().__init__(config=config, **kwargs)
     self.user = User(parent=self)
Ejemplo n.º 8
0
def load_py_config(in_name):
    reader = PyFileConfigLoader(in_name)
    reader.load_config()
    logging.info('load from [%s] conf: %s', in_name, reader.config)
    return reader.config
Ejemplo n.º 9
0
 def load(self, f):
     f = os.path.expanduser(f)
     cl = PyFileConfigLoader(filename=f, path=(".", os.getenv("HOME")))
     self.setup(cl.load_config())
Ejemplo n.º 10
0
 def from_library_config(cls):
     """ Create annotation DB from library config file.
     """
     config_path = Path(flowgraph.__file__).parent.joinpath("config.py")
     config = PyFileConfigLoader(str(config_path)).load_config()
     return cls(config=config)