Changeset 342


Ignore:
Timestamp:
10/23/09 18:22:26 (10 years ago)
Author:
eliedebrauwer
Message:

Ticket #127. Fix by octavio, PEP-8 code cleanup, identation fix fixes[s:trac, t:127]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/objects/__init__.py

    r310 r342  
    2828        for class_name in module.__all__: 
    2929            result[class_name] = getattr (module,class_name) 
    30              
     30 
    3131    return result 
    3232 
    3333def createObject(info, extra = {}): 
    34         """Called when we need to get an actual object.  
    35            @type info: dict 
    36            @param info: stores information about the object we want to create 
    37            @type extra: dict 
    38            @param extra: stores additionally required attributes, like agent layer, engine etc. 
    39            @return: the object""" 
    40         # First, we try to get the type and ID, which every game_obj needs. 
    41         try: 
    42             obj_type = info.pop('type') 
    43             ID = info.pop('id') 
    44         except KeyError: 
    45             sys.stderr.write("Error: Game object missing type or id.") 
    46             sys.exit(False) 
    47          
    48         # add the extra info 
    49         for key, val in extra.items(): 
    50             info[key] = val 
     34    """Called when we need to get an actual object. 
     35    @type info: dict 
     36    @param info: stores information about the object we want to create 
     37    @type extra: dict 
     38    @param extra: stores additionally required attributes, like agent layer, engine etc. 
     39    @return: the object""" 
     40    # First, we try to get the type and ID, which every game_obj needs. 
     41    try: 
     42        obj_type = info.pop('type') 
     43        ID = info.pop('id') 
     44    except KeyError: 
     45        sys.stderr.write("Error: Game object missing type or id.") 
     46        sys.exit(False) 
    5147 
    52         # this is for testing purposes 
    53         return getAllObjects()[obj_type](ID, **info) 
     48    # add the extra info 
     49    for key, val in extra.items(): 
     50        info[key] = val 
     51 
     52    # this is for testing purposes 
     53    return getAllObjects()[obj_type](ID, **info) 
Note: See TracChangeset for help on using the changeset viewer.