From 1c148cc8cdaccfbd4e6e506aa2fd35e53920ddf0 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 24 Mar 2025 18:04:01 +0100 Subject: ♻️ django 3.2 - new version of libraries: fix errors and deprecation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models_imports.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'ishtar_common/models_imports.py') diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 55bbd1906..b66fe7a72 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -1352,6 +1352,7 @@ def convert_geom(feature, srid): if not feature: return feature srid = int(srid) + feature = dict(feature) geo_type = feature["type"] if geo_type in ("LineString", "Polygon"): feature["type"] = "Multi" + geo_type @@ -2251,7 +2252,8 @@ class Import(BaseImport): if self.number_of_line: return self.number_of_line imported_values = self.get_imported_values() - if (not imported_values or not imported_values.path or not imported_values.path.endswith(".csv")) \ + if (not imported_values or not imported_values.path + or not imported_values.path.endswith(".csv")) \ and self.importer_type.type == "gis": return self._data_table_gis(get_number_only=True) if not imported_values or not imported_values.path: @@ -2260,8 +2262,11 @@ class Import(BaseImport): encodings = [self.encoding] encodings += [coding for coding, c in ENCODINGS if coding != self.encoding] for encoding in encodings: + options = {} + if encoding: + options["encoding"] = encoding try: - with open(filename, "r", encoding=encoding) as f: + with open(filename, "r", **options) as f: reader = csv.reader(f, delimiter=self.csv_sep) nb = sum(1 for __ in reader) - self.skip_lines except UnicodeDecodeError: @@ -2499,6 +2504,8 @@ class Import(BaseImport): # https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6 elif crs.startswith("+init=epsg:"): srid = crs[len("+init=epsg:"):] + elif crs.lower().startswith("epsg:"): + srid = crs[len("epsg:"):] else: srid = CRS.from_proj4(crs).to_epsg() data = [] -- cgit v1.2.3