Ejemplo n.º 1
0
    def writeDataDescriptor(self):
        if not self.can_write:
            return

        self.computeDataPatterns()

        jsonData = {
            "arguments_order": self.argOrder,
            "type": self.types,
            "arguments": self.arguments,
            "metadata": self.metadata,
            "data": []
        }

        # Add sections
        for key, value in iteritems(self.sections):
            jsonData[key] = value

        # Add data
        for key, value in iteritems(self.data):
            jsonData['data'].append(value)

        filePathToWrite = os.path.join(self.__root, "index.json")
        with open(filePathToWrite, "w") as fileToWrite:
            fileToWrite.write(json.dumps(jsonData))
Ejemplo n.º 2
0
    def writeDataDescriptor(self):
        if not self.can_write:
            return

        self.computeDataPatterns()

        jsonData = {
            "arguments_order" : self.argOrder,
            "type"            : self.types,
            "arguments"       : self.arguments,
            "metadata"        : self.metadata,
            "data"            : []
        }

        # Add sections
        for key, value in iteritems(self.sections):
            jsonData[key] = value

        # Add data
        for key, value in iteritems(self.data):
            jsonData['data'].append(value)

        filePathToWrite = os.path.join(self.__root, "index.json")
        with open(filePathToWrite, "w") as fileToWrite:
            fileToWrite.write(json.dumps(jsonData))
Ejemplo n.º 3
0
    def __init__(self, location, camera_data, metadata={}, sections={}):
        self.dataHandler = DataHandler(location)
        self.cameraDescription = camera_data
        self.camera = None
        self.imageCapture = CaptureRenderWindow()

        for key, value in iteritems(metadata):
            self.dataHandler.addMetaData(key, value)

        for key, value in iteritems(sections):
            self.dataHandler.addSection(key, value)
Ejemplo n.º 4
0
    def __init__(self, location, camera_data, metadata={}, sections={}):
        self.dataHandler = DataHandler(location)
        self.cameraDescription = camera_data
        self.camera = None
        self.imageCapture = CaptureRenderWindow()

        for key, value in iteritems(metadata):
            self.dataHandler.addMetaData(key, value)

        for key, value in iteritems(sections):
            self.dataHandler.addSection(key, value)
Ejemplo n.º 5
0
    def __init__(self, directory):
        self.basePath = directory
        self.layers = []
        self.data = []
        self.imageReader = vtkPNGReader()

        # Load JSON metadata
        with open(os.path.join(directory, "config.json"), "r") as f:
            self.config = json.load(f)
            self.nbLayers = len(self.config['scene'])
            while len(self.layers) < self.nbLayers:
                self.layers.append({})

        with open(os.path.join(directory, "index.json"), "r") as f:
            self.info = json.load(f)

        with open(os.path.join(directory, "offset.json"), "r") as f:
            offsets = json.load(f)
            for key, value in iteritems(offsets):
                meta = key.split('|')
                if len(meta) == 2:
                    self.layers[int(meta[0])][meta[1]] = value
                elif meta[1] in self.layers[int(meta[0])]:
                    self.layers[int(meta[0])][meta[1]][int(meta[2])] = value
                else:
                    self.layers[int(meta[0])][meta[1]] = [value, value, value]

        self.composite = CompositeJSON(len(self.layers))
Ejemplo n.º 6
0
    def getDataAbsoluteFilePath(self, name, createDirectories=True):
        dataPattern = self.data[name]['pattern']
        if '{pattern}' in dataPattern:
            if len(self.basePattern) == 0:
                dataPattern = dataPattern.replace('{pattern}/',
                                                  self.basePattern).replace(
                                                      '{pattern}',
                                                      self.basePattern)
                self.data[name]['pattern'] = dataPattern
            else:
                dataPattern = dataPattern.replace('{pattern}',
                                                  self.basePattern)
                self.data[name]['pattern'] = dataPattern

        keyValuePair = {}
        for key, value in iteritems(self.current):
            keyValuePair[key] = self.arguments[key]['values'][value]

        fullpath = os.path.join(self.__root,
                                dataPattern.format(**keyValuePair))

        if createDirectories and self.can_write:
            if not os.path.exists(os.path.dirname(fullpath)):
                os.makedirs(os.path.dirname(fullpath))

        return fullpath
Ejemplo n.º 7
0
    def registerData(self, **kwargs):
        """
        name, type, mimeType, fileName, dependencies
        """
        newData = { 'metadata': {} }
        argName = kwargs['name']
        for key, value in iteritems(kwargs):
            if key == 'fileName':
                if 'rootFile' in kwargs and kwargs['rootFile']:
                    newData['pattern'] = '{pattern}/%s' % value
                else:
                    newData['pattern'] = '{pattern}%s' % value
            else:
                newData[key] = value

        self.data[argName] = newData
Ejemplo n.º 8
0
    def registerData(self, **kwargs):
        """
        name, type, mimeType, fileName, dependencies
        """
        newData = {'metadata': {}}
        argName = kwargs['name']
        for key, value in iteritems(kwargs):
            if key == 'fileName':
                if 'rootFile' in kwargs and kwargs['rootFile']:
                    newData['pattern'] = '{pattern}/%s' % value
                else:
                    newData['pattern'] = '{pattern}%s' % value
            else:
                newData[key] = value

        self.data[argName] = newData
Ejemplo n.º 9
0
    def getDataAbsoluteFilePath(self, name, createDirectories=True):
        dataPattern = self.data[name]['pattern']
        if '{pattern}' in dataPattern:
            if len(self.basePattern) == 0:
                dataPattern = dataPattern.replace('{pattern}/', self.basePattern).replace('{pattern}', self.basePattern)
                self.data[name]['pattern'] = dataPattern
            else:
                dataPattern = dataPattern.replace('{pattern}', self.basePattern)
                self.data[name]['pattern'] = dataPattern

        keyValuePair = {}
        for key, value in iteritems(self.current):
            keyValuePair[key] = self.arguments[key]['values'][value]

        fullpath = os.path.join(self.__root, dataPattern.format(**keyValuePair))

        if createDirectories and self.can_write:
            if not os.path.exists(os.path.dirname(fullpath)):
                os.makedirs(os.path.dirname(fullpath))

        return fullpath
Ejemplo n.º 10
0
    def registerArgument(self, **kwargs):
        """
        We expect the following set of arguments
         - priority
         - name
         - label (optional)
         - values
         - uiType
         - defaultIdx
        """
        newArgument = {}
        argName = kwargs['name']
        self.argOrder.append(argName)
        for key, value in iteritems(kwargs):
            if key == 'priority':
                self.priority.append([argName, value])
            elif key == 'values':
                self.realValues[argName] = value
                newArgument[key] = [ "{value}".format(value=x) for x in value ]
            else:
                newArgument[key] = value

        self.arguments[argName] = newArgument
Ejemplo n.º 11
0
    def registerArgument(self, **kwargs):
        """
        We expect the following set of arguments
         - priority
         - name
         - label (optional)
         - values
         - uiType
         - defaultIdx
        """
        newArgument = {}
        argName = kwargs['name']
        self.argOrder.append(argName)
        for key, value in iteritems(kwargs):
            if key == 'priority':
                self.priority.append([argName, value])
            elif key == 'values':
                self.realValues[argName] = value
                newArgument[key] = ["{value}".format(value=x) for x in value]
            else:
                newArgument[key] = value

        self.arguments[argName] = newArgument
Ejemplo n.º 12
0
 def setArguments(self, **kwargs):
     """
     Update the arguments index
     """
     for key, value in iteritems(kwargs):
         self.current[key] = value
Ejemplo n.º 13
0
 def setArguments(self, **kwargs):
     """
     Update the arguments index
     """
     for key, value in iteritems(kwargs):
         self.current[key] = value