<commit_before>#! /usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
import reportlab.lib.pagesizes
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib import units
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
import re
import sys
import os


def align_up(x, n):
    """Round up"""
    return ((x+n-1)//n)*n


def expand_tabs(s, tab_size=4):
    # Convert tabs to spaces, based on position in string. I.e. do not naively replace a single tab with fixed tab_size number spaces
    pos = 0
    result = []
    for c in s:
        if c == '\t':
            aligned = align_up(pos, tab_size)
            if pos % 4 != 0:
                num_spaces = aligned - pos
            else:
                num_spaces = tab_size
            co = ' ' * num_spaces
            pos += num_spaces
        else:
            co = c
            pos += 1
        result.append(co)
    return ''.join(result)

class Margins(object):
    def __init__(self, right, left, top, bottom):
        self._right = right
        self._left = left
        self._top = top
        self._bottom = bottom

    @property
    def right(self):
        return self._right * units.cm

    @property
    def left(self):
        return self._left * units.cm

    @property
    def top(self):
        return self._top * units.cm

    @property
    def bottom(self):
        return self._bottom * units.cm

    def adjustLeft(self, width):
        self._left -= width / units.cm


class PDFCreator(object):
    appName = "txt2pdf (version 1.0)"

    def __init__(self, args, margins):
        pageWidth, pageHeight = reportlab.lib.pagesizes.__dict__[args.media]
        if args.landscape:
            pageWidth, pageHeight = reportlab.lib.pagesizes.landscape(
                (pageWidth, pageHeight))
        self.author = args.author
        self.title = args.title
        self.keywords = args.keywords
        self.subject = args.subject
        self.canvas = Canvas(args.output, pagesize=(pageWidth, pageHeight))
        self.canvas.setCreator(self.appName)
        if len(args.author) > 0:
            self.canvas.setAuthor(args.author)
        if len(args.title) > 0:
            self.canvas.setTitle(args.title)
        if len(args.subject) > 0:<commit_msg>Version 1.0.1 bump<commit_after>#! /usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
import reportlab.lib.pagesizes
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib import units
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
import re
import sys
import os


version_tuple = version_info = (1, 0, 1)
version = version_string = __version__ = '%d.%d.%d' % version_tuple

def align_up(x, n):
    """Round up"""
    return ((x+n-1)//n)*n


def expand_tabs(s, tab_size=4):
    # Convert tabs to spaces, based on position in string. I.e. do not naively replace a single tab with fixed tab_size number spaces
    pos = 0
    result = []
    for c in s:
        if c == '\t':
            aligned = align_up(pos, tab_size)
            if pos % 4 != 0:
                num_spaces = aligned - pos
            else:
                num_spaces = tab_size
            co = ' ' * num_spaces
            pos += num_spaces
        else:
            co = c
            pos += 1
        result.append(co)
    return ''.join(result)

class Margins(object):
    def __init__(self, right, left, top, bottom):
        self._right = right
        self._left = left
        self._top = top
        self._bottom = bottom

    @property
    def right(self):
        return self._right * units.cm

    @property
    def left(self):
        return self._left * units.cm

    @property
    def top(self):
        return self._top * units.cm

    @property
    def bottom(self):
        return self._bottom * units.cm

    def adjustLeft(self, width):
        self._left -= width / units.cm


class PDFCreator(object):
    appName = "txt2pdf (version %s)" % __version__

    def __init__(self, args, margins):
        pageWidth, pageHeight = reportlab.lib.pagesizes.__dict__[args.media]
        if args.landscape:
            pageWidth, pageHeight = reportlab.lib.pagesizes.landscape(
                (pageWidth, pageHeight))
        self.author = args.author
        self.title = args.title
        self.keywords = args.keywords
        self.subject = args.subject
        self.canvas = Canvas(args.output, pagesize=(pageWidth, pageHeight))
        self.canvas.setCreator(self.appName)
        if len(args.author) > 0:
            self.canvas.setAuthor(args.author)
        if len(args.title) > 0:
            self.canvas.setTitle(args.title)
        if len(args.subject) > 0:
{'fraction_non_alphanumeric': 0.10494880546075085, 'fraction_numerical': 0.0063993174061433445, 'mean_word_length': 2.0991407799074686, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3539866', 'n_tokens_mistral': 1467, 'n_tokens_neox': 1404, 'n_words': 388}