You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/12/16 15:43:51 UTC

[GitHub] [ozone] adoroszlai commented on pull request #1712: HDDS-4601. envtoconf broken for .conf and few other formats

adoroszlai commented on pull request #1712:
URL: https://github.com/apache/ozone/pull/1712#issuecomment-746502308


   (Answering the part of your comment from #1667 relevant to this PR.)
   
   > The change itself in transformation.py is to go through the items instead of the collection means that we are transforming something different in those cases and we do it similarly as the one case you mentioned working well before this change also, I am not sure though, how this solves the problem.
   
   @fapifta Here's a Python REPL session to show what's going on:
   
   ```python
   >>> props = {"key": "value"}
   >>> props
   {'key': 'value'}
   >>> props.keys()
   ['key']
   >>> props.values()
   ['value']
   >>> props.items()
   [('key', 'value')]
   >>> for x in props: print x
   ...
   key
   >>> for x in props.keys(): print x
   ...
   key
   >>> for x, y in props: print "{}={}".format(x, y)
   ...
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   ValueError: too many values to unpack
   >>> for x, y in props.items(): print "{}={}".format(x, y)
   ...
   key=value
   >>>
   ```
   
   `props` is a map (dictionary).  `for x in props` iterates keys, same as `for x in props.keys()`.  `for x, y in props` also iterates keys (`in props`), but tries to extract key-value pairs, which fails with `ValueError`, since each key is only a single item.  `for x, y in props.items()` correctly iterates key-value pairs.
   
   Already used correctly in `to_properties`:
   
   https://github.com/apache/ozone/blob/cbe8651217930181057f7a4e496ae20d891ad032/hadoop-ozone/dist/src/main/dockerlibexec/transformation.py#L81-L85


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org