-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94f5cb4
commit 19c70c6
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# FLO-2D Preprocessor tools for QGIS | ||
# Copyright © 2021 Lutra Consulting for FLO-2D | ||
|
||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version | ||
import os | ||
import re | ||
import shutil | ||
import subprocess | ||
|
||
|
||
def get_plugin_version(directory): | ||
metadata = os.path.join(directory, "metadata.txt") | ||
reg = "\nversion=(.+)\n" | ||
version = "" | ||
with open(metadata, "r") as f: | ||
match = re.search(reg, f.read()) | ||
if match: | ||
version = match.group(1) | ||
return version | ||
|
||
|
||
if __name__ == "__main__": | ||
print("Creating plugin package...") | ||
this_dir = os.path.dirname(os.path.realpath(__file__)) | ||
plugin_dirname = "rasterizor" | ||
plugin_path = os.path.join(this_dir, plugin_dirname) | ||
print("Zipping plugin package...") | ||
plugin_version = get_plugin_version(plugin_path) | ||
zip_filename = f"{plugin_dirname}-{plugin_version}" | ||
plugin_zip_path = os.path.join(this_dir, zip_filename) | ||
shutil.make_archive(plugin_zip_path, "zip", this_dir, plugin_dirname) | ||
print(f"Creating plugin package '{zip_filename}' finished.") |