def import_device(self, directory):
<EOL>with open(os.path.join(directory, "<STR_LIT>"), "<STR_LIT:r>") as f:<EOL><INDENT>ddata = json.load(f)<EOL><DEDENT>d = self[ddata["<STR_LIT:name>"]]<EOL>dname = ddata["<STR_LIT:name>"]<EOL>del ddata["<STR_LIT:name>"]<EOL>if dname == "<STR_LIT>":<EOL><INDENT>return<EOL><DEDENT>elif dname == "<STR_LIT:user>":<EOL><INDENT>d.set(ddata)<EOL><DEDENT>elif d.exists():<EOL><INDENT>raise ValueError("<STR_LIT>" + d.name + "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>d.create(**ddata)<EOL><DEDENT>for name in os.listdir(directory):<EOL><INDENT>sdir = os.path.join(directory, name)<EOL>if os.path.isdir(sdir):<EOL><INDENT>d.import_stream(sdir)<EOL><DEDENT><DEDENT>
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.