Base Crawler¶
pcapkit.vendor.default
contains Vendor
only, which is the base meta class for all vendor crawlers.
Vendor Crawler¶
- class pcapkit.vendor.default.Vendor[source]¶
Bases:
object
Default vendor generator.
Inherit this class with
FLAG
&LINK
attributes, etc., to implement a new vendor generator.- Return type
- static __new__(cls)[source]¶
Subclassing checkpoint.
- Raises
VendorNotImplemented – If
cls
is not a subclass ofVendor
.- Return type
- rename(name, code, *, original=None)[source]¶
Rename duplicated fields.
- Parameters
- Return type
- Returns
Revised field name.
Example
If
name
has multiple occurrences in the source registry, the field name will be sanitised as${name}_${code}
.Otherwise, the plain
name
will be returned.
- _request()[source]¶
Fetch CSV data from
LINK
.This is the low-level call of
request()
.If
LINK
isNone
, it will directly call the upper methodrequest()
with NO arguments.The method will first try to GET the content of
LINK
. Should any exception raised, it will first try with proxy settings fromget_proxies()
.Note
Since some
LINK
links are from Wikipedia, etc., they might not be available in certain areas, e.g. the amazing PRC :)Would proxies failed again, it will prompt for user intervention, i.e. it will use
webbrowser.open()
to open the page in browser for you, and you can manually load that page and save the HTML source at the location it provides.- Returns
CSV data.
- Warns
VendorRequestWarning – If connection failed with and/or without proxies.
- Return type
See also
Crawler Template¶
- pcapkit.vendor.default.LINE(NAME, DOCS, FLAG, ENUM, MISS, MODL)¶
Default constant template of enumeration registry from IANA CSV.
- Parameters
NAME (str) – name of the constant enumeration class
DOCS (str) – docstring for the constant enumeration class
FLAG (str) – threshold value validator (range of valid values)
ENUM (str) – enumeration data (class attributes)
MISS (str) – missing value handler (default value)
MODL (str) – module name of the constant enumeration class
- Return type