Commit Graph

7 Commits

Author SHA1 Message Date
Hervé Beraud 8c0d58075b Remove six and python 2.7 full support
Six is in use to help us to keep support for python 2.7.
Since the ussuri cycle we decide to remove the python 2.7
support so we can go ahead and also remove six usage from
the python code.

Review process and help
-----------------------
Removing six introduce a lot of changes and an huge amount of modified files
To simplify reviews we decided to split changes into several patches to avoid
painful reviews and avoid mistakes.

To review this patch you can use the six documentation [1] to obtain help and
understand choices.

Additional informations
-----------------------
Changes related to 'six.b(data)' [2]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

six.b [2] encode the given datas in latin-1 in python3 so I did the same
things in this patch.

Latin-1 is equal to iso-8859-1 [3].

This encoding is the default encoding [4] of certain descriptive HTTP
headers.

I suggest to keep latin-1 for the moment and to move to another encoding
in a follow-up patch if needed to move to most powerful encoding (utf8).

HTML4 support utf8 charset and utf8 is the default charset for HTML5 [5].

Note that this commit message is autogenerated and not necesserly contains
changes related to 'six.b'

[1] https://six.readthedocs.io/
[2] https://six.readthedocs.io/#six.b
[3] https://docs.python.org/3/library/codecs.html#standard-encodings
[4] https://www.w3schools.com/charsets/ref_html_8859.asp
[5] https://www.w3schools.com/html/html_charset.asp

Patch 6 of a serie of 28 patches

Change-Id: Ic56cf6da5ff9ab8f4bd218e6516b87f47165206d
2020-04-23 14:49:12 +02:00
Zane Bitter 694dac75ca Define resource/output definition sections with constants
It was unclear what the valid arguments to Template.get_section_name() were
(especially since the function is mis-named for what it actually does in
HOT). Define the arguments as constants and don't pass string literals any
more. Be consistent in how we define paths, standardising on the method in
Resource.validate_template().

Change-Id: Ifd073d9889ff60502f78aaa54532cec2b7814d93
2017-11-16 15:26:40 -05:00
Zane Bitter 3c13cb82a6 Cache dep_attrs for all resources in definitions
When the dep_attrs function was written, it was used only in convergence
after checking a single resource. However, now we also use it to generate
data for the ResourceProxy objects, which is often done for all resources
simultaneously. That means doing O(n^2) dep_attrs() calls, which can really
slow things down when there is a large number of resources with complex
properties (or metadata).

This change adds an all_dep_attrs() call, which runs as fast as dep_attrs()
on everything except get_attr functions and their arguments, but only needs
to be called once instead of once per resource. (The get_attr function can
in future override the default implementation of all_dep_attrs() to be as
efficient as dep_attrs() as well.) The resulting data is cached in the
ResourceDefinition or OutputDefinition so that subsequent calls to their
get_attr() methods with different (or the same) resource names will use the
existing data.

Change-Id: If95f4c04b841519ce3d7492211f2696588c0ed48
Partially-Implements: blueprint stack-definition
Closes-Bug: #1684272
2017-07-21 10:44:51 -04:00
Zane Bitter 6b6d3779cd Add a way to get the resources depended on by an output
Change-Id: Ib17de40c4289df58002ca982bf4f2e319993948d
2017-07-21 10:44:51 -04:00
Zane Bitter 4250958a03 Add an add_output() method to Template
This helps with dynamically building templates, and is similar to the
add_resource method.

Change-Id: I51ce5c913438083d6d43eb6d8a8bf55cfa8ea3ee
Related-Bug: #1660831
2017-06-29 09:07:02 -04:00
Oleksii Chuprykov ec45f0e47e Return error with path in function validate
Error with path to the function is returned now in the
case of failed validation.

Closes-Bug: #1625723
Change-Id: Ib96a944c751543f3eb7cb5f8ba09911fc5cae586
2016-09-22 16:31:52 +03:00
Zane Bitter 7de1c141db Handle outputs with an OutputDefinition class
This is the last remaining area of the code where we were slinging around
CloudFormation-formatted snippets of template. Replace it with a proper API
along the lines of ResourceDefinition.

The default implementation of the new template.Template.outputs() method is
equivalent to what we have previously done spread throughout the code, so
that third-party Template plugins will not be affected until they have had
time to write their own custom implementations.

Change-Id: Ib65dad6db55ae5dafab473bebba67e841ca9a984
2016-09-09 16:14:16 -04:00