pol_fetcher.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding: utf-8 -*-
  2. from app.visa_free_config_fetchers.base_fetcher import BaseFetcher
  3. CITY_MAP = {
  4. "bjs": "Beijing",
  5. "sha": "Shanghai",
  6. "dub": "Dublin",
  7. "tok": "Tokio",
  8. "tyo": "Tokio"
  9. }
  10. class POLFetcher(BaseFetcher):
  11. def __init__(self):
  12. super(POLFetcher, self).__init__("pol")
  13. def fetch_free_config(self, origin, target, visa_type, vac_code=None):
  14. origin_clean = origin.lower().strip()
  15. target_clean = target.lower().strip()
  16. vac_clean = (vac_code or "").lower().strip()
  17. missions = self.metadata.get("missions", {})
  18. mission_key = "{}_{}".format(origin_clean, target_clean)
  19. if vac_clean and "{}_{}_{}".format(origin_clean, vac_clean, target_clean) in missions:
  20. mission_key = "{}_{}_{}".format(origin_clean, vac_clean, target_clean)
  21. mission_data = missions.get(mission_key, {})
  22. if not mission_data:
  23. location = CITY_MAP.get(vac_clean, vac_clean.capitalize() if vac_clean else "")
  24. mission_data = {
  25. "query_url": "https://secure.e-konsulat.gov.pl",
  26. "service_type": "Wiza Schengen",
  27. "location": location
  28. }
  29. return mission_data