55from os .path import dirname , exists
66
77import nxc
8- from nxc .paths import NXC_PATH
98
109
1110class ProtocolLoader :
@@ -17,27 +16,22 @@ def load_protocol(self, protocol_path):
1716
1817 def get_protocols (self ):
1918 protocols = {}
20- protocol_paths = [
21- path_join (dirname (nxc .__file__ ), "protocols" ),
22- path_join (NXC_PATH , "protocols" ),
23- ]
24-
25- for path in protocol_paths :
26- for protocol in listdir (path ):
27- if protocol [- 3 :] == ".py" and protocol [:- 3 ] != "__init__" :
28- protocol_path = path_join (path , protocol )
29- protocol_name = protocol [:- 3 ]
30-
31- protocols [protocol_name ] = {"path" : protocol_path }
32-
33- db_file_path = path_join (path , protocol_name , "database.py" )
34- db_nav_path = path_join (path , protocol_name , "db_navigator.py" )
35- protocol_args_path = path_join (path , protocol_name , "proto_args.py" )
36- if exists (db_file_path ):
37- protocols [protocol_name ]["dbpath" ] = db_file_path
38- if exists (db_nav_path ):
39- protocols [protocol_name ]["nvpath" ] = db_nav_path
40- if exists (protocol_args_path ):
41- protocols [protocol_name ]["argspath" ] = protocol_args_path
4219
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
4337 return protocols
0 commit comments