~ubuntu-branches/debian/stretch/phatch/stretch

« back to all changes in this revision

Viewing changes to tests/test_suite/phatchtools.py

  • Committer: Bazaar Package Importer
  • Author(s): Stani M
  • Date: 2009-10-15 18:22:54 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20091015182254-fu9tucj6k2zk8095
Tags: 0.2.4-1
* Upstream bugfix release (Closes LP: #450693, #449404, #452261,
  #448993)
  
* debian/control: added for phatch: Replaces: phatch-cli (<= 0.2.3-2)
  to fix file overwrite errors (LP: #450800)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
# Test suite modules
29
29
import utils
30
30
import config
 
31
import defaults
 
32
import gettext
 
33
gettext.install('_')
31
34
 
32
35
# Phatch modules
33
36
from lib.safe import eval_safe
35
38
#################################
36
39
#   Building Actions Hashtable  #
37
40
#################################
 
41
__DEFAULTS = {}
 
42
def get_defaults():
 
43
    """Get actions custom defaults
 
44
    Returns a dictionary that maps action names to defaults"""
 
45
    global __DEFAULTS
 
46
    if __DEFAULTS:
 
47
        return __DEFAULTS
 
48
    __DEFAULTS = dict(
 
49
        (action, getattr(defaults, action))
 
50
        for action in dir(defaults)
 
51
        if not action.startswith('__')
 
52
    )
 
53
    return __DEFAULTS
 
54
 
38
55
 
39
56
__ACTIONS = {}
40
57
def get_actions():
45
62
        return __ACTIONS
46
63
    action_names = [utils.file_name(action_file) for action_file in
47
64
            glob.glob(os.path.join(config.PHATCH_ACTIONS_PATH, '*.py'))]
 
65
    default_values = get_defaults()
48
66
    __ACTIONS = dict(
49
67
        (name, __import__('actions.%s' % name, name, fromlist=['actions']).Action())
50
68
        for name in action_names
51
69
        if name != '__init__'
52
70
    )
 
71
    for name, fields in default_values.iteritems():
 
72
        set_action_fields(__ACTIONS[name], fields)
53
73
    return __ACTIONS
54
74
 
55
75
 
178
198
    logs_file.close()
179
199
    if logs:
180
200
        logging.error(
181
 
            'actionlist: %s generated the following logs:\n%s\n'
 
201
            '\nactionlist: %s\n%s\n'
182
202
            % (actionlist, logs)
183
203
        )
184
204
    if error:
185
205
        logging.error(
186
 
            'actionlist: %s generated the following error:\n%s\n'
 
206
            '\nactionlist: %s\n%s\n'
187
207
            % (actionlist, error)
188
208
        )
189
209
    return not(error or logs)