<commit_before>#!/bin/env python2.7
# -*- encoding: utf-8 -*-
from __future__ import absolute_import

import logging as log
import io
import os

from . import Engine, Entry

from acrylamid.core import load as loadconf
from acrylamid.readers import load as loadentries

class AcrylamidEngine(Engine):
    def __init__(self, session):
        # TODO retrieve user drafts from SCM
        self.__user_drafts = []
        self._session = session
        try:
            self._root = os.path.join(session.conf.blogbase, session.user)
            confile = os.path.join(self._root, session.conf.blogconf)
            self.conf = loadconf(confile)
            (self.__entries, self.__pages, _, self.__drafts) = loadentries(self.conf)
        except Exception as e:
            log.critical("fail to initialize Acrylamid: %s" % str(e))
            raise e

    def get_user_drafts(self):
        return self.__user_drafts if len(self.__user_drafts) else None

    def get_entries(self):
        return self._wrap_entries(self.__entries) if len(self.__entries) else None

    def get_pages(self):
        return self._wrap_entries(self.__pages) if len(self.__pages) else None

    def get_drafts(self):
        return self._wrap_entries(self.__drafts) if len(self.__drafts) else None

    def _wrap_entries(self, entries):
        for e in entries:
            yield Entry(e.props.title, e.date, e.filename)
        raise StopIteration()

    def store_file(self, file_path, content):
        log.trace("some messy work to do: " + file_path)
        pass

    def finish_file(self, file_path):
        log.trace("some messy work to do: " + file_path)<commit_msg>update acrylamid method names<commit_after># -*- encoding: utf-8 -*-
from __future__ import absolute_import

import logging as log
import io
import os

from . import Engine, Entry

from acrylamid.core import load as load_conf
from acrylamid.readers import load as load_entries

class AcrylamidEngine(Engine):
    def __init__(self, session):
        # TODO retrieve user drafts from SCM
        self.__user_drafts = []
        self._session = session
        try:
            self._root = os.path.join(session.conf.blogbase, session.user)
            confile = os.path.join(self._root, session.conf.blogconf)
            self.conf = load_conf(confile)
            (self.__entries, self.__pages, _, self.__drafts) = load_entries(self.conf)
        except Exception as e:
            log.critical("fail to initialize Acrylamid: %s" % str(e))
            raise e

    def get_user_drafts(self):
        return self.__user_drafts if len(self.__user_drafts) else None

    def get_entries(self):
        return self._wrap_entries(self.__entries) if len(self.__entries) else None

    def get_pages(self):
        return self._wrap_entries(self.__pages) if len(self.__pages) else None

    def get_drafts(self):
        return self._wrap_entries(self.__drafts) if len(self.__drafts) else None

    def _wrap_entries(self, entries):
        for e in entries:
            yield Entry(e.props.title, e.date, e.filename)
        raise StopIteration()

    def store_file(self, file_path, content):
        log.trace("some messy work to do: " + file_path)
        pass

    def finish_file(self, file_path):
        log.trace("some messy work to do: " + file_path)
{'fraction_non_alphanumeric': 0.0934381614756577, 'fraction_numerical': 0.0012095554883580285, 'mean_word_length': 2.771949828962372, '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': '4302110', 'n_tokens_mistral': 1006, 'n_tokens_neox': 976, 'n_words': 273}