Generovani flist.txt opet funkcni, template promenne, verze 1.3.0

This commit is contained in:
Pavel Brychta 2020-08-28 12:53:37 +02:00
parent 284a0c1b8c
commit 58983e4b1b
2 changed files with 38 additions and 19 deletions

View File

@ -65,6 +65,11 @@ Doplňující parametry v sekci `copy` jsou:
* `flistignore` - soubor se neuloží do seznamu v souboru * `flistignore` - soubor se neuloží do seznamu v souboru
* `syntehtic` - příznak, že soubor pro přesun vznikl pomocí sekce `combine` a nemá se tedy hledat ve zdrojových adresářích * `syntehtic` - příznak, že soubor pro přesun vznikl pomocí sekce `combine` a nemá se tedy hledat ve zdrojových adresářích
* `templatevariables` - seznam proměnných a jejich hodnoty, nahrazované template procesorem.
```json
"templatevariables": {"title":"Titulek", "name":"Jmeno aplikace"}
```
K projektu ho většinou přidáváme pomocí K projektu ho většinou přidáváme pomocí
```sh ```sh

View File

@ -9,7 +9,7 @@ __author__ = "Pavel Brychta"
__copyright__ = "Copyright (c) 2019-2020, Pavel Brychta" __copyright__ = "Copyright (c) 2019-2020, Pavel Brychta"
__credits__ = ["Pavel Brychta"] __credits__ = ["Pavel Brychta"]
__license__ = "Private" __license__ = "Private"
__version__ = "1.2.0" __version__ = "1.3.0"
__maintainer__ = "Pavel Brychta" __maintainer__ = "Pavel Brychta"
__email__ = "Pablo@xPablo.cz" __email__ = "Pablo@xPablo.cz"
__status__ = "Beta" __status__ = "Beta"
@ -156,7 +156,7 @@ def copycompresstree(src, dst, compress, dirbase):
outfile = gzip.open(d, 'wb') outfile = gzip.open(d, 'wb')
outfile.writelines(infile) outfile.writelines(infile)
outfile.close() outfile.close()
if flist is not None and not fignore: if (flist is not None) and (not fignore):
flc = item + ".gz" flc = item + ".gz"
if fforce: if fforce:
flc += ",force" flc += ",force"
@ -165,7 +165,7 @@ def copycompresstree(src, dst, compress, dirbase):
d = os.path.normpath(os.path.join(dst, item)) d = os.path.normpath(os.path.join(dst, item))
print(s + ' (F)-> ' + d) print(s + ' (F)-> ' + d)
shutil.copy2(s, d) shutil.copy2(s, d)
if flist is not None and not fignore: if (flist is not None) and (not fignore):
flc = item flc = item
if fforce: if fforce:
flc += ",force" flc += ",force"
@ -174,33 +174,42 @@ def copycompresstree(src, dst, compress, dirbase):
# Ziskani verze repozitare z gitu # Ziskani verze repozitare z gitu
def getgitversion(): def getgitversion():
isgit = True
after = b"0" after = b"0"
mod = b"" mod = b""
try: try:
tag = subprocess.check_output(["git", "describe", "--tags", "--always"]).strip() tag = subprocess.check_output(["git", "describe", "--tags", "--always"]).strip()
except: except:
tag = b"0.0.0" tag = b"0.0.0"
if tag.find(b".") < 0: isgit = False
tag = b"0.0.0"
if tag == b"0.0.0": if isgit:
after = subprocess.check_output(["git", "rev-list", "--all", "--count"]).strip() if tag.find(b".") < 0:
else: tag = b"0.0.0"
if tag.find(b"-") > 0: if tag == b"0.0.0":
taginfo = tag.split(b'-') after = subprocess.check_output(["git", "rev-list", "--all", "--count"]).strip()
tag = taginfo[0]
after = taginfo[1]
else: else:
after = subprocess.check_output(["git", "rev-list", tag + "..HEAD", "--count"]).strip() if tag.find(b"-") > 0:
mod = subprocess.check_output(["git", "diff-index", "HEAD"]).strip() taginfo = tag.split(b'-')
if after == b"0": tag = taginfo[0]
revision = tag after = taginfo[1]
else:
after = subprocess.check_output(["git", "rev-list", tag + "..HEAD", "--count"]).strip()
mod = subprocess.check_output(["git", "diff-index", "HEAD"]).strip()
if after == b"0":
revision = tag
else:
revision = tag + b'.' + after
if mod != b"":
revision = revision + b"m"
else: else:
revision = tag + b'.' + after revision = b"0.0.0.x"
if mod != b"":
revision = revision + b"m"
return revision.decode("utf-8") return revision.decode("utf-8")
def main(argv): def main(argv):
global flist
global flistcontent
projectfile = PROJECT_FILE # default jmeno projektoveho souboru projectfile = PROJECT_FILE # default jmeno projektoveho souboru
try: try:
opts, args = getopt.getopt(argv, "hi:o:", ["ifile="]) opts, args = getopt.getopt(argv, "hi:o:", ["ifile="])
@ -217,6 +226,11 @@ def main(argv):
with open(projectfile) as fd: with open(projectfile) as fd:
project = json.load(fd) project = json.load(fd)
if "templatevariables" in project:
tv = project["templatevariables"]
for entry in tv:
templatevars[entry] = tv[entry]
if "build" in project: if "build" in project:
build = project["build"] build = project["build"]