Changeset 3205

Show
Ignore:
Timestamp:
07/23/08 16:43:01 (5 years ago)
Author:
nopper
Message:

protocols attribute for protocols source

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/PacketManipulator/Backend/__init__.py

    r3198 r3205  
    22 
    33from umpa import protocols 
    4 from umpa.protocols.base import Protocol 
     4from umpa.protocols._ import Protocol 
    55 
    66# Globals UMPA protocols 
     
    1616def load_gprotocols(): 
    1717    path = protocols.__path__[0] 
     18    glob = [] 
    1819 
    1920    for fname in os.listdir(path): 
    20         if not fname.lower().endswith(".py"): 
     21        if not fname.lower().endswith(".py") or fname[0] == "_": 
    2122            continue 
    2223 
    2324        try: 
    2425            # We'll try to load this 
    25             module = __import__("%s.%s" % (protocols.__name__, 
    26                                 fname.replace(".py", ""))) 
     26            module = __import__( 
     27                "%s.%s" % (protocols.__name__, fname.replace(".py", "")), 
     28                fromlist=[protocols] 
     29            ) 
     30 
     31            glob.extend( 
     32                filter(lambda x: not isinstance(x, Protocol), module.protocols) 
     33            ) 
     34 
    2735        except Exception, err: 
    2836            print "Ignoring exception", err 
    2937 
    30     # This is a dirty hack becouse we could have multiple 
    31     # objects that derives protocols but aren't protocols 
    32     # like private classes. 
    33     return Protocol.__subclasses__() 
     38    return glob 
    3439 
    3540def get_protocols(): 
     
    7176    return field.__doc__ 
    7277 
     78def get_flag_keys(flag_inst): 
     79    for key in flag_inst._ordered_fields: 
     80        yield key 
     81 
    7382gprotos = load_gprotocols()