File tree Expand file tree Collapse file tree 2 files changed +81
-1
lines changed
src/datascience/ydata/datascience/common Expand file tree Collapse file tree 2 files changed +81
-1
lines changed Original file line number Diff line number Diff line change 11from .privacy import PrivacyLevel
2+ from .anonymizer import AnonymizerType
23
34
45__all__ = [
5- "PrivacyLevel"
6+ "PrivacyLevel" ,
7+ "AnonymizerType"
68]
Original file line number Diff line number Diff line change 1+ """
2+ Enum class for Anonymizer configs
3+ """
4+ from enum import Enum
5+
6+
7+ class AnonymizerType (Enum ):
8+ REGEX = 1
9+ IP = 2
10+ IPV4 = 3
11+ IPV6 = 4
12+ HOSTNAME = 5
13+ LICENSE_PLATE = 6
14+ ABA = 7
15+ BANK_COUNTRY = 8
16+ BBAN = 9
17+ IBAN = 10
18+ SWIFT = 11
19+ BARCODE = 12
20+ COMPANY = 13
21+ COMPANY_SUFFIX = 14
22+ COMPANY_EMAIL = 15
23+ EMAIL = 16
24+ DOMAIN_NAME = 17
25+ MAC_ADDRESS = 18
26+ PORT_NUMBER = 19
27+ URI = 20
28+ USER_NAME = 21
29+ JOB = 22
30+ FIRST_NAME = 23
31+ FIRST_NAME_FEMALE = 24
32+ FIRST_NAME_MALE = 25
33+ LAST_NAME = 26
34+ NAME = 27
35+ NAME_FEMALE = 28
36+ NAME_MALE = 29
37+ SSN = 30
38+ CITY = 31
39+ COUNTRY = 32
40+ COUNTRY_CODE = 33
41+ STREET_ADDRESS = 34
42+ STREET_NAME = 35
43+ FULL_ADDRESS = 36
44+ URL = 37
45+ CREDIT_CARD_NUMBER = 38
46+ CREDIT_CARD_PROVIDER = 39
47+ CREDIT_CARD_EXPIRE = 40
48+ VAT = 41
49+ POSTCODE = 42
50+ PHONE = 43
51+ INT = 44
52+ UUID = 45
53+
54+ @staticmethod
55+ def get_anonymizer_type (name ):
56+ """Helper function that receives the anonymizer type either as
57+ AnonymizerType or its int or string representations and returns the
58+ anonymizer type. e.g. AnonymizerType.NAME can also be represented by the
59+ string 'name' or the identifier 27.
60+
61+ Args:
62+ name (AnonymizerType | str | int): name or id of the anonymizer type.
63+
64+ Returns:
65+ AnonymizerType: A
66+ """
67+
68+ if isinstance (name , AnonymizerType ):
69+ return name
70+
71+ if isinstance (name , str ):
72+ if name .upper () in AnonymizerType ._member_names_ :
73+ return AnonymizerType [name .upper ()]
74+ else :
75+ return None
76+
77+ if isinstance (name , int ):
78+ return AnonymizerType (name )
You can’t perform that action at this time.
0 commit comments