From 0340caccd07b29621ff4bcf4b4a4c261e0b937de Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Fri, 26 Jun 2015 17:04:40 -0300 Subject: [PATCH] Fix field id detection in scraping --- legacy/scripts/scrap_original_forms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/legacy/scripts/scrap_original_forms.py b/legacy/scripts/scrap_original_forms.py index e02857413..281fab900 100644 --- a/legacy/scripts/scrap_original_forms.py +++ b/legacy/scripts/scrap_original_forms.py @@ -7,15 +7,19 @@ from bs4 import BeautifulSoup from bs4.element import NavigableString, Tag from field_mappings import field_mappings +from migration import appconfs from utils import listify, getsourcelines +assert appconfs # to prevent removal by automatic organize imports on this file + + def _read_line(tr): for td in tr.find_all('td'): label = td.text.strip().split('\n')[0].strip(u'\xa0' + string.whitespace) if label.endswith('(*)'): label = label[:-3].strip() - names = [c.attrs['name'] for c in td.children if isinstance(c, Tag) and 'name' in c.attrs] + names = [c.attrs['name'] for c in td.findAll() if isinstance(c, Tag) and 'name' in c.attrs] if names: name = names[0].split('_', 1)[-1] yield name, label