tdrpa.tdworker 1.1.9.3__py39-none-win_amd64.whl

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.
Files changed (97) hide show
  1. tdrpa/_tdxlwings/__init__.py +193 -0
  2. tdrpa/_tdxlwings/__pycache__/__init__.cpython-311.pyc +0 -0
  3. tdrpa/_tdxlwings/__pycache__/__init__.cpython-38.pyc +0 -0
  4. tdrpa/_tdxlwings/__pycache__/_win32patch.cpython-311.pyc +0 -0
  5. tdrpa/_tdxlwings/__pycache__/_win32patch.cpython-38.pyc +0 -0
  6. tdrpa/_tdxlwings/__pycache__/_xlwindows.cpython-311.pyc +0 -0
  7. tdrpa/_tdxlwings/__pycache__/_xlwindows.cpython-38.pyc +0 -0
  8. tdrpa/_tdxlwings/__pycache__/apps.cpython-311.pyc +0 -0
  9. tdrpa/_tdxlwings/__pycache__/apps.cpython-38.pyc +0 -0
  10. tdrpa/_tdxlwings/__pycache__/base_classes.cpython-311.pyc +0 -0
  11. tdrpa/_tdxlwings/__pycache__/base_classes.cpython-38.pyc +0 -0
  12. tdrpa/_tdxlwings/__pycache__/com_server.cpython-311.pyc +0 -0
  13. tdrpa/_tdxlwings/__pycache__/com_server.cpython-38.pyc +0 -0
  14. tdrpa/_tdxlwings/__pycache__/constants.cpython-311.pyc +0 -0
  15. tdrpa/_tdxlwings/__pycache__/constants.cpython-38.pyc +0 -0
  16. tdrpa/_tdxlwings/__pycache__/expansion.cpython-311.pyc +0 -0
  17. tdrpa/_tdxlwings/__pycache__/expansion.cpython-38.pyc +0 -0
  18. tdrpa/_tdxlwings/__pycache__/main.cpython-311.pyc +0 -0
  19. tdrpa/_tdxlwings/__pycache__/main.cpython-38.pyc +0 -0
  20. tdrpa/_tdxlwings/__pycache__/udfs.cpython-311.pyc +0 -0
  21. tdrpa/_tdxlwings/__pycache__/udfs.cpython-38.pyc +0 -0
  22. tdrpa/_tdxlwings/__pycache__/utils.cpython-311.pyc +0 -0
  23. tdrpa/_tdxlwings/__pycache__/utils.cpython-38.pyc +0 -0
  24. tdrpa/_tdxlwings/_win32patch.py +90 -0
  25. tdrpa/_tdxlwings/_xlmac.py +2240 -0
  26. tdrpa/_tdxlwings/_xlwindows.py +2518 -0
  27. tdrpa/_tdxlwings/addin/Dictionary.cls +474 -0
  28. tdrpa/_tdxlwings/addin/IWebAuthenticator.cls +71 -0
  29. tdrpa/_tdxlwings/addin/WebClient.cls +772 -0
  30. tdrpa/_tdxlwings/addin/WebHelpers.bas +3203 -0
  31. tdrpa/_tdxlwings/addin/WebRequest.cls +875 -0
  32. tdrpa/_tdxlwings/addin/WebResponse.cls +453 -0
  33. tdrpa/_tdxlwings/addin/xlwings.xlam +0 -0
  34. tdrpa/_tdxlwings/apps.py +35 -0
  35. tdrpa/_tdxlwings/base_classes.py +1092 -0
  36. tdrpa/_tdxlwings/cli.py +1306 -0
  37. tdrpa/_tdxlwings/com_server.py +385 -0
  38. tdrpa/_tdxlwings/constants.py +3080 -0
  39. tdrpa/_tdxlwings/conversion/__init__.py +103 -0
  40. tdrpa/_tdxlwings/conversion/framework.py +147 -0
  41. tdrpa/_tdxlwings/conversion/numpy_conv.py +34 -0
  42. tdrpa/_tdxlwings/conversion/pandas_conv.py +184 -0
  43. tdrpa/_tdxlwings/conversion/standard.py +321 -0
  44. tdrpa/_tdxlwings/expansion.py +83 -0
  45. tdrpa/_tdxlwings/ext/__init__.py +3 -0
  46. tdrpa/_tdxlwings/ext/sql.py +73 -0
  47. tdrpa/_tdxlwings/html/xlwings-alert.html +71 -0
  48. tdrpa/_tdxlwings/js/xlwings.js +577 -0
  49. tdrpa/_tdxlwings/js/xlwings.ts +729 -0
  50. tdrpa/_tdxlwings/mac_dict.py +6399 -0
  51. tdrpa/_tdxlwings/main.py +5205 -0
  52. tdrpa/_tdxlwings/mistune/__init__.py +63 -0
  53. tdrpa/_tdxlwings/mistune/block_parser.py +366 -0
  54. tdrpa/_tdxlwings/mistune/inline_parser.py +216 -0
  55. tdrpa/_tdxlwings/mistune/markdown.py +84 -0
  56. tdrpa/_tdxlwings/mistune/renderers.py +220 -0
  57. tdrpa/_tdxlwings/mistune/scanner.py +121 -0
  58. tdrpa/_tdxlwings/mistune/util.py +41 -0
  59. tdrpa/_tdxlwings/pro/__init__.py +40 -0
  60. tdrpa/_tdxlwings/pro/_xlcalamine.py +536 -0
  61. tdrpa/_tdxlwings/pro/_xlofficejs.py +146 -0
  62. tdrpa/_tdxlwings/pro/_xlremote.py +1293 -0
  63. tdrpa/_tdxlwings/pro/custom_functions_code.js +150 -0
  64. tdrpa/_tdxlwings/pro/embedded_code.py +60 -0
  65. tdrpa/_tdxlwings/pro/udfs_officejs.py +549 -0
  66. tdrpa/_tdxlwings/pro/utils.py +199 -0
  67. tdrpa/_tdxlwings/quickstart.xlsm +0 -0
  68. tdrpa/_tdxlwings/quickstart_addin.xlam +0 -0
  69. tdrpa/_tdxlwings/quickstart_addin_ribbon.xlam +0 -0
  70. tdrpa/_tdxlwings/quickstart_fastapi/main.py +47 -0
  71. tdrpa/_tdxlwings/quickstart_fastapi/requirements.txt +3 -0
  72. tdrpa/_tdxlwings/quickstart_standalone.xlsm +0 -0
  73. tdrpa/_tdxlwings/reports.py +12 -0
  74. tdrpa/_tdxlwings/rest/__init__.py +1 -0
  75. tdrpa/_tdxlwings/rest/api.py +368 -0
  76. tdrpa/_tdxlwings/rest/serializers.py +103 -0
  77. tdrpa/_tdxlwings/server.py +14 -0
  78. tdrpa/_tdxlwings/udfs.py +775 -0
  79. tdrpa/_tdxlwings/utils.py +777 -0
  80. tdrpa/_tdxlwings/xlwings-0.31.6.applescript +30 -0
  81. tdrpa/_tdxlwings/xlwings.bas +2061 -0
  82. tdrpa/_tdxlwings/xlwings_custom_addin.bas +2042 -0
  83. tdrpa/_tdxlwings/xlwingslib.cp38-win_amd64.pyd +0 -0
  84. tdrpa/tdworker/__init__.pyi +8 -0
  85. tdrpa/tdworker/_excel.pyi +703 -0
  86. tdrpa/tdworker/_img.pyi +173 -0
  87. tdrpa/tdworker/_os.pyi +46 -0
  88. tdrpa/tdworker/_w.pyi +129 -0
  89. tdrpa/tdworker/_web.pyi +248 -0
  90. tdrpa/tdworker/_winE.pyi +246 -0
  91. tdrpa/tdworker/_winK.pyi +74 -0
  92. tdrpa/tdworker/_winM.pyi +117 -0
  93. tdrpa/tdworker.cp39-win_amd64.pyd +0 -0
  94. tdrpa.tdworker-1.1.9.3.dist-info/METADATA +25 -0
  95. tdrpa.tdworker-1.1.9.3.dist-info/RECORD +97 -0
  96. tdrpa.tdworker-1.1.9.3.dist-info/WHEEL +5 -0
  97. tdrpa.tdworker-1.1.9.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,474 @@
1
+ VERSION 1.0 CLASS
2
+ BEGIN
3
+ MultiUse = -1 'True
4
+ END
5
+ Attribute VB_Name = "Dictionary"
6
+ Attribute VB_GlobalNameSpace = False
7
+ Attribute VB_Creatable = False
8
+ Attribute VB_PredeclaredId = False
9
+ Attribute VB_Exposed = True
10
+ Attribute VB_Description = "Drop-in replacement for Scripting.Dictionary on Mac\r\n\r\nDictionary v1.4.0\r\n(c) Tim Hall - https://github.com/timhall/VBA-Dictionary\r\nAuthor: tim.hall.engr@gmail.com\r\nLicense: MIT (http://www.opensource.org/licenses/mit-license.php)\r\n"
11
+ ''
12
+ ' Dictionary v1.4.1
13
+ ' (c) Tim Hall - https://github.com/timhall/VBA-Dictionary
14
+ '
15
+ ' Drop-in replacement for Scripting.Dictionary on Mac
16
+ '
17
+ ' @author: tim.hall.engr@gmail.com
18
+ ' @license: MIT (http://www.opensource.org/licenses/mit-license.php
19
+ '
20
+ ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
21
+ Option Explicit
22
+
23
+ ' --------------------------------------------- '
24
+ ' Constants and Private Variables
25
+ ' --------------------------------------------- '
26
+
27
+ #Const UseScriptingDictionaryIfAvailable = True
28
+
29
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
30
+
31
+ ' dict_KeyValue 0: FormattedKey, 1: OriginalKey, 2: Value
32
+ Private dict_pKeyValues As Collection
33
+ Private dict_pKeys() As Variant
34
+ Private dict_pItems() As Variant
35
+ Private dict_pObjectKeys As Collection
36
+ Private dict_pCompareMode As CompareMethod
37
+
38
+ #Else
39
+
40
+ Private dict_pDictionary As Object
41
+
42
+ #End If
43
+
44
+ ' --------------------------------------------- '
45
+ ' Types
46
+ ' --------------------------------------------- '
47
+
48
+ Public Enum CompareMethod
49
+ BinaryCompare = VBA.vbBinaryCompare
50
+ TextCompare = VBA.vbTextCompare
51
+ DatabaseCompare = VBA.vbDatabaseCompare
52
+ End Enum
53
+
54
+ ' --------------------------------------------- '
55
+ ' Properties
56
+ ' --------------------------------------------- '
57
+
58
+ Public Property Get CompareMode() As CompareMethod
59
+ Attribute CompareMode.VB_Description = "Set or get the string comparison method."
60
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
61
+ CompareMode = dict_pCompareMode
62
+ #Else
63
+ CompareMode = dict_pDictionary.CompareMode
64
+ #End If
65
+ End Property
66
+ Public Property Let CompareMode(Value As CompareMethod)
67
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
68
+ If Me.Count > 0 Then
69
+ ' Can't change CompareMode for Dictionary that contains data
70
+ ' http://msdn.microsoft.com/en-us/library/office/gg278481(v=office.15).aspx
71
+ Err.Raise 5 ' Invalid procedure call or argument
72
+ End If
73
+
74
+ dict_pCompareMode = Value
75
+ #Else
76
+ dict_pDictionary.CompareMode = Value
77
+ #End If
78
+ End Property
79
+
80
+ Public Property Get Count() As Long
81
+ Attribute Count.VB_Description = "Get the number of items in the dictionary.\n"
82
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
83
+ Count = dict_pKeyValues.Count
84
+ #Else
85
+ Count = dict_pDictionary.Count
86
+ #End If
87
+ End Property
88
+
89
+ Public Property Get Item(Key As Variant) As Variant
90
+ Attribute Item.VB_Description = "Set or get the item for a given key."
91
+ Attribute Item.VB_UserMemId = 0
92
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
93
+ Dim dict_KeyValue As Variant
94
+ dict_KeyValue = dict_GetKeyValue(Key)
95
+
96
+ If Not IsEmpty(dict_KeyValue) Then
97
+ If VBA.IsObject(dict_KeyValue(2)) Then
98
+ Set Item = dict_KeyValue(2)
99
+ Else
100
+ Item = dict_KeyValue(2)
101
+ End If
102
+ Else
103
+ ' Not found -> Returns Empty
104
+ End If
105
+ #Else
106
+ If VBA.IsObject(dict_pDictionary.Item(Key)) Then
107
+ Set Item = dict_pDictionary.Item(Key)
108
+ Else
109
+ Item = dict_pDictionary.Item(Key)
110
+ End If
111
+ #End If
112
+ End Property
113
+ Public Property Let Item(Key As Variant, Value As Variant)
114
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
115
+ If Me.Exists(Key) Then
116
+ dict_ReplaceKeyValue dict_GetKeyValue(Key), Key, Value
117
+ Else
118
+ dict_AddKeyValue Key, Value
119
+ End If
120
+ #Else
121
+ dict_pDictionary.Item(Key) = Value
122
+ #End If
123
+ End Property
124
+ Public Property Set Item(Key As Variant, Value As Variant)
125
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
126
+ If Me.Exists(Key) Then
127
+ dict_ReplaceKeyValue dict_GetKeyValue(Key), Key, Value
128
+ Else
129
+ dict_AddKeyValue Key, Value
130
+ End If
131
+ #Else
132
+ Set dict_pDictionary.Item(Key) = Value
133
+ #End If
134
+ End Property
135
+
136
+ Public Property Let Key(Previous As Variant, Updated As Variant)
137
+ Attribute Key.VB_Description = "Change a key to a different key."
138
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
139
+ Dim dict_KeyValue As Variant
140
+ dict_KeyValue = dict_GetKeyValue(Previous)
141
+
142
+ If Not VBA.IsEmpty(dict_KeyValue) Then
143
+ dict_ReplaceKeyValue dict_KeyValue, Updated, dict_KeyValue(2)
144
+ End If
145
+ #Else
146
+ dict_pDictionary.Key(Previous) = Updated
147
+ #End If
148
+ End Property
149
+
150
+ ' ============================================= '
151
+ ' Public Methods
152
+ ' ============================================= '
153
+
154
+ ''
155
+ ' Add an item with the given key
156
+ '
157
+ ' @param {Variant} Key
158
+ ' @param {Variant} Item
159
+ ' --------------------------------------------- '
160
+ Public Sub Add(Key As Variant, Item As Variant)
161
+ Attribute Add.VB_Description = "Add a new key and item to the dictionary."
162
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
163
+ If Not Me.Exists(Key) Then
164
+ dict_AddKeyValue Key, Item
165
+ Else
166
+ ' This key is already associated with an element of this collection
167
+ Err.Raise 457
168
+ End If
169
+ #Else
170
+ dict_pDictionary.Add Key, Item
171
+ #End If
172
+ End Sub
173
+
174
+ ''
175
+ ' Check if an item exists for the given key
176
+ '
177
+ ' @param {Variant} Key
178
+ ' @return {Boolean}
179
+ ' --------------------------------------------- '
180
+ Public Function Exists(Key As Variant) As Boolean
181
+ Attribute Exists.VB_Description = "Determine if a given key is in the dictionary."
182
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
183
+ Exists = Not IsEmpty(dict_GetKeyValue(Key))
184
+ #Else
185
+ Exists = dict_pDictionary.Exists(Key)
186
+ #End If
187
+ End Function
188
+
189
+ ''
190
+ ' Get an array of all items
191
+ '
192
+ ' @return {Variant}
193
+ ' --------------------------------------------- '
194
+ Public Function Items() As Variant
195
+ Attribute Items.VB_Description = "Get an array containing all items in the dictionary."
196
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
197
+ If Me.Count > 0 Then
198
+ Items = dict_pItems
199
+ Else
200
+ ' Split("") creates initialized empty array that matches Dictionary Keys and Items
201
+ Items = VBA.Split("")
202
+ End If
203
+ #Else
204
+ Items = dict_pDictionary.Items
205
+ #End If
206
+ End Function
207
+
208
+ ''
209
+ ' Get an array of all keys
210
+ '
211
+ ' @return {Variant}
212
+ ' --------------------------------------------- '
213
+ Public Function Keys() As Variant
214
+ Attribute Keys.VB_Description = "Get an array containing all keys in the dictionary."
215
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
216
+ If Me.Count > 0 Then
217
+ Keys = dict_pKeys
218
+ Else
219
+ ' Split("") creates initialized empty array that matches Dictionary Keys and Items
220
+ Keys = VBA.Split("")
221
+ End If
222
+ #Else
223
+ Keys = dict_pDictionary.Keys
224
+ #End If
225
+ End Function
226
+
227
+ ''
228
+ ' Remove an item for the given key
229
+ '
230
+ ' @param {Variant} Key
231
+ ' --------------------------------------------- '
232
+ Public Sub Remove(Key As Variant)
233
+ Attribute Remove.VB_Description = "Remove a given key from the dictionary."
234
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
235
+ Dim dict_KeyValue As Variant
236
+ dict_KeyValue = dict_GetKeyValue(Key)
237
+
238
+ If Not VBA.IsEmpty(dict_KeyValue) Then
239
+ dict_RemoveKeyValue dict_KeyValue
240
+ Else
241
+ ' Application-defined or object-defined error
242
+ Err.Raise 32811
243
+ End If
244
+ #Else
245
+ dict_pDictionary.Remove Key
246
+ #End If
247
+ End Sub
248
+
249
+ ''
250
+ ' Remove all items
251
+ ' --------------------------------------------- '
252
+ Public Sub RemoveAll()
253
+ Attribute RemoveAll.VB_Description = "Remove all information from the dictionary."
254
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
255
+ Set dict_pKeyValues = New Collection
256
+
257
+ Erase dict_pKeys
258
+ Erase dict_pItems
259
+ #Else
260
+ dict_pDictionary.RemoveAll
261
+ #End If
262
+ End Sub
263
+
264
+ ' ============================================= '
265
+ ' Private Functions
266
+ ' ============================================= '
267
+
268
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
269
+
270
+ Private Function dict_GetKeyValue(dict_Key As Variant) As Variant
271
+ On Error Resume Next
272
+ dict_GetKeyValue = dict_pKeyValues(dict_GetFormattedKey(dict_Key))
273
+ Err.Clear
274
+ End Function
275
+
276
+ Private Sub dict_AddKeyValue(dict_Key As Variant, dict_Value As Variant, Optional dict_Index As Long = -1)
277
+ If Me.Count = 0 Then
278
+ ReDim dict_pKeys(0 To 0)
279
+ ReDim dict_pItems(0 To 0)
280
+ Else
281
+ ReDim Preserve dict_pKeys(0 To UBound(dict_pKeys) + 1)
282
+ ReDim Preserve dict_pItems(0 To UBound(dict_pItems) + 1)
283
+ End If
284
+
285
+ Dim dict_FormattedKey As String
286
+ dict_FormattedKey = dict_GetFormattedKey(dict_Key)
287
+
288
+ If dict_Index >= 0 And dict_Index < dict_pKeyValues.Count Then
289
+ ' Shift keys/items after + including index into empty last slot
290
+ Dim dict_i As Long
291
+ For dict_i = UBound(dict_pKeys) To dict_Index + 1 Step -1
292
+ dict_pKeys(dict_i) = dict_pKeys(dict_i - 1)
293
+ If VBA.IsObject(dict_pItems(dict_i - 1)) Then
294
+ Set dict_pItems(dict_i) = dict_pItems(dict_i - 1)
295
+ Else
296
+ dict_pItems(dict_i) = dict_pItems(dict_i - 1)
297
+ End If
298
+ Next dict_i
299
+
300
+ ' Add key/item at index
301
+ dict_pKeys(dict_Index) = dict_Key
302
+ If VBA.IsObject(dict_Value) Then
303
+ Set dict_pItems(dict_Index) = dict_Value
304
+ Else
305
+ dict_pItems(dict_Index) = dict_Value
306
+ End If
307
+
308
+ ' Add key-value at proper index
309
+ dict_pKeyValues.Add Array(dict_FormattedKey, dict_Key, dict_Value), dict_FormattedKey, Before:=dict_Index + 1
310
+ Else
311
+ ' Add key-value as last item
312
+ If VBA.IsObject(dict_Key) Then
313
+ Set dict_pKeys(UBound(dict_pKeys)) = dict_Key
314
+ Else
315
+ dict_pKeys(UBound(dict_pKeys)) = dict_Key
316
+ End If
317
+ If VBA.IsObject(dict_Value) Then
318
+ Set dict_pItems(UBound(dict_pItems)) = dict_Value
319
+ Else
320
+ dict_pItems(UBound(dict_pItems)) = dict_Value
321
+ End If
322
+
323
+ dict_pKeyValues.Add Array(dict_FormattedKey, dict_Key, dict_Value), dict_FormattedKey
324
+ End If
325
+ End Sub
326
+
327
+ Private Sub dict_ReplaceKeyValue(dict_KeyValue As Variant, dict_Key As Variant, dict_Value As Variant)
328
+ Dim dict_Index As Long
329
+ Dim dict_i As Integer
330
+
331
+ dict_Index = dict_GetKeyIndex(dict_KeyValue(1))
332
+
333
+ ' Remove existing dict_Value
334
+ dict_RemoveKeyValue dict_KeyValue, dict_Index
335
+
336
+ ' Add new dict_Key dict_Value back
337
+ dict_AddKeyValue dict_Key, dict_Value, dict_Index
338
+ End Sub
339
+
340
+ Private Sub dict_RemoveKeyValue(dict_KeyValue As Variant, Optional ByVal dict_Index As Long = -1)
341
+ Dim dict_i As Long
342
+ If dict_Index = -1 Then
343
+ dict_Index = dict_GetKeyIndex(dict_KeyValue(1))
344
+ End If
345
+
346
+ If dict_Index >= 0 And dict_Index <= UBound(dict_pKeys) Then
347
+ ' Shift keys/items after index down
348
+ For dict_i = dict_Index To UBound(dict_pKeys) - 1
349
+ dict_pKeys(dict_i) = dict_pKeys(dict_i + 1)
350
+
351
+ If VBA.IsObject(dict_pItems(dict_i + 1)) Then
352
+ Set dict_pItems(dict_i) = dict_pItems(dict_i + 1)
353
+ Else
354
+ dict_pItems(dict_i) = dict_pItems(dict_i + 1)
355
+ End If
356
+ Next dict_i
357
+
358
+ ' Resize keys/items to remove empty slot
359
+ If UBound(dict_pKeys) = 0 Then
360
+ Erase dict_pKeys
361
+ Erase dict_pItems
362
+ Else
363
+ ReDim Preserve dict_pKeys(0 To UBound(dict_pKeys) - 1)
364
+ ReDim Preserve dict_pItems(0 To UBound(dict_pItems) - 1)
365
+ End If
366
+ End If
367
+
368
+ dict_pKeyValues.Remove dict_KeyValue(0)
369
+ dict_RemoveObjectKey dict_KeyValue(1)
370
+ End Sub
371
+
372
+ Private Function dict_GetFormattedKey(dict_Key As Variant) As String
373
+ If VBA.IsObject(dict_Key) Then
374
+ dict_GetFormattedKey = dict_GetObjectKey(dict_Key)
375
+ ElseIf VarType(dict_Key) = VBA.vbBoolean Then
376
+ dict_GetFormattedKey = IIf(dict_Key, "-1__-1", "0__0")
377
+ ElseIf VarType(dict_Key) = VBA.vbString Then
378
+ dict_GetFormattedKey = dict_Key
379
+
380
+ If Me.CompareMode = CompareMethod.BinaryCompare Then
381
+ ' Collection does not have method of setting key comparison
382
+ ' So case-sensitive keys aren't supported by default
383
+ ' -> Approach: Append lowercase characters to original key
384
+ ' AbC -> AbC___b_, abc -> abc__abc, ABC -> ABC_____
385
+ Dim dict_Lowercase As String
386
+ dict_Lowercase = ""
387
+
388
+ Dim dict_i As Integer
389
+ Dim dict_Char As String
390
+ Dim dict_Ascii As Integer
391
+ For dict_i = 1 To VBA.Len(dict_GetFormattedKey)
392
+ dict_Char = VBA.Mid$(dict_GetFormattedKey, dict_i, 1)
393
+ dict_Ascii = VBA.Asc(dict_Char)
394
+ If dict_Ascii >= 97 And dict_Ascii <= 122 Then
395
+ dict_Lowercase = dict_Lowercase & dict_Char
396
+ Else
397
+ dict_Lowercase = dict_Lowercase & "_"
398
+ End If
399
+ Next dict_i
400
+
401
+ If dict_Lowercase <> "" Then
402
+ dict_GetFormattedKey = dict_GetFormattedKey & "__" & dict_Lowercase
403
+ End If
404
+ End If
405
+ Else
406
+ ' For numbers, add duplicate to distinguish from strings
407
+ ' -> 123 -> "123__123"
408
+ ' "123" -> "123"
409
+ dict_GetFormattedKey = VBA.CStr(dict_Key) & "__" & CStr(dict_Key)
410
+ End If
411
+ End Function
412
+
413
+ Private Function dict_GetObjectKey(dict_ObjKey As Variant) As String
414
+ Dim dict_i As Integer
415
+ For dict_i = 1 To dict_pObjectKeys.Count
416
+ If dict_pObjectKeys.Item(dict_i) Is dict_ObjKey Then
417
+ dict_GetObjectKey = "__object__" & dict_i
418
+ Exit Function
419
+ End If
420
+ Next dict_i
421
+
422
+ dict_pObjectKeys.Add dict_ObjKey
423
+ dict_GetObjectKey = "__object__" & dict_pObjectKeys.Count
424
+ End Function
425
+
426
+ Private Sub dict_RemoveObjectKey(dict_ObjKey As Variant)
427
+ Dim dict_i As Integer
428
+ For dict_i = 1 To dict_pObjectKeys.Count
429
+ If dict_pObjectKeys.Item(dict_i) Is dict_ObjKey Then
430
+ dict_pObjectKeys.Remove dict_i
431
+ Exit Sub
432
+ End If
433
+ Next dict_i
434
+ End Sub
435
+
436
+ Private Function dict_GetKeyIndex(dict_Key As Variant) As Long
437
+ Dim dict_i As Long
438
+ For dict_i = 0 To UBound(dict_pKeys)
439
+ If VBA.IsObject(dict_pKeys(dict_i)) And VBA.IsObject(dict_Key) Then
440
+ If dict_pKeys(dict_i) Is dict_Key Then
441
+ dict_GetKeyIndex = dict_i
442
+ Exit For
443
+ End If
444
+ ElseIf VBA.IsObject(dict_pKeys(dict_i)) Or VBA.IsObject(dict_Key) Then
445
+ ' Both need to be objects to check equality, skip
446
+ ElseIf dict_pKeys(dict_i) = dict_Key Then
447
+ dict_GetKeyIndex = dict_i
448
+ Exit For
449
+ End If
450
+ Next dict_i
451
+ End Function
452
+
453
+ #End If
454
+
455
+ Private Sub Class_Initialize()
456
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
457
+ Set dict_pKeyValues = New Collection
458
+
459
+ Erase dict_pKeys
460
+ Erase dict_pItems
461
+ Set dict_pObjectKeys = New Collection
462
+ #Else
463
+ Set dict_pDictionary = CreateObject("Scripting.Dictionary")
464
+ #End If
465
+ End Sub
466
+
467
+ Private Sub Class_Terminate()
468
+ #If Mac Or Not UseScriptingDictionaryIfAvailable Then
469
+ Set dict_pKeyValues = Nothing
470
+ Set dict_pObjectKeys = Nothing
471
+ #Else
472
+ Set dict_pDictionary = Nothing
473
+ #End If
474
+ End Sub
@@ -0,0 +1,71 @@
1
+ VERSION 1.0 CLASS
2
+ BEGIN
3
+ MultiUse = -1 'True
4
+ END
5
+ Attribute VB_Name = "IWebAuthenticator"
6
+ Attribute VB_GlobalNameSpace = False
7
+ Attribute VB_Creatable = False
8
+ Attribute VB_PredeclaredId = False
9
+ Attribute VB_Exposed = True
10
+ ''
11
+ ' IWebAuthenticator v4.1.6
12
+ ' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
13
+ '
14
+ ' Interface for creating authenticators for rest client
15
+ '
16
+ ' @class IWebAuthenticator
17
+ ' @author tim.hall.engr@gmail.com
18
+ ' @license MIT (http://www.opensource.org/licenses/mit-license.php)
19
+ '' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
20
+ Option Explicit
21
+
22
+ ' ============================================= '
23
+ ' Public Methods
24
+ ' ============================================= '
25
+
26
+ ''
27
+ ' Hook for taking action before a request is executed
28
+ '
29
+ ' @method BeforeExecute
30
+ ' @param {WebClient} Client The client that is about to execute the request
31
+ ' @param in|out {WebRequest} Request The request about to be executed
32
+ ''
33
+ Public Sub BeforeExecute(ByVal Client As WebClient, ByRef Request As WebRequest)
34
+ ' e.g Add headers, cookies, etc.
35
+ End Sub
36
+
37
+ ''
38
+ ' Hook for taking action after request has been executed
39
+ '
40
+ ' @method AfterExecute
41
+ ' @param {WebClient} Client The client that executed request
42
+ ' @param {WebRequest} Request The request that was just executed
43
+ ' @param in|out {WebResponse} Response to request
44
+ ''
45
+ Public Sub AfterExecute(ByVal Client As WebClient, ByVal Request As WebRequest, ByRef Response As WebResponse)
46
+ ' e.g. Handle 401 Unauthorized or other issues
47
+ End Sub
48
+
49
+ ''
50
+ ' Hook for updating http before send
51
+ '
52
+ ' @method PrepareHttp
53
+ ' @param {WebClient} Client
54
+ ' @param {WebRequest} Request
55
+ ' @param in|out {WinHttpRequest} Http
56
+ ''
57
+ Public Sub PrepareHttp(ByVal Client As WebClient, ByVal Request As WebRequest, ByRef Http As Object)
58
+ ' e.g. Update option, headers, etc.
59
+ End Sub
60
+
61
+ ''
62
+ ' Hook for updating cURL before send
63
+ '
64
+ ' @method PrepareCurl
65
+ ' @param {WebClient} Client
66
+ ' @param {WebRequest} Request
67
+ ' @param in|out {String} Curl
68
+ ''
69
+ Public Sub PrepareCurl(ByVal Client As WebClient, ByVal Request As WebRequest, ByRef Curl As String)
70
+ ' e.g. Add flags to cURL
71
+ End Sub