<commit_before>'''
Created on 12-03-2013

@author: kamil
'''
import sys

from asciiart import parsers, shortcuts

parsers = {
    'monochrome': parsers.BinaryParser,
    'greyscale': parsers.GreyscaleParser,
    'greyscalehtml': parsers.HtmlGreyscaleParser,
    'colorhtml': parsers.HtmlColorParser,
}

html_template = '''
    <!doctype html>
        <head>
            {0}
        </head>
        </body>
            {1}
        </body>
    </html>
    '''
    
styles = """
<style>
    pre {
        font-size: 10px;
        font-weight: bold;
        line-height: 6px;
    }
</style>
"""

def file2ascii():
    parser_name = sys.argv[1]
    inp = sys.argv[2]
    dimensions = sys.argv[3]
    output = sys.argv[4]
    
    with open(output, 'w') as fp:
        image = shortcuts.image_from_file(inp)
        parser_klass = parsers[parser_name]
        parser = parser_klass(image)
        width, height = [int(x) for x in dimensions.split("x")]
        fp.write(html_template.format(styles, parser.parse(width, height)))

def url2ascii():
    parser_name = sys.argv[1]
    url = sys.argv[2]
    dimensions = sys.argv[3]
    filename = sys.argv[4]
    
    with open(filename, 'w') as fp:
        image = shortcuts.image_from_url(url)
        parser_klass = parsers[parser_name]
        parser = parser_klass(image)
        width, height = [int(x) for x in dimensions.split("x")]
        fp.write(html_template.format(styles, parser.parse(width, height)))<commit_msg>Command line output of html parsers is wrapped in <pre> tags<commit_after>'''
Created on 12-03-2013

@author: kamil
'''
import sys

from asciiart import parsers, shortcuts

parsers = {
    'monochrome': parsers.BinaryParser,
    'greyscale': parsers.GreyscaleParser,
    'greyscalehtml': parsers.HtmlGreyscaleParser,
    'colorhtml': parsers.HtmlColorParser,
}

html_template = '''
    <!doctype html>
        <head>
            {0}
        </head>
        </body>
            <pre>
                {1}
            </pre>
        </body>
    </html>
    '''
    
styles = """
<style>
    pre {
        font-size: 10px;
        font-weight: bold;
        line-height: 6px;
    }
</style>
"""

def file2ascii():
    parser_name = sys.argv[1]
    inp = sys.argv[2]
    dimensions = sys.argv[3]
    output = sys.argv[4]
    
    with open(output, 'w') as fp:
        image = shortcuts.image_from_file(inp)
        parser_klass = parsers[parser_name]
        parser = parser_klass(image)
        width, height = [int(x) for x in dimensions.split("x")]
        fp.write(html_template.format(styles, parser.parse(width, height)))

def url2ascii():
    parser_name = sys.argv[1]
    url = sys.argv[2]
    dimensions = sys.argv[3]
    filename = sys.argv[4]
    
    with open(filename, 'w') as fp:
        image = shortcuts.image_from_url(url)
        parser_klass = parsers[parser_name]
        parser = parser_klass(image)
        width, height = [int(x) for x in dimensions.split("x")]
        fp.write(html_template.format(styles, parser.parse(width, height)))

{'fraction_non_alphanumeric': 0.13586776859504132, 'fraction_numerical': 0.015206611570247934, 'mean_word_length': 2.4269535673839187, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, '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': '4005187', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1032, 'n_words': 219}