diff --git a/pyproject.toml b/pyproject.toml index 1167802..d8ab60e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pywhat" -version = "4.3.0" +version = "4.3.1" description = "What is that thing?" authors = ["Bee "] license = "MIT" diff --git a/pywhat/Data/regex.json b/pywhat/Data/regex.json index 8cb572c..f9c5df4 100644 --- a/pywhat/Data/regex.json +++ b/pywhat/Data/regex.json @@ -1763,7 +1763,7 @@ "Regex": "^([0-9a-fA-F]{24})$", "plural_name": false, "Description": null, - "Rarity": 0.1, + "Rarity": 0, "URL": null, "Tags": [ "Identifiers", @@ -1776,7 +1776,7 @@ "Regex": "^([0-9]{10})$", "plural_name": false, "Description": "Seconds elapsed since unix epoch: 1970, between year 2001 and 2286", - "Rarity": 0.1, + "Rarity": 0, "URL": null, "Tags": [ "UNIX Timestamp", @@ -1789,7 +1789,7 @@ "Regex": "^([0-9]{13})$", "plural_name": false, "Description": "Milliseconds elapsed since unix epoch: 1970, between year 2001 and 2286", - "Rarity": 0.1, + "Rarity": 0, "URL": null, "Tags": [ "UNIX Timestamp", @@ -1802,7 +1802,7 @@ "Regex": "^([0-9]{8,10})$", "plural_name": false, "Description": "Seconds elapsed since unix epoch: 1970", - "Rarity": 0.1, + "Rarity": 0, "URL": null, "Tags": [ "UNIX Timestamp", @@ -1815,7 +1815,7 @@ "Regex": "^([0-9]{11,13})$", "plural_name": false, "Description": "Milliseconds elapsed since unix epoch: 1970", - "Rarity": 0.1, + "Rarity": 0, "URL": null, "Tags": [ "UNIX Timestamp", @@ -1828,7 +1828,7 @@ "Regex": "^([0-9A-HJKMNP-TV-Z]{26})$", "plural_name": false, "Description": null, - "Rarity": 0.1, + "Rarity": 0, "URL": null, "Tags": [ "Identifiers", @@ -1840,7 +1840,7 @@ "Regex": "^((?=.*[A-Z])(?=.*[a-z])[0-9A-Za-z_-]{10}[048AEIMQUYcgkosw]{1})$", "plural_name": false, "Description": null, - "Rarity": 0.1, + "Rarity": 0, "URL": "https://www.youtube.com/watch?v=", "Tags": [ "Media", @@ -1853,7 +1853,7 @@ "Regex": "^([0-9]{10})$", "plural_name": false, "Description": null, - "Rarity": 0.1, + "Rarity": 0, "URL": null, "Tags": [ "Credentials", diff --git a/pywhat/__init__.py b/pywhat/__init__.py index 200f217..8be36c6 100644 --- a/pywhat/__init__.py +++ b/pywhat/__init__.py @@ -2,7 +2,7 @@ from pywhat.helper import AvailableTags, Keys from pywhat.identifier import Identifier -__version__ = "4.3.0" +__version__ = "4.3.1" tags = AvailableTags().get_tags() pywhat_tags = tags # left for backward compatibility purposes diff --git a/tests/test_click.py b/tests/test_click.py index 0936674..b6a54f6 100644 --- a/tests/test_click.py +++ b/tests/test_click.py @@ -573,7 +573,7 @@ def test_pgp_private_key(): def test_file_fixture_turkish_car_plate(): runner = CliRunner() - result = runner.invoke(main, ["fixtures/file"]) + result = runner.invoke(main, ["--rarity", "0:", "fixtures/file"]) assert result.exit_code == 0 assert re.findall("Turkish License Plate Number", str(result.output)) @@ -594,7 +594,7 @@ def test_file_fixture_turkish_id_number(): def test_file_fixture_turkish_tax_number(): runner = CliRunner() - result = runner.invoke(main, ["fixtures/file"]) + result = runner.invoke(main, ["--rarity", "0:", "fixtures/file"]) assert result.exit_code == 0 assert re.findall("Turkish Tax Number", str(result.output)) @@ -608,14 +608,14 @@ def test_file_fixture_uuid(): def test_file_fixture_objectid(): runner = CliRunner() - result = runner.invoke(main, ["fixtures/file"]) + result = runner.invoke(main, ["--rarity", "0:", "fixtures/file"]) assert result.exit_code == 0 assert re.findall("ObjectID", str(result.output)) def test_file_fixture_ulid(): runner = CliRunner() - result = runner.invoke(main, ["fixtures/file"]) + result = runner.invoke(main, ["--rarity", "0:", "fixtures/file"]) assert result.exit_code == 0 assert re.findall("ULID", str(result.output)) diff --git a/tests/test_regex_identifier.py b/tests/test_regex_identifier.py index 6732296..f91ace3 100644 --- a/tests/test_regex_identifier.py +++ b/tests/test_regex_identifier.py @@ -3,11 +3,14 @@ import pytest from pywhat import regex_identifier -from pywhat.filter import Filter +from pywhat.filter import Distribution, Filter from pywhat.helper import load_regexes database = load_regexes() r = regex_identifier.RegexIdentifier() +filter1 = Filter({"MinRarity": 0.0}) +d = Distribution(filter1) +r_rarity_0 = regex_identifier.RegexIdentifier() def _assert_match_first_item(name, res): @@ -415,12 +418,12 @@ def test_youtube2(): def test_youtube_id(): - res = r.check(["dQw4w9WgXcQ"]) + res = r.check(["dQw4w9WgXcQ"], dist=d) _assert_match_first_item("YouTube Video ID", res) def test_youtube_id2(): - res = r.check(["078-05-1120"]) + res = r.check(["078-05-1120"], dist=d) assert "YouTube Video ID" not in res @@ -533,35 +536,35 @@ def test_arn4(): def test_unix_timestamp(): - res = r.check(["1577836800"]) # 2020-01-01 + res = r.check(["1577836800"], dist=d) # 2020-01-01 keys = [m["Regex Pattern"]["Name"] for m in res] assert "Unix Timestamp" in keys assert "Recent Unix Timestamp" in keys def test_unix_timestamp2(): - res = r.check(["94694400"]) # 1973-01-01 + res = r.check(["94694400"], dist=d) # 1973-01-01 keys = [m["Regex Pattern"]["Name"] for m in res] assert "Unix Timestamp" in keys assert "Recent Unix Timestamp" not in keys def test_unix_timestamp3(): - res = r.check(["1234567"]) # 7 numbers + res = r.check(["1234567"], dist=d) # 7 numbers keys = [m["Regex Pattern"]["Name"] for m in res] assert "Unix Timestamp" not in keys assert "Recent Unix Timestamp" not in keys def test_unix_timestamp4(): - res = r.check(["1577836800000"]) # 2020-01-01 + res = r.check(["1577836800000"], dist=d) # 2020-01-01 keys = [m["Regex Pattern"]["Name"] for m in res] assert "Unix Millisecond Timestamp" in keys assert "Recent Unix Millisecond Timestamp" in keys def test_unix_timestamp5(): - res = r.check(["94694400000"]) # 1973-01-01 + res = r.check(["94694400000"], dist=d) # 1973-01-01 keys = [m["Regex Pattern"]["Name"] for m in res] assert "Unix Millisecond Timestamp" in keys assert "Recent Unix Millisecond Timestamp" not in keys @@ -1006,7 +1009,7 @@ def test_turkish_id_number2(): def test_turkish_tax_number(): - res = r.check(["1234567890"]) + res = r.check(["1234567890"], dist=d) assert "Turkish Tax Number" in str(res) @@ -1016,12 +1019,12 @@ def test_uuid(): def test_objectid(): - res = r.check(["5fc7c33a7ef88b139122a38a"]) + res = r_rarity_0.check(["5fc7c33a7ef88b139122a38a"], dist=d) assert "ObjectID" in str(res) def test_ulid(): - res = r.check(["01ERJ58HMWDN3VTRRHZQV2T5R5"]) + res = r_rarity_0.check(["01ERJ58HMWDN3VTRRHZQV2T5R5"], dist=d) assert "ULID" in str(res)