Exemplo n.º 1
0
Arquivo: fetch.py Projeto: siudej/Cite
def homogeneize_latex_encoding(record):
    """ Replace accents with latex equivalents. """
    for val in record:
        if val not in ('ID',):
            record[val] = string_to_latex(record[val])
            if val == 'title':
                record[val] = protect_uppercase(record[val])
    return record
Exemplo n.º 2
0
def homogeneize_latex_encoding(record):
    """
    Homogeneize the latex enconding style for bibtex

    This function is experimental.

    :param record: the record.
    :type record: dict
    :returns: dict -- the modified record.
    """
    # First, we convert everything to unicode
    record = convert_to_unicode(record)
    # And then, we fall back
    for val in record:
        record[val] = string_to_latex(record[val])
        if val == 'title':
            record[val] = protect_uppercase(record[val])
    return record
def homogeneize_latex_encoding(record):
    """
    Homogeneize the latex enconding style for bibtex

    This function is experimental.

    :param record: the record.
    :type record: dict
    :returns: dict -- the modified record.
    """
    # First, we convert everything to unicode
    record = convert_to_unicode(record)
    # And then, we fall back
    for val in record:
        record[val] = string_to_latex(record[val])
        if val == 'title':
            record[val] = protect_uppercase(record[val])
    return record
Exemplo n.º 4
0
def homogenize_latex_encoding(record):
    """
    Homogenize the latex enconding style for bibtex

    This function is experimental.

    :param record: the record.
    :type record: dict
    :returns: dict -- the modified record.
    """
    # First, we convert everything to unicode
    record = convert_to_unicode(record)
    # And then, we fall back
    for val in record:
        if val not in ('ID', ):
            logger.debug('Apply string_to_latex to: %s', val)
            record[val] = string_to_latex(record[val])
            if val == 'title':
                logger.debug('Protect uppercase in title')
                logger.debug('Before: %s', record[val])
                record[val] = protect_uppercase(record[val])
                logger.debug('After: %s', record[val])
    return record
def homogeneize_latex_encoding(record):
    """
    Homogeneize the latex enconding style for bibtex

    This function is experimental.

    :param record: the record.
    :type record: dict
    :returns: dict -- the modified record.
    """
    # First, we convert everything to unicode
    record = convert_to_unicode(record)
    # And then, we fall back
    for val in record:
        if val not in ('ID',):
            logger.debug('Apply string_to_latex to: %s', val)
            record[val] = string_to_latex(record[val])
            if val == 'title':
                logger.debug('Protect uppercase in title')
                logger.debug('Before: %s', record[val])
                record[val] = protect_uppercase(record[val])
                logger.debug('After: %s', record[val])
    return record
Exemplo n.º 6
0
 def test_traps2(self):
     string = 'A}, mA}gnificient, it is a A}'
     result = protect_uppercase(string)
     expected = 'A}, mA}gnificient, it is a A}'
     self.assertEqual(result, expected)
Exemplo n.º 7
0
 def test_traps(self):
     string = '{A, m{Agnificient, it is a {A'
     result = protect_uppercase(string)
     expected = '{A, m{Agnificient, it is a {A'
     self.assertEqual(result, expected)
Exemplo n.º 8
0
 def test_alreadyprotected(self):
     string = '{A}, m{A}gnificient, it is a {A}...'
     result = protect_uppercase(string)
     expected = '{A}, m{A}gnificient, it is a {A}...'
     self.assertEqual(result, expected)
Exemplo n.º 9
0
 def test_lowercase(self):
     string = 'a'
     result = protect_uppercase(string)
     expected = 'a'
     self.assertEqual(result, expected)
Exemplo n.º 10
0
 def test_uppercase(self):
     string = 'An upPer Case A'
     result = protect_uppercase(string)
     expected = '{A}n up{P}er {C}ase {A}'
     self.assertEqual(result, expected)
Exemplo n.º 11
0
 def test_traps2(self):
     string = 'A}, mA}gnificient, it is a A}'
     result = protect_uppercase(string)
     expected = 'A}, mA}gnificient, it is a A}'
     self.assertEqual(result, expected)
Exemplo n.º 12
0
 def test_traps(self):
     string = '{A, m{Agnificient, it is a {A'
     result = protect_uppercase(string)
     expected = '{A, m{Agnificient, it is a {A'
     self.assertEqual(result, expected)
Exemplo n.º 13
0
 def test_alreadyprotected(self):
     string = '{A}, m{A}gnificient, it is a {A}...'
     result = protect_uppercase(string)
     expected = '{A}, m{A}gnificient, it is a {A}...'
     self.assertEqual(result, expected)
Exemplo n.º 14
0
 def test_lowercase(self):
     string = 'a'
     result = protect_uppercase(string)
     expected = 'a'
     self.assertEqual(result, expected)
Exemplo n.º 15
0
 def test_uppercase(self):
     string = 'An upPer Case A'
     result = protect_uppercase(string)
     expected = '{A}n up{P}er {C}ase {A}'
     self.assertEqual(result, expected)