/usr/share/pyshared/twill/namespaces.py is in python-twill 0.9-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | """
Global and local dictionaries, + initialization/utility functions.
"""
global_dict = {}
def init_global_dict():
"""
Initialize global dictionary with twill commands.
This must be done after all the other modules are loaded, so that all
of the commands are already defined.
"""
exec "from twill.commands import *" in global_dict
import twill.commands
command_list = twill.commands.__all__
import twill.parse
twill.parse.command_list.extend(command_list)
# local dictionaries.
_local_dict_stack = []
###
# local dictionary management functions.
def new_local_dict():
"""
Initialize a new local dictionary & push it onto the stack.
"""
d = {}
_local_dict_stack.append(d)
return d
def pop_local_dict():
"""
Get rid of the current local dictionary.
"""
_local_dict_stack.pop()
###
def get_twill_glocals():
"""
Return global dict & current local dictionary.
"""
global global_dict, _local_dict_stack
assert global_dict is not None, "must initialize global namespace first!"
if len(_local_dict_stack) == 0:
new_local_dict()
return global_dict, _local_dict_stack[-1]
###
|