rockymeza/wifi — pull request #24 by rockymeza (2014-01-22 16:42:24+00:00)
Title: Fill missing "Channel" field

For some reason my output from 'iwlist wlan0 scanning' is missing a channel field.

However, the channel is present at the frequency field:
Frequency:2.457 GHz (Channel 10)

So to use this value if it is available or the channel field if it is available this is what I did:

To solve this I changed and added these lines to scan.py:
```python
quality_re_dict = {'dBm': re.compile(r'Quality=(\d+/\d+).*Signal level=(-\d+) dBm'),
'relative': re.compile(r'Quality=(\d+/\d+).*Signal level=(\d+/\d+)')}
frequency_re = re.compile(r'([\d\.]+ .Hz).*Channel (\d+).*')

```
```python
normalize_value = {
'ssid': lambda v: v.strip('"'),
# 'frequency': lambda v: frequency_re.search(v).group(1),
'encrypted': lambda v: v == 'on',
```
```python
if 'WPA2' in value:
cell.encryption_type = 'wpa2'
elif key == 'frequency':
setattr(cell, 'frequency' ,frequency_re.search(value).group(1) )
setattr(cell, 'channel' ,int(frequency_re.search(value).group(2) ))
elif key in normalize_value:
setattr(cell, key, normalize_value[key](value))
```

Hope you can insert it to the code so that it might help some one else too.