<commit_before># types.py
# Copyright (C) 2005,2006 <NAME> <EMAIL>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php

__all__ = [ 'TypeEngine', 'TypeDecorator', 'NullTypeEngine',
            'INT', 'CHAR', 'VARCHAR', 'TEXT', 'FLOAT', 'DECIMAL', 
            'TIMESTAMP', 'DATETIME', 'CLOB', 'BLOB', 'BOOLEAN', 'String', 'Integer', 'Smallinteger',
            'Numeric', 'Float', 'DateTime', 'Date', 'Time', 'Binary', 'Boolean', 'Unicode', 'NULLTYPE'
            ]

import sqlalchemy.util as util

class TypeEngine(object):
    def get_col_spec(self):
        raise NotImplementedError()
    def convert_bind_param(self, value, engine):
        raise NotImplementedError()
    def convert_result_value(self, value, engine):
        raise NotImplementedError()
    def adapt(self, typeobj):
        return typeobj()
    def adapt_args(self):
        return self
    def __repr__(self):
        return util.generic_repr(self)
        
def adapt_type(typeobj, colspecs):
    """given a generic type from this package, and a dictionary of 
    "conversion" specs from a DB-specific package, adapts the type
    to a correctly-configured type instance from the DB-specific package."""
    if type(typeobj) is type:
        typeobj = typeobj()
    # if the type is not a base type, i.e. not from our module, or its Null, 
    # we return the type as is
    if typeobj.__module__ != 'sqlalchemy.types' or typeobj.__class__==NullTypeEngine:
        return typeobj
    typeobj = typeobj.adapt_args()
    t = typeobj.__class__
    for t in t.__mro__[0:-1]:
        try:
            return typeobj.adapt(colspecs[t])
        except KeyError, e:
            pass
    return typeobj.adapt(typeobj.__class__)
    
class NullTypeEngine(TypeEngine):
    def __init__(self, *args, **kwargs):
        pass
    def get_col_spec(self):
        raise NotImplementedError()
    def convert_bind_param(self, value, engine):
        return value
    def convert_result_value(self, value, engine):
        return value

class TypeDecorator(object):
    def get_col_spec(self):
        return self.extended.get_col_spec()
    def adapt(self, typeobj):
        t = self.__class__.__mro__[2]
        print repr(t)
        c = self.__class__()
        c.extended = t.adapt(self, typeobj)
        return c
    
class String(NullTypeEngine):
    def __init__(self, length = None, is_unicode=False):
        self.length = length
        self.is_unicode = is_unicode
    def adapt(self, typeobj):
        return typeobj(self.length)
    def adapt_args(self):
        if self.length is None:
            return TEXT(is_unicode=self.is_unicode)
        else:
            return self

class Unicode(String):
    def __init__(self, length=None):
        String.__init__(self, length, is_unicode=True)
    def adapt(self, typeobj):
        return typeobj(self.length, is_unicode=True)
        
class Integer(NullTypeEngine):
    """integer datatype"""
    # TODO: do string bind params need int(value) performed before sending ?  
    # seems to be not needed with SQLite, Postgres
    pass

class Smallinteger(Integer):
    """ smallint datatype """
    pass

class Numeric(NullTypeEngine):
    def __init__(self, precision = 10, length = 2):
        self.precision = precision
        self.length = length
    def adapt(self, typeobj):
        return typeobj(self.precision, self.length)

class Float(NullTypeEngine):
    def __init__(self, precision = 10):
        self.precision = precision
    def adapt(self, typeobj):
        return typeobj(self.precision)

class DateTime(NullTypeEngine):
    pass

class Date(NullTypeEngine):
    pass

class Time(NullTypeEngine):
    pass

class Binary(NullTypeEngine):
    def __init__(self, length=None):
        self.length = length
    def convert_bind_param(self, value, engine):
        return engine.dbapi().Binary(value)
    def convert_result_value(self, value, engine):
        return value
    def adapt(self, typeobj):
        return typeobj(self.length)

class Boolean(NullTypeEngine):
    pass

class FLOAT(Float):pass
class TEXT(String):pass
class DECIMAL(Numeric):pass
class INT(Integer):pass
INTEGER = INT
class SMALLINT(Smallinteger):pass
class TIMESTAMP(DateTime): pass
class DATETIME(DateTime): pass
class DATE(Date): pass
class TIME(Time): pass
class CLOB(String): pass
class VARCHAR(String): pass
class CHAR(String):pass
class BLOB(Binary): pass
class BOOLEAN(Boolean): pass

NULLTYPE = NullTypeEngine()
<commit_msg>added DATE, TIME, SMALLINT to __all__<commit_after># types.py
# Copyright (C) 2005,2006 <NAME> <EMAIL>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php

__all__ = [ 'TypeEngine', 'TypeDecorator', 'NullTypeEngine',
            'INT', 'CHAR', 'VARCHAR', 'TEXT', 'FLOAT', 'DECIMAL', 
            'TIMESTAMP', 'DATETIME', 'CLOB', 'BLOB', 'BOOLEAN', 'String', 'Integer', 'Smallinteger',
            'Numeric', 'Float', 'DateTime', 'Date', 'Time', 'Binary', 'Boolean', 'Unicode', 'NULLTYPE',
		'SMALLINT', 'DATE', 'TIME'
            ]

import sqlalchemy.util as util

class TypeEngine(object):
    def get_col_spec(self):
        raise NotImplementedError()
    def convert_bind_param(self, value, engine):
        raise NotImplementedError()
    def convert_result_value(self, value, engine):
        raise NotImplementedError()
    def adapt(self, typeobj):
        return typeobj()
    def adapt_args(self):
        return self
    def __repr__(self):
        return util.generic_repr(self)
        
def adapt_type(typeobj, colspecs):
    """given a generic type from this package, and a dictionary of 
    "conversion" specs from a DB-specific package, adapts the type
    to a correctly-configured type instance from the DB-specific package."""
    if type(typeobj) is type:
        typeobj = typeobj()
    # if the type is not a base type, i.e. not from our module, or its Null, 
    # we return the type as is
    if typeobj.__module__ != 'sqlalchemy.types' or typeobj.__class__==NullTypeEngine:
        return typeobj
    typeobj = typeobj.adapt_args()
    t = typeobj.__class__
    for t in t.__mro__[0:-1]:
        try:
            return typeobj.adapt(colspecs[t])
        except KeyError, e:
            pass
    return typeobj.adapt(typeobj.__class__)
    
class NullTypeEngine(TypeEngine):
    def __init__(self, *args, **kwargs):
        pass
    def get_col_spec(self):
        raise NotImplementedError()
    def convert_bind_param(self, value, engine):
        return value
    def convert_result_value(self, value, engine):
        return value

class TypeDecorator(object):
    def get_col_spec(self):
        return self.extended.get_col_spec()
    def adapt(self, typeobj):
        t = self.__class__.__mro__[2]
        print repr(t)
        c = self.__class__()
        c.extended = t.adapt(self, typeobj)
        return c
    
class String(NullTypeEngine):
    def __init__(self, length = None, is_unicode=False):
        self.length = length
        self.is_unicode = is_unicode
    def adapt(self, typeobj):
        return typeobj(self.length)
    def adapt_args(self):
        if self.length is None:
            return TEXT(is_unicode=self.is_unicode)
        else:
            return self

class Unicode(String):
    def __init__(self, length=None):
        String.__init__(self, length, is_unicode=True)
    def adapt(self, typeobj):
        return typeobj(self.length, is_unicode=True)
        
class Integer(NullTypeEngine):
    """integer datatype"""
    # TODO: do string bind params need int(value) performed before sending ?  
    # seems to be not needed with SQLite, Postgres
    pass

class Smallinteger(Integer):
    """ smallint datatype """
    pass

class Numeric(NullTypeEngine):
    def __init__(self, precision = 10, length = 2):
        self.precision = precision
        self.length = length
    def adapt(self, typeobj):
        return typeobj(self.precision, self.length)

class Float(NullTypeEngine):
    def __init__(self, precision = 10):
        self.precision = precision
    def adapt(self, typeobj):
        return typeobj(self.precision)

class DateTime(NullTypeEngine):
    pass

class Date(NullTypeEngine):
    pass

class Time(NullTypeEngine):
    pass

class Binary(NullTypeEngine):
    def __init__(self, length=None):
        self.length = length
    def convert_bind_param(self, value, engine):
        return engine.dbapi().Binary(value)
    def convert_result_value(self, value, engine):
        return value
    def adapt(self, typeobj):
        return typeobj(self.length)

class Boolean(NullTypeEngine):
    pass

class FLOAT(Float):pass
class TEXT(String):pass
class DECIMAL(Numeric):pass
class INT(Integer):pass
INTEGER = INT
class SMALLINT(Smallinteger):pass
class TIMESTAMP(DateTime): pass
class DATETIME(DateTime): pass
class DATE(Date): pass
class TIME(Time): pass
class CLOB(String): pass
class VARCHAR(String): pass
class CHAR(String):pass
class BLOB(Binary): pass
class BOOLEAN(Boolean): pass

NULLTYPE = NullTypeEngine()

{'fraction_non_alphanumeric': 0.10584743899758188, 'fraction_numerical': 0.003517256539898879, 'mean_word_length': 3.168117269812185, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4517933', 'n_tokens_mistral': 2807, 'n_tokens_neox': 2717, 'n_words': 780}