FileReader and FileWriter for 2 classes

Hello,

I have used the [ModuleName] FileReader and [ModuleName] FileWriter before to allow drag and drop of a file with a specific extension into my module. However, I cannot figure out how to add more than one file extension. Do you have any example of this?

The code below shows a simple FileReader, but because the name of the class matches the name of the module, I cannot add more than one extension.

class MyModuleFileReader:

    def __init__(self, parent):
        self.parent = parent

    def description(self):
        return 'Specific type'

    def fileType(self):
        return 'Specific'

    def extensions(self):
        return ['Specific (*.spc)']

    def canLoadFile(self, filePath):
        return filePath.endswith('.spc')

    def load(self, properties):
        try:
            pass
        except Exception as e:
            logging.error('Failed to load file: ' + str(e))
            import traceback
            traceback.print_exc()
            return False

        return True

You should be able to use a format like this:

1 Like

Oh this allows me to add more than one extension for the same type of file. But, is it possible to also add more than one file type?

I believe it follows the conventions described here:

1 Like