def _update_fields(self, other): """ Update the session data from a Transmission JSON-RPC arguments dictionary """ if isinstance(other, dict): for key, value in iteritems(other): self._fields[key.replace('-', '_')] = Field(value, False) elif isinstance(other, Session): for key in list(other._fields.keys()): self._fields[key] = Field(other._fields[key].value, False) else: raise ValueError('Cannot update with supplied data')
def mirror_dict(source): """ Creates a dictionary with all values as keys and all keys as values. """ source.update(dict((value, key) for key, value in iteritems(source))) return source