[CapHousing] add and handle in flatboob house_types field
This commit is contained in:
parent
26c929ff9d
commit
7304f1dee1
2 changed files with 47 additions and 8 deletions
|
|
@ -18,7 +18,6 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
from weboob.capabilities.housing import CapHousing, Query
|
||||
from weboob.tools.application.repl import ReplApplication, defaultcount
|
||||
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
|
||||
|
|
@ -137,6 +136,25 @@ class Flatboob(ReplApplication):
|
|||
else:
|
||||
query.cities.append(city)
|
||||
|
||||
r = 'notempty'
|
||||
while r != '':
|
||||
for good in Query.HOUSE_TYPES.values:
|
||||
print ' %s%2d)%s [%s] %s' % (self.BOLD,
|
||||
Query.HOUSE_TYPES.index[good] + 1,
|
||||
self.NC,
|
||||
'x' if good in query.house_types else ' ', good)
|
||||
r = self.ask(' Select type of house (or empty to stop)', regexp='(\d+|)', default='')
|
||||
if not r.isdigit():
|
||||
continue
|
||||
r = int(r)
|
||||
if r <= 0 or r > len(Query.TYPE_OF_GOOD.values):
|
||||
continue
|
||||
value = Query.TYPE_OF_GOOD.values[r - 1]
|
||||
if value in query.type_of_good:
|
||||
query.type_of_good.remove(value)
|
||||
else:
|
||||
query.type_of_good.append(value)
|
||||
|
||||
query.area_min = self.ask_int('Enter min area')
|
||||
query.area_max = self.ask_int('Enter max area')
|
||||
query.cost_min = self.ask_int('Enter min cost')
|
||||
|
|
|
|||
|
|
@ -70,16 +70,37 @@ class Query(BaseObject):
|
|||
TYPE_RENT = 0
|
||||
TYPE_SALE = 1
|
||||
|
||||
type = IntField('Type of housing to find (TYPE_* constants)')
|
||||
cities = Field('List of cities to search in', list, tuple)
|
||||
area_min = IntField('Minimal area (in m2)')
|
||||
area_max = IntField('Maximal area (in m2)')
|
||||
cost_min = IntField('Minimal cost')
|
||||
cost_max = IntField('Maximal cost')
|
||||
nb_rooms = IntField('Number of rooms')
|
||||
def enum(**enums):
|
||||
_values = enums.values()
|
||||
_items = enums.items()
|
||||
_index = dict((value, i) for i, value in enumerate(enums.values()))
|
||||
_types = list((type(value) for value in enums.values()))
|
||||
enums['values'] = _values
|
||||
enums['items'] = _items
|
||||
enums['index'] = _index
|
||||
enums['types'] = _types
|
||||
return type('Enum', (), enums)
|
||||
|
||||
HOUSE_TYPES = enum(APART=u'Apartment',
|
||||
HOUSE=u'House',
|
||||
PARKING=u'Parking',
|
||||
LAND=u'Land',
|
||||
OTHER=u'Other')
|
||||
|
||||
type = IntField('Type of housing to find (TYPE_* constants)')
|
||||
cities = Field('List of cities to search in', list, tuple)
|
||||
area_min = IntField('Minimal area (in m2)')
|
||||
area_max = IntField('Maximal area (in m2)')
|
||||
cost_min = IntField('Minimal cost')
|
||||
cost_max = IntField('Maximal cost')
|
||||
nb_rooms = IntField('Number of rooms')
|
||||
house_types = Field('List of house types', list, tuple)
|
||||
|
||||
def __init__(self):
|
||||
BaseObject.__init__(self, '')
|
||||
self.house_types = []
|
||||
for value in self.HOUSE_TYPES.values:
|
||||
self.house_types.append(value)
|
||||
|
||||
|
||||
class City(BaseObject):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue