comaps-map-distributor 0.2.0__tar.gz → 0.4.0__tar.gz
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.
- {comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/PKG-INFO +1 -1
- {comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/pyproject.toml +1 -1
- comaps_map_distributor-0.4.0/src/comaps_map_distributor/.app.py.swp +0 -0
- comaps_map_distributor-0.4.0/src/comaps_map_distributor/.downloader.py.swp +0 -0
- {comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/src/comaps_map_distributor/app.py +1 -1
- {comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/src/comaps_map_distributor/downloader.py +28 -16
- {comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/COPYING +0 -0
- {comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/README.md +0 -0
- {comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/src/comaps_map_distributor/__init__.py +0 -0
- {comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/src/comaps_map_distributor/server.py +0 -0
|
Binary file
|
{comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/src/comaps_map_distributor/app.py
RENAMED
|
@@ -41,8 +41,8 @@ def cli_download_maps(directory, map_version, download_server):
|
|
|
41
41
|
map_version, country_list = get_map_names(download_server,
|
|
42
42
|
map_version,
|
|
43
43
|
user_specified_server)
|
|
44
|
-
selected_maps = select_maps(country_list)
|
|
45
44
|
download_location = select_download_path(map_version,directory)
|
|
45
|
+
selected_maps = select_maps(country_list, download_location)
|
|
46
46
|
download_maps(selected_maps,
|
|
47
47
|
download_server,
|
|
48
48
|
map_version,
|
|
@@ -66,7 +66,7 @@ def recurse_map_json(countries, name_list=[]):
|
|
|
66
66
|
return name_list
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
def select_maps(country_list):
|
|
69
|
+
def select_maps(country_list, download_location):
|
|
70
70
|
"""
|
|
71
71
|
build fuzzy match UI for selecting which maps to download
|
|
72
72
|
"""
|
|
@@ -83,8 +83,12 @@ def select_maps(country_list):
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
# make world map and world coast map selected by default
|
|
86
|
+
# also pre-select existing maps to help find which maps already exist
|
|
87
|
+
# (existing files won't be re-downloaded from 0.4.0)
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
old_maps = [i.name.replace('.mwm','') for i in Path(download_location).glob("*.mwm")]
|
|
90
|
+
|
|
91
|
+
country_list = list(map(lambda x: Choice(x, enabled=True) if (x == 'World') or (x == 'WorldCoasts') or (x in old_maps) else x, country_list))
|
|
88
92
|
|
|
89
93
|
questions = [
|
|
90
94
|
{
|
|
@@ -154,20 +158,28 @@ def download_maps(selected_maps, base_url, map_version, download_location):
|
|
|
154
158
|
for map_name in selected_maps:
|
|
155
159
|
download_url = create_download_url(base_url, map_version, map_name)
|
|
156
160
|
local_filename = "{}/{}.mwm".format(download_location, map_name)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
161
|
+
if Path(local_filename).is_file():
|
|
162
|
+
# if local file is already existing, skip downloading it
|
|
163
|
+
print(":white_check_mark:[bold] Already existed: [/bold][italic]{}[/italic]".format(
|
|
164
|
+
map_name,
|
|
165
|
+
))
|
|
166
|
+
continue
|
|
167
|
+
else:
|
|
168
|
+
with requests.get(download_url, stream=True) as r:
|
|
169
|
+
r.raise_for_status()
|
|
170
|
+
per_file_progress = download_progress.add_task(
|
|
171
|
+
"[yellow]File: {}".format(map_name),
|
|
172
|
+
total=int(r.headers.get("content-length", 0)))
|
|
173
|
+
with open(local_filename+".part", 'wb') as f:
|
|
174
|
+
for chunk in r.iter_content(chunk_size=8192):
|
|
175
|
+
f.write(chunk)
|
|
176
|
+
download_progress.update(per_file_progress, advance=8192)
|
|
177
|
+
download_progress.update(per_file_progress, visible=False)
|
|
178
|
+
os.rename(local_filename+".part", local_filename)
|
|
179
|
+
download_progress.update(overall_progress, advance=1)
|
|
180
|
+
print(":white_check_mark:[bold] Downloaded: [/bold][italic]{}[/italic] from {}".format(
|
|
181
|
+
map_name,
|
|
182
|
+
download_url))
|
|
171
183
|
download_progress.stop()
|
|
172
184
|
print("[bold]:rocket: All files downloaded! [/bold]")
|
|
173
185
|
|
|
File without changes
|
|
File without changes
|
{comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/src/comaps_map_distributor/__init__.py
RENAMED
|
File without changes
|
{comaps_map_distributor-0.2.0 → comaps_map_distributor-0.4.0}/src/comaps_map_distributor/server.py
RENAMED
|
File without changes
|