<commit_before>
from libeeyore.eeyinterface import implements_interface
from libeeyore.values import *
from libeeyore.builtinmodules.eeysys import EeySysArgv


class FormatString( object ):
    def __init__( self, string ):
        self.string = string

    def append( self, to_append ):
        self.string += to_append

    def __str__( self ):
        return self.string

class FormatArgs( object ):
    def __init__( self ):
        self.lst = []

    def append( self, to_append ):
        self.lst.append( to_append )

    def as_list( self ):
        return self.lst


def append_print_arg( fmtstr, fmtargs, env, value ):

    if value.__class__ is EeyPlus: # TODO: and if an arg is a string
        append_print_arg( fmtstr, fmtargs, env, value.left_value )
        append_print_arg( fmtstr, fmtargs, env, value.right_value )
        return

    if value.is_known( env ):
        cls = value.__class__
    else:
        cls = value.evaluated_type( env )

    if cls is EeyString:
        # We don't call render, because we add our own quotes here
        fmtstr.append( value.as_py_str() )
    elif cls is EeyInt:
        fmtstr.append( "%d" )
        fmtargs.append( value.render( env ) )
    elif cls is EeyFloat:
        fmtstr.append( "%f" )
        fmtargs.append( value.render( env ) )
    elif implements_interface( value, EeyString ):
        fmtstr.append( "%s" )
        fmtargs.append( value.render( env ) )
    else:
        raise Exception( "Unknown argument type to print: "
            + str( arg0.__class__ ) )


def render_EeyRuntimePrint( env, value ):
    assert( len( value.args ) == 1 ) # TODO: not an assert<commit_msg>Add a TODO to format floats better.<commit_after>
from libeeyore.eeyinterface import implements_interface
from libeeyore.values import *
from libeeyore.builtinmodules.eeysys import EeySysArgv


class FormatString( object ):
    def __init__( self, string ):
        self.string = string

    def append( self, to_append ):
        self.string += to_append

    def __str__( self ):
        return self.string

class FormatArgs( object ):
    def __init__( self ):
        self.lst = []

    def append( self, to_append ):
        self.lst.append( to_append )

    def as_list( self ):
        return self.lst


def append_print_arg( fmtstr, fmtargs, env, value ):

    if value.__class__ is EeyPlus: # TODO: and if an arg is a string
        append_print_arg( fmtstr, fmtargs, env, value.left_value )
        append_print_arg( fmtstr, fmtargs, env, value.right_value )
        return

    if value.is_known( env ):
        cls = value.__class__
    else:
        cls = value.evaluated_type( env )

    if cls is EeyString:
        # We don't call render, because we add our own quotes here
        fmtstr.append( value.as_py_str() )
    elif cls is EeyInt:
        fmtstr.append( "%d" )
        fmtargs.append( value.render( env ) )
    elif cls is EeyFloat:
        fmtstr.append( "%f" )
        fmtargs.append( value.render( env ) )
        # TODO: format float output better
    elif implements_interface( value, EeyString ):
        fmtstr.append( "%s" )
        fmtargs.append( value.render( env ) )
    else:
        raise Exception( "Unknown argument type to print: "
            + str( arg0.__class__ ) )


def render_EeyRuntimePrint( env, value ):
    assert( len( value.args ) == 1 ) # TODO: not an assert
{'fraction_non_alphanumeric': 0.09479940564635958, 'fraction_numerical': 0.001188707280832095, 'mean_word_length': 2.484472049689441, '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': '5374130', 'n_tokens_mistral': 1049, 'n_tokens_neox': 1031, 'n_words': 318}