Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 348710 | Differences between
and this patch

Collapse All | Expand All

(-)a/paver/setuputils.py (+1 lines)
Lines 135-140 class DistutilsTask(tasks.Task): Link Here
135
        self.option_names = set()
135
        self.option_names = set()
136
        self.needs = []
136
        self.needs = []
137
        self.user_options = command_class.user_options
137
        self.user_options = command_class.user_options
138
        self.negative_opt = getattr(command_class, "negative_opt", {})
138
        # Parse distutils config files.
139
        # Parse distutils config files.
139
        distribution.parse_config_files()
140
        distribution.parse_config_files()
140
        
141
        
(-)a/paver/tasks.py (-2 / +11 lines)
Lines 238-243 class Task(object): Link Here
238
        self.name = "%s.%s" % (func.__module__, func.__name__)
238
        self.name = "%s.%s" % (func.__module__, func.__name__)
239
        self.option_names = set()
239
        self.option_names = set()
240
        self.user_options = []
240
        self.user_options = []
241
        self.negative_opt = {}
241
        try:
242
        try:
242
            self.__doc__ = func.__doc__
243
            self.__doc__ = func.__doc__
243
        except AttributeError:
244
        except AttributeError:
Lines 250-256 class Task(object): Link Here
250
    
251
    
251
    def __repr__(self):
252
    def __repr__(self):
252
        return "Task: " + self.__name__
253
        return "Task: " + self.__name__
253
    
254
254
    @property    
255
    @property    
255
    def parser(self):
256
    def parser(self):
256
        options = self.user_options
257
        options = self.user_options
Lines 265-270 class Task(object): Link Here
265
            if not task:
266
            if not task:
266
                raise PavementError("Task %s needed by %s does not exist"
267
                raise PavementError("Task %s needed by %s does not exist"
267
                    % (task_name, self))
268
                    % (task_name, self))
269
268
            for option in task.user_options:
270
            for option in task.user_options:
269
                try:
271
                try:
270
                    longname = option[0]
272
                    longname = option[0]
Lines 294-299 by another task in the dependency chain.""" % (self, option, task)) Link Here
294
                except IndexError:
296
                except IndexError:
295
                    raise PavementError("Invalid option format provided for %r: %s"
297
                    raise PavementError("Invalid option format provided for %r: %s"
296
                                        % (self, option))
298
                                        % (self, option))
299
297
        return parser
300
        return parser
298
        
301
        
299
    def display_help(self, parser=None):
302
    def display_help(self, parser=None):
Lines 320-334 by another task in the dependency chain.""" % (self, option, task)) Link Here
320
            sys.exit(0)
323
            sys.exit(0)
321
            
324
            
322
        for task_name, option_name in self.option_names:
325
        for task_name, option_name in self.option_names:
326
            dist_option_name = option_name
323
            option_name = option_name.replace('-', '_')
327
            option_name = option_name.replace('-', '_')
324
            try:
328
            try:
325
                optholder = environment.options[task_name]
329
                optholder = environment.options[task_name]
326
            except KeyError:
330
            except KeyError:
327
                optholder = paver.options.Bunch()
331
                optholder = paver.options.Bunch()
328
                environment.options[task_name] = optholder
332
                environment.options[task_name] = optholder
333
329
            value = getattr(options, option_name)
334
            value = getattr(options, option_name)
330
            if value is not None:
335
            if value is not None:
331
                optholder[option_name] = getattr(options, option_name)
336
                if dist_option_name in getattr(self, "negative_opt"):
337
                    optholder[self.negative_opt[dist_option_name].replace('-', '_')] = False
338
                else:
339
                    optholder[option_name] = getattr(options, option_name)
340
332
        return args
341
        return args
333
        
342
        
334
    @property
343
    @property
(-)a/paver/tests/test_setuputils.py (-4 / +19 lines)
Lines 1-4 Link Here
1
from pprint import pprint
2
from distutils.core import Command
1
from distutils.core import Command
3
2
4
from paver.setuputils import install_distutils_tasks, \
3
from paver.setuputils import install_distutils_tasks, \
Lines 11-19 class _sdist(Command): Link Here
11
    called = False
10
    called = False
12
    foo_set = False
11
    foo_set = False
13
    fin = None
12
    fin = None
14
    user_options = [("foo", "f", "Foo")]
13
    user_options = [("foo", "f", "Foo"), ("no-foo", None, "No Foo")]
15
    boolean_options = ['foo']
14
    boolean_options = ['foo']
16
    negative_opt = {}
15
    negative_opt = {'no-foo' : 'foo'}
17
    
16
    
18
    def initialize_options(self):
17
    def initialize_options(self):
19
        self.foo = False
18
        self.foo = False
Lines 33-38 class _sdist(Command): Link Here
33
        cls.fin = None
32
        cls.fin = None
34
33
35
34
35
class _sdist_with_default_foo(_sdist):
36
    def initialize_options(self):
37
        self.foo = True
38
36
#----------------------------------------------------------------------
39
#----------------------------------------------------------------------
37
def test_override_distutils_command():
40
def test_override_distutils_command():
38
    @tasks.task
41
    @tasks.task
Lines 133-135 def test_needs_sdist_without_options(): Link Here
133
    cmd = d.get_command_obj('sdist')
136
    cmd = d.get_command_obj('sdist')
134
    assert not cmd.foo
137
    assert not cmd.foo
135
    assert not _sdist.foo_set
138
    assert not _sdist.foo_set
136
- 
139
140
def test_negative_opts_handled_for_distutils():
141
    _sdist.reset()
142
    env = _set_environment()
143
    env.options = options.Bunch(setup=options.Bunch())
144
    install_distutils_tasks()
145
    d = _get_distribution()
146
    d.cmdclass['sdist'] = _sdist_with_default_foo
147
148
    tasks._process_commands(['sdist', '--no-foo'])
149
150
    assert _sdist.called
151
    assert not _sdist.foo_set

Return to bug 348710