<commit_before>'''
Functionality for handling basis set and family notes
'''

import os
import textwrap
from . import fileio
from . import references


def process_notes(notes, data_dir):
    '''Add reference information to the bottom of a notes file

    `:ref:` tags are removed and the actual reference data is appended
    '''

    reffile_path = os.path.join(data_dir, 'REFERENCES.json')
    ref_data = fileio.read_references(reffile_path)            

    ref_keys = ref_data.keys()

    found_refs = set()
    for k in ref_keys:
        if k in notes:
            found_refs.add(k)

    # The block to append
    reference_sec = '\n\n'
    reference_sec += '-------------------------------------\n'
    reference_sec += ' REFERENCES\n'
    reference_sec += '-------------------------------------\n'

    # Add reference data
    for r in sorted(found_refs):
        rtxt= references.reference_text(ref_data[r])
        reference_sec += r + '\n'
        reference_sec += textwrap.indent(rtxt, ' '*4)
        reference_sec += '\n\n'

    return notes + reference_sec<commit_msg>Don't put reference block at bottom of notes if there aren't any<commit_after>'''
Functionality for handling basis set and family notes
'''

import os
import textwrap
from . import fileio
from . import references


def process_notes(notes, data_dir):
    '''Add reference information to the bottom of a notes file

    `:ref:` tags are removed and the actual reference data is appended
    '''

    reffile_path = os.path.join(data_dir, 'REFERENCES.json')
    ref_data = fileio.read_references(reffile_path)            

    ref_keys = ref_data.keys()

    found_refs = set()
    for k in ref_keys:
        if k in notes:
            found_refs.add(k)

    # The block to append
    reference_sec = '\n\n'
    reference_sec += '-------------------------------------\n'
    reference_sec += ' REFERENCES\n'
    reference_sec += '-------------------------------------\n'

    # Add reference data
    if len(found_refs) == 0:
        return notes

    for r in sorted(found_refs):
        rtxt= references.reference_text(ref_data[r])
        reference_sec += r + '\n'
        reference_sec += textwrap.indent(rtxt, ' '*4)
        reference_sec += '\n\n'

    return notes + reference_sec
{'fraction_non_alphanumeric': 0.1591710758377425, 'fraction_numerical': 0.0013227513227513227, 'mean_word_length': 2.1645746164574615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1243436', 'n_tokens_mistral': 685, 'n_tokens_neox': 651, 'n_words': 201}