-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
139 lines (124 loc) · 3.69 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import os
from dotenv import load_dotenv
def convert_megabytes_to_bytes(num_of_mb_: int) -> int:
"""
Convert megabytes to bytes.
:param num_of_mb_: A number of megabytes.
:return: A number of bytes.
"""
return num_of_mb_ * (1024 * 1024)
load_dotenv() # Load environment variables from .env file
APPEND_OPT = "a" # Option to append data to file
READ_OPT = "r" # Option to read data from file
WRITE_OPT = "w" # Option to write data to file
ENCOD = "utf-8" # Encoding used to convert strings to bytes and back
SALT_ENCOD = "ASCII" # Encoding used to convert salt to bytes and back
BYTEORDER = "big" # Byte order used to convert integers to bytes and back
DELIM = "," # Delimiter for csv file
INPUT_DELIM = ", " # Delimiter for input file
HIDDEN_FILE = "." # Hidden file
# File extensions
CSV_TYPE = ".csv"
TXT_TYPE = ".txt"
UIDS_TYPE = ".uids"
STABLE_TYPE = ".stable"
# Ad spaces names for witch file creating
AR_SPACE = "AdRiver"
BZ_SPACE = "Buzzoola"
DV_SPACE = "DV360"
FB_SPACE = "Facebook"
IG_SPACE = "Instagram"
MT_SPACE = "MyTarget"
OTM_SPACE = "OTM"
SP_SPACE = "Sape"
VK_SPACE = "VKontakte"
YD_SPACE = "Yandex"
YT_SPACE = "YouTube"
ALL_SPACES = (AR_SPACE, BZ_SPACE, DV_SPACE, FB_SPACE, IG_SPACE, MT_SPACE, OTM_SPACE, VK_SPACE, YD_SPACE, YT_SPACE)
NUM_START_WITH = "7" # Country code at the beginning of the phone number
SALT = "salt" # Secret key for hashing
LIMIT = "limit" # Limit of bytes in file
FILE_TYPE = "file_type" # File extension
FIRST_ROW = "first_row" # First row in file
overfill_insurance = convert_megabytes_to_bytes(10) # 10 MB for insurance of max size of file
SPACES = {
# AdRiver: hash md5 with salt + .stable
AR_SPACE: {
FIRST_ROW: None,
FILE_TYPE: STABLE_TYPE,
SALT: os.getenv(AR_SPACE.upper()),
LIMIT: None
},
# Buzzoola: hash md5 with salt + .stable
BZ_SPACE: {
FIRST_ROW: None,
FILE_TYPE: STABLE_TYPE,
SALT: os.getenv(BZ_SPACE.upper()),
LIMIT: None
},
# DV360: "Phone" + msisdn + .csv
DV_SPACE: {
FIRST_ROW: "Phone",
FILE_TYPE: CSV_TYPE,
SALT: None,
LIMIT: None
},
# Facebook: msisdn + .txt
FB_SPACE: {
FIRST_ROW: None,
FILE_TYPE: TXT_TYPE,
SALT: None,
LIMIT: None
},
# Instagram: msisdn + .txt
IG_SPACE: {
FIRST_ROW: None,
FILE_TYPE: TXT_TYPE,
SALT: None,
LIMIT: None
},
# MyTarget: hash + .txt (min 2000, max 5000000)
MT_SPACE: {
FIRST_ROW: None,
FILE_TYPE: TXT_TYPE,
SALT: None,
LIMIT: convert_megabytes_to_bytes(128) - overfill_insurance
},
# OTM: hash md5 with salt + .stable
OTM_SPACE: {
FIRST_ROW: None,
FILE_TYPE: STABLE_TYPE,
SALT: os.getenv(OTM_SPACE.upper()),
LIMIT: None
},
# Sape: hash md5 with salt + .stable
SP_SPACE: {
FIRST_ROW: None,
FILE_TYPE: STABLE_TYPE,
SALT: os.getenv(SP_SPACE.upper()),
LIMIT: None
},
# VKontakte: hash + .txt (min 2000, max 5000000)
VK_SPACE: {
FIRST_ROW: None,
FILE_TYPE: TXT_TYPE,
SALT: None,
LIMIT: convert_megabytes_to_bytes(128) - overfill_insurance
},
# Yandex: "phone" + hash md5 + .csv (min 100, max ...)
YD_SPACE: {
FIRST_ROW: "phone",
FILE_TYPE: CSV_TYPE,
SALT: None,
LIMIT: convert_megabytes_to_bytes(1000) - overfill_insurance
},
# YouTube: "Phone" + msisdn + .csv
YT_SPACE: {
FIRST_ROW: "Phone",
FILE_TYPE: CSV_TYPE,
SALT: None,
LIMIT: None
}
}
FIRST_INPUT = "Type path to folder: "
SECOND_INPUT = f"Type Spaces -> ({INPUT_DELIM.join(SPACES.keys())}): "