connectordb/_user.py
def import_device(self, directory):
        """Imports a device from the given directory. You export the device
        by using device.export()

        There are two special cases: user and meta devices.
        If the device name is meta, import_device will not do anything.
        If the device name is "user", import_device will overwrite the user device
        even if it exists already.
        """

        # read the device's info
        with open(os.path.join(directory, "device.json"), "r") as f:
            ddata = json.load(f)

        d = self[ddata["name"]]

        dname = ddata["name"]
        del ddata["name"]

        if dname == "meta":
            return
        elif dname == "user":
            d.set(ddata)
        elif d.exists():
            raise ValueError("The device " + d.name + " already exists")
        else:
            d.create(**ddata)

        # Now import all of the streams
        for name in os.listdir(directory):
            sdir = os.path.join(directory, name)
            if os.path.isdir(sdir):
                d.import_stream(sdir)
def import_device(self, directory):
        """Imports a device from the given directory. You export the device
        by using device.export()

        There are two special cases: user and meta devices.
        If the device name is meta, import_device will not do anything.
        If the device name is "user", import_device will overwrite the user device
        even if it exists already.
        """

        # read the device's info
        with open(os.path.join(directory, "device.json"), "r") as f:
            ddata = json.load(f)

        d = self[ddata["name"]]

        dname = ddata["name"]
        del ddata["name"]

        if dname == "meta":
            return
        elif dname == "user":
            d.set(ddata)
        elif d.exists():
            raise ValueError("The device " + d.name + " already exists")
        else:
            d.create(**ddata)

        # Now import all of the streams
        for name in os.listdir(directory):
            sdir = os.path.join(directory, name)
            if os.path.isdir(sdir):
                d.import_stream(sdir)
Imports a device from the given directory. You export the device
        by using device.export()

        There are two special cases: user and meta devices.
        If the device name is meta, import_device will not do anything.
        If the device name is "user", import_device will overwrite the user device
        even if it exists already.