예제 #1
0
 def gradient(self, gradient):
     ret = handle_object_placement(self.__gradient, gradient, Gradient)
     if ret:
         self.__gradient = ret
     else:
         try:
             loadChecker(type(self).__name__, gradient, ['colors', 'minValue', 'maxValue'], "gradient")
             self.__gradient = Gradient(gradient['colors'], gradient['minValue'], gradient['maxValue'])
         except MissingParameters as e:
             handler(type(self).__name__, 'Gradient {} is missing parameters: '
                                          '{}. Skipping.'
                     .format(gradient, e))
예제 #2
0
 def links(self, links):
     typeChecker(type(self).__name__, links, list, "links")
     if not handle_object_placement(self.__links, links, Link):
         self.__links = []
     entry = ""
     try:
         for entry in links:
             if "divider" in entry:
                 self.__links.append(Link(entry["divider"]))
             else:
                 self.__links.append(Link(entry['label'], entry['url']))
     except KeyError as e:
         handler(type(self).__name__, 'Link {} is missing parameters: '
                                      '{}. Unable to load.'
                 .format(entry, e))
예제 #3
0
 def versions(self, versions):
     ret = handle_object_placement(self.__versions, versions, Versions)
     if ret:
         self.__versions = ret
     else:
         typeChecker(type(self).__name__, versions, dict, "version")
         attack = UNSETVALUE
         if 'attack' in versions:
             attack = versions['attack']
         try:
             loadChecker(type(self).__name__, versions, ['layer', 'navigator'], "versions")
             self.__versions = Versions(versions['layer'], attack, versions['navigator'])
         except MissingParameters as e:
             handler(type(self).__name__, 'versions {} is missing parameters: '
                                          '{}. Skipping.'
                     .format(versions, e))
예제 #4
0
 def legendItems(self, legendItems):
     typeChecker(type(self).__name__, legendItems, list, "legendItems")
     self.__legendItems = []
     for entry in legendItems:
         ret = handle_object_placement(self.__legendItems, entry, LegendItem, list=True)
         if ret:
             self.__legendItems = ret
         else:
             try:
                 loadChecker(type(self).__name__, entry, ['label', 'color'], "legendItem")
                 temp = LegendItem(entry['label'], entry['color'])
                 self.__legendItems.append(temp)
             except MissingParameters as e:
                 handler(type(self).__name__, 'Legend Item {} is missing parameters: '
                                              '{}. Skipping.'
                         .format(entry, e))
예제 #5
0
 def metadata(self, metadata):
     typeChecker(type(self).__name__, metadata, list, "metadata")
     if not handle_object_placement(self.__metadata, metadata, Metadata):
         self.__metadata = []
     entry = ""
     try:
         for entry in metadata:
             if "divider" in entry:
                 self.__metadata.append(MetaDiv(entry["divider"]))
             else:
                 self.__metadata.append(
                     Metadata(entry['name'], entry['value']))
     except KeyError as e:
         handler(
             type(self).__name__, 'Metadata {} is missing parameters: '
             '{}. Unable to load.'.format(entry, e))
예제 #6
0
 def filters(self, filters):
     ret = handle_object_placement(self.__filters, filters, Filter)
     if ret:
         self.__filters = ret
     else:
         temp = Filter(self.domain)
         try:
             loadChecker(type(self).__name__, filters, ['platforms'], "filters")
             # force upgrade to v4
             if 'stages' in filters:
                 print('[Filters] - V3 Field "stages" detected. Upgrading Filters object to V4.')
             temp.platforms = filters['platforms']
             self.__filters = temp
         except MissingParameters as e:
             handler(type(self).__name__, 'Filters {} is missing parameters: '
                                          '{}. Skipping.'
                     .format(filters, e))
예제 #7
0
    def techniques(self, techniques):
        typeChecker(type(self).__name__, techniques, list, "techniques")
        self.__techniques = []

        for entry in techniques:
            ret = handle_object_placement(self.__techniques, entry, Technique, list=True)
            if ret:
                self.__techniques = ret
            else:
                try:
                    loadChecker(type(self).__name__, entry, ['techniqueID'], "technique")
                    temp = Technique(entry['techniqueID'])
                    temp._loader(entry)
                    self.__techniques.append(temp)
                except MissingParameters as e:
                    handler(type(self).__name__, 'Technique {} is missing parameters: '
                                                 '{}. Skipping.'
                            .format(entry, e))
예제 #8
0
 def metadata(self, metadata):
     typeChecker(type(self).__name__, metadata, list, "metadata")
     self.__metadata = []
     for entry in metadata:
         ret = handle_object_placement(self.__metadata, entry, Metadata, list=True)
         if ret:
             self.__metadata = ret
         else:
             try:
                 if "divider" in entry:
                     self.__metadata.append(MetaDiv(entry["divider"]))
                 else:
                     loadChecker(type(self).__name__, entry, ['name', 'value'], "metadata")
                     self.__metadata.append(Metadata(entry['name'], entry['value']))
             except MissingParameters as e:
                 handler(
                     type(self).__name__,
                     'Metadata {} is missing parameters: {}. Skipping.'.format(entry, e)
                 )
예제 #9
0
 def layout(self, layout):
     ret = handle_object_placement(self.__layout, layout, Layout)
     if ret:
         self.__layout = ret
     else:
         temp = Layout()
         if "layout" in layout:
             temp.layout = layout['layout']
         if "showName" in layout:
             temp.showName = layout['showName']
         if "showID" in layout:
             temp.showID = layout['showID']
         if "showAggregateScores" in layout:
             temp.showAggregateScores = layout['showAggregateScores']
         if "countUnscored" in layout:
             temp.countUnscored = layout['countUnscored']
         if 'aggregateFunction' in layout:
             temp.aggregateFunction = layout['aggregateFunction']
         self.__layout = temp