# Path: gtool/core/types/core.py
# class FunctionType(object):
#     """
#     Use as the base class for method plugins
#     """
# 
#     @abstractmethod
#     def __init__(self, obj, config=str(), defer=False):
#         """
#         Based class for method plugins
# 
#         :param obj: the DynamicType Object that the function will operate one
#         :param config: instructions on how the plugin should work. May be a list, dict or string
#         """
# 
#         self.targetobject = obj
#         self.config = config
#         self.computable = False
#         self.__result__ = None
#         self.__context__ = obj.__context__
#         self.__defer__ = defer
# 
#     # TODO implement an  attribute getter for method plugins
#     def __getname__(self, attrname, nativetypes = [], singletononly=False):
#         raise NotImplemented
# 
#     @abstractmethod
#     def compute(self):
#         """
#         processes any instructions in config, determine if required input exists.
#         If required input exists, sets self.computable to true, computes and stores result
#         :return:  None
#         """
#         # process config or do something
# 
#         if True: #determine if result can be computed
#             self.computable = True
# 
#         if self.computable:
#             self.__result__ = 'some result' #set result
#             raise NotImplemented('compute must be overridden')
#         else:
#             pass
#             # if not computable don't set result
#         #TODO look at returning True or False is compute completes
# 
#     @property
#     def context(self):
#         return self.__context__
# 
#     def result(self, force=False):
# 
#         if not self.__defer__ or force:
#             self.compute() #TODO look at making this an if statement
#             return self.__result__
#         else:
#             raise NotComputed('Computation deferred')
# 
#     def __repr__(self):
#         return '<%s>:()' % (self.__class__, self.config)
# 
#     def __str__(self):
#         self.compute() #TODO look at making this an if statement
#         return self.__result__
# 
# Path: gtool/core/utils/misc.py
# def striptoclassname(fullclassstring):
#     return '{0}'.format(fullclassstring)[7:-2].split('.')[-1]


from gtool.core.types.core import FunctionType
from gtool.core.utils.misc import striptoclassname
from cvsslib import cvss2, calculate_vector
import pyparsing as p
            if isinstance(_val, str):
                return _val

            try:
                if _val.isdynamic:
                    raise ValueError('Cvssv2 plugin cannot process %s because it contains a dynamic class' % name)
            except AttributeError:
                raise TypeError('Expected an attribute but got a %s' % type(_val))

            if _val.issingleton():
                _ret = '%s' % _val[0].raw()
            else:
                raise ValueError('Cvssv2 method plugin specified in user defined class %s '
                                 'only works on singleton attributes' % striptoclassname(type(self.targetobject)))

            return _ret

        attrid = (p.Literal('@') | p.Literal('!')).suppress() + p.Word(p.alphanums)

        attrexpr = attrid.setResultsName('attribute')

        parseresult = attrexpr.parseString(self.config)


        _attrname = parseresult.get('attribute', None)[0]

        if _attrname is None:
            raise ValueError('The configuration string provided to the Cvssv2 method '
                             'plugin in user defined class %s does not contain an '
                             'identifiable attribute. Please provide a configuration '

# Path: gtool/core/types/core.py
# class FunctionType(object):
#     """
#     Use as the base class for method plugins
#     """
# 
#     @abstractmethod
#     def __init__(self, obj, config=str(), defer=False):
#         """
#         Based class for method plugins
# 
#         :param obj: the DynamicType Object that the function will operate one
#         :param config: instructions on how the plugin should work. May be a list, dict or string
#         """
# 
#         self.targetobject = obj
#         self.config = config
#         self.computable = False
#         self.__result__ = None
#         self.__context__ = obj.__context__
#         self.__defer__ = defer
# 
#     # TODO implement an  attribute getter for method plugins
#     def __getname__(self, attrname, nativetypes = [], singletononly=False):
#         raise NotImplemented
# 
#     @abstractmethod
#     def compute(self):
#         """
#         processes any instructions in config, determine if required input exists.
#         If required input exists, sets self.computable to true, computes and stores result
#         :return:  None
#         """
#         # process config or do something
# 
#         if True: #determine if result can be computed
#             self.computable = True
# 
#         if self.computable:
#             self.__result__ = 'some result' #set result
#             raise NotImplemented('compute must be overridden')
#         else:
#             pass
#             # if not computable don't set result
#         #TODO look at returning True or False is compute completes
# 
#     @property
#     def context(self):
#         return self.__context__
# 
#     def result(self, force=False):
# 
#         if not self.__defer__ or force:
#             self.compute() #TODO look at making this an if statement
#             return self.__result__
#         else:
#             raise NotComputed('Computation deferred')
# 
#     def __repr__(self):
#         return '<%s>:()' % (self.__class__, self.config)
# 
#     def __str__(self):
#         self.compute() #TODO look at making this an if statement
#         return self.__result__
# 
# Path: gtool/core/utils/misc.py
# def striptoclassname(fullclassstring):
#     return '{0}'.format(fullclassstring)[7:-2].split('.')[-1]


# Path: gtool/plugins/cvssv2.py
from gtool.core.types.core import FunctionType
from gtool.core.utils.misc import striptoclassname
from cvsslib import cvss2, calculate_vector
import pyparsing as p

            if isinstance(_val, str):
                return _val

            try:
                if _val.isdynamic:
                    raise ValueError('Cvssv2 plugin cannot process %s because it contains a dynamic class' % name)
            except AttributeError:
                raise TypeError('Expected an attribute but got a %s' % type(_val))

            if _val.issingleton():
                _ret = '%s' % _val[0].raw()
            else:
                raise ValueError('Cvssv2 method plugin specified in user defined class %s '
                                 'only works on singleton attributes' % striptoclassname(type(self.targetobject)))

            return _ret

        attrid = (p.Literal('@') | p.Literal('!')).suppress() + p.Word(p.alphanums)

        attrexpr = attrid.setResultsName('attribute')

        parseresult = attrexpr.parseString(self.config)


        _attrname = parseresult.get('attribute', None)[0]

        if _attrname is None:
            raise ValueError('The configuration string provided to the Cvssv2 method '
                             'plugin in user defined class %s does not contain an '
                             'identifiable attribute. Please provide a configuration '

                             'string in the form of \'@attribute[#:#]\'' % striptoclassname(type(self.targetobject)))