# Path: gtool/core/types/core.py
# class CoreType(object):
#     """
#     CoreType is the base object for all attribute types (except user created classes)
#     """
# 
#     def __init__(self, *args, **kwargs):
#         self.__valuetype__ = kwargs.pop('valuetype', None)
#         if self.__valuetype__ == None:
#             raise NotImplementedError('You need to specify a valuetype in keyword args')
# 
#         # assume singleton if not overridden
#         # self.__singleton = kwargs.pop('singleton', True)
# 
#         initvalue = None
#         if len(args) > 0:
#             initvalue = args[0]
#         self.__value__ = initvalue #None
# 
#     # TODO valid alternative repr requirements (if any)
#     def __repr__(self):
#         #return '%s' % self.__value__
#         #return '{0}: {1}'.format(striptoclassname(type(self)), self.__value__)
#         return  '%s' % self.__convert__(self.__value__)
# 
#     def raw(self):
#         return self.__convert__(self.__value__)
# 
#     def __str__(self):
#         return '%s' % self.__value__
# 
#     def __validate__(self, validatedict):
#         """
#         Abstract Validation method, must be implemented by sub-classes.
#         Must raise a ValueError if the value does not match the criteria
#         Look at gtool.type.common for examples
#         """
#         raise NotImplementedError('Please implement a __validate__ method for your class %s' % self.__class__)
# 
#     @classmethod
#     def __convert__(cls, item):
#         try:
#             return cls.__converter__()(item)
#         except ValueError:
#             raise ValueError('cannot convert %s to type %s' %(item, cls.__converter__()))


import warnings
from distutils.util import strtobool
from validators import url, ValidationFailure
from gtool.core.types.core import CoreType




class Url(CoreType):

    def __validate__(self, valuedict):
        _public = valuedict.get('public', None)
        if _public is None:
            public = 0 # False
        else:
            public = strtobool('%s' % _public)
            warnings.warn('public check does not currently work due a problem in the underlying validators library')
        try:
            url(self.__value__, public=public) # TODO public / private test doesn't work
        except ValidationFailure:
            raise ValueError('Was expecting a valid %s but got %s' % ('public URL' if public else 'URL', len(self.__value__)))
        return True

    @classmethod
    def __converter__(cls):
        return str

    def __init__(self, *args, **kwargs):
        self.__validators__ = ['public']
        super().__init__(*args, valuetype=str, **kwargs)


# Path: gtool/core/types/core.py
# class CoreType(object):
#     """
#     CoreType is the base object for all attribute types (except user created classes)
#     """
# 
#     def __init__(self, *args, **kwargs):
#         self.__valuetype__ = kwargs.pop('valuetype', None)
#         if self.__valuetype__ == None:
#             raise NotImplementedError('You need to specify a valuetype in keyword args')
# 
#         # assume singleton if not overridden
#         # self.__singleton = kwargs.pop('singleton', True)
# 
#         initvalue = None
#         if len(args) > 0:
#             initvalue = args[0]
#         self.__value__ = initvalue #None
# 
#     # TODO valid alternative repr requirements (if any)
#     def __repr__(self):
#         #return '%s' % self.__value__
#         #return '{0}: {1}'.format(striptoclassname(type(self)), self.__value__)
#         return  '%s' % self.__convert__(self.__value__)
# 
#     def raw(self):
#         return self.__convert__(self.__value__)
# 
#     def __str__(self):
#         return '%s' % self.__value__
# 
#     def __validate__(self, validatedict):
#         """
#         Abstract Validation method, must be implemented by sub-classes.
#         Must raise a ValueError if the value does not match the criteria
#         Look at gtool.type.common for examples
#         """
#         raise NotImplementedError('Please implement a __validate__ method for your class %s' % self.__class__)
# 
#     @classmethod
#     def __convert__(cls, item):
#         try:
#             return cls.__converter__()(item)
#         except ValueError:
#             raise ValueError('cannot convert %s to type %s' %(item, cls.__converter__()))


# Path: test/test17/plugins/url.py
import warnings
from distutils.util import strtobool
from validators import url, ValidationFailure
from gtool.core.types.core import CoreType





class Url(CoreType):

    def __validate__(self, valuedict):
        _public = valuedict.get('public', None)
        if _public is None:
            public = 0 # False
        else:
            public = strtobool('%s' % _public)
            warnings.warn('public check does not currently work due a problem in the underlying validators library')
        try:
            url(self.__value__, public=public) # TODO public / private test doesn't work
        except ValidationFailure:
            raise ValueError('Was expecting a valid %s but got %s' % ('public URL' if public else 'URL', len(self.__value__)))
        return True

    @classmethod
    def __converter__(cls):
        return str

    def __init__(self, *args, **kwargs):
        self.__validators__ = ['public']
        super().__init__(*args, valuetype=str, **kwargs)


def load():