On Monday 15 November 2010 21:40:17 Okko Willeboordse wrote:
> Hello,
> 
hi,

> We have a tool that runs scripts created by users.
> 
> Scripts are run using eval in some namespace with entities in it such
> that users can use a convenient syntax.
> 
> Following illustrates this;
> def function(i):
>   print i
> 
> scriptglobals = {}
> scriptglobals['okko'] = function
> 
> script_created_by_user = \
> '''
> i = 5
> okko(i)
> '''
> 
> eval(compile(script_created_by_user, 'file name', 'exec'),
> scriptglobals)
> 
> 
> Now we want to lint the user created script.
> 
> Running lint with the script obviously fails because the namespace is
> missing.
> 
> 
> Any ideas how we can pull this off?

I don't know if there is a "classical" way to do it;
but maybe you could overwrite lint.Pylinter.get_astng to return 
logilab.astng.builder.ASTNGBuilder.string_build(script_created_by_user)

But that's only half of the job; you will need to use the --init-hook
option to activate the scriptglobals

hope, that helps ;)

-- 

Emile Anclin <[email protected]>
http://www.logilab.fr/   http://www.logilab.org/ 
Informatique scientifique & et gestion de connaissances
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to