<commit_before># -*- coding: utf-8 -*-


'''latexdiffcite.latexdiffcite: the actual script, and the entry point main().'''


from __future__ import division, print_function, absolute_import

import os
import re
import json
import logging
import argparse
import tempfile
import subprocess

import io

__version__ = '0.9.0'

log = logging.getLogger(__name__)


# ==============================================================================
#  Classes to hold "global" variables during runtime
# ==============================================================================


class Config(object):

    @staticmethod
    def load_defaults():
        log.debug('loading default settings')
        Config.encoding = 'utf-8'
        Config.latexdiff_args = ''
        Config.git_force_unix_pathsep = True
        Config.ref_single_word = True
        Config.bib = {
            'max_authors': 2,
            'sep_authors_first': ', ',
            'author_serialcomma': True,
            'sep_authors_last': ' and ',
            'et_al': ' et~al.'
        }
        Config.bbl = {
            'regex': r'\\bibitem\[{((?:(?!^$).)*?)\(((?:(?!^$).)*?)(?:{\\natexlab{(.?)}})?\)((?:(?!^$).)*?)}\]{%REFKEY%}',
            'author': '%CG1%',
            'year': '%CG2%%CG3%'
        }
        Config.cmd_format = {
            'citep':
                {'cite_start': '[',
                 'sep_prenote': ' ',
                 'author': '\\textit{%AUTHOR%}',
                 'sep_author_year': ', ',
                 'year': '%YEAR%',
                 'sep_same_author_year': ', ',
                 'sep_ref': '; ',
                 'sep_postnote': ', ',
                 'cite_end': ']'},
            'citet':
                {'cite_start': '',
                 'sep_prenote': ' ',
                 'author': '\\textit{%AUTHOR%}',
                 'sep_author_year': ' ',
                 'year': '[%YEAR%]',
                 'sep_same_author_year': ', ',
                 'sep_ref': '; ',
                 'sep_postnote': ', ',
                 'cite_end': ''},
            'cite':
                {'cite_start': '',
                 'sep_prenote': ' ',
                 'author': '\\textit{%AUTHOR%}',
                 'sep_author_year': ' ',
                 'year': '[%YEAR%]',
                 'sep_same_author_year': ', ',
                 'sep_ref': '; ',
                 'sep_postnote': ', ',
                 'cite_end': ''}
        }

    @staticmethod
    def load_config(json_file):
        '''Loads settings from config file'''
        if json_file is None:
            return
        with io.open(json_file, 'r', encoding=Config.encoding) as f:
            config = json.load(f)
        for k, v in config.items():
            setattr(Config, k, v)


class References(object):
    refkeys_old = []
    refkeys_new = []
    capture_groups_old = {}
    capture_groups_new = {}
    authyear_old = {}
    authyear_new = {}


class Files(object):
    '''Container for file-related info'''

    out_path = None
    tex_old_path = None
    tex_new_path = None
    bbl_old_path = None
    bbl_new_path = None
    bib_old_path = []
    bib_new_path = []

    # temp files<commit_msg>add debug message in Config.load_config() to show loaded values<commit_after># -*- coding: utf-8 -*-


'''latexdiffcite.latexdiffcite: the actual script, and the entry point main().'''


from __future__ import division, print_function, absolute_import

import os
import re
import json
import logging
import argparse
import tempfile
import subprocess

import io

__version__ = '0.9.0'

log = logging.getLogger(__name__)


# ==============================================================================
#  Classes to hold "global" variables during runtime
# ==============================================================================


class Config(object):

    @staticmethod
    def load_defaults():
        log.debug('loading default settings')
        Config.encoding = 'utf-8'
        Config.latexdiff_args = ''
        Config.git_force_unix_pathsep = True
        Config.ref_single_word = True
        Config.bib = {
            'max_authors': 2,
            'sep_authors_first': ', ',
            'author_serialcomma': True,
            'sep_authors_last': ' and ',
            'et_al': ' et~al.'
        }
        Config.bbl = {
            'regex': r'\\bibitem\[{((?:(?!^$).)*?)\(((?:(?!^$).)*?)(?:{\\natexlab{(.?)}})?\)((?:(?!^$).)*?)}\]{%REFKEY%}',
            'author': '%CG1%',
            'year': '%CG2%%CG3%'
        }
        Config.cmd_format = {
            'citep':
                {'cite_start': '[',
                 'sep_prenote': ' ',
                 'author': '\\textit{%AUTHOR%}',
                 'sep_author_year': ', ',
                 'year': '%YEAR%',
                 'sep_same_author_year': ', ',
                 'sep_ref': '; ',
                 'sep_postnote': ', ',
                 'cite_end': ']'},
            'citet':
                {'cite_start': '',
                 'sep_prenote': ' ',
                 'author': '\\textit{%AUTHOR%}',
                 'sep_author_year': ' ',
                 'year': '[%YEAR%]',
                 'sep_same_author_year': ', ',
                 'sep_ref': '; ',
                 'sep_postnote': ', ',
                 'cite_end': ''},
            'cite':
                {'cite_start': '',
                 'sep_prenote': ' ',
                 'author': '\\textit{%AUTHOR%}',
                 'sep_author_year': ' ',
                 'year': '[%YEAR%]',
                 'sep_same_author_year': ', ',
                 'sep_ref': '; ',
                 'sep_postnote': ', ',
                 'cite_end': ''}
        }

    @staticmethod
    def load_config(json_file):
        '''Loads settings from config file'''
        if json_file is None:
            return
        with io.open(json_file, 'r', encoding=Config.encoding) as f:
            config = json.load(f)
        for k, v in config.items():
            log.debug('setting Config.%s to %s', k, v)
            setattr(Config, k, v)


class References(object):
    refkeys_old = []
    refkeys_new = []
    capture_groups_old = {}
    capture_groups_new = {}
    authyear_old = {}
    authyear_new = {}


class Files(object):
    '''Container for file-related info'''

    out_path = None
    tex_old_path = None
    tex_new_path = None
    bbl_old_path = None
    bbl_new_path = None
    bib_old_path = []
    bib_new_path = []

    # temp files
{'fraction_non_alphanumeric': 0.204084790345041, 'fraction_numerical': 0.00278508432616432, 'mean_word_length': 1.7958477508650519, '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': '3204198', 'n_tokens_mistral': 1937, 'n_tokens_neox': 1881, 'n_words': 355}