KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/22697/root/usr/lib64/python2.4/site-packages/rhpl/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/22697/root/usr/lib64/python2.4/site-packages/rhpl/genModule.py
#
# genModule.py: make python modules on the fly
#
# Peter Jones <pjones@redhat.com>
#
# Copyright 2005 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
def create(mname, attrs):
    import imp

    m = imp.new_module(mname)
    del imp
    for k,v in attrs.items():
        setattr(m, k, v)
    return m

def install(mname, m):
    import sys
    sys.modules[mname] = m
    del sys

def generate(parent, mname, attrs):
    m = create(mname, attrs)
    # if parent isn't in sys.modules, this won't work...
    install(parent + '.' + mname, m)
    return m
    
# this is just a set of random examples, really
if __name__ == '__main__':
    m = create('a', {'b': lambda x: x})

    import sys
    sys.modules['a'] = m

    print m.b(1)

    import a
    print a.b(2)

    def zoink(x):
        print x

    generate('__main__', 'bar', {'baz': zoink})
    from __main__.bar import baz
    baz(3)

Anon7 - 2021