| 8 | |
| 9 | |
| 10 | class ProtocolLoader: |
| 11 | def load_protocol(self, protocol_path): |
| 12 | loader = SourceFileLoader("protocol", protocol_path) |
| 13 | protocol = ModuleType(loader.name) |
| 14 | loader.exec_module(protocol) |
| 15 | return protocol |
| 16 | |
| 17 | def get_protocols(self): |
| 18 | protocols = {} |
| 19 | |
| 20 | proto_path = path_join(dirname(nxc.__file__), "protocols") |
| 21 | for protocol in listdir(proto_path): |
| 22 | if protocol[-3:] == ".py" and protocol[:-3] != "__init__": |
| 23 | protocol_path = path_join(proto_path, protocol) |
| 24 | protocol_name = protocol[:-3] |
| 25 | |
| 26 | protocols[protocol_name] = {"path": protocol_path} |
| 27 | |
| 28 | db_file_path = path_join(proto_path, protocol_name, "database.py") |
| 29 | db_nav_path = path_join(proto_path, protocol_name, "db_navigator.py") |
| 30 | protocol_args_path = path_join(proto_path, protocol_name, "proto_args.py") |
| 31 | if exists(db_file_path): |
| 32 | protocols[protocol_name]["dbpath"] = db_file_path |
| 33 | if exists(db_nav_path): |
| 34 | protocols[protocol_name]["nvpath"] = db_nav_path |
| 35 | if exists(protocol_args_path): |
| 36 | protocols[protocol_name]["argspath"] = protocol_args_path |
| 37 | return protocols |
no outgoing calls