本文整理匯總了Python中mptracker.patcher.TablePatcher.update方法的典型用法代碼示例。如果您正苦於以下問題:Python TablePatcher.update方法的具體用法?Python TablePatcher.update怎麽用?Python TablePatcher.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mptracker.patcher.TablePatcher
的用法示例。
在下文中一共展示了TablePatcher.update方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: committee_summaries
# 需要導入模塊: from mptracker.patcher import TablePatcher [as 別名]
# 或者: from mptracker.patcher.TablePatcher import update [as 別名]
def committee_summaries(year=2014):
from mptracker.scraper.committee_summaries import SummaryScraper
patcher = TablePatcher(models.CommitteeSummary,
models.db.session,
key_columns=['pdf_url'])
summary_scraper = SummaryScraper(get_cached_session(),
get_cached_session('question-pdf'))
records = summary_scraper.fetch_summaries(year, get_pdf_text=True)
patcher.update(records)
models.db.session.commit()
示例2: load
# 需要導入模塊: from mptracker.patcher import TablePatcher [as 別名]
# 或者: from mptracker.patcher.TablePatcher import update [as 別名]
def load(name, include_columns=None, create=True, remove=False,
_file=sys.stdin):
from mptracker.patcher import TablePatcher
if include_columns:
include_columns = set(include_columns.split(','))
def filter_record(r):
return {k: r[k] for k in r if k in include_columns}
else:
filter_record = lambda r: r
loader = TableLoader(name)
patcher = TablePatcher(loader.model, db.session, key_columns=['id'])
records = (filter_record(loader.decode_dict(flask.json.loads(line)))
for line in _file)
patcher.update(records, create=create, remove=remove)
db.session.commit()
示例3: test_remove_extra_records_honors_filter
# 需要導入模塊: from mptracker.patcher import TablePatcher [as 別名]
# 或者: from mptracker.patcher.TablePatcher import update [as 別名]
def test_remove_extra_records_honors_filter(db_app):
records = [{'code': 'an', 'number': 1, 'name': "Anne"},
{'code': 'bo', 'number': 1, 'name': "Bob"},
{'code': 'cl', 'number': 2, 'name': "Claire"},
{'code': 'da', 'number': 2, 'name': "Dan"}]
from mptracker.patcher import TablePatcher
filter_patcher = TablePatcher(
Thing,
db.session,
key_columns=['code'],
filter={'number': 1},
)
filter_patcher.update(records)
filter_patcher.update(records[:1], remove=True)
assert sorted([t.name for t in Thing.query]) == ["Anne", "Claire", "Dan"]