(type, db, dump, empty_id=False)
| 333 | |
| 334 | |
| 335 | def dispatch(type, db, dump, empty_id=False): |
| 336 | if db.execute("SELECT * FROM comments").fetchone(): |
| 337 | if input("Isso DB is not empty! Continue? [y/N]: ") not in ("y", "Y"): |
| 338 | raise SystemExit("Abort.") |
| 339 | |
| 340 | if type == "disqus": |
| 341 | cls = Disqus |
| 342 | elif type == "wordpress": |
| 343 | cls = WordPress |
| 344 | elif type == "generic": |
| 345 | cls = Generic |
| 346 | else: |
| 347 | with io.open(dump, encoding="utf-8") as fp: |
| 348 | cls = autodetect(fp.read(io.DEFAULT_BUFFER_SIZE)) |
| 349 | |
| 350 | if cls is None: |
| 351 | raise SystemExit("Unknown format, abort.") |
| 352 | |
| 353 | if cls is Disqus: |
| 354 | cls = functools.partial(cls, empty_id=empty_id) |
| 355 | |
| 356 | cls(db, dump).migrate() |
nothing calls this directly
no test coverage detected