Given a directory that contains output from
    a DFT calculation, parse the data and return
    a pif object

    Input:
        files - [str] list of files from which the parser is allowed to read.
        verbose - int, How much status messages to print

    Output:
        pif - ChemicalSystem, Results and settings of
            the DFT calculation in pif format

def files_to_pif(files, verbose=0, quality_report=True, inline=True):
    '''Given a directory that contains output from
    a DFT calculation, parse the data and return
    a pif object

    Input:
        files - [str] list of files from which the parser is allowed to read.
        verbose - int, How much status messages to print

    Output:
        pif - ChemicalSystem, Results and settings of
            the DFT calculation in pif format
    '''

    # Look for the first parser compatible with the directory
    found_parser = False
    for possible_parser in [PwscfParser, VaspParser]:
        try:
            parser = possible_parser(files)
            found_parser = True
            break
        except InvalidIngesterException:
            # Constructors fail when they cannot find appropriate files
            pass
    if not found_parser:
        raise Exception('Directory is not in correct format for an existing parser')
    if verbose > 0:
        print("Found a {} directory".format(parser.get_name()))
        
    # Get information about the chemical system
    chem = ChemicalSystem()
    chem.chemical_formula = parser.get_composition()
        
    # Get software information, to list as method
    software = Software(name=parser.get_name(),
        version=parser.get_version_number())
        
    # Define the DFT method object
    method = Method(name='Density Functional Theory',
        software=[software])
        
    # Get the settings (aka. "conditions") of the DFT calculations
    conditions = []
    for name, func in parser.get_setting_functions().items():
        # Get the condition
        cond = getattr(parser, func)()

        # If the condition is None or False, skip it
        if cond is None:
            continue

        if inline and cond.files is not None:
            continue

        # Set the name
        cond.name = name

        # Set the types
        conditions.append(cond)
    
    # Get the properties of the system
    chem.properties = []
    for name, func in parser.get_result_functions().items():
        # Get the property
        prop = getattr(parser, func)()
        
        # If the property is None, skip it
        if prop is None:
            continue

        if inline and prop.files is not None:
            continue

        # Add name and other data
        prop.name = name
        prop.methods = [method,]
        prop.data_type='COMPUTATIONAL'
        if verbose > 0 and isinstance(prop, Value):
            print(name)
        if prop.conditions is None:
            prop.conditions = conditions
        else:
            if not isinstance(prop.conditions, list):
                prop.conditions = [prop.conditions]
            prop.conditions.extend(conditions)

        # Add it to the output
        chem.properties.append(prop)

    # Check to see if we should add the quality report
    if quality_report and isinstance(parser, VaspParser):
        _add_quality_report(parser, chem)

    return chem