maps4fs 2.7.6__py3-none-any.whl → 2.8.0__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.

Potentially problematic release.


This version of maps4fs might be problematic. Click here for more details.

@@ -37,6 +37,11 @@ logger.info(
37
37
  MFS_GSETTINGS_DEFAULTS_DIR,
38
38
  )
39
39
 
40
+ TEMPLATES_STRUCTURE = {
41
+ "fs25": ["texture_schemas", "tree_schemas", "map_templates"],
42
+ "fs22": ["texture_schemas", "map_templates"],
43
+ }
44
+
40
45
 
41
46
  def ensure_templates():
42
47
  """Ensure templates directory exists and is populated with data.
@@ -122,7 +127,19 @@ def ensure_templates():
122
127
  raise
123
128
 
124
129
 
130
+ def ensure_template_subdirs() -> None:
131
+ """Ensure that all expected subdirectories exist in the templates directory."""
132
+ for game_version, subdirs in TEMPLATES_STRUCTURE.items():
133
+ for subdir in subdirs:
134
+ dir_path = os.path.join(MFS_TEMPLATES_DIR, game_version, subdir)
135
+ if not os.path.exists(dir_path):
136
+ logger.debug("Expected template subdirectory missing: %s", dir_path)
137
+ os.makedirs(dir_path, exist_ok=True)
138
+ logger.info("Templates directory is ready at: %s", MFS_TEMPLATES_DIR)
139
+
140
+
125
141
  ensure_templates()
142
+ ensure_template_subdirs()
126
143
 
127
144
  MFS_ROOT_DIR = os.getenv("MFS_ROOT_DIRECTORY", os.path.join(os.getcwd(), "mfsrootdir"))
128
145
  MFS_CACHE_DIR = os.path.join(MFS_ROOT_DIR, "cache")
maps4fs/generator/map.py CHANGED
@@ -129,8 +129,22 @@ class Map:
129
129
  # endregion
130
130
 
131
131
  # region prepare map working directory
132
+ custom_template_path = kwargs.get("custom_template_path", None)
133
+ if custom_template_path:
134
+ self.logger.info("Using custom map template: %s", custom_template_path)
135
+ if not os.path.isfile(custom_template_path):
136
+ self.logger.error(
137
+ "Custom map template file %s does not exist.", custom_template_path
138
+ )
139
+ raise FileNotFoundError(
140
+ f"Custom map template file {custom_template_path} does not exist."
141
+ )
142
+ template_path = custom_template_path
143
+ else:
144
+ self.logger.info("Using default map template: %s", game.template_path)
145
+ template_path = game.template_path
132
146
  try:
133
- shutil.unpack_archive(game.template_path, self.map_directory)
147
+ shutil.unpack_archive(template_path, self.map_directory)
134
148
  self.logger.debug("Map template unpacked to %s", self.map_directory)
135
149
  except Exception as e:
136
150
  raise RuntimeError(f"Can not unpack map template due to error: {e}") from e
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maps4fs
3
- Version: 2.7.6
3
+ Version: 2.8.0
4
4
  Summary: Generate map templates for Farming Simulator from real places.
5
5
  Author-email: iwatkot <iwatkot@gmail.com>
6
6
  License: GNU Affero General Public License v3.0
@@ -1,9 +1,9 @@
1
1
  maps4fs/__init__.py,sha256=5ixsCA5vgcIV0OrF9EJBm91Mmc_KfMiDRM-QyifMAvo,386
2
2
  maps4fs/logger.py,sha256=6sem0aFKQqtVjQ_yNu9iGcc-hqzLQUhfxco05K6nqow,763
3
3
  maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
- maps4fs/generator/config.py,sha256=iCrxIRkETUwL-VVq8eskIekPnA8YD09b-I9gWPxsvqQ,6401
4
+ maps4fs/generator/config.py,sha256=KwYYWM5wrMB_tKn3Fls6WpEurZJxmrBH5AgAXPGHTJE,7122
5
5
  maps4fs/generator/game.py,sha256=nf6iuYNA5NJc-ir_WOgkw-MdJVgetVHeEtxbWJYt3Vo,14462
6
- maps4fs/generator/map.py,sha256=T-oVU9aNSgFwqell_FglFlNu8EJJ1e8CQRtaSpznVAE,13315
6
+ maps4fs/generator/map.py,sha256=IC72Mr_04wm5kby4J0m-Bw32UrcE6qn2KwaX9vLEzn4,14036
7
7
  maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
8
8
  maps4fs/generator/settings.py,sha256=oDs_bgvqHMJfKGK7uVVkm6MykAL3dVkvm5L3-hvZx2c,13044
9
9
  maps4fs/generator/statistics.py,sha256=Dp1-NS-DWv0l0UdmhOoXeQs_N-Hs7svYUnmziSW5Z9I,2098
@@ -22,8 +22,8 @@ maps4fs/generator/component/base/component.py,sha256=lf0V9CLUXMg88Nm2yI3rP5taVYY
22
22
  maps4fs/generator/component/base/component_image.py,sha256=WTGC6v1KuS5sLNCC95Z48nCspvATKKNOuhTNYzTWXr4,8315
23
23
  maps4fs/generator/component/base/component_mesh.py,sha256=3hC-qDT8Vde6SmRMqs9USAkrF-gL2dDTYW71ATpxUS4,9130
24
24
  maps4fs/generator/component/base/component_xml.py,sha256=MT-VhU2dEckLFxAgmxg6V3gnv11di_94Qq6atfpOLdc,5342
25
- maps4fs-2.7.6.dist-info/licenses/LICENSE.md,sha256=Ptw8AkqJ60c4tRts6yuqGP_8B0dxwOGmJsp6YJ8dKqM,34328
26
- maps4fs-2.7.6.dist-info/METADATA,sha256=ADAop0VKLnkMSu_aAT_oa5LlEW025DLz6K3N-c8KoOI,9425
27
- maps4fs-2.7.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
- maps4fs-2.7.6.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
29
- maps4fs-2.7.6.dist-info/RECORD,,
25
+ maps4fs-2.8.0.dist-info/licenses/LICENSE.md,sha256=Ptw8AkqJ60c4tRts6yuqGP_8B0dxwOGmJsp6YJ8dKqM,34328
26
+ maps4fs-2.8.0.dist-info/METADATA,sha256=2B7C0vyf7n4hctRTS2qYYHnR-gJ89WCXdhh6Zo13MLg,9425
27
+ maps4fs-2.8.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
+ maps4fs-2.8.0.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
29
+ maps4fs-2.8.0.dist-info/RECORD,,