How to use the bw2io.extractors.Ecospold2DataExtractor function in bw2io

To help you get started, we’ve selected a few bw2io examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LCA-ActivityBrowser / activity-browser / activity_browser / app / ui / wizards / db_import_wizard.py View on Github external
valid = False
        if exists:
            base, ext = os.path.splitext(self.path.text())
            valid = True if ext.lower() == ".bw2package" else False
            if not valid:
                import_signals.import_failure.emit(
                    ("Invalid extension", "Expecting 'local' import database file to have '.bw2package' extension")
                )
        self.complete = all([exists, valid])
        self.completeChanged.emit()

    def isComplete(self):
        return self.complete


class ActivityBrowserExtractor(Ecospold2DataExtractor):
    """
    - modified from bw2io
    - qt and python multiprocessing don't like each other on windows
    - need to display progress in gui
    """
    @classmethod
    def extract(cls, dirpath, db_name, *args, **kwargs):
        assert os.path.exists(dirpath), dirpath
        if os.path.isdir(dirpath):
            filelist = [filename for filename in os.listdir(dirpath)
                        if os.path.isfile(os.path.join(dirpath, filename))
                        and filename.split(".")[-1].lower() == "spold"
                        ]
        elif os.path.isfile(dirpath):
            filelist = [dirpath]
        else: