def read_from_data_directory(
    globpath: str, user: str, overwrite: bool = False
) -> DFIQAddition:
    """Read DFIQ files from a directory and add them to the database.

    Args:
        globpath: Glob path to search for DFIQ files (supports recursion).
        user: User to attribute the changes to.
        overwrite: Whether to overwrite existing DFIQs with the same ID.
    """
    dfiq_kb = {}
    total_added = 0
    dfiq_addition = DFIQAddition(dfiq=[], indicators=[])

    for file in glob.glob(globpath, recursive=True):
        if not file.endswith(".yaml"):
            continue
        logging.debug("Processing %s", file)
        with open(file, "r") as f:
            try:
                dfiq_object = DFIQBase.from_yaml(f.read())
                db_dfiq = None
                if dfiq_object.uuid:
                    db_dfiq = DFIQBase.find(uuid=dfiq_object.uuid)
                if not db_dfiq and dfiq_object.dfiq_id:
                    db_dfiq = DFIQBase.find(dfiq_id=dfiq_object.dfiq_id)
                if not overwrite:
                    if db_dfiq:
                        incoming_v = Version(dfiq_object.dfiq_version)
                        if incoming_v > Version(LATEST_SUPPORTED_DFIQ_VERSION):
                            logging.warning(
                                "DFIQ %s has unsupported version %s, skipping",
                                dfiq_object.dfiq_id,
                                dfiq_object.dfiq_version,
                            )
                            continue
                        db_v = Version(db_dfiq.dfiq_version)
                        if incoming_v <= db_v:
                            logging.info(
                                "DFIQ %s already exists, skipping",
                                dfiq_object.dfiq_id,
                            )
                        continue
                if not dfiq_object.uuid:
                    dfiq_object.uuid = str(uuid.uuid4())
                dfiq_object = dfiq_object.save()
                rbac.set_acls(dfiq_object)
                dfiq_addition.dfiq.append(dfiq_object)
                audit.log_timeline(user, dfiq_object, old=db_dfiq)
                total_added += 1
            except (ValueError, KeyError) as e:
                logging.warning("Error processing %s: %s", file, e)
                raise e

        dfiq_kb[dfiq_object.dfiq_id] = dfiq_object

    for dfiq_id, dfiq_object in dfiq_kb.items():
        dfiq_object.update_parents(soft_fail=True)

    return dfiq_addition
Read DFIQ files from a directory and add them to the database.

    Args:
        globpath: Glob path to search for DFIQ files (supports recursion).
        user: User to attribute the changes to.
        overwrite: Whether to overwrite existing DFIQs with the same ID.
    
core/schemas/dfiq.py