text
stringlengths
0
828
promulgation_step['date'] = data['end']
data['steps'].append(promulgation_step)
# add predicted next step for unfinished projects
elif predicted_next_step:
data['steps'].append(predicted_next_step)
if 'url_dossier_senat' not in data or 'dossier-legislatif' not in data['url_dossier_senat']:
senat_url = find_senat_url(data)
if senat_url:
data['url_dossier_senat'] = senat_url
# append previous works if there are some
if previous_works and parse_previous_works:
log_warning('MERGING %s WITH PREVIOUS WORKS %s' % (url_an, previous_works))
resp = download_historic_dosleg(previous_works)
prev_data = historic_doslegs_parse(
resp.text, previous_works,
logfile=logfile,
nth_dos_in_page=nth_dos_in_page, parse_next_works=False)
if prev_data:
prev_data = prev_data[nth_dos_in_page] if len(prev_data) > 1 else prev_data[0]
data = merge_previous_works_an(prev_data, data)
else:
log_warning('INVALID PREVIOUS WORKS', previous_works)
# is this part of a dosleg previous works ?
next_legislature = data['assemblee_legislature'] + 1 if 'assemblee_legislature' in data else 9999
if parse_next_works and next_legislature < 15:
# TODO: parse 15th legislature from open data if it exists
resp = download_historic_dosleg(url_an.replace('/%d/' % data['assemblee_legislature'], '/%d/' % (data['assemblee_legislature'] + 1)))
if resp.status_code == 200:
recent_data = historic_doslegs_parse(
resp.text, resp.url,
logfile=logfile,
nth_dos_in_page=nth_dos_in_page, parse_previous_works=False)
if recent_data:
log_warning('FOUND MORE RECENT WORKS', resp.url)
recent_data = recent_data[nth_dos_in_page] if len(recent_data) > 1 else recent_data[0]
data = merge_previous_works_an(data, recent_data)
if another_dosleg_inside:
others = historic_doslegs_parse(another_dosleg_inside, url_an, logfile=logfile, nth_dos_in_page=nth_dos_in_page+1)
if others:
return [data] + others
return [data]"
1187,"def auto_need(form):
""""""Automatically ``need()`` the relevant Fanstatic resources for a form.
This function automatically utilises libraries in the ``js.*`` namespace
(such as ``js.jquery``, ``js.tinymce`` and so forth) to allow Fanstatic
to better manage these resources (caching, minifications) and avoid
duplication across the rest of your application.
""""""
requirements = form.get_widget_requirements()
for library, version in requirements:
resources = resource_mapping[library]
if not isinstance(resources, list): # pragma: no cover (bw compat only)
resources = [resources]
for resource in resources:
resource.need()"
1188,"def setup_logger():
""""""
setup basic logger
""""""
logger = logging.getLogger('dockerstache')
logger.setLevel(logging.INFO)
handler = logging.StreamHandler(stream=sys.stdout)
handler.setLevel(logging.INFO)
logger.addHandler(handler)
return logger"
1189,"def named_any(name):
""""""
Retrieve a Python object by its fully qualified name from the global Python
module namespace. The first part of the name, that describes a module,
will be discovered and imported. Each subsequent part of the name is
treated as the name of an attribute of the object specified by all of the
name which came before it.
@param name: The name of the object to return.
@return: the Python object identified by 'name'.
""""""
assert name, 'Empty module name'
names = name.split('.')
topLevelPackage = None
moduleNames = names[:]
while not topLevelPackage:
if moduleNames:
trialname = '.'.join(moduleNames)
try:
topLevelPackage = __import__(trialname)
except Exception, ex:
moduleNames.pop()
else:
if len(names) == 1:
raise Exception(""No module named %r"" % (name,))
else:
raise Exception('%r does not name an object' % (name,))