sample-ui-component-library 0.0.49-dev → 0.0.50-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,131 @@
1
+ [
2
+ {
3
+ "type": "Import",
4
+ "uid": "039c9c46-3788-4017-84cf-2abeb3932507",
5
+ "start_line": 1,
6
+ "end_line": 1,
7
+ "source": "import threading"
8
+ },
9
+ {
10
+ "type": "Import",
11
+ "uid": "bf733fea-d7c8-4794-8fd1-cfc6fd2bca62",
12
+ "start_line": 2,
13
+ "end_line": 2,
14
+ "source": "import queue"
15
+ },
16
+ {
17
+ "type": "ImportFrom",
18
+ "uid": "9a0f0e12-558d-4304-ad22-f4ebd2b91928",
19
+ "start_line": 3,
20
+ "end_line": 3,
21
+ "source": "from deep_translator import GoogleTranslator"
22
+ },
23
+ {
24
+ "type": "ClassDef",
25
+ "uid": "c4a41b12-0ac1-4032-ab1b-5437ed633eb1",
26
+ "start_line": 5,
27
+ "end_line": 5,
28
+ "source": [
29
+ "class FrenchTranslator(threading.Thread):"
30
+ ]
31
+ },
32
+ {
33
+ "type": "FunctionDef",
34
+ "uid": "74e069aa-bcb8-4323-be03-20b55491659e",
35
+ "start_line": 6,
36
+ "end_line": 6,
37
+ "source": [
38
+ " def __init__(self, id, queue, packerQueue):"
39
+ ]
40
+ },
41
+ {
42
+ "type": "FunctionDef",
43
+ "uid": "daf299b9-7a1e-421f-a0ee-91c5f8da02e1",
44
+ "start_line": 13,
45
+ "end_line": 13,
46
+ "source": [
47
+ " def run(self):"
48
+ ]
49
+ },
50
+ {
51
+ "type": "Expr",
52
+ "uid": "06d8f1f0-580f-47c1-9fd6-9f8a8995d419",
53
+ "start_line": 7,
54
+ "end_line": 7,
55
+ "source": "super().__init__(daemon=True)"
56
+ },
57
+ {
58
+ "type": "Assign",
59
+ "uid": "f6a558d1-977f-4881-ab8e-0365c35e1c91",
60
+ "start_line": 8,
61
+ "end_line": 8,
62
+ "source": "self.queue = queue"
63
+ },
64
+ {
65
+ "type": "Assign",
66
+ "uid": "1da17a50-6792-4fe1-8a1d-de37a0042ba5",
67
+ "start_line": 9,
68
+ "end_line": 9,
69
+ "source": "self.id = id"
70
+ },
71
+ {
72
+ "type": "Assign",
73
+ "uid": "5d8e18b0-7520-494d-9511-c707402733e6",
74
+ "start_line": 10,
75
+ "end_line": 10,
76
+ "source": "self.packerQueue = packerQueue"
77
+ },
78
+ {
79
+ "type": "Expr",
80
+ "uid": "613a77d5-8adb-4a62-be61-96b121dbb03f",
81
+ "start_line": 11,
82
+ "end_line": 11,
83
+ "source": "self.start()"
84
+ },
85
+ {
86
+ "type": "While",
87
+ "uid": "4b76898c-ead0-4f47-b3f5-28130cfaa2d2",
88
+ "start_line": 14,
89
+ "end_line": 14,
90
+ "source": [
91
+ " while True:"
92
+ ]
93
+ },
94
+ {
95
+ "type": "Try",
96
+ "uid": "944b63bf-01ba-45cc-a24a-9b20aa7e753a",
97
+ "start_line": 15,
98
+ "end_line": 15,
99
+ "source": [
100
+ " try:"
101
+ ]
102
+ },
103
+ {
104
+ "type": "Assign",
105
+ "uid": "cb68a874-432e-4d5b-8a3b-1674a19b73d9",
106
+ "start_line": 20,
107
+ "end_line": 20,
108
+ "source": "translatedMsg = GoogleTranslator(source=\"auto\", target=\"french\").translate(job[\"value\"][\"data\"])"
109
+ },
110
+ {
111
+ "type": "Expr",
112
+ "uid": "b03928c0-673e-4ff5-a205-89207ec8a26c",
113
+ "start_line": 21,
114
+ "end_line": 28,
115
+ "source": "self.packerQueue.put({\n \"uid\": job[\"uid\"],\n \"value\": {\n \"language\": \"french\",\n \"original\": job[\"value\"][\"data\"],\n \"translated\": translatedMsg\n }\n })"
116
+ },
117
+ {
118
+ "type": "Assign",
119
+ "uid": "145c185d-8e8c-427b-a192-cb1da0f79f53",
120
+ "start_line": 16,
121
+ "end_line": 16,
122
+ "source": "job = self.queue.get(timeout=10)"
123
+ },
124
+ {
125
+ "type": "Continue",
126
+ "uid": "7cbe5c90-9bf8-49de-a952-0b8e601828f7",
127
+ "start_line": 18,
128
+ "end_line": 18,
129
+ "source": "continue"
130
+ }
131
+ ]
@@ -0,0 +1,149 @@
1
+ [
2
+ {
3
+ "type": "Import",
4
+ "uid": "3379cd52-2d8c-4e8a-9b1d-bc232f60576b",
5
+ "start_line": 1,
6
+ "end_line": 1,
7
+ "source": "import sqlite3"
8
+ },
9
+ {
10
+ "type": "Import",
11
+ "uid": "e5d628dc-f651-4245-a200-79d1873c3386",
12
+ "start_line": 2,
13
+ "end_line": 2,
14
+ "source": "import atexit"
15
+ },
16
+ {
17
+ "type": "Import",
18
+ "uid": "c85d079d-1268-421d-a4bb-fc1f5792d63b",
19
+ "start_line": 3,
20
+ "end_line": 3,
21
+ "source": "import uuid"
22
+ },
23
+ {
24
+ "type": "Expr",
25
+ "uid": "8bf2605a-1940-49de-9b2f-0efa22bf658c",
26
+ "start_line": 8,
27
+ "end_line": 8,
28
+ "source": "atexit.register(self.cleanup_function)"
29
+ },
30
+ {
31
+ "type": "Expr",
32
+ "uid": "595db236-990c-4aea-bae0-d46f17e89729",
33
+ "start_line": 9,
34
+ "end_line": 9,
35
+ "source": "self.initializeDB()"
36
+ },
37
+ {
38
+ "type": "Expr",
39
+ "uid": "df540a11-0f67-41ce-a9f7-02aafb9996f0",
40
+ "start_line": 12,
41
+ "end_line": 12,
42
+ "source": "self.conn.close()"
43
+ },
44
+ {
45
+ "type": "Assign",
46
+ "uid": "720ce1a8-58d8-4dfc-aaeb-11865bc5311f",
47
+ "start_line": 16,
48
+ "end_line": 16,
49
+ "source": "self.conn = sqlite3.connect(\"translations.db\")"
50
+ },
51
+ {
52
+ "type": "Assign",
53
+ "uid": "41f3eec1-71eb-4272-941b-c5209befe90d",
54
+ "start_line": 17,
55
+ "end_line": 17,
56
+ "source": "self.cursor = self.conn.cursor()"
57
+ },
58
+ {
59
+ "type": "Expr",
60
+ "uid": "df8a04d5-3b90-445a-8d2f-8a6278cde108",
61
+ "start_line": 19,
62
+ "end_line": 29,
63
+ "source": "self.cursor.execute(\"\"\"\n CREATE TABLE IF NOT EXISTS translation_jobs (\n job_id INTEGER PRIMARY KEY AUTOINCREMENT,\n uid TEXT NOT NULL UNIQUE,\n english TEXT NOT NULL,\n french TEXT,\n spanish TEXT,\n tamil TEXT,\n done INTEGER NOT NULL DEFAULT 0\n );\n \"\"\")"
64
+ },
65
+ {
66
+ "type": "Expr",
67
+ "uid": "0297ec2d-e27c-483a-97ac-a82d4f185a45",
68
+ "start_line": 30,
69
+ "end_line": 30,
70
+ "source": "self.conn.commit()"
71
+ },
72
+ {
73
+ "type": "Assign",
74
+ "uid": "12d3fdc6-44f3-4526-b461-a1037636dc33",
75
+ "start_line": 33,
76
+ "end_line": 33,
77
+ "source": "uid = str(uuid.uuid4())"
78
+ },
79
+ {
80
+ "type": "Expr",
81
+ "uid": "7e3e96ad-99c5-43e1-9e60-2ec7593692e9",
82
+ "start_line": 34,
83
+ "end_line": 40,
84
+ "source": "self.conn.execute(\n \"\"\"\n INSERT INTO translation_jobs (uid, english)\n VALUES (?, ?)\n \"\"\",\n (uid, data)\n )"
85
+ },
86
+ {
87
+ "type": "Expr",
88
+ "uid": "33aaf4bc-2c5c-44d7-aa23-ed4c00dc9850",
89
+ "start_line": 41,
90
+ "end_line": 41,
91
+ "source": "self.conn.commit()"
92
+ },
93
+ {
94
+ "type": "Return",
95
+ "uid": "91b23b1a-6dbc-4be4-a5c9-3c25bb7e4d31",
96
+ "start_line": 43,
97
+ "end_line": 46,
98
+ "source": "return {\n \"uid\": uid,\n \"value\": {\"data\": data}\n }"
99
+ },
100
+ {
101
+ "type": "Expr",
102
+ "uid": "9283152d-497a-4adf-ae94-bd36ddfa7ec3",
103
+ "start_line": 49,
104
+ "end_line": 56,
105
+ "source": "self.conn.execute(\n f\"\"\"\n UPDATE translation_jobs\n SET {msg[\"value\"][\"language\"]} = ?\n WHERE uid = ?\n \"\"\",\n (msg[\"value\"][\"translated\"], msg[\"uid\"])\n )"
106
+ },
107
+ {
108
+ "type": "Expr",
109
+ "uid": "9e49a0c5-d0f2-41f9-bea7-42db302ba180",
110
+ "start_line": 57,
111
+ "end_line": 57,
112
+ "source": "self.conn.commit()"
113
+ },
114
+ {
115
+ "type": "Assign",
116
+ "uid": "b0885662-490e-4679-84f9-636be9b68198",
117
+ "start_line": 61,
118
+ "end_line": 71,
119
+ "source": "cur = self.conn.execute(\n \"\"\"\n SELECT\n french IS NOT NULL\n AND spanish IS NOT NULL\n AND tamil IS NOT NULL\n FROM translation_jobs\n WHERE uid = ?\n \"\"\",\n (uid,)\n )"
120
+ },
121
+ {
122
+ "type": "Assign",
123
+ "uid": "9185886f-b795-45fb-9676-aa65e0e54fb5",
124
+ "start_line": 72,
125
+ "end_line": 72,
126
+ "source": "row = cur.fetchone()"
127
+ },
128
+ {
129
+ "type": "Return",
130
+ "uid": "8bdd4fd1-2678-4fd2-943c-016cc601bfe5",
131
+ "start_line": 73,
132
+ "end_line": 73,
133
+ "source": "return bool(row[0]) if row else False"
134
+ },
135
+ {
136
+ "type": "Expr",
137
+ "uid": "c4f43010-71ef-46e6-bf38-0548d3a34012",
138
+ "start_line": 76,
139
+ "end_line": 83,
140
+ "source": "self.conn.execute(\n \"\"\"\n UPDATE translation_jobs\n SET done = 1\n WHERE uid = ?\n \"\"\",\n (uid,)\n )"
141
+ },
142
+ {
143
+ "type": "Expr",
144
+ "uid": "d1678a59-0a81-4126-8ca9-befbafbd8986",
145
+ "start_line": 84,
146
+ "end_line": 84,
147
+ "source": "self.conn.commit()"
148
+ }
149
+ ]