-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_information_pages.py
64 lines (57 loc) · 2.43 KB
/
edit_information_pages.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
from web_scrap import get_full_url_2
import datetime
class EditInformationPage:
def __init__(self, fb_page_name, source, post_time, url):
"""
information saved: Brand,Source,Post Date,Link,Full True Path,Purpose,Status,PIC?,T&C?,Opt-in/Opt-out,remarks,PII
"""
self.fb_page_name = fb_page_name
self.source = source
self.post_time = post_time
self.url = url
self.full_url = get_full_url_2(self.url)
self.purpose = "Choose Marketing Purpose"
self.expire_date = datetime.date.today()
self.status = "Expire soon"
self.PICS = "No"
self.TnC = "No"
self.Opt_in_out = "No"
self.remarks = ""
self.PII = ""
self.Label_Category_dict = {"Label": [], "Category": []}
self.Keywords_Exist_dict = {"Keyword": ["T&C", "P.I.C.S.", "Opt-in/Opt-out"], "Exist?": ["Default", "Default", "Default"]}
def dict_to_output(self):
# convert Label_Category_dict to PII export item
self.PII = ""
for categories in self.Label_Category_dict["Category"]:
if categories != "Unrelated" and categories != "P.I.C.S." and categories != "T&C" and \
categories != "Opt-in/Opt-out" and categories != "Marketing Purpose" and \
categories != "Expiry Date" and categories != "":
if categories not in self.PII:
self.PII = self.PII + categories + ", "
self.PII = self.PII.rstrip(", ")
# convert Keywords_Exist_dict to export items
self.TnC = self.Keywords_Exist_dict["Exist?"][0]
self.PICS = self.Keywords_Exist_dict["Exist?"][1]
self.Opt_in_out = self.Keywords_Exist_dict["Exist?"][2]
def export(self):
# Convert information to export values
if self.TnC == "Default":
self.TnC = "No"
if self.PICS == "Default":
self.PICS = "No"
if self.Opt_in_out == "Default":
self.Opt_in_out = "No"
export_list = [self.fb_page_name,
self.source,
self.post_time,
self.url,
self.full_url,
self.purpose,
self.status,
self.PICS,
self.TnC,
self.Opt_in_out,
self.remarks,
self.PII]
return export_list