On Thu, 2012-11-29 at 14:23 -0800, Brian C. Lane wrote:
On Thu, Nov 29, 2012 at 03:30:43PM +0100, Vratislav Podzimek wrote:
> The rules for hostname are more strict. Also, it was not easy to use
> this function because of its return values.
>
> Related: rhbz#865869
>
> Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
> ---
> pyanaconda/network.py | 37 +++++++++++++++++++++++++++++--------
> 1 file changed, 29 insertions(+), 8 deletions(-)
> - return None
> + if any(not HOSTNAME_PART_RE.match(part) for part in
hostname.split(".")):
> + return (False, _("Hostnames can only contain the characters
'a-z', "
> + "'A-Z', '0-9', '-', or
'.', and parts between periods "
> + "must contain something and cannot start or end with
"
> + "'-'."))
I think 'not all(HOSTNAME_PART_RE...)' would be easier to read. You want
all of the parts to match so if they don't all match return an error.
I was
deciding between these two versions and ended up with the
'any(not...)'. I'll change it locally before pushing.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic