<commit_before>from ckan import plugins as p

import ckan.lib.dictization

import sqlalchemy

_table_dictize = ckan.lib.dictization.table_dictize

_select = sqlalchemy.sql.select

class TermTranslationActions(p.SingletonPlugin):
    p.implements(p.IActions)

    def get_actions(self):
        return {
            'term_translations': self.term_translations
        }

    def term_translations(self, context, data_dict):
        '''Returns a list of all term translations

        :param lang_code: Filter for one language. If lang_code is empty,
            all term translations are returned

        '''

        model = context['model']

        lang_code = data_dict.get('lang_code')

        trans_table = model.term_translation_table

        q = _select([trans_table])

        if lang_code:
            q = q.where(trans_table.c.lang_code == lang_code)

        conn = model.Session.connection()
        cursor = conn.execute(q)

        results = []

        for row in cursor:
            results.append(_table_dictize(row, context))

        return results<commit_msg>stick with ckans naming convention<commit_after>from ckan import plugins as p

import ckan.lib.dictization

import sqlalchemy

_table_dictize = ckan.lib.dictization.table_dictize

_select = sqlalchemy.sql.select

class TermTranslationActions(p.SingletonPlugin):
    p.implements(p.IActions)

    def get_actions(self):
        return {
            'term_translation_list': self.term_translation_list
        }

    def term_translation_list(self, context, data_dict):
        '''Returns a list of all term translations

        :param lang_code: Filter for one language. If lang_code is empty,
            all term translations are returned

        '''

        model = context['model']

        lang_code = data_dict.get('lang_code', '')

        trans_table = model.term_translation_table

        q = _select([trans_table])

        if lang_code:
            q = q.where(trans_table.c.lang_code == lang_code)

        conn = model.Session.connection()
        cursor = conn.execute(q)

        results = []

        for row in cursor:
            results.append(_table_dictize(row, context))

        return results
{'fraction_non_alphanumeric': 0.08314402544298047, 'fraction_numerical': 0.0, 'mean_word_length': 2.5516129032258066, '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': '6333556', 'n_tokens_mistral': 650, 'n_tokens_neox': 614, 'n_words': 151}