# Path: modules/seloger/constants.py
# TYPES = {POSTS_TYPES.RENT: 1,
#          POSTS_TYPES.SALE: 2,
#          POSTS_TYPES.FURNISHED_RENT: 1,
#          POSTS_TYPES.VIAGER: 5}
# 
# RET = {HOUSE_TYPES.HOUSE: '2',
#        HOUSE_TYPES.APART: '1',
#        HOUSE_TYPES.LAND: '4',
#        HOUSE_TYPES.PARKING: '3',
#        HOUSE_TYPES.OTHER: '10'}


from woob.browser.pages import JsonPage, pagination, HTMLPage
from woob.browser.elements import ItemElement, DictElement, method
from woob.browser.filters.json import Dict
from woob.browser.filters.html import XPath
from woob.browser.filters.standard import (CleanText, CleanDecimal, Currency,
                                             Env, Regexp, Field, BrowserURL)
from woob.capabilities.base import NotAvailable, NotLoaded
from woob.capabilities.housing import (Housing, HousingPhoto, City,
                                         UTILITIES, ENERGY_CLASS, POSTS_TYPES,
                                         ADVERT_TYPES)
from woob.capabilities.address import PostalAddress
from woob.tools.capabilities.housing.housing import PricePerMeterFilter
from woob.tools.json import json
from woob.exceptions import ActionNeeded
from .constants import TYPES, RET
import codecs
import decimal
            CleanText('//script'),
            r"window\[\"initialData\"\] = JSON.parse\(\"({.*})\"\);"
        )(self.doc)
        json_content = codecs.unicode_escape_decode(json_content)[0]
        json_content = json_content.encode('utf-8', 'surrogatepass').decode('utf-8')
        self.doc = {
            "advert": json.loads(json_content).get('advert', {}).get('mainAdvert', {}),
            "agency": json.loads(json_content).get('agency', {})
        }

    @method
    class get_housing(ItemElement):
        klass = Housing

        def parse(self, el):
            self.agency_doc = el['agency']
            self.el = el['advert']

        obj_id = Dict('id')

        def obj_house_type(self):
            naturebien = Dict('propertyNatureId')(self)
            try:
                return next(k for k, v in RET.items() if v == naturebien)
            except StopIteration:
                return NotLoaded

        def obj_type(self):
            idType = Dict('idTransactionType')(self)
            try:

# Path: modules/seloger/constants.py
# TYPES = {POSTS_TYPES.RENT: 1,
#          POSTS_TYPES.SALE: 2,
#          POSTS_TYPES.FURNISHED_RENT: 1,
#          POSTS_TYPES.VIAGER: 5}
# 
# RET = {HOUSE_TYPES.HOUSE: '2',
#        HOUSE_TYPES.APART: '1',
#        HOUSE_TYPES.LAND: '4',
#        HOUSE_TYPES.PARKING: '3',
#        HOUSE_TYPES.OTHER: '10'}


# Path: modules/seloger/pages.py
from woob.browser.pages import JsonPage, pagination, HTMLPage
from woob.browser.elements import ItemElement, DictElement, method
from woob.browser.filters.json import Dict
from woob.browser.filters.html import XPath
from woob.browser.filters.standard import (CleanText, CleanDecimal, Currency,
                                             Env, Regexp, Field, BrowserURL)
from woob.capabilities.base import NotAvailable, NotLoaded
from woob.capabilities.housing import (Housing, HousingPhoto, City,
                                         UTILITIES, ENERGY_CLASS, POSTS_TYPES,
                                         ADVERT_TYPES)
from woob.capabilities.address import PostalAddress
from woob.tools.capabilities.housing.housing import PricePerMeterFilter
from woob.tools.json import json
from woob.exceptions import ActionNeeded
from .constants import TYPES, RET
import codecs
import decimal

            CleanText('//script'),
            r"window\[\"initialData\"\] = JSON.parse\(\"({.*})\"\);"
        )(self.doc)
        json_content = codecs.unicode_escape_decode(json_content)[0]
        json_content = json_content.encode('utf-8', 'surrogatepass').decode('utf-8')
        self.doc = {
            "advert": json.loads(json_content).get('advert', {}).get('mainAdvert', {}),
            "agency": json.loads(json_content).get('agency', {})
        }

    @method
    class get_housing(ItemElement):
        klass = Housing

        def parse(self, el):
            self.agency_doc = el['agency']
            self.el = el['advert']

        obj_id = Dict('id')

        def obj_house_type(self):
            naturebien = Dict('propertyNatureId')(self)
            try:
                return next(k for k, v in RET.items() if v == naturebien)
            except StopIteration:
                return NotLoaded

        def obj_type(self):
            idType = Dict('idTransactionType')(self)
            try:

                type = next(k for k, v in TYPES.items() if v == idType)