Exemple #1
0
 def __init__(self, logdir, *args, **kwargs):
     indent = kwargs.pop('indent', self.default_indent)
     timeout = kwargs.pop('timeout', self.default_timeout)
     delay = kwargs.pop('delay', self.default_delay)
     path = os.path.join(logdir, self.default_file_name)
     TinyDB.__init__(self, path, *args, indent=indent, **kwargs)
     FileLock.__init__(self, path, timeout=timeout, delay=delay)
    def load_db(self,
                db_file: PathType,
                *init_args,
                default_table: str = DEFAULT_TABLE,
                **kwargs):
        """Method that load raw files and assign each field to an attribute.

        :param db_file: Path to a raw file
        :param tinydb.storages.Storage storage: storage class to be used.
        :param default_table: default main field in the raw file."""
        check_if_valid_instance(self, DataType)

        db_file = auto_convert_to_pathlib(db_file)
        extension = get_extension(db_file)
        storage = get_storage_from_extension(extension)

        TinyDB.__init__(self,
                        db_file,
                        *init_args,
                        storage=storage,
                        default_table=default_table,
                        **kwargs)

        for current_field in self.all():
            setattr(self,
                    list(current_field.keys())[0],
                    list(current_field.values())[0])
    def __init__(self, name):
        """
        This is the constructor for the class.

        :param name:     The probe name that needs this db.
        :return:
        """

        # Override the base class
        TinyDB.__init__(
            self,
            storage = MemoryStorage
        )
        return
Exemple #4
0
 def __init__(self, *args, **kwds):
     TinyDB.__init__(self, *args, **kwds)