diff options
author | Toshio Kuratomi <a.badger@gmail.com> | 2017-07-03 15:27:15 -0700 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2017-07-04 01:12:43 -0700 |
commit | 3ee997b720a55a5d581c164a4a61275878625366 (patch) | |
tree | a5d127db5ed42824d5e90217e58057d932b8aa3f /hacking/metadata-tool.py | |
parent | 785ed2cfc0df71b19edaa70b7979bc53e7f1125b (diff) | |
download | ansible-3ee997b720a55a5d581c164a4a61275878625366.tar.gz |
metadata and doc generator optimization and fixes
* Fix ansible-doc traceback when a plugin doesn't parse correctly
* Change extract_metadata ivocation to take either an ast or source
code. When given source code, it can find file offsets for the start
and end of dict. When given the ast, it is quicker as it doesn't have
to reparse the source. Requires changing the call to the function to
use a keyword arg.
* Fix reading of metadata to find the last occurrence of
ANSIBLE_METADATA instead of the first.
* Add some more unittests to get closer to complete coverage
Diffstat (limited to 'hacking/metadata-tool.py')
-rwxr-xr-x | hacking/metadata-tool.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/hacking/metadata-tool.py b/hacking/metadata-tool.py index 418feee578..1069c50007 100755 --- a/hacking/metadata-tool.py +++ b/hacking/metadata-tool.py @@ -205,7 +205,8 @@ def write_metadata(filename, new_metadata, version=None, overwrite=False): module_data = f.read() try: - current_metadata, start_line, start_col, end_line, end_col, targets = extract_metadata(module_data) + current_metadata, start_line, start_col, end_line, end_col, targets = \ + extract_metadata(module_data=module_data, offsets=True) except SyntaxError: if filename.endswith('.py'): raise @@ -257,7 +258,7 @@ def return_metadata(plugins): if name not in metadata or metadata[name] is not None: with open(filename, 'rb') as f: module_data = f.read() - metadata[name] = extract_metadata(module_data)[0] + metadata[name] = extract_metadata(module_data=module_data, offsets=True)[0] return metadata @@ -408,7 +409,7 @@ def upgrade_metadata(version=None): # For each plugin, read the existing metadata with open(filename, 'rb') as f: module_data = f.read() - metadata = extract_metadata(module_data)[0] + metadata = extract_metadata(module_data=module_data, offsets=True)[0] # If the metadata isn't the requested version, convert it to the new # version |