Package SPyRO :: Module exec_code
[hide private]
[frames] | no frames]

Source Code for Module SPyRO.exec_code

 1  #coding: utf8; 
 2  ############################################################################ 
 3  #                                                                          # 
 4  #    This file 'exec_code.py'                                              # 
 5  #    is part of 'SPyRO: Simple Python Remote Objects'                      # 
 6  #    Copyright (C) 2004-2005 by Eric Sadit T�lez Avila                     # 
 7  #    Copyright (C) 2005-2006 by Eric Sadit T�lez Avila                     # 
 8  #    sadit@lsc.fie.umich.mx or donsadit@gmail.com                          # 
 9  #                                                                          # 
10  #    This program is free software; you can redistribute it and#or modify  # 
11  #    it under the terms of the GNU General Public License as published by  # 
12  #    the Free Software Foundation; either version 2 of the License, or     # 
13  #    (at your option) any later version.                                   # 
14  #                                                                          # 
15  #    This program is distributed in the hope that it will be useful,       # 
16  #    but WITHOUT ANY WARRANTY; without even the implied warranty of        # 
17  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         # 
18  #    GNU General Public License for more details.                          # 
19  #                                                                          # 
20  #    You should have received a copy of the GNU General Public License     # 
21  #    along with this program; if not, write to the                         # 
22  #    Free Software Foundation, Inc.,                                       # 
23  #    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             # 
24  ############################################################################ 
25   
26 -def exec_code(filename, gvars, lvars, data):
27 """ Execute the code inside |filename| with the globalvars |gvars| y 28 |lvars.__dict__|, then lvars will become the object containing 29 localvariables of the script |filename| as object attributes 30 """ 31 code = compile(data + "\n", filename, 'exec') 32 exec code in lvars.__dict__, lvars.__dict__
33