<commit_before>use artano::{self, Canvas, Typeface};
use config::{Options, OutputFormat};
use error::Error;
use std::path::Path;
use std::result;

type Result<T> = result::Result<T, Error>;

pub struct App;

impl App {
    pub fn run(&self, options: &Options) -> Result<()> {
        let font = build_font(&options.font_path)?;
        let mut canvas = options
            .base_image
            .get()
            .map_err(|e| Error::not_found("Base image not found", e))
            .and_then(|buf| {
                Canvas::read_from_buffer(&buf).map_err(|e| Error::bad_image(e))
            })?;

        for annotation in &options.annotations {
            canvas.add_annotation(annotation, &font, options.scale_mult);
        }

        canvas.render();
        save_pixels(&options.output_path, &canvas, options.output_format)
    }
}

fn build_font(path: &Path) -> Result<Typeface> {
    use std::fs::File;
    use std::io::BufReader;

    let data = File::open(path).map_err(
        |e| Error::not_found("Font not found", e),
    )?;<commit_msg>Clippy lints<commit_after>use artano::{self, Canvas, Typeface};
use config::{Options, OutputFormat};
use error::Error;
use std::path::Path;
use std::result;

type Result<T> = result::Result<T, Error>;

pub struct App;

impl App {
    pub fn run(&self, options: &Options) -> Result<()> {
        let font = build_font(&options.font_path)?;
        let mut canvas = options
            .base_image
            .get()
            .map_err(|e| Error::not_found("Base image not found", e))
            .and_then(|buf| {
                Canvas::read_from_buffer(&buf).map_err(Error::bad_image)
            })?;

        for annotation in &options.annotations {
            canvas.add_annotation(annotation, &font, options.scale_mult);
        }

        canvas.render();
        save_pixels(&options.output_path, &canvas, options.output_format)
    }
}

fn build_font(path: &Path) -> Result<Typeface> {
    use std::fs::File;
    use std::io::BufReader;

    let data = File::open(path).map_err(
        |e| Error::not_found("Font not found", e),
    )?;
{'fraction_non_alphanumeric': 0.15304182509505704, 'fraction_numerical': 0.0, 'mean_word_length': 2.779174147217235, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '3904126', 'n_tokens_mistral': 671, 'n_tokens_neox': 664, 'n_words': 146}