Skip to content

Commit 8edb89b

Browse files
authored
add rdap and set version to v2 (#50)
* specific C901 ignore * initial tests whodap * testing * use dataresponse with message in case of error * remove pylint, simplefy ruff * test whoisdomain formatting with raw * move classes to files * testing * set ruff checks more explicit on items * cleanup ruff rule errors in the code * lint clean again * more ruff rules clarify * diocument all exceptions in ruff rules * rdap info first , if none try whois * cleanup tld db * testing * update readme * update readme * update readme * update readme * update ci cd gh-action * add flags rdapOnly and whoisOnly * main now has --whoisOnly and --rdapOnly for testing it * version 2.20260522.1 * round one Claude code review * replace parametercontext * add __lookup__ rdap/whois
1 parent 7fbf206 commit 8edb89b

55 files changed

Lines changed: 1340 additions & 1383 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@ jobs:
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
26-
pip install ruff mypy pylint tld types-redis types-requests python-dateutil
26+
pip install ruff tld types-redis types-requests python-dateutil whodap
2727
2828
- name: Run ruff format check
29-
run: ruff format --check *.py whoisdomain/
29+
run: ruff format --check whoisdomain/
3030

3131
- name: Run ruff lint
32-
run: ruff check *.py whoisdomain/
33-
34-
- name: Run mypy (strict)
35-
run: mypy --strict --no-incremental *.py whoisdomain/
32+
run: ruff check whoisdomain/
3633

3734
test:
3835
name: Test on Python ${{ matrix.python-version }}
@@ -54,6 +51,7 @@ jobs:
5451
- name: Install package
5552
run: |
5653
python -m pip install --upgrade pip
54+
pip install tld whodap
5755
pip install .
5856
5957
- name: Smoke test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ out
7979
lint.txt
8080
pylint.txt
8181
vtmp/
82+
*.1
83+
*.2

CLAUDE_TODO

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
3+
# TLD regex database compiled eagerly at import
4+
whoisdomain/helpers.py · lines 99–100
5+
6+
Importing whoisdomain forces processing all 3,000+ lines of ZZ immediately.
7+
Consumers who only need one TLD pay the cost of all of them.
8+
Make MY_TLD_INFO lazy — initialize on first call to get_TLD_RE() or filterTldToSupportedPattern().
9+
Bonus: significantly faster python -c "import whoisdomain", which matters for CLI tools and lambdas.
10+
11+
---
12+
13+
# Module-level mutable globals everywhere
14+
helpers.py:99, doWhoisCommand.py:20, lastWhois.py:21, main.py:550
15+
16+
MY_TLD_INFO, CACHE_STUB, LastWhois, and a 14-name global declaration in main().
17+
This makes the package effectively a singleton — concurrent users (e.g. an async webapp) will fight over state,
18+
and tests can't run in parallel.
19+
Move shared state onto a Whois client class that callers instantiate,
20+
and keep the module-level helpers as thin wrappers around a default instance for backwards compatibility.
21+
22+
---
23+
24+
# Quick nits
25+
is True / is False comparisons throughout — just use if x: / if not x:
26+
~40 sites

Makefile

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,11 @@
11
# ==========================================================
2-
SHELL := /bin/bash -l
3-
export SHELL
4-
5-
VENV := ./vtmp/
6-
export VENV
7-
8-
# tested on 3.10-3.14
9-
MIN_PYTHON_VERSION := $(shell basename $$( ls /usr/bin/python3.[0-9][0-9] | awk '{print $0; exit}' ) )
10-
export MIN_PYTHON_VERSION
11-
12-
PIP_INSTALL := pip3 -q \
13-
--require-virtualenv \
14-
--disable-pip-version-check \
15-
--no-color install --no-cache-dir
16-
17-
# ==========================================
18-
# Code formatting and checks
19-
PY_FILES := *.py whoisdomain/
20-
21-
# LINE_LENGTH := 160
2+
include Makefile.inc
3+
# ==========================================================
224

235
MYPY_INSTALL := \
246
types-requests \
25-
types-python-dateutil redis tld
26-
27-
COMMON_VENV := rm -rf $(VENV); \
28-
$(MIN_PYTHON_VERSION) -m venv $(VENV); \
29-
source ./$(VENV)/bin/activate;
7+
types-python-dateutil redis
308

31-
# --------------------------------------------------
32-
# reformat, lint and verify basics
33-
# --------------------------------------------------
349
prep: clean format check mypy
3510

3611
clean:
@@ -47,7 +22,7 @@ check:
4722

4823
mypy:
4924
$(COMMON_VENV) \
50-
$(PIP_INSTALL) mypy $(MYPY_INSTALL); \
25+
$(PIP_INSTALL) -r requirements.txt mypy $(MYPY_INSTALL); \
5126
mypy \
5227
--strict \
5328
--no-incremental \
@@ -61,3 +36,8 @@ build:
6136

6237
test:
6338
make -f Makefile.tests
39+
40+
t2:
41+
$(COMMON_VENV) \
42+
$(PIP_INSTALL) -r requirements.txt; \
43+
$(MIN_PYTHON_VERSION) t2.py 2>$@.2 | tee $@.1

Makefile.docker

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# ==========================================================
2-
SHELL := /bin/bash -l
3-
export SHELL
4-
5-
# tested on 3.10-3.14
6-
MIN_PYTHON_VERSION := $(shell basename $$( ls /usr/bin/python3.[0-9][0-9] | awk '{print $0; exit}' ) )
7-
export MIN_PYTHON_VERSION
2+
include Makefile.inc
3+
# ==========================================================
84

95
WHAT := whoisdomain
106
DOCKER_WHO := mbootgithub

Makefile.inc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
SHELL := /bin/bash -l
2+
export SHELL
3+
4+
VENV := ./vtmp/
5+
export VENV
6+
7+
MIN_PYTHON_VERSION := $(shell basename $$( ls /usr/bin/python3.[0-9][0-9] | awk '{print $0; exit}' ) )
8+
export MIN_PYTHON_VERSION
9+
10+
COMMON_VENV := rm -rf $(VENV); \
11+
$(MIN_PYTHON_VERSION) -m venv $(VENV); \
12+
source ./$(VENV)/bin/activate;
13+
14+
PIP_INSTALL := pip3 -q \
15+
--require-virtualenv \
16+
--disable-pip-version-check \
17+
--no-color install --no-cache-dir
18+
19+
# ==========================================
20+
# Code formatting and checks
21+
PY_FILES := *.py whoisdomain/

Makefile.pypi

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
# ==========================================================
22
# ==========================================================
3-
# https://docs.secure.software/cli
4-
5-
SHELL := /bin/bash -l
6-
export SHELL
7-
8-
# tested on 3.10-3.14
9-
MIN_PYTHON_VERSION := $(shell basename $$( ls /usr/bin/python3.[0-9][0-9] | awk '{print $0; exit}' ) )
10-
export MIN_PYTHON_VERSION
3+
include Makefile.inc
4+
# ==========================================================
115

126
run: pypiTest
137

Makefile.tests

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
# Makefile
2-
3-
SHELL := /bin/bash -l
4-
export SHELL
5-
6-
VENV := ./vtmp/
7-
export VENV
8-
9-
# tested on 3.10-3.14
10-
MIN_PYTHON_VERSION := $(shell basename $$( ls /usr/bin/python3.[0-9][0-9] | awk '{print $0; exit}' ) )
11-
export MIN_PYTHON_VERSION
12-
13-
# ==========================================
14-
# Code formatting and checks
15-
PY_FILES := *.py bin/*.py whoisdomain/
16-
17-
LINE_LENGTH := 160
1+
# ==========================================================
2+
include Makefile.inc
3+
# ==========================================================
184

195
TEST_OPTIONS_ALL = \
206
--withPublicSuffix \
@@ -26,32 +12,50 @@ TEST_OPTIONS_ALL = \
2612
# --------------------------------------------------
2713
# Tests
2814
# --------------------------------------------------
29-
test: test1 testwith test2 test3 test4
15+
test: prep test1 test2 test3 test4
16+
# test: prep test2
17+
18+
prep:
19+
mkdir -p tmp
3020

3121
test1:
32-
./test1.py | tee tmp/$@.1
22+
$(COMMON_VENV) \
23+
$(PIP_INSTALL) -r requirements.txt; \
24+
./test1.py 2>tmp/$@.2| tee tmp/$@.1
3325

3426
# test2 has the data type in the output
3527
test2:
36-
./test2.py -f testdata/DOMAINS.txt 2>tmp/$@.2 | tee tmp/$@.1
28+
$(COMMON_VENV) \
29+
$(PIP_INSTALL) -r requirements.txt; \
30+
./test2.py --whoisOnly -f testdata/DOMAINS.txt 2>tmp/$@.2 | tee tmp/$@.1;
3731

3832
# test3 simulates the whoisdomain command and has no data type in the output
3933
test3:
34+
$(COMMON_VENV) \
35+
$(PIP_INSTALL) -r requirements.txt; \
4036
./test3.py -f testdata/DOMAINS.txt 2>tmp/$@.2 | tee tmp/$@.1
4137

4238
test4:
39+
$(COMMON_VENV) \
40+
$(PIP_INSTALL) -r requirements.txt; \
4341
LOGLEVEL=DEBUG ./test2.py $(TEST_OPTIONS_ALL) -t 2>tmp/$@.2 | tee tmp/$@.1
4442

4543
testwith: withPublicSuffix withExtractServers stripHttpStatus
4644

4745
withPublicSuffix:
46+
$(COMMON_VENV) \
47+
$(PIP_INSTALL) -r requirements.txt; \
4848
./test2.py -d www.dublin.airport.aero --withPublicSuffix
4949

5050
withExtractServers:
51+
$(COMMON_VENV) \
52+
$(PIP_INSTALL) -r requirements.txt; \
5153
./test2.py -d google.com --extractServers
5254

5355
stripHttpStatus:
54-
./test2.py -d nic.aarp --stripHttpStatus
55-
./test2.py -d nic.abudhabi --stripHttpStatus
56-
./test2.py -d META.AU --stripHttpStatus
57-
./test2.py -d google.AU --stripHttpStatus
56+
$(COMMON_VENV) \
57+
$(PIP_INSTALL) -r requirements.txt; \
58+
./test2.py -d nic.aarp --stripHttpStatus;\
59+
./test2.py -d nic.abudhabi --stripHttpStatus; \
60+
./test2.py -d META.AU --stripHttpStatus; \
61+
./test2.py -d google.AU --stripHttpStatus; \

0 commit comments

Comments
 (0)