Exemplo n.º 1
0
 def iter_devices(self):
     groups = walklevel(os.path.join(base, "devices"), level=1)
     for group in list(groups)[1:]:
         mod_name = os.path.basename(group[0])
         for f in group[2]:
             root, ext = os.path.splitext(f)
             if ext != ".py" or root == "__init__": continue
             mod = import_class("snmp_orm.devices.%s.%s" % (mod_name, root))
             device = getattr(mod, "Device", None)
             if device is None: continue
             yield device
Exemplo n.º 2
0
    def iter_devices(self):
        tmp_groups = [walklevel(parent_dir, level=1) for parent_dir in base]
        groups = []

        for i in tmp_groups:
            groups.extend(list(i)[1:])


        for group in groups:
            mod_path = group[0]
            mod_name = os.path.basename(mod_path)
            for f in group[2]:
                root, ext = os.path.splitext(f)
                if ext != ".py" or root == "__init__": continue
                mod = import_class("%s.%s" %(mod_name, root), path=mod_path)
                device = getattr(mod, "Device", None)
                if device is None: continue

                yield device