text
stringlengths 0
828
|
|---|
for conv in converter._converters_list:
|
if not Parser.are_worth_chaining(base_parser, to_type, conv):
|
return False
|
# all good
|
return True
|
else:
|
return Parser.are_worth_chaining(base_parser, to_type, converter)"
|
1243,"def set_mode(self, mode):
|
""""""Set Lupusec alarm mode.""""""
|
_LOGGER.debug('State change called from alarm device')
|
if not mode:
|
_LOGGER.info('No mode supplied')
|
elif mode not in CONST.ALL_MODES:
|
_LOGGER.warning('Invalid mode')
|
response_object = self._lupusec.set_mode(CONST.MODE_TRANSLATION[mode])
|
if response_object['result'] != 1:
|
_LOGGER.warning('Mode setting unsuccessful')
|
self._json_state['mode'] = mode
|
_LOGGER.info('Mode set to: %s', mode)
|
return True"
|
1244,"def parse_amendements_summary(url, json_response):
|
""""""
|
json schema :
|
{
|
infoGenerales: {
|
nb_resultats, debut, nb_docs
|
},
|
data_table: 'id|numInit|titreDossierLegislatif|urlDossierLegislatif|'
|
'instance|numAmend|urlAmend|designationArticle|'
|
'designationAlinea|dateDepot|signataires|sort'
|
}
|
NB : the json response does not contain the dispositif and expose, that's
|
why we call it ""amendement's summary""
|
""""""
|
amendements = []
|
fields = [convert_camelcase_to_underscore(field) for field in
|
json_response['infoGenerales']['description_schema'].split('|')]
|
for row in json_response['data_table']:
|
values = row.split('|')
|
amd = AmendementSummary(**dict(zip(fields, values)))
|
amd.legislature = re.search(r'www.assemblee-nationale.fr/(\d+)/',
|
amd.url_amend).groups()[0]
|
amendements.append(amd)
|
return AmendementSearchResult(**{
|
'url': url,
|
'total_count': json_response['infoGenerales']['nb_resultats'],
|
'start': json_response['infoGenerales']['debut'],
|
'size': json_response['infoGenerales']['nb_docs'],
|
'results': amendements
|
})"
|
1245,"def get(self, **kwargs):
|
""""""
|
:param texteRecherche:
|
:param numAmend:
|
:param idArticle:
|
:param idAuteur:
|
:param idDossierLegislatif:
|
:param idExamen:
|
:param idExamens:
|
:param periodeParlementaire:
|
:param dateDebut:
|
:param dateFin:
|
:param rows:
|
:param start:
|
:param sort:
|
""""""
|
params = self.default_params.copy()
|
params.update(kwargs)
|
start = time.time()
|
response = requests.get(self.base_url, params=params)
|
end = time.time()
|
LOGGER.debug(
|
'fetched amendements with search params: %s in %0.2f s',
|
params,
|
end - start
|
)
|
return parse_amendements_summary(response.url, response.json())"
|
1246,"def to_utf8(value):
|
""""""Returns a string encoded using UTF-8.
|
This function comes from `Tornado`_.
|
:param value:
|
A unicode or string to be encoded.
|
:returns:
|
The encoded string.
|
""""""
|
if isinstance(value, unicode):
|
return value.encode('utf-8')
|
assert isinstance(value, str)
|
return value"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.