Repository: ultrabug/py3status

Issue:
Updating placeholder formats rejects placeholders containing periods
Hi. It is not possible to update placeholder formats for placeholders containing periods.

I ran into this in `nvidia_smi`. Here's a list of placeholders containing periods and/or underscores.
```shell
$ python nvidia_smi.py --list
[
    {
        "= This GPU contains at most 24 usable placeholders.": "",
        "===================================================": "",
        "clocks_throttle_reasons.supported": "0x0000000000000000",
        "compute_mode": "Default",
        "count": "1",
        "driver_version": "340.102",
        "gpu_bus_id": "0000:05:00.0",
        "gpu_name": "Quadro NVS 295",
        "gpu_uuid": "GPU-abcdefgh-ijkl-mopq-rstu-vwxyz0123456",
        "index": "0",
        "memory.free": "148",
        "memory.total": "255",
        "memory.used": "107",
        "name": "Quadro NVS 295",
        "pci.bus": "0x05",
        "pci.bus_id": "0000:05:00.0",
        "pci.device": "0x00",
        "pci.device_id": "0x6FD10DE",
        "pci.domain": "0x0000",
        "pci.sub_device_id": "0x62E10DE",
        "persistence_mode": "Disabled",
        "pstate": "P10",
        "temperature.gpu": "66",
        "timestamp": "2018/02/14 02:39:51.983",
        "uuid": "GPU-abcdefgh-ijkl-mopq-rstu-vwxyz0123456",
        "vbios_version": "62.98.75.00.07"
    }
]
```

I made two new placeholders. To stay consistent with placeholders above, I named them `{memory.used_percent}` and `{memory.free_percent}`. Everything works fine.

The percents are just too long like `34.11768213143`. I used this.
```python
    class Meta:
        update_config = {
            'update_placeholder_format': [
                {
                    'placeholder_formats': {
                        'memory.used_percent': ':.1f',
                        'memory.free_percent': ':.1f',
                    },
                    'format_strings': ['format_gpu']
                },
            ],
        }
```

That's when I ran into this bug. We would print `{test.abc}` instead of `123.4`. Thank you.

```diff
diff --git a/py3status/modules/static_string.py b/py3status/modules/static_string.py
index dbcec8c6..ad2bc21f 100644
--- a/py3status/modules/static_string.py
+++ b/py3status/modules/static_string.py
@@ -16,12 +16,30 @@ class Py3status:
     """
     """
     # available configuration parameters
-    format = 'Hello, world!'
+    format = 'Hello, world! {test}'
+    # format = 'Hello, world! {test.abc}'
+
+    class Meta:
+        update_config = {
+            'update_placeholder_format': [
+                {
+                    'placeholder_formats': {
+                        'test': ':.1f',
+                        'test.abc': ':.1f',
+                    },
+                    'format_strings': ['format']
+                },
+            ],
+        }
 
     def static_string(self):
+        data = {
+            'test': 000.700000,
+            'test.abc': 123.4567,
+        }
         return {
             'cached_until': self.py3.CACHE_FOREVER,
-            'full_text': self.py3.safe_format(self.format),
+            'full_text': self.py3.safe_format(self.format, data)
         }
 
 
```


Discussion:
The thing is that we are using python formatting at the core and the `.` has meaning there as it is about accessing attributes of an object.  So I think we should close this issue.  Maybe better documentation helps if you wish to add some

Resolving patch:
diff --git a/py3status/formatter.py b/py3status/formatter.py
--- a/py3status/formatter.py
+++ b/py3status/formatter.py
@@ -255,8 +255,8 @@ def get(self, get_params, block):
                         value = float(value)
                     if 'd' in self.format:
                         value = int(float(value))
-                    output = u'{%s%s}' % (self.key, self.format)
-                    value = output.format(**{self.key: value})
+                    output = u'{[%s]%s}' % (self.key, self.format)
+                    value = output.format({self.key: value})
                     value_ = float(value)
                 except ValueError:
                     pass


Test patch: