diff options
author | David Robillard <d@drobilla.net> | 2020-02-15 13:23:46 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-02-16 17:15:42 +0100 |
commit | 441ed560e2479f793c5926e73910fad2b4e927e8 (patch) | |
tree | 13ccb6c0c9e678137139540c198484582905812a /extras | |
parent | 128f51a32ab3107bb3ee676de931c364bf0e853b (diff) | |
download | autowaf-441ed560e2479f793c5926e73910fad2b4e927e8.tar.gz autowaf-441ed560e2479f793c5926e73910fad2b4e927e8.tar.bz2 autowaf-441ed560e2479f793c5926e73910fad2b4e927e8.zip |
Tolerate a missing wscript, or missing attributes
This will cause a failure later if these values are actually needed, but is
useful for using the news utilities for subprojects.
Diffstat (limited to 'extras')
-rwxr-xr-x | extras/autoship.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/extras/autoship.py b/extras/autoship.py index 7469f74..17d969f 100755 --- a/extras/autoship.py +++ b/extras/autoship.py @@ -34,16 +34,24 @@ def get_project_info(top=None): loader = importlib.machinery.SourceFileLoader("wscript", wscript_path) spec = importlib.util.spec_from_loader("wscript", loader) wscript = importlib.util.module_from_spec(spec) - spec.loader.exec_module(wscript) - - return { - "name": wscript.APPNAME, - "version": wscript.VERSION, - "uri": getattr(wscript, "uri", None), - "title": getattr(wscript, "title", wscript.APPNAME.title()), - "dist_pattern": wscript.dist_pattern, - "post_tags": wscript.post_tags, - } + + try: + spec.loader.exec_module(wscript) + + info = {"name": wscript.APPNAME, "version": wscript.VERSION} + + for key in ["uri", "title", "dist_pattern", "post_tags"]: + value = getattr(wscript, key, None) + if value is not None: + info[key] = value + + if "title" not in info: + info["title"] = wscript.APPNAME.title() + + return info + + except Exception: + return {} def parse_version(revision): |