| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- '''
- @author: olivier.massot, 2019
- '''
- import configparser
- from zipfile import ZipFile, ZIP_DEFLATED
- from path import Path
- from mncheck.core import constants
- HERE = Path(__file__).parent
- build_dir = HERE / "build"
- build_dir.mkdir_p()
- version = constants.VERSION
- pluginname = "mncheck"
- name = "{}_v{}.zip".format(pluginname, version.replace(".", "-"))
- config = configparser.ConfigParser()
- config["general"] = {"name" : pluginname,
- "qgisminimumversion" : "3.4",
- "description" : "Contrôle des données FTTH format MN",
- "version" : version,
- "author" : "Manche Numérique 2019",
- "email" : constants.CONTACT,
- "about" : "Auto-contrôle des livrables FTTH aux formats Manche Numérique",
- "tracker" : "",
- "repository" : "",
- "tags" : "python",
- "homepage" : "http://www.manchenumerique.fr/",
- "category" : "Plugins",
- "icon" : "icon.png",
- "experimental" : "False",
- "deprecated" : "False"}
- with open(constants.MAIN / 'metadata.txt', 'w+', encoding='utf-8') as mdf:
- mdf.write("# This file was generated by the build.py script, do not modify it direcly\n".upper())
- config.write(mdf)
- with ZipFile(build_dir / name, 'w', ZIP_DEFLATED, 9) as zip_:
-
- def _zip_write(p, arcname=None):
- if p.ext == ".pyc":
- return
- if not arcname:
- arcname = ("{}/{}".format(pluginname, p.relpath(constants.MAIN)).replace("\\", "/"))
- print(arcname)
- zip_.write(p, arcname)
- _zip_write(constants.MAIN)
-
- _zip_write(constants.MAIN / "core")
- for f in Path(constants.MAIN / "core").walkfiles():
- _zip_write(f)
-
- _zip_write(constants.MAIN / "schemas")
- for f in Path(constants.MAIN / "schemas").walkfiles():
- _zip_write(f)
-
- _zip_write(constants.MAIN / "ui")
- for f in Path(constants.MAIN / "ui").walkfiles():
- _zip_write(f)
- _zip_write(constants.MAIN / "ext")
- for f in Path(constants.MAIN / "ext").walkfiles():
- _zip_write(f)
-
- _zip_write(constants.MAIN / "__init__.py")
- _zip_write(constants.MAIN / "main.py")
- _zip_write(constants.MAIN / "icon.png")
- _zip_write(constants.MAIN / "metadata.txt")
-
- _zip_write(HERE / "README.md", f"{pluginname}/README.md")
- _zip_write(HERE / "LICENSE", f"{pluginname}/LICENSE")
-
- Path(build_dir / "metadata.txt").remove_p()
- print(f"-- {name} file built --")
|