-
Notifications
You must be signed in to change notification settings - Fork 0
/
zip_plugin.py
30 lines (26 loc) · 1.04 KB
/
zip_plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 3Di Models and Simulations for QGIS, licensed under GPLv2 or (at your option) any later version
# Copyright (C) 2023 by Lutra Consulting for 3Di Water Management
import os
import re
import shutil
def get_version(directory):
metadata = os.path.join(directory, "metadata.txt")
reg = "\nversion=(.+)\n"
version = ""
with open(metadata, "r") as f:
m0 = re.search(reg, f.read())
if m0:
version = m0.group(1)
return version
if __name__ == "__main__":
print("ZIPPING PLUGIN STARTED")
this_dir = os.path.dirname(os.path.realpath(__file__))
plugin_dirname = "threedi_models_and_simulations"
plugin_name = "threedi_models_and_simulations"
# ^^^ no spaces, preferably lowercase.
plugin_path = os.path.join(this_dir, plugin_dirname)
plugin_version = get_version(plugin_path)
zip_filename = f"{plugin_name}.{plugin_version}"
plugin_zip_path = os.path.join(this_dir, zip_filename)
shutil.make_archive(plugin_zip_path, "zip", this_dir, plugin_dirname)
print("ZIPPING PLUGIN FINISHED")