<commit_before># types.py
# Copyright (C) 2005, 2006, 2007 <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',
            'INT', 'CHAR', 'VARCHAR', 'NCHAR', 'TEXT', 'FLOAT', 'DECIMAL',
            'TIMESTAMP', 'DATETIME', 'CLOB', 'BLOB', 'BOOLEAN',
            'SMALLINT', 'DATE', 'TIME',
            'String', 'Integer', 'SmallInteger','Smallinteger',
            'Numeric', 'Float', 'DateTime', 'Date', 'Time', 'Binary',
            'Boolean', 'Unicode', 'PickleType', 'Interval',
            ]

import inspect
import datetime as dt

from sqlalchemy import exceptions
from sqlalchemy.util import Decimal, pickle

class _UserTypeAdapter(type):
    """adapts 0.3 style user-defined types with convert_bind_param/convert_result_value
    to use newer bind_processor()/result_processor() methods."""
    
    def __init__(cls, clsname, bases, dict):
        if not hasattr(cls.convert_result_value, '_sa_override'):
            cls.__instrument_result_proc(cls)
            
        if not hasattr(cls.convert_bind_param, '_sa_override'):
            cls.__instrument_bind_proc(cls)
            
        return super(_UserTypeAdapter, cls).__init__(clsname, bases, dict)

    def __instrument_bind_proc(cls, class_):
        def bind_processor(self, dialect):
            def process(value):
                return self.convert_bind_param(value, dialect)
            return process
        class_.super_bind_processor = class_.bind_processor
        class_.bind_processor = bind_processor

    def __instrument_result_proc(cls, class_):    
        def result_processor(self, dialect):
            def process(value):
                return self.convert_result_value(value, dialect)
            return process
        class_.super_result_processor = class_.result_processor
        class_.result_processor = result_processor

        
class AbstractType(object):
    __metaclass__ = _UserTypeAdapter
    
    def __init__(self, *args, **kwargs):
        pass
        
    def copy_value(self, value):
        return value

    def convert_result_value(self, value, dialect):
        """legacy convert_result_value() method.
        
        this method is only used when called via a user-defined
        subclass' own convert_result_value() method, and adapts
        the call to use the result_processor() callable.

        The method is configured at class definition time 
        by a legacy adapter metaclass, and
        will not work with a subclass that does not 
        define a convert_result_value() method of its own.
        """
        return self.super_result_processor(dialect)(value)
    convert_result_value._sa_override = True
    
    def convert_bind_param(self, value, dialect):
        """legacy convert_bind_param() method.
        
        this method is only used when called via a user-defined
        subclass' own convert_bind_param() method, and adapts
        the call to use the bind_processor() callable.
        
        The method is configured at class definition time 
        by a legacy adapter metaclass, and
        will not work with a subclass that does not 
        define a convert_bind_param() method of its own.
        """
        return self.super_bind_processor(dialect)(value)
    convert_bind_param._sa_override = True
    
    def bind_processor(self, dialect):
        """define a bind parameter processing function."""
        
        return None

    def result_processor(self, dialect):
        """define a result-column processing function."""
        
        return None

    def compare_values(self, x, y):
        """compare two values for equality."""
        
        return x == y

    def is_mutable(self):
        """return True if the target Python type is 'mutable'.
        
        This allows systems like the ORM to know if an object
        can be considered 'not changed' by identity alone.
        """
        
        return False

    def get_dbapi_type(self, dbapi):
        """Return the corresponding type object from the underlying DB-API, if any.

        This can be useful for calling ``setinputsizes()``, for example.
        """

        return None

    def __repr__(self):
        return "%s(%s)" % (self.__class__.__name__, ",".join(["%s=%s" % (k, getattr(self, k)) for k in inspect.getargspec(self.__init__)[0][1:]]))<commit_msg>- Fixed convert_result_value/bind_param compatibility for types without processors.<commit_after># types.py
# Copyright (C) 2005, 2006, 2007 <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',
            'INT', 'CHAR', 'VARCHAR', 'NCHAR', 'TEXT', 'FLOAT', 'DECIMAL',
            'TIMESTAMP', 'DATETIME', 'CLOB', 'BLOB', 'BOOLEAN',
            'SMALLINT', 'DATE', 'TIME',
            'String', 'Integer', 'SmallInteger','Smallinteger',
            'Numeric', 'Float', 'DateTime', 'Date', 'Time', 'Binary',
            'Boolean', 'Unicode', 'PickleType', 'Interval',
            ]

import inspect
import datetime as dt

from sqlalchemy import exceptions
from sqlalchemy.util import Decimal, pickle

class _UserTypeAdapter(type):
    """adapts 0.3 style user-defined types with convert_bind_param/convert_result_value
    to use newer bind_processor()/result_processor() methods."""
    
    def __init__(cls, clsname, bases, dict):
        if not hasattr(cls.convert_result_value, '_sa_override'):
            cls.__instrument_result_proc(cls)
            
        if not hasattr(cls.convert_bind_param, '_sa_override'):
            cls.__instrument_bind_proc(cls)
            
        return super(_UserTypeAdapter, cls).__init__(clsname, bases, dict)

    def __instrument_bind_proc(cls, class_):
        def bind_processor(self, dialect):
            def process(value):
                return self.convert_bind_param(value, dialect)
            return process
        class_.super_bind_processor = class_.bind_processor
        class_.bind_processor = bind_processor

    def __instrument_result_proc(cls, class_):    
        def result_processor(self, dialect):
            def process(value):
                return self.convert_result_value(value, dialect)
            return process
        class_.super_result_processor = class_.result_processor
        class_.result_processor = result_processor

        
class AbstractType(object):
    __metaclass__ = _UserTypeAdapter
    
    def __init__(self, *args, **kwargs):
        pass
        
    def copy_value(self, value):
        return value

    def convert_result_value(self, value, dialect):
        """Legacy convert_result_value() compatibility method.

        This adapter method is provided for user-defined types that implement
        the older convert_* interface and need to call their super method.
        These calls are adapted behind the scenes to use the newer
        callable-based interface via result_processor().

        Compatibility is configured on a case-by-case basis at class
        definition time by a legacy adapter metaclass.  This method is only
        available and functional if the concrete subclass implements the
        legacy interface.
        """

        processor = self.super_result_processor(dialect)
        if processor:
            return processor(value)
        else:
            return value
    convert_result_value._sa_override = True
    
    def convert_bind_param(self, value, dialect):
        """Legacy convert_bind_param() compatability method.
        
        This adapter method is provided for user-defined types that implement
        the older convert_* interface and need to call their super method.
        These calls are adapted behind the scenes to use the newer
        callable-based interface via bind_processor().

        Compatibility is configured on a case-by-case basis at class
        definition time by a legacy adapter metaclass.  This method is only
        available and functional if the concrete subclass implements the
        legacy interface.
        """

        processor = self.super_bind_processor(dialect)
        if processor:
            return processor(value)
        else:
            return value
    convert_bind_param._sa_override = True
    
    def bind_processor(self, dialect):
        """Defines a bind parameter processing function."""
        
        return None

    def result_processor(self, dialect):
        """Defines a result-column processing function."""
        
        return None

    def compare_values(self, x, y):
        """compare two values for equality."""
        
        return x == y

    def is_mutable(self):
        """return True if the target Python type is 'mutable'.
        
        This allows systems like the ORM to know if an object
        can be considered 'not changed' by identity alone.
        """
        
        return False

    def get_dbapi_type(self, dbapi):
        """Return the corresponding type object from the underlying DB-API, if any.

        This can be useful for calling ``setinputsizes()``, for example.
        """

        return None

    def __repr__(self):
        return "%s(%s)" % (self.__class__.__name__, ",".join(["%s=%s" % (k, getattr(self, k)) for k in inspect.getargspec(self.__init__)[0][1:]]))
{'fraction_non_alphanumeric': 0.08883947479881406, 'fraction_numerical': 0.0033883947479881405, 'mean_word_length': 2.5628064881176913, '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': '2723650', 'n_tokens_mistral': 2553, 'n_tokens_neox': 2479, 'n_words': 814}