Commit Graph

5 Commits

Author SHA1 Message Date
Stephen Finucane 57e9754093 Switch to collections.abc.*
The abstract base classes previously defined in 'collections' were moved
to 'collections.abc' in 3.3. The aliases will be removed in 3.10.
Preempt this change now with a simple find-replace:

  $ ag -l 'collections.($TYPES)' | \
      xargs sed -i 's/\(collections\)\.\($TYPES\)/\1.abc.\2/g'

Where $TYPES is the list of moved ABCs from [1].

[1] https://docs.python.org/3/library/collections.abc.html

Change-Id: Ia282479bb1d466bd2189ebb21b51d91e89b9581e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-02-01 11:15:59 +00:00
Hervé Beraud 6ccd16cc32 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 5 of a serie of 28 patches

Change-Id: Idb037ded55698790fc1658896f1e2dcdce89f3f9
2020-04-22 12:23:44 +02:00
huangtianhua 4a92678f18 Allows condition name using boolean or function
This change supports:
1. Allow boolean value or condition function as
   condition name of 'if' function:
   resources:
     r1:
        ...
	properties:
	  a: {if: [true, 'value_true', 'value_false']}
     r2:
       ...
       properties:
         b: {if: [{equals: [...]}, 'value_true', 'value_false']}
2. Allow boolean value or condition function as
   condtiion name in resource definition:
   resources:
     r1:
       ...
       condition: false
     r2:
       ...
       condition: {and: [cd1, cd2]}
3. Allow boolean value or condition function as
   condition name in outputs:
   outputs:
     output1:
       value: ...
       condition: true
     output2:
       value: ...
       condition: {not: cd3}

Change-Id: I2bf9bb0b608788c928d12425cbfdaf658df9e880
Co-Authored-By: Zane Bitter <zbitter@redhat.com>
Blueprint: support-conditions-function
2016-09-12 21:40:06 -04:00
Zane Bitter bca8b8e804 Allow referencing conditions by name
This change allows reference with other conditions by name in
definition of a condition, something like:
   conditions:
     cd1: {equals: [{get_param: env_type}, 'prod']}
     cd2: {not: cd1}
     cd3: {equals: [{get_param: zone}, 'fujian']}
     cd4: {and: [cd1, cd3]}

Change-Id: I6a0a00c23aa7d559dedd6998adaa7962d607f315
Co-Authored-By: huangtianhua <huangtianhua@huawei.com>
Blueprint: support-conditions-function
Related-Bug: #1621529
2016-09-12 21:39:01 -04:00
Zane Bitter 6d61a7a7ff Create a public Conditions class API
Change the definitions of the Template.conditions() method to return a new
heat.engine.conditions.Conditions object. This class encapsulates the error
handling involved in looking up a condition, and lazily caches resolved
values so that conditions we never reference are not evaluated.

By raising ValueError instead of StackValidationFailed inside
Conditions.is_enabled(), we ensure that the user sees the full path to the
erroneous condition name if it appears inside the 'if' intrinsic function.

Change-Id: I266eec7e87d185182c4c0fea864e7ebdafa11bd5
2016-09-12 12:09:15 -04:00