Search is not available for this dataset
text stringlengths 75 104k |
|---|
def _coeff4(N, a0, a1, a2, a3):
"""a common internal function to some window functions with 4 coeffs
For the blackmna harris for instance, the results are identical to octave if N is odd
but not for even values...if n =0 whatever N is, the w(0) must be equal to a0-a1+a2-a3, which
is the case here, but... |
def window_nuttall(N):
r"""Nuttall tapering window
:param N: window length
.. math:: w(n) = a_0 - a_1 \cos\left(\frac{2\pi n}{N-1}\right)+ a_2 \cos\left(\frac{4\pi n}{N-1}\right)- a_3 \cos\left(\frac{6\pi n}{N-1}\right)
with :math:`a_0 = 0.355768`, :math:`a_1 = 0.487396`, :math:`a_2=0.144232` and :ma... |
def window_blackman_nuttall(N):
r"""Blackman Nuttall window
returns a minimum, 4-term Blackman-Harris window. The window is minimum in the sense that its maximum sidelobes are minimized.
The coefficients for this window differ from the Blackman-Harris window coefficients and produce slightly lower sidelobe... |
def window_blackman_harris(N):
r"""Blackman Harris window
:param N: window length
.. math:: w(n) = a_0 - a_1 \cos\left(\frac{2\pi n}{N-1}\right)+ a_2 \cos\left(\frac{4\pi n}{N-1}\right)- a_3 \cos\left(\frac{6\pi n}{N-1}\right)
=============== =========
coeff value
=============== =... |
def window_bohman(N):
r"""Bohman tapering window
:param N: window length
.. math:: w(n) = (1-|x|) \cos (\pi |x|) + \frac{1}{\pi} \sin(\pi |x|)
where x is a length N vector of linearly spaced values between
-1 and 1.
.. plot::
:width: 80%
:include-source:
from spectru... |
def window_tukey(N, r=0.5):
"""Tukey tapering window (or cosine-tapered window)
:param N: window length
:param r: defines the ratio between the constant section and the cosine
section. It has to be between 0 and 1.
The function returns a Hanning window for `r=0` and a full box for `r=1`.
..... |
def window_parzen(N):
r"""Parsen tapering window (also known as de la Valle-Poussin)
:param N: window length
Parzen windows are piecewise cubic approximations
of Gaussian windows. Parzen window sidelobes fall off as :math:`1/\omega^4`.
if :math:`0\leq|x|\leq (N-1)/4`:
.. math:: w(n) = 1-6 \l... |
def window_flattop(N, mode='symmetric',precision=None):
r"""Flat-top tapering window
Returns symmetric or periodic flat top window.
:param N: window length
:param mode: way the data are normalised. If mode is *symmetric*, then
divide n by N-1. IF mode is *periodic*, divide by N,
to be ... |
def window_taylor(N, nbar=4, sll=-30):
"""Taylor tapering window
Taylor windows allows you to make tradeoffs between the
mainlobe width and sidelobe level (sll).
Implemented as described by Carrara, Goodman, and Majewski
in 'Spotlight Synthetic Aperture Radar: Signal Processing Algorithms'
Pa... |
def window_riesz(N):
r"""Riesz tapering window
:param N: window length
.. math:: w(n) = 1 - \left| \frac{n}{N/2} \right|^2
with :math:`-N/2 \leq n \leq N/2`.
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'riesz')
..... |
def window_riemann(N):
r"""Riemann tapering window
:param int N: window length
.. math:: w(n) = 1 - \left| \frac{n}{N/2} \right|^2
with :math:`-N/2 \leq n \leq N/2`.
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'riesz')... |
def window_poisson(N, alpha=2):
r"""Poisson tapering window
:param int N: window length
.. math:: w(n) = \exp^{-\alpha \frac{|n|}{N/2} }
with :math:`-N/2 \leq n \leq N/2`.
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'po... |
def window_poisson_hanning(N, alpha=2):
r"""Hann-Poisson tapering window
This window is constructed as the product of the Hanning and Poisson
windows. The parameter **alpha** is the Poisson parameter.
:param int N: window length
:param float alpha: parameter of the poisson window
.. plot::
... |
def window_cauchy(N, alpha=3):
r"""Cauchy tapering window
:param int N: window length
:param float alpha: parameter of the poisson window
.. math:: w(n) = \frac{1}{1+\left(\frac{\alpha*n}{N/2}\right)**2}
.. plot::
:width: 80%
:include-source:
from spectrum import window_v... |
def compute_response(self, **kargs):
"""Compute the window data frequency response
:param norm: True by default. normalised the frequency data.
:param int NFFT: total length of the final data sets( 2048 by default.
if less than data length, then NFFT is set to the data length*2).
... |
def plot_frequencies(self, mindB=None, maxdB=None, norm=True):
"""Plot the window in the frequency domain
:param mindB: change the default lower y bound
:param maxdB: change the default upper lower bound
:param bool norm: if True, normalise the frequency response.
.. plot::
... |
def plot_window(self):
"""Plot the window in the time domain
.. plot::
:width: 80%
:include-source:
from spectrum.window import Window
w = Window(64, name='hamming')
w.plot_window()
"""
from pylab import plot, xlim, grid, tit... |
def plot_time_freq(self, mindB=-100, maxdB=None, norm=True,
yaxis_label_position="right"):
"""Plotting method to plot both time and frequency domain results.
See :meth:`plot_frequencies` for the optional arguments.
.. plot::
:width: 80%
:include-source:
... |
def TOEPLITZ(T0, TC, TR, Z):
"""solve the general toeplitz linear equations
Solve TX=Z
:param T0: zero lag value
:param TC: r1 to rN
:param TR: r1 to rN
returns X
requires 3M^2+M operations instead of M^3 with gaussian elimination
.. warning:: not used right now
"""
... |
def HERMTOEP(T0, T, Z):
"""solve Tx=Z by a variation of Levinson algorithm where T
is a complex hermitian toeplitz matrix
:param T0: zero lag value
:param T: r1 to rN
:return: X
used by eigen PSD method
"""
assert len(T)>0
M = len(T)
X = numpy.zeros(M+1,dtype=complex... |
def get_short_module_name(module_name, obj_name):
""" Get the shortest possible module name """
parts = module_name.split('.')
short_name = module_name
for i in range(len(parts) - 1, 0, -1):
short_name = '.'.join(parts[:i])
try:
exec('from %s import %s' % (short_name, obj_nam... |
def identify_names(code):
"""Builds a codeobj summary by identifying and resolving used names
>>> code = '''
... from a.b import c
... import d as e
... print(c)
... e.HelloWorld().f.g
... '''
>>> for name, o in sorted(identify_names(code).items()):
... print(name, o['name'], o[... |
def _thumbnail_div(full_dir, fname, snippet, is_backref=False):
"""Generates RST to place a thumbnail in a gallery"""
thumb = os.path.join(full_dir, 'images', 'thumb',
'sphx_glr_%s_thumb.png' % fname[:-3])
ref_name = os.path.join(full_dir, fname).replace(os.path.sep, '_')
templ... |
def modcovar_marple (X,IP):
"""Fast algorithm for the solution of the modified covariance least squares normal equations.
This implementation is based on [Marple]_. This code is far more
complicated and slower than :func:`modcovar` function, which is now the official version.
See :func:`modcovar` for a... |
def modcovar(x, order):
"""Simple and fast implementation of the covariance AR estimate
This code is 10 times faster than :func:`modcovar_marple` and more importantly
only 10 lines of code, compared to a 200 loc for :func:`modcovar_marple`
:param X: Array of complex data samples
:param int ... |
def aryule(X, order, norm='biased', allow_singularity=True):
r"""Compute AR coefficients using Yule-Walker method
:param X: Array of complex data values, X(1) to X(N)
:param int order: Order of autoregressive process to be fitted (integer)
:param str norm: Use a biased or unbiased correlation.
:par... |
def LEVINSON(r, order=None, allow_singularity=False):
r"""Levinson-Durbin recursion.
Find the coefficients of a length(r)-1 order autoregressive linear process
:param r: autocorrelation sequence of length N + 1 (first element being the zero-lag autocorrelation)
:param order: requested order of the aut... |
def rlevinson(a, efinal):
"""computes the autocorrelation coefficients, R based
on the prediction polynomial A and the final prediction error Efinal,
using the stepdown algorithm.
Works for real or complex data
:param a:
:param efinal:
:return:
* R, the autocorrelation
* U... |
def levdown(anxt, enxt=None):
"""One step backward Levinson recursion
:param anxt:
:param enxt:
:return:
* acur the P'th order prediction polynomial based on the P+1'th order prediction polynomial, anxt.
* ecur the the P'th order prediction error based on the P+1'th order prediction er... |
def levup(acur, knxt, ecur=None):
"""LEVUP One step forward Levinson recursion
:param acur:
:param knxt:
:return:
* anxt the P+1'th order prediction polynomial based on the P'th order prediction polynomial, acur, and the
P+1'th order reflection coefficient, Knxt.
* enxt the P... |
def arcovar_marple(x, order):
r"""Estimate AR model parameters using covariance method
This implementation is based on [Marple]_. This code is far more
complicated and slower than :func:`arcovar` function, which is now the official version.
See :func:`arcovar` for a detailed description of Covariance m... |
def arcovar(x, order):
r"""Simple and fast implementation of the covariance AR estimate
This code is 10 times faster than :func:`arcovar_marple` and more importantly
only 10 lines of code, compared to a 200 loc for :func:`arcovar_marple`
:param array X: Array of complex data samples
:param int o... |
def lpc(x, N=None):
"""Linear Predictor Coefficients.
:param x:
:param int N: default is length(X) - 1
:Details:
Finds the coefficients :math:`A=(1, a(2), \dots a(N+1))`, of an Nth order
forward linear predictor that predicts the current value value of the
real-valued time series x based ... |
def minvar(X, order, sampling=1., NFFT=default_NFFT):
r"""Minimum Variance Spectral Estimation (MV)
This function computes the minimum variance spectral estimate using
the Musicus procedure. The Burg algorithm from :func:`~spectrum.burg.arburg`
is used for the estimation of the autoregressive paramete... |
def pascal(n):
"""Return Pascal matrix
:param int n: size of the matrix
.. doctest::
>>> from spectrum import pascal
>>> pascal(6)
array([[ 1., 1., 1., 1., 1., 1.],
[ 1., 2., 3., 4., 5., 6.],
[ 1., 3., 6., 1... |
def corrmtx(x_input, m, method='autocorrelation'):
r"""Correlation matrix
This function is used by PSD estimator functions. It generates
the correlation matrix from a correlation data set and a maximum lag.
:param array x: autocorrelation samples (1D)
:param int m: the maximum lag
Depending o... |
def csvd(A):
"""SVD decomposition using numpy.linalg.svd
:param A: a M by N matrix
:return:
* U, a M by M matrix
* S the N eigen values
* V a N by N matrix
See :func:`numpy.linalg.svd` for a detailed documentation.
Should return the same as in [Marple]_ , CSVD routine.
... |
def compatible_staticpath(path):
"""
Try to return a path to static the static files compatible all
the way back to Django 1.2. If anyone has a cleaner or better
way to do this let me know!
"""
if VERSION >= (1, 10):
# Since Django 1.10, forms.Media automatically invoke static
#... |
def main(argv=None):
"""Main command line interface."""
if argv is None:
argv = sys.argv[1:]
cli = CommandLineTool()
return cli.run(argv) |
def pass_from_pipe(cls):
"""Return password from pipe if not on TTY, else False.
"""
is_pipe = not sys.stdin.isatty()
return is_pipe and cls.strip_last_newline(sys.stdin.read()) |
def _load_plugins():
"""
Locate all setuptools entry points by the name 'keyring backends'
and initialize them.
Any third-party library may register an entry point by adding the
following to their setup.py::
entry_points = {
'keyring.backends': [
'plugin_name = m... |
def get_all_keyring():
"""
Return a list of all implemented keyrings that can be constructed without
parameters.
"""
_load_plugins()
viable_classes = KeyringBackend.get_viable_backends()
rings = util.suppress_exceptions(viable_classes, exceptions=TypeError)
return list(rings) |
def name(cls):
"""
The keyring name, suitable for display.
The name is derived from module and class name.
"""
parent, sep, mod_name = cls.__module__.rpartition('.')
mod_name = mod_name.replace('_', ' ')
return ' '.join([mod_name, cls.__name__]) |
def get_credential(self, service, username):
"""Gets the username and password for the service.
Returns a Credential instance.
The *username* argument is optional and may be omitted by
the caller or ignored by the backend. Callers must use the
returned username.
"""
... |
def get_password(self, service, username):
"""Get password of the username for the service
"""
if not self.connected(service):
# the user pressed "cancel" when prompted to unlock their keyring.
raise KeyringLocked("Failed to unlock the keyring!")
if not self.iface... |
def set_password(self, service, username, password):
"""Set password for the username of the service
"""
if not self.connected(service):
# the user pressed "cancel" when prompted to unlock their keyring.
raise PasswordSetError("Cancelled by user")
self.iface.write... |
def delete_password(self, service, username):
"""Delete the password for the username of the service.
"""
if not self.connected(service):
# the user pressed "cancel" when prompted to unlock their keyring.
raise PasswordDeleteError("Cancelled by user")
if not self.... |
def _get_env(self, env_var):
"""Helper to read an environment variable
"""
value = os.environ.get(env_var)
if not value:
raise ValueError('Missing environment variable:%s' % env_var)
return value |
def get_preferred_collection(self):
"""If self.preferred_collection contains a D-Bus path,
the collection at that address is returned. Otherwise,
the default collection is returned.
"""
bus = secretstorage.dbus_init()
try:
if hasattr(self, 'preferred_collectio... |
def get_password(self, service, username):
"""Get password of the username for the service
"""
collection = self.get_preferred_collection()
items = collection.search_items(
{"username": username, "service": service})
for item in items:
if hasattr(item, 'un... |
def set_password(self, service, username, password):
"""Set password for the username of the service
"""
collection = self.get_preferred_collection()
attributes = {
"application": self.appid,
"service": service,
"username": username
}
l... |
def delete_password(self, service, username):
"""Delete the stored password (only the first one)
"""
collection = self.get_preferred_collection()
items = collection.search_items(
{"username": username, "service": service})
for item in items:
return item.de... |
def unpack(word):
r"""
>>> PackedAttributes.unpack(0)
0
>>> PackedAttributes.unpack('\x00\x00\x00\x01')
1
>>> PackedAttributes.unpack('abcd')
1633837924
"""
if not isinstance(word, str):
return word
val, = struct.unpack('!I', wo... |
def backends(cls):
"""
Discover all keyrings for chaining.
"""
allowed = (
keyring
for keyring in filter(backend._limit, backend.get_all_keyring())
if not isinstance(keyring, ChainerBackend)
and keyring.priority > 0
)
return... |
def set_keyring(keyring):
"""Set current keyring backend.
"""
global _keyring_backend
if not isinstance(keyring, backend.KeyringBackend):
raise TypeError("The keyring must be a subclass of KeyringBackend")
_keyring_backend = keyring |
def disable():
"""
Configure the null keyring as the default.
"""
root = platform.config_root()
try:
os.makedirs(root)
except OSError:
pass
filename = os.path.join(root, 'keyringrc.cfg')
if os.path.exists(filename):
msg = "Refusing to overwrite {filename}".format(... |
def init_backend(limit=None):
"""
Load a keyring specified in the config file or infer the best available.
Limit, if supplied, should be a callable taking a backend and returning
True if that backend should be included for consideration.
"""
# save the limit for the chainer to honor
backend... |
def _load_keyring_class(keyring_name):
"""
Load the keyring class indicated by name.
These popular names are tested to ensure their presence.
>>> popular_names = [
... 'keyring.backends.Windows.WinVaultKeyring',
... 'keyring.backends.OS_X.Keyring',
... 'keyring.backends.kwal... |
def load_config():
"""Load a keyring using the config file in the config root."""
filename = 'keyringrc.cfg'
keyring_cfg = os.path.join(platform.config_root(), filename)
if not os.path.exists(keyring_cfg):
return
config = configparser.RawConfigParser()
config.read(keyring_cfg)
_l... |
def _load_keyring_path(config):
"load the keyring-path option (if present)"
try:
path = config.get("backend", "keyring-path").strip()
sys.path.insert(0, path)
except (configparser.NoOptionError, configparser.NoSectionError):
pass |
def _data_root_Linux():
"""
Use freedesktop.org Base Dir Specfication to determine storage
location.
"""
fallback = os.path.expanduser('~/.local/share')
root = os.environ.get('XDG_DATA_HOME', None) or fallback
return os.path.join(root, 'python_keyring') |
def _check_old_config_root():
"""
Prior versions of keyring would search for the config
in XDG_DATA_HOME, but should probably have been
searching for config in XDG_CONFIG_HOME. If the
config exists in the former but not in the latter,
raise a RuntimeError to force the change.
"""
# disab... |
def _config_root_Linux():
"""
Use freedesktop.org Base Dir Specfication to determine config
location.
"""
_check_old_config_root()
fallback = os.path.expanduser('~/.local/share')
key = 'XDG_CONFIG_HOME'
root = os.environ.get(key, None) or fallback
return os.path.join(root, 'python_ke... |
def make_formatter(format_name):
"""Returns a callable that outputs the data. Defaults to print."""
if "json" in format_name:
from json import dumps
import datetime
def jsonhandler(obj): obj.isoformat() if isinstance(obj, (datetime.datetime, datetime.date)) else obj
if format_na... |
def argparser():
"""Constructs the ArgumentParser for the CLI"""
parser = ArgumentParser(prog='pynetgear')
parser.add_argument("--format", choices=['json', 'prettyjson', 'py'], default='prettyjson')
router_args = parser.add_argument_group("router connection config")
router_args.add_argument("--ho... |
def run_subcommand(netgear, args):
"""Runs the subcommand configured in args on the netgear session"""
subcommand = args.subcommand
if subcommand == "block_device" or subcommand == "allow_device":
return netgear.allow_block_device(args.mac_addr, BLOCK if subcommand == "block_device" else ALLOW)
... |
def main():
"""Scan for devices and print results."""
args = argparser().parse_args(sys.argv[1:])
password = os.environ.get('PYNETGEAR_PASSWORD') or args.password
netgear = Netgear(password, args.host, args.user, args.port, args.ssl, args.url, args.force_login_v2)
results = run_subcommand(netgear... |
def autodetect_url():
"""
Try to autodetect the base URL of the router SOAP service.
Returns None if it can't be found.
"""
for url in ["http://routerlogin.net:5000", "https://routerlogin.net",
"http://routerlogin.net"]:
try:
r = requests.get(url + "/soap/server_... |
def _xml_get(e, name):
"""
Returns the value of the subnode "name" of element e.
Returns None if the subnode doesn't exist
"""
r = e.find(name)
if r is not None:
return r.text
return None |
def _convert(value, to_type, default=None):
"""Convert value to to_type, returns default if fails."""
try:
return default if value is None else to_type(value)
except ValueError:
# If value could not be converted
return default |
def login(self):
"""
Login to the router.
Will be called automatically by other actions.
"""
if not self.force_login_v2:
v1_result = self.login_v1()
if v1_result:
return v1_result
return self.login_v2() |
def get_attached_devices(self):
"""
Return list of connected devices to the router.
Returns None if error occurred.
"""
_LOGGER.info("Get attached devices")
success, response = self._make_request(SERVICE_DEVICE_INFO,
"GetAt... |
def get_attached_devices_2(self):
"""
Return list of connected devices to the router with details.
This call is slower and probably heavier on the router load.
Returns None if error occurred.
"""
_LOGGER.info("Get attached devices 2")
success, response = self._... |
def get_traffic_meter(self):
"""
Return dict of traffic meter stats.
Returns None if error occurred.
"""
_LOGGER.info("Get traffic meter")
def parse_text(text):
"""
there are three kinds of values in the returned data
This fun... |
def config_start(self):
"""
Start a configuration session.
For managing router admin functionality (ie allowing/blocking devices)
"""
_LOGGER.info("Config start")
success, _ = self._make_request(
SERVICE_DEVICE_CONFIG, "ConfigurationStarted", {"NewSessionID":... |
def config_finish(self):
"""
End of a configuration session.
Tells the router we're done managing admin functionality.
"""
_LOGGER.info("Config finish")
if not self.config_started:
return True
success, _ = self._make_request(
SERVICE_DEVIC... |
def allow_block_device(self, mac_addr, device_status=BLOCK):
"""
Allow or Block a device via its Mac Address.
Pass in the mac address for the device that you want to set. Pass in the
device_status you wish to set the device to: Allow (allow device to access the
network) or Block ... |
def _make_request(self, service, method, params=None, body="",
need_auth=True):
"""Make an API request to the router."""
# If we have no cookie (v2) or never called login before (v1)
# and we need auth, the request will fail for sure.
if need_auth and not self.cooki... |
def ip2long(ip):
"""
Wrapper function for IPv4 and IPv6 converters.
:arg ip: IPv4 or IPv6 address
"""
try:
return int(binascii.hexlify(socket.inet_aton(ip)), 16)
except socket.error:
return int(binascii.hexlify(socket.inet_pton(socket.AF_INET6, ip)), 16) |
def str2fp(data):
"""
Convert bytes data to file handle object (StringIO or BytesIO).
:arg data: String data to transform
"""
return BytesIO(bytearray(data, const.ENCODING)) if const.PY3 else StringIO(data) |
def _setup_segments(self):
"""
Parses the database file to determine what kind of database is
being used and setup segment sizes and start points that will
be used by the seek*() methods later.
"""
self._databaseType = const.COUNTRY_EDITION
self._recordLength = co... |
def _seek_country(self, ipnum):
"""
Using the record length and appropriate start points, seek to the
country that corresponds to the converted IP address integer.
Return offset of record.
:arg ipnum: Result of ip2long conversion
"""
try:
offset = 0
... |
def _get_org(self, ipnum):
"""
Seek and return organization or ISP name for ipnum.
Return org/isp name.
:arg ipnum: Result of ip2long conversion
"""
seek_org = self._seek_country(ipnum)
if seek_org == self._databaseSegments:
return None
read_... |
def _get_region(self, ipnum):
"""
Seek and return the region information.
Returns dict containing country_code and region_code.
:arg ipnum: Result of ip2long conversion
"""
region_code = None
country_code = None
seek_country = self._seek_country(ipnum)
... |
def _get_record(self, ipnum):
"""
Populate location dict for converted IP.
Returns dict with numerous location properties.
:arg ipnum: Result of ip2long conversion
"""
seek_country = self._seek_country(ipnum)
if seek_country == self._databaseSegments:
... |
def _gethostbyname(self, hostname):
"""
Hostname lookup method, supports both IPv4 and IPv6.
"""
if self._databaseType in const.IPV6_EDITIONS:
response = socket.getaddrinfo(hostname, 0, socket.AF_INET6)
family, socktype, proto, canonname, sockaddr = response[0]
... |
def id_by_name(self, hostname):
"""
Returns the database ID for specified hostname.
The id might be useful as array index. 0 is unknown.
:arg hostname: Hostname to get ID from.
"""
addr = self._gethostbyname(hostname)
return self.id_by_addr(addr) |
def id_by_addr(self, addr):
"""
Returns the database ID for specified address.
The ID might be useful as array index. 0 is unknown.
:arg addr: IPv4 or IPv6 address (eg. 203.0.113.30)
"""
if self._databaseType in (const.PROXY_EDITION, const.NETSPEED_EDITION_REV1, const.NE... |
def country_code_by_addr(self, addr):
"""
Returns 2-letter country code (e.g. US) from IP address.
:arg addr: IP address (e.g. 203.0.113.30)
"""
VALID_EDITIONS = (const.COUNTRY_EDITION, const.COUNTRY_EDITION_V6)
if self._databaseType in VALID_EDITIONS:
countr... |
def country_code_by_name(self, hostname):
"""
Returns 2-letter country code (e.g. US) from hostname.
:arg hostname: Hostname (e.g. example.com)
"""
addr = self._gethostbyname(hostname)
return self.country_code_by_addr(addr) |
def netspeed_by_addr(self, addr):
"""
Returns NetSpeed name from address.
:arg addr: IP address (e.g. 203.0.113.30)
"""
if self._databaseType == const.NETSPEED_EDITION:
return const.NETSPEED_NAMES[self.id_by_addr(addr)]
elif self._databaseType in (const.NETSP... |
def netspeed_by_name(self, hostname):
"""
Returns NetSpeed name from hostname. Can be Unknown, Dial-up,
Cable, or Corporate.
:arg hostname: Hostname (e.g. example.com)
"""
addr = self._gethostbyname(hostname)
return self.netspeed_by_addr(addr) |
def country_name_by_addr(self, addr):
"""
Returns full country name for specified IP address.
:arg addr: IP address (e.g. 203.0.113.30)
"""
VALID_EDITIONS = (const.COUNTRY_EDITION, const.COUNTRY_EDITION_V6)
if self._databaseType in VALID_EDITIONS:
country_id ... |
def country_name_by_name(self, hostname):
"""
Returns full country name for specified hostname.
:arg hostname: Hostname (e.g. example.com)
"""
addr = self._gethostbyname(hostname)
return self.country_name_by_addr(addr) |
def org_by_addr(self, addr):
"""
Returns Organization, ISP, or ASNum name for given IP address.
:arg addr: IP address (e.g. 203.0.113.30)
"""
valid = (const.ORG_EDITION, const.ISP_EDITION,
const.ASNUM_EDITION, const.ASNUM_EDITION_V6)
if self._databaseTyp... |
def org_by_name(self, hostname):
"""
Returns Organization, ISP, or ASNum name for given hostname.
:arg hostname: Hostname (e.g. example.com)
"""
addr = self._gethostbyname(hostname)
return self.org_by_addr(addr) |
def record_by_addr(self, addr):
"""
Returns dictionary with city data containing `country_code`, `country_name`,
`region`, `city`, `postal_code`, `latitude`, `longitude`, `dma_code`,
`metro_code`, `area_code`, `region_code` and `time_zone`.
:arg addr: IP address (e.g. 203.0.113.... |
def record_by_name(self, hostname):
"""
Returns dictionary with city data containing `country_code`, `country_name`,
`region`, `city`, `postal_code`, `latitude`, `longitude`, `dma_code`,
`metro_code`, `area_code`, `region_code` and `time_zone`.
:arg hostname: Hostname (e.g. exam... |
def region_by_addr(self, addr):
"""
Returns dictionary containing `country_code` and `region_code`.
:arg addr: IP address (e.g. 203.0.113.30)
"""
if self._databaseType not in const.REGION_CITY_EDITIONS:
message = 'Invalid database type, expected Region or City'
... |
def region_by_name(self, hostname):
"""
Returns dictionary containing `country_code` and `region_code`.
:arg hostname: Hostname (e.g. example.com)
"""
addr = self._gethostbyname(hostname)
return self.region_by_addr(addr) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.