karrio-dhl-poland 2026.1.3__py3-none-any.whl → 2026.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,6 @@
1
+ import csv
2
+ import pathlib
3
+
1
4
  import karrio.lib as lib
2
5
  import karrio.core.units as units
3
6
  import karrio.core.models as models
@@ -100,47 +103,54 @@ def shipping_options_initializer(
100
103
  return units.ShippingOptions(_options, ShippingOption, items_filter=items_filter)
101
104
 
102
105
 
103
- DEFAULT_SERVICES = [
104
- models.ServiceLevel(
105
- service_name="DHL Poland Premium",
106
- service_code="dhl_poland_premium",
107
- currency="EUR",
108
- domicile=True,
109
- zones=[models.ServiceZone(label="Zone 1", rate=0.0)],
110
- ),
111
- models.ServiceLevel(
112
- service_name="DHL Poland Polska",
113
- service_code="dhl_poland_polska",
114
- currency="EUR",
115
- domicile=True,
116
- zones=[models.ServiceZone(label="Zone 1", rate=0.0)],
117
- ),
118
- models.ServiceLevel(
119
- service_name="DHL Poland 09",
120
- service_code="dhl_poland_09",
121
- currency="EUR",
122
- domicile=True,
123
- zones=[models.ServiceZone(label="Zone 1", rate=0.0)],
124
- ),
125
- models.ServiceLevel(
126
- service_name="DHL Poland 12",
127
- service_code="dhl_poland_12",
128
- currency="EUR",
129
- domicile=True,
130
- zones=[models.ServiceZone(label="Zone 1", rate=0.0)],
131
- ),
132
- models.ServiceLevel(
133
- service_name="DHL Poland Connect",
134
- service_code="dhl_poland_connect",
135
- currency="EUR",
136
- international=True,
137
- zones=[models.ServiceZone(label="Zone 1", rate=0.0)],
138
- ),
139
- models.ServiceLevel(
140
- service_name="DHL Poland International",
141
- service_code="dhl_poland_international",
142
- currency="EUR",
143
- international=True,
144
- zones=[models.ServiceZone(label="Zone 1", rate=0.0)],
145
- ),
146
- ]
106
+ def load_services_from_csv() -> list:
107
+ csv_path = pathlib.Path(__file__).resolve().parent / "services.csv"
108
+ if not csv_path.exists():
109
+ return []
110
+ services_dict: dict[str, dict] = {}
111
+ with open(csv_path, "r", encoding="utf-8") as f:
112
+ reader = csv.DictReader(f)
113
+ for row in reader:
114
+ service_code = row["service_code"]
115
+ karrio_service_code = Service.map(service_code).name_or_key
116
+ row_min_weight = float(row["min_weight"]) if row.get("min_weight") else None
117
+ row_max_weight = float(row["max_weight"]) if row.get("max_weight") else None
118
+ if karrio_service_code not in services_dict:
119
+ services_dict[karrio_service_code] = {
120
+ "service_name": row["service_name"],
121
+ "service_code": karrio_service_code,
122
+ "currency": row.get("currency", "PLN"),
123
+ "min_weight": row_min_weight,
124
+ "max_weight": row_max_weight,
125
+ "max_length": float(row["max_length"]) if row.get("max_length") else None,
126
+ "max_width": float(row["max_width"]) if row.get("max_width") else None,
127
+ "max_height": float(row["max_height"]) if row.get("max_height") else None,
128
+ "weight_unit": "KG",
129
+ "dimension_unit": "CM",
130
+ "domicile": True if (row.get("domicile") or "").lower() == "true" else None,
131
+ "international": True if (row.get("international") or "").lower() == "true" else None,
132
+ "zones": [],
133
+ }
134
+ else:
135
+ # Update service-level weight bounds to cover all zones
136
+ current = services_dict[karrio_service_code]
137
+ if row_min_weight is not None:
138
+ if current["min_weight"] is None or row_min_weight < current["min_weight"]:
139
+ current["min_weight"] = row_min_weight
140
+ if row_max_weight is not None:
141
+ if current["max_weight"] is None or row_max_weight > current["max_weight"]:
142
+ current["max_weight"] = row_max_weight
143
+ country_codes = [c.strip() for c in row.get("country_codes", "").split(",") if c.strip()]
144
+ zone = models.ServiceZone(
145
+ label=row.get("zone_label", "Default Zone"),
146
+ rate=float(row.get("rate", 0.0)),
147
+ min_weight=row_min_weight,
148
+ max_weight=row_max_weight,
149
+ transit_days=int(row["transit_days"].split("-")[0]) if row.get("transit_days") and row["transit_days"].split("-")[0].isdigit() else None,
150
+ country_codes=country_codes if country_codes else None,
151
+ )
152
+ services_dict[karrio_service_code]["zones"].append(zone)
153
+ return [models.ServiceLevel(**service_data) for service_data in services_dict.values()]
154
+
155
+
156
+ DEFAULT_SERVICES = load_services_from_csv()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: karrio_dhl_poland
3
- Version: 2026.1.3
3
+ Version: 2026.1.5
4
4
  Summary: Karrio - DHL Parcel Poland Shipping Extension
5
5
  Author-email: karrio <hello@karrio.io>
6
6
  License-Expression: LGPL-3.0
@@ -6,15 +6,15 @@ karrio/plugins/dhl_poland/__init__.py,sha256=MdBRoFyYsyc8APZ8PI3Esn6kZOlwAtC66hc
6
6
  karrio/providers/dhl_poland/__init__.py,sha256=oLgXPC778tlkc-zFag7y40sBkgvf5IsTtt10FZ_e9Xk,328
7
7
  karrio/providers/dhl_poland/error.py,sha256=OXxiuVdmtW55THG8Uv0UTDC-wXoj_CENVRLK6niV6vs,621
8
8
  karrio/providers/dhl_poland/tracking.py,sha256=IxOu5ken3OTHRJm0WEmUrj_Ni9uKdShXV1xkTJQ-Zag,3068
9
- karrio/providers/dhl_poland/units.py,sha256=6L4wxpjqUB0o8mkjy8_y2p1Jmv-NpFcOV7abtEsc2T8,4612
9
+ karrio/providers/dhl_poland/units.py,sha256=LmuMjMnUsJUFXH7bOi97W0CFnipJ75K1uYsyLWazK6I,6220
10
10
  karrio/providers/dhl_poland/utils.py,sha256=fCajKIynwom0mPk8Ev3VYbNMZxrDHKpKZGsZSkrpwJo,1862
11
11
  karrio/providers/dhl_poland/shipment/__init__.py,sha256=kH1OP9BIPNfzxj6k41NI5TGBQX6CZ9y0qinn3BkL9xI,236
12
12
  karrio/providers/dhl_poland/shipment/cancel.py,sha256=OHFV3O6NjuZ0dcjb_bkX2RvX9y5vBJcSCv_enKwuyOA,1576
13
13
  karrio/providers/dhl_poland/shipment/create.py,sha256=1DF1LX7qpiwfuu_4D4t9Z3BE6HFIOwhFmozcCh_D3cU,13464
14
14
  karrio/schemas/dhl_poland/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  karrio/schemas/dhl_poland/services.py,sha256=f1fyVKQfVce7u-UzSGGU2Xbac7Ulg98rXwckXahvC8M,1471874
16
- karrio_dhl_poland-2026.1.3.dist-info/METADATA,sha256=a0gmJ72b1i6YeKAATVHBejj08P8v_l0Hvc2B66gchGo,1028
17
- karrio_dhl_poland-2026.1.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
18
- karrio_dhl_poland-2026.1.3.dist-info/entry_points.txt,sha256=dszDSNQ_aAw9xldHUTWmvd6OoTldQje9eMlYH0hN9QE,65
19
- karrio_dhl_poland-2026.1.3.dist-info/top_level.txt,sha256=FZCY8Nwft8oEGHdl--xku8P3TrnOxu5dETEU_fWpRSM,20
20
- karrio_dhl_poland-2026.1.3.dist-info/RECORD,,
16
+ karrio_dhl_poland-2026.1.5.dist-info/METADATA,sha256=bJlGvXCn9j1CWQ86694cvpOKmXV_lLAPTtdvjvZywG4,1028
17
+ karrio_dhl_poland-2026.1.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
18
+ karrio_dhl_poland-2026.1.5.dist-info/entry_points.txt,sha256=dszDSNQ_aAw9xldHUTWmvd6OoTldQje9eMlYH0hN9QE,65
19
+ karrio_dhl_poland-2026.1.5.dist-info/top_level.txt,sha256=FZCY8Nwft8oEGHdl--xku8P3TrnOxu5dETEU_fWpRSM,20
20
+ karrio_dhl_poland-2026.1.5.dist-info/RECORD,,