brightway2-ui / bw2ui /

# -*- coding: utf-8 -*-
from brightway2 import databases, methods, Database, Method, config, reset_meta
from import EcospoldImporter, EcospoldImpactAssessmentImporter
from errors import UnknownAction

class Controller(object):
    def database_or_method(self, name):
        if name in databases:
            return (name, "database")
        elif name in methods:
            return (name, "method")
        elif tuple(name.split(":")) in methods:
            return (tuple(name.split(":")), "method")
            raise ValueError

    def dispatch(self, **kwargs):
        if kwargs.get('list', None):
            return self.list(kwargs)
        elif kwargs.get('details', None):
            return self.details(kwargs)
        elif kwargs.get('remove', None):
            return self.remove(kwargs)
        elif kwargs.get('import', None) and kwargs.get('database', None):
            return self.import_database(kwargs)
        elif kwargs.get('import', None) and kwargs.get('method', None):
            return self.import_method(kwargs)
        raise UnknownAction("No suitable action found")

    def list(self, kwargs):
        if kwargs.get('databases', None):
            return databases.list
            return methods.list

    def details(self, kwargs):
        name, kind = self.database_or_method(kwargs.get('<name>', None))
        if kind == "database":
            return databases[name]
            return methods[name]

    def remove(self, kwargs):
        name, kind = self.database_or_method(kwargs.get('<name>', None))
        if kind == "database":

    def import_database(self, path):

    def import_method(self, path):

    def setup_directory(self, path):
        config.dir = path
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.