Exemplo n.º 1
0
    def __init__(self,
                 statistics_names=None,
                 statistics_handlers=None,
                 _use_identity_line=True,
                 use_buffer=True,
                 statistics_classes=None):
        '''
        Constructor
        '''
        self.__statistics_classes__ = statistics_classes \
                                        if statistics_classes else []
        self.__statistics_objects__ = []
        self.__statistics_handlers__ = statistics_handlers
        self.__use_identity_line__ = _use_identity_line
        self.__use_buffer__ = nvl(use_buffer, True)
        global USE_IDENTITY_LINE
        USE_IDENTITY_LINE = self.__use_identity_line__

        #if statistics_names is a string object which included
        #names of statistics separater by comma we change it into list of names
        if not statistics_names == None:
            if isinstance(statistics_names, str):
                statistics_names = expand_to_real_statistics_names(
                    statistics_names)

            for type_or_name in statistics_names:
                #if type_or_name is a string
                if isinstance(type_or_name, str):
                    type_or_name = create_class_object_with_suffix(
                        'hra_math.statistics.statistics', type_or_name,
                        'Statistic')
                #if type_or_name is a class type
                if isinstance(type_or_name, type):
                    self.__statistics_classes__.append(type_or_name)
Exemplo n.º 2
0
    def addFilter(self, _filter_object_or_handler_or_names):
        """
        filter entity could be passed as filter object itself, handler method
        or a name of filter class
        """
        arg_count = get_method_arguments_count(
            _filter_object_or_handler_or_names)  # @IgnorePep8

        # filter as a string
        if isinstance(_filter_object_or_handler_or_names, str):
            for filter_name in expand_to_real_filters_names(
                    _filter_object_or_handler_or_names):
                if filter_name == None:
                    return
                _module = get_package_for_filter(filter_name)
                filter_object = create_class_object_with_suffix(
                    get_package_for_filter(filter_name),
                    filter_name,
                    _suffix='Filter')
                filter_object = filter_object(_shift=self.__shift__)
                filter_object.arg_count = -1
                self.__filters__.append(filter_object)
        # filter as a function
        elif arg_count > -1:
            filter_method = _filter_object_or_handler_or_names
            filter_method.arg_count = arg_count
            self.__filters__.append(filter_method)
        # filter as an object
        else:
            filter_object = _filter_object_or_handler_or_names
            filter_object.arg_count = -1
            self.__filters__.append(filter_object)
Exemplo n.º 3
0
    def addFilter(self, _filter_object_or_handler_or_names):
        """
        filter entity could be passed as filter object itself, handler method
        or a name of filter class
        """
        arg_count = get_method_arguments_count(_filter_object_or_handler_or_names) # @IgnorePep8

        # filter as a string
        if isinstance(_filter_object_or_handler_or_names, str):
            for filter_name in expand_to_real_filters_names(
                                        _filter_object_or_handler_or_names):
                if filter_name == None:
                    return
                _module = get_package_for_filter(filter_name)
                filter_object = create_class_object_with_suffix(
                                    get_package_for_filter(filter_name),
                                    filter_name,
                                    _suffix='Filter')
                filter_object = filter_object(_shift=self.__shift__)
                filter_object.arg_count = -1
                self.__filters__.append(filter_object)
        # filter as a function
        elif arg_count > -1:
            filter_method = _filter_object_or_handler_or_names
            filter_method.arg_count = arg_count
            self.__filters__.append(filter_method)
        # filter as an object
        else:
            filter_object = _filter_object_or_handler_or_names
            filter_object.arg_count = -1
            self.__filters__.append(filter_object)
Exemplo n.º 4
0
    def __init__(self, statistics_names=None, statistics_handlers=None,
                 _use_identity_line=True, use_buffer=True,
                 statistics_classes=None):
        '''
        Constructor
        '''
        self.__statistics_classes__ = statistics_classes \
                                        if statistics_classes else []
        self.__statistics_objects__ = []
        self.__statistics_handlers__ = statistics_handlers
        self.__use_identity_line__ = _use_identity_line
        self.__use_buffer__ = nvl(use_buffer, True)
        global USE_IDENTITY_LINE
        USE_IDENTITY_LINE = self.__use_identity_line__

        #if statistics_names is a string object which included
        #names of statistics separater by comma we change it into list of names
        if not statistics_names == None:
            if isinstance(statistics_names, str):
                statistics_names = expand_to_real_statistics_names(
                                                            statistics_names)

            for type_or_name in statistics_names:
                #if type_or_name is a string
                if isinstance(type_or_name, str):
                    type_or_name = create_class_object_with_suffix(
                                            'hra_math.statistics.statistics',
                                            type_or_name, 'Statistic')
                #if type_or_name is a class type
                if isinstance(type_or_name, type):
                    self.__statistics_classes__.append(type_or_name)
Exemplo n.º 5
0
    def __init__(self, summary_statistics_names=None,
                 summary_statistics_classes=None):
        '''
        Constructor
        '''
        self.__summary_statistics_objects__ = []
        if not summary_statistics_classes == None:
            for summary_statistic_class in summary_statistics_classes:
                self.__summary_statistics_objects__.append(
                                                summary_statistic_class())
        if not summary_statistics_names == None:

            #if summary_statistics_names is a string object which
            #included names of statistics separater by comma we change it into
            #list of names
            if isinstance(summary_statistics_names, str):
                summary_statistics_names = \
                    expand_to_real_summary_statistics_names(
                                                    summary_statistics_names)

            for type_or_name in summary_statistics_names:
                #if type_or_name is a string
                if isinstance(type_or_name, str):
                    type_or_name = create_class_object_with_suffix(
                                   'hra_math.statistics.summary_statistics',
                                   type_or_name, 'SummaryStatistic')
                if isinstance(type_or_name, __Inner__):
                    continue
                #if type_or_name is a class type
                if isinstance(type_or_name, type):
                    summary_statistic_object = type_or_name.__new__(type_or_name) # @IgnorePep8
                    summary_statistic_object.__init__()
                    self.__summary_statistics_objects__.append(
                                                    summary_statistic_object)
Exemplo n.º 6
0
    def __init__(self,
                 summary_statistics_names=None,
                 summary_statistics_classes=None):
        '''
        Constructor
        '''
        self.__summary_statistics_objects__ = []
        if not summary_statistics_classes == None:
            for summary_statistic_class in summary_statistics_classes:
                self.__summary_statistics_objects__.append(
                    summary_statistic_class())
        if not summary_statistics_names == None:

            #if summary_statistics_names is a string object which
            #included names of statistics separater by comma we change it into
            #list of names
            if isinstance(summary_statistics_names, str):
                summary_statistics_names = \
                    expand_to_real_summary_statistics_names(
                                                    summary_statistics_names)

            for type_or_name in summary_statistics_names:
                #if type_or_name is a string
                if isinstance(type_or_name, str):
                    type_or_name = create_class_object_with_suffix(
                        'hra_math.statistics.summary_statistics', type_or_name,
                        'SummaryStatistic')
                if isinstance(type_or_name, __Inner__):
                    continue
                #if type_or_name is a class type
                if isinstance(type_or_name, type):
                    summary_statistic_object = type_or_name.__new__(
                        type_or_name)  # @IgnorePep8
                    summary_statistic_object.__init__()
                    self.__summary_statistics_objects__.append(
                        summary_statistic_object)