summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035>2010-02-04 06:14:14 +0000
committerpmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035>2010-02-04 06:14:14 +0000
commit433f3cdf1869148d6d1e5a9c89ea0a928d1eebcc (patch)
treef3f5fbe8891d08b4a6a6b7cbba70f47b231a0043
parentebc3e47236ee7370656d7978542f4e90ad971fd4 (diff)
downloadipaddr-py-433f3cdf1869148d6d1e5a9c89ea0a928d1eebcc.tar.gz
+ begin updating documentation for 2.x (waaaaaaay too long in coming)
git-svn-id: https://ipaddr-py.googlecode.com/svn@135 09200d28-7f98-11dd-ad27-0f66e57d2035
-rw-r--r--wiki/ExampleUsage-1x.wiki124
-rw-r--r--wiki/ExampleUsage.wiki125
2 files changed, 125 insertions, 124 deletions
diff --git a/wiki/ExampleUsage-1x.wiki b/wiki/ExampleUsage-1x.wiki
new file mode 100644
index 0000000..3a978ac
--- /dev/null
+++ b/wiki/ExampleUsage-1x.wiki
@@ -0,0 +1,124 @@
+
+Examples of the functionality of the 1.x version of the ipaddr library. Documentation for the current version (2.x) will be coming shortly.
+
+A lot of the functionality of the IPv4 class is derived from the BaseIP class. The same is true for the IPv6 class. that means that all of the functionality you see here is exactly the same when dealing with IPv6 addresses.
+
+=== IPv4 ===
+_using ipaddr with IPv4 addresses_
+
+Start by creating your address object.
+You can create an IPv4 object with:
+
+netmask
+{{{
+>>> addr = ipaddr.IPv4('1.1.1.1/255.255.255.0')
+>>> addr
+IPv4('1.1.1.1/24')
+}}}
+
+hostmask
+{{{
+>>> addr = ipaddr.IPv4('1.1.1.1/0.0.0.255')
+>>> addr
+IPv4('1.1.1.1/24')
+}}}
+
+prefix length
+{{{
+>>> addr = ipaddr.IPv4('1.1.1.1/24')
+>>> addr
+IPv4('1.1.1.1/24')
+}}}
+
+nothing (nothing implies a /32 netmask)
+{{{
+>>> addr = ipaddr.IPv4('1.1.1.1')
+>>> addr
+IPv4('1.1.1.1/32')
+}}}
+
+Many of the standard Python operations are supported
+{{{
+# comparisons
+>>> ipaddr.IPv4('1.1.1.1') == ipaddr.IPv4('1.1.1.2')
+False
+>>> ipaddr.IPv4('1.1.1.1') < ipaddr.IPv4('1.1.1.2')
+True
+
+# list inclusion
+>>> a = ipaddr.IPv4('1.1.1.1')
+>>> b = ipaddr.IPv4('1.1.1.2')
+>>> c = ipaddr.IPv4('1.1.1.3')
+>>> a in [a, b, c]
+True
+
+# inclusion
+>>> ipaddr.IPv4('1.1.1.1') in ipaddr.IPv4("1.0.0.0/8")
+True
+
+# sorting
+>>> a = ipaddr.IPv4('1.1.1.10')
+>>> b = ipaddr.IPv4('1.10.1.10')
+>>> c = ipaddr.IPv4('1.1.10.10')
+>>> d = ipaddr.IPv4('1.1.1.1')
+>>> sorted([a, b, c, d])
+[IPv4('1.1.1.1/32'), IPv4('1.1.1.10/32'), IPv4('1.1.10.10/32'), IPv4('1.10.1.10/32')]
+
+# str
+>>> str(ipaddr.IP('1.2.3.4'))
+'1.2.3.4/32'
+
+# int/hex.
+>>> int(ipaddr.IP('1.2.3.4'))
+16909060
+>>> hex(ipaddr.IP('1.2.3.4'))
+'0x1020304'
+}}}
+
+Additionally, there are quite a few network-specific features available to ipaddr.
+{{{
+>>> ipaddr.IPv4('10.0.0.0/8').Supernet()
+IPv4('10.0.0.0/7')
+
+>>> ipaddr.IPv4('10.0.0.0/8').Subnet()
+[IPv4('10.0.0.0/9'), IPv4('10.128.0.0/9')]
+
+>>> ipaddr.IPv4('10.0.0.0/8').Subnet(prefixlen_diff=2) # this returns networks with a prefix length of /10
+[IPv4('10.0.0.0/10'), IPv4('10.64.0.0/10'),
+ IPv4('10.128.0.0/10'), IPv4('10.192.0.0/10')]
+
+# AddressExclude removes an address from a superblock.
+>>> ipaddr.IPv4('10.0.0.0/24').AddressExclude(ipaddr.IPv4('10.0.0.0/32'))
+[IPv4('10.0.0.1/32'), IPv4('10.0.0.2/31'),
+ IPv4('10.0.0.4/30'), IPv4('10.0.0.8/29'),
+ IPv4('10.0.0.16/28'), IPv4('10.0.0.32/27'),
+ IPv4('10.0.0.64/26'), IPv4('10.0.0.128/25')]
+
+}}}
+
+=== IPv6 ===
+
+IPv6 methods are exactly the same as their IPv4 counterparts. this is because a lot of the functionality for both the IPv4 and IPv6 classes is inherited from the BaseIP class. For example:
+
+{{{
+>>> addr = ipaddr.IPv6('ffff::1/120')
+>>> addr
+IPv6('ffff::1/120')
+>>> addr.prefixlen
+120
+>>> addr == ipaddr.IPv6('ffff::2/120')
+False
+>>> addr > ipaddr.IPv6('ffff::2/120')
+False
+>>> addr < ipaddr.IPv6('ffff::2/120')
+True
+>>> addr in ipaddr.IPv6('ffff::1/119')
+True
+>>> hex(addr)
+'0xFFFF0000000000000000000000000001L'
+>>> int(addr)
+340277174624079928635746076935438991361L
+}}}
+
+
+As always, consult your local help(ipaddr) pydoc documentation with questions. \ No newline at end of file
diff --git a/wiki/ExampleUsage.wiki b/wiki/ExampleUsage.wiki
index 3a978ac..48cdce8 100644
--- a/wiki/ExampleUsage.wiki
+++ b/wiki/ExampleUsage.wiki
@@ -1,124 +1 @@
-
-Examples of the functionality of the 1.x version of the ipaddr library. Documentation for the current version (2.x) will be coming shortly.
-
-A lot of the functionality of the IPv4 class is derived from the BaseIP class. The same is true for the IPv6 class. that means that all of the functionality you see here is exactly the same when dealing with IPv6 addresses.
-
-=== IPv4 ===
-_using ipaddr with IPv4 addresses_
-
-Start by creating your address object.
-You can create an IPv4 object with:
-
-netmask
-{{{
->>> addr = ipaddr.IPv4('1.1.1.1/255.255.255.0')
->>> addr
-IPv4('1.1.1.1/24')
-}}}
-
-hostmask
-{{{
->>> addr = ipaddr.IPv4('1.1.1.1/0.0.0.255')
->>> addr
-IPv4('1.1.1.1/24')
-}}}
-
-prefix length
-{{{
->>> addr = ipaddr.IPv4('1.1.1.1/24')
->>> addr
-IPv4('1.1.1.1/24')
-}}}
-
-nothing (nothing implies a /32 netmask)
-{{{
->>> addr = ipaddr.IPv4('1.1.1.1')
->>> addr
-IPv4('1.1.1.1/32')
-}}}
-
-Many of the standard Python operations are supported
-{{{
-# comparisons
->>> ipaddr.IPv4('1.1.1.1') == ipaddr.IPv4('1.1.1.2')
-False
->>> ipaddr.IPv4('1.1.1.1') < ipaddr.IPv4('1.1.1.2')
-True
-
-# list inclusion
->>> a = ipaddr.IPv4('1.1.1.1')
->>> b = ipaddr.IPv4('1.1.1.2')
->>> c = ipaddr.IPv4('1.1.1.3')
->>> a in [a, b, c]
-True
-
-# inclusion
->>> ipaddr.IPv4('1.1.1.1') in ipaddr.IPv4("1.0.0.0/8")
-True
-
-# sorting
->>> a = ipaddr.IPv4('1.1.1.10')
->>> b = ipaddr.IPv4('1.10.1.10')
->>> c = ipaddr.IPv4('1.1.10.10')
->>> d = ipaddr.IPv4('1.1.1.1')
->>> sorted([a, b, c, d])
-[IPv4('1.1.1.1/32'), IPv4('1.1.1.10/32'), IPv4('1.1.10.10/32'), IPv4('1.10.1.10/32')]
-
-# str
->>> str(ipaddr.IP('1.2.3.4'))
-'1.2.3.4/32'
-
-# int/hex.
->>> int(ipaddr.IP('1.2.3.4'))
-16909060
->>> hex(ipaddr.IP('1.2.3.4'))
-'0x1020304'
-}}}
-
-Additionally, there are quite a few network-specific features available to ipaddr.
-{{{
->>> ipaddr.IPv4('10.0.0.0/8').Supernet()
-IPv4('10.0.0.0/7')
-
->>> ipaddr.IPv4('10.0.0.0/8').Subnet()
-[IPv4('10.0.0.0/9'), IPv4('10.128.0.0/9')]
-
->>> ipaddr.IPv4('10.0.0.0/8').Subnet(prefixlen_diff=2) # this returns networks with a prefix length of /10
-[IPv4('10.0.0.0/10'), IPv4('10.64.0.0/10'),
- IPv4('10.128.0.0/10'), IPv4('10.192.0.0/10')]
-
-# AddressExclude removes an address from a superblock.
->>> ipaddr.IPv4('10.0.0.0/24').AddressExclude(ipaddr.IPv4('10.0.0.0/32'))
-[IPv4('10.0.0.1/32'), IPv4('10.0.0.2/31'),
- IPv4('10.0.0.4/30'), IPv4('10.0.0.8/29'),
- IPv4('10.0.0.16/28'), IPv4('10.0.0.32/27'),
- IPv4('10.0.0.64/26'), IPv4('10.0.0.128/25')]
-
-}}}
-
-=== IPv6 ===
-
-IPv6 methods are exactly the same as their IPv4 counterparts. this is because a lot of the functionality for both the IPv4 and IPv6 classes is inherited from the BaseIP class. For example:
-
-{{{
->>> addr = ipaddr.IPv6('ffff::1/120')
->>> addr
-IPv6('ffff::1/120')
->>> addr.prefixlen
-120
->>> addr == ipaddr.IPv6('ffff::2/120')
-False
->>> addr > ipaddr.IPv6('ffff::2/120')
-False
->>> addr < ipaddr.IPv6('ffff::2/120')
-True
->>> addr in ipaddr.IPv6('ffff::1/119')
-True
->>> hex(addr)
-'0xFFFF0000000000000000000000000001L'
->>> int(addr)
-340277174624079928635746076935438991361L
-}}}
-
-
-As always, consult your local help(ipaddr) pydoc documentation with questions. \ No newline at end of file
+placeholder