Ñò
+z2Wc @ sb d d k Z d d k Z d d d „ ƒ YZ d „ Z e d j o e ƒ n d Z d Z d Z d S(
iÿÿÿÿNt IPCalcc B sA e Z d Z d d d „ Z d „ Z d „ Z d „ Z d „ Z RS( s« A wrapper class that encapsulates the command line
functionality of the ipcalc command, providing access to computing
network prefixes, netmasks, etc. from python.c C s | | _ | | _ | | _ d S( s· Initialize an IPCalc object. Address must be provided, and
in order for most of the other calculations to be possible,
one of prefix or netmask must also be provided.N( t _addresst _prefixt _netmask( t selft addresst prefixt netmask( ( s5 /usr/share/system-config-network/netconfpkg/ipcalc.pyt __init__ s c C sª | i o | i S| i p? t i d | i ƒ i ƒ } t i d | ƒ i ƒ d | _ n t i d | i | i f ƒ i ƒ } t i d | ƒ i ƒ d | _ | i Sd S( Ns ipcalc -m %ss
NETMASK=(\S+)i s ipcalc -p %s %ss PREFIX=(\d+)( R R t ost popenR t readt ret matcht groups( R t text( ( s5 /usr/share/system-config-network/netconfpkg/ipcalc.pyR s
# c C s… | i o | i S| i p t i d | i ƒ i ƒ } n t i d | i | i f ƒ } t i d | ƒ i ƒ d | _ | i Sd S( Ns ipcalc -m %ss ipcalc -m %s/%ss
NETMASK=(\S+)i ( R R R R
R R R R
R ( R R ( ( s5 /usr/share/system-config-network/netconfpkg/ipcalc.pyR * s
c C sW | i p | i ƒ n t i d | i | i f ƒ i ƒ } t i d | ƒ i ƒ d S( Ns ipcalc -n %s/%ss
NETWORK=(\S+)i ( R R R R
R R R R
R ( R R ( ( s5 /usr/share/system-config-network/netconfpkg/ipcalc.pyt network6 s
c C sW | i p | i ƒ n t i d | i | i f ƒ i ƒ } t i d | ƒ i ƒ d S( Ns ipcalc -b %s/%ss BROADCAST=(\S+)i ( R R R R
R R R R
R ( R R ( ( s5 /usr/share/system-config-network/netconfpkg/ipcalc.pyt broadcast= s
N( t __name__t
__module__t __doc__t NoneR R R R R ( ( ( s5 /usr/share/system-config-network/netconfpkg/ipcalc.pyR s
c C sR t d d d ƒ} d G| i ƒ GHd G| i ƒ GHd G| i ƒ GHd G| i ƒ GHd S( s# Test function for the IPCalc class.s
207.175.42.15R s
255.255.254.0s prefix:s netmask:s bcast:s network:N( R R R R R ( t ipc( ( s5 /usr/share/system-config-network/netconfpkg/ipcalc.pyt testD s
t __main__s Harald Hoyer