-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME
330 lines (313 loc) · 11.1 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
Help on module hilbert:
NAME
hilbert
CLASSES
__builtin__.object
HilbertCurve
HilbertContainer
class HilbertContainer(HilbertCurve)
| A container that can be indexed along either the 1- or 2-dimensional aspects
| of a Hilbert curve.
|
| Indexing by the 1-dimensional distance is done just like indexing into a list: curve[d]
|
| Indexing by 2-dimensional coordinates works the same way: curve[x,y]
|
| For example:
|
| >>> curve = HilbertContainer(8)
| >>> curve[3] = "example"
| >>> curve.d2xy(3)
| (1, 0)
| >>> curve[1,0]
| 'example'
|
| Method resolution order:
| HilbertContainer
| HilbertCurve
| __builtin__.object
|
| Methods defined here:
|
| __getitem__(self, d)
|
| __init__(self, side_length, empty=None)
|
| __iter__(self)
| Generator for iterating over the curve. Yields a 2-tuple of (x, y)
| and the value at that point, in Hilbert-curve order (a la turtle).
|
| __setitem__(self, d, value)
|
| ----------------------------------------------------------------------
| Methods inherited from HilbertCurve:
|
| d2xy(self, d)
| Find the coordinates (x, y) of a point some distance *d* along the curve.
|
| xy2d(self, x, y)
| Find the distance of the point (x, y) along the curve.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from HilbertCurve:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| side_length
class HilbertCurve(__builtin__.object)
| Object-oriented interface to 2-dimensional Hilbert curves.
|
| A HilbertCurve object has one attribute, *side_length*, which is the square of
| the order of the curve. A third-order Hilbert curve has a side length of 2**3, or 8.
| The side length will be coerced into the next highest positive power of 2.
|
| Methods defined here:
|
| __init__(self, side_length)
|
| d2xy(self, d)
| Find the coordinates (x, y) of a point some distance *d* along the curve.
|
| xy2d(self, x, y)
| Find the distance of the point (x, y) along the curve.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| side_length
FUNCTIONS
d2xy(side_length, d)
Find the coordinates (x, y) of a point some distance *d* along
a Hilbert curve which fills a square *side_length* units on a side.
xy2d(side_length, x, y)
Find the distance of the point (x, y) along a Hilbert curve
which fills a square *side_length* units on a side.
Help on module ipmap:
NAME
ipmap
CLASSES
hilbert.HilbertContainer(hilbert.HilbertCurve)
IPMap
IPMapHtmlTable
IPMapImage
class IPMap(hilbert.HilbertContainer)
| Base class for IPMap objects. Puts IP/value pairs into buckets and generates
| a Hilbert curve mapping of buckets to x/y coordinates.
|
| Method resolution order:
| IPMap
| hilbert.HilbertContainer
| hilbert.HilbertCurve
| __builtin__.object
|
| Methods defined here:
|
| __init__(self, cidr, side_length=16)
| Required argument *cidr* is the network mask in CIDR notation, e.g. 192.168.1.0/24.
|
| add(self, ip, value)
| Update the IPMap with a new IP and value
|
| bucket(self, ip)
| Get the bucket (0..resolution] that the IP belongs in
|
| build(self)
| Build and return the whole map. Assumes there are no more values to
| add, though the base class version is not destructive. Override this to
| generate different kinds of maps.
|
| update_value(self, bucket, new)
| Given a bucket, update its contents with the new value. Override this
| method to use a different algorithm than addition (the default)
|
| xy2ip(self, x, y)
| Given a set of x/y coordinates, return the lower bound of the IP
| addresses in the corresponding bucket
|
| ----------------------------------------------------------------------
| Methods inherited from hilbert.HilbertContainer:
|
| __getitem__(self, d)
|
| __iter__(self)
| Generator for iterating over the curve. Yields a 2-tuple of (x, y)
| and the value at that point, in Hilbert-curve order (a la turtle).
|
| __setitem__(self, d, value)
|
| ----------------------------------------------------------------------
| Methods inherited from hilbert.HilbertCurve:
|
| d2xy(self, d)
| Find the coordinates (x, y) of a point some distance *d* along the curve.
|
| xy2d(self, x, y)
| Find the distance of the point (x, y) along the curve.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from hilbert.HilbertCurve:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| side_length
class IPMapHtmlTable(IPMap)
| IPMap as an HTML table
|
| Method resolution order:
| IPMapHtmlTable
| IPMap
| hilbert.HilbertContainer
| hilbert.HilbertCurve
| __builtin__.object
|
| Methods defined here:
|
| build(self, numclasses=10)
| Returns the map as HTML *<tr>* and *<td>* elements, suitable for
| including in the *<tbody>* element of a table. Text content is the base
| IP for each bucket, and the class is the return value of
| self.get_class(self[bucket]).
|
| get_class(self, num)
| Override to enum classes
|
| ----------------------------------------------------------------------
| Methods inherited from IPMap:
|
| __init__(self, cidr, side_length=16)
| Required argument *cidr* is the network mask in CIDR notation, e.g. 192.168.1.0/24.
|
| add(self, ip, value)
| Update the IPMap with a new IP and value
|
| bucket(self, ip)
| Get the bucket (0..resolution] that the IP belongs in
|
| update_value(self, bucket, new)
| Given a bucket, update its contents with the new value. Override this
| method to use a different algorithm than addition (the default)
|
| xy2ip(self, x, y)
| Given a set of x/y coordinates, return the lower bound of the IP
| addresses in the corresponding bucket
|
| ----------------------------------------------------------------------
| Methods inherited from hilbert.HilbertContainer:
|
| __getitem__(self, d)
|
| __iter__(self)
| Generator for iterating over the curve. Yields a 2-tuple of (x, y)
| and the value at that point, in Hilbert-curve order (a la turtle).
|
| __setitem__(self, d, value)
|
| ----------------------------------------------------------------------
| Methods inherited from hilbert.HilbertCurve:
|
| d2xy(self, d)
| Find the coordinates (x, y) of a point some distance *d* along the curve.
|
| xy2d(self, x, y)
| Find the distance of the point (x, y) along the curve.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from hilbert.HilbertCurve:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| side_length
class IPMapImage(IPMap)
| IPMap as a heatmap image
|
| Method resolution order:
| IPMapImage
| IPMap
| hilbert.HilbertContainer
| hilbert.HilbertCurve
| __builtin__.object
|
| Methods defined here:
|
| build(self, image_size=256, out='IPMap.png', fmt='PNG')
| Saves a square (*image_size* x *image_size*) image with values
| scaled to a 256-color heatmap.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| palette = [53, 52, 61, 51, 51, 61, 49, 50, 62, 48, 48, 63, 46, 46, 64,...
|
| ----------------------------------------------------------------------
| Methods inherited from IPMap:
|
| __init__(self, cidr, side_length=16)
| Required argument *cidr* is the network mask in CIDR notation, e.g. 192.168.1.0/24.
|
| add(self, ip, value)
| Update the IPMap with a new IP and value
|
| bucket(self, ip)
| Get the bucket (0..resolution] that the IP belongs in
|
| update_value(self, bucket, new)
| Given a bucket, update its contents with the new value. Override this
| method to use a different algorithm than addition (the default)
|
| xy2ip(self, x, y)
| Given a set of x/y coordinates, return the lower bound of the IP
| addresses in the corresponding bucket
|
| ----------------------------------------------------------------------
| Methods inherited from hilbert.HilbertContainer:
|
| __getitem__(self, d)
|
| __iter__(self)
| Generator for iterating over the curve. Yields a 2-tuple of (x, y)
| and the value at that point, in Hilbert-curve order (a la turtle).
|
| __setitem__(self, d, value)
|
| ----------------------------------------------------------------------
| Methods inherited from hilbert.HilbertCurve:
|
| d2xy(self, d)
| Find the coordinates (x, y) of a point some distance *d* along the curve.
|
| xy2d(self, x, y)
| Find the distance of the point (x, y) along the curve.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from hilbert.HilbertCurve:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| side_length
FUNCTIONS
ip_inttostr(ip)
Convert an integer to an IPv4 address in dotted-decimal.
ip_strtoint(ipstr)
Convert an IPv4 address in dotted-decimal to an integer.