connectordb/_connectordb.py
def import_users(self, directory):
        """Imports version 1 of ConnectorDB export. These exports can be generated
        by running user.export(dir), possibly on multiple users.
        """
        exportInfoFile = os.path.join(directory, "connectordb.json")
        with open(exportInfoFile) as f:
            exportInfo = json.load(f)
        if exportInfo["Version"] != 1:
            raise ValueError("Not able to read this import version")

        # Now we list all the user directories
        for name in os.listdir(directory):
            udir = os.path.join(directory, name)
            if os.path.isdir(udir):
                # Let's read in the user
                with open(os.path.join(udir, "user.json")) as f:
                    usrdata = json.load(f)

                u = self(usrdata["name"])
                if u.exists():
                    raise ValueError("The user " + name + " already exists")

                del usrdata["name"]
                u.create(password=name, **usrdata)

                # Now read all of the user's devices
                for dname in os.listdir(udir):
                    ddir = os.path.join(udir, dname)
                    if os.path.isdir(ddir):
                        u.import_device(ddir)
def import_users(self, directory):
        """Imports version 1 of ConnectorDB export. These exports can be generated
        by running user.export(dir), possibly on multiple users.
        """
        exportInfoFile = os.path.join(directory, "connectordb.json")
        with open(exportInfoFile) as f:
            exportInfo = json.load(f)
        if exportInfo["Version"] != 1:
            raise ValueError("Not able to read this import version")

        # Now we list all the user directories
        for name in os.listdir(directory):
            udir = os.path.join(directory, name)
            if os.path.isdir(udir):
                # Let's read in the user
                with open(os.path.join(udir, "user.json")) as f:
                    usrdata = json.load(f)

                u = self(usrdata["name"])
                if u.exists():
                    raise ValueError("The user " + name + " already exists")

                del usrdata["name"]
                u.create(password=name, **usrdata)

                # Now read all of the user's devices
                for dname in os.listdir(udir):
                    ddir = os.path.join(udir, dname)
                    if os.path.isdir(ddir):
                        u.import_device(ddir)
Imports version 1 of ConnectorDB export. These exports can be generated
        by running user.export(dir), possibly on multiple users.