Skip to content

Commit

Permalink
Merge pull request #57 from alexey-grom/master
Browse files Browse the repository at this point in the history
Added lxml.html.CheckboxGroup.value_options property
  • Loading branch information
scoder committed Jun 26, 2012
2 parents bdacc2e + 492c765 commit 57d2b5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lxml/html/__init__.py
Expand Up @@ -1299,6 +1299,13 @@ def _value__del(self):
self.value.clear()
value = property(_value__get, _value__set, _value__del, doc=_value__get.__doc__)

def value_options(self):
"""
Returns a list of all the possible values.
"""
return [el.get('value') for el in self]
value_options = property(value_options, doc=value_options.__doc__)

def __repr__(self):
return '%s(%s)' % (
self.__class__.__name__, list.__repr__(self))
Expand Down
2 changes: 2 additions & 0 deletions src/lxml/html/tests/test_forms.txt
Expand Up @@ -76,6 +76,8 @@ b'<input type="checkbox" name="single_checkbox" checked>'
<CheckboxValues {'1', '2', '3'} for checkboxes name='check_group'>
>>> tostring(group[0])
b'<input type="checkbox" name="check_group" value="1" checked>'
>>> group.value_options
['1', '2', '3', '4']
>>> group.value.add('doesnotexist')
Traceback (most recent call last):
...
Expand Down

0 comments on commit 57d2b5a

Please sign in to comment.