minchoc 0.0.8__py3-none-any.whl → 0.1.0__py3-none-any.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.

Potentially problematic release.


This version of minchoc might be problematic. Click here for more details.

minchoc/parsetab.py CHANGED
@@ -1,89 +1,350 @@
1
1
  # parsetab.py
2
2
  # This file is automatically generated. Do not edit.
3
+ # pylint: disable=W,C,R
3
4
  _tabversion = '3.10'
4
5
 
5
6
  _lr_method = 'LALR'
6
7
 
7
- _lr_signature = 'AND EQ ISLATESTVERSION LPAREN RPAREN STRING TOLOWER_ID\n expression : expression AND expression\n | LPAREN expression RPAREN\n expression : ISLATESTVERSIONexpression : TOLOWER_ID EQ STRING'
8
+ _lr_signature = 'AND COMMA EQ FIELD ISLATESTVERSION LPAREN NE NULL OR RPAREN STRING SUBSTRINGOF TOLOWERexpression : LPAREN expression RPARENsubstringof : SUBSTRINGOF LPAREN STRING COMMA expression RPARENtolower : TOLOWER LPAREN FIELD RPARENexpression : FIELDexpression : expression OR expression\n| expression AND expression\n| expression NE expression\n| expression EQ expressionexpression : STRINGexpression : NULL\n| substringof\n| tolower\n| ISLATESTVERSION'
8
9
 
9
10
  _lr_action_items = {
10
11
  'LPAREN': ([
11
12
  0,
12
13
  2,
13
- 5,
14
+ 9,
15
+ 10,
16
+ 11,
17
+ 12,
18
+ 13,
19
+ 14,
20
+ 25,
14
21
  ], [
22
+ 2,
23
+ 2,
24
+ 16,
25
+ 17,
26
+ 2,
27
+ 2,
15
28
  2,
16
29
  2,
17
30
  2,
18
31
  ]),
19
- 'ISLATESTVERSION': ([
32
+ 'FIELD': ([
20
33
  0,
21
34
  2,
22
- 5,
35
+ 11,
36
+ 12,
37
+ 13,
38
+ 14,
39
+ 17,
40
+ 25,
23
41
  ], [
24
42
  3,
25
43
  3,
26
44
  3,
45
+ 3,
46
+ 3,
47
+ 3,
48
+ 24,
49
+ 3,
27
50
  ]),
28
- 'TOLOWER_ID': ([
51
+ 'STRING': ([
29
52
  0,
30
53
  2,
31
- 5,
54
+ 11,
55
+ 12,
56
+ 13,
57
+ 14,
58
+ 16,
59
+ 25,
32
60
  ], [
33
61
  4,
34
62
  4,
35
63
  4,
64
+ 4,
65
+ 4,
66
+ 4,
67
+ 23,
68
+ 4,
69
+ ]),
70
+ 'NULL': ([
71
+ 0,
72
+ 2,
73
+ 11,
74
+ 12,
75
+ 13,
76
+ 14,
77
+ 25,
78
+ ], [
79
+ 5,
80
+ 5,
81
+ 5,
82
+ 5,
83
+ 5,
84
+ 5,
85
+ 5,
86
+ ]),
87
+ 'ISLATESTVERSION': ([
88
+ 0,
89
+ 2,
90
+ 11,
91
+ 12,
92
+ 13,
93
+ 14,
94
+ 25,
95
+ ], [
96
+ 8,
97
+ 8,
98
+ 8,
99
+ 8,
100
+ 8,
101
+ 8,
102
+ 8,
103
+ ]),
104
+ 'SUBSTRINGOF': ([
105
+ 0,
106
+ 2,
107
+ 11,
108
+ 12,
109
+ 13,
110
+ 14,
111
+ 25,
112
+ ], [
113
+ 9,
114
+ 9,
115
+ 9,
116
+ 9,
117
+ 9,
118
+ 9,
119
+ 9,
120
+ ]),
121
+ 'TOLOWER': ([
122
+ 0,
123
+ 2,
124
+ 11,
125
+ 12,
126
+ 13,
127
+ 14,
128
+ 25,
129
+ ], [
130
+ 10,
131
+ 10,
132
+ 10,
133
+ 10,
134
+ 10,
135
+ 10,
136
+ 10,
36
137
  ]),
37
138
  '$end': ([
38
139
  1,
39
140
  3,
141
+ 4,
142
+ 5,
143
+ 6,
144
+ 7,
40
145
  8,
41
- 9,
42
- 10,
146
+ 18,
147
+ 19,
148
+ 20,
149
+ 21,
150
+ 22,
151
+ 26,
152
+ 28,
43
153
  ], [
44
154
  0,
45
- -3,
155
+ -4,
156
+ -9,
157
+ -10,
158
+ -11,
159
+ -12,
160
+ -13,
161
+ -5,
162
+ -6,
163
+ -7,
164
+ -8,
46
165
  -1,
166
+ -3,
47
167
  -2,
168
+ ]),
169
+ 'OR': ([
170
+ 1,
171
+ 3,
172
+ 4,
173
+ 5,
174
+ 6,
175
+ 7,
176
+ 8,
177
+ 15,
178
+ 18,
179
+ 19,
180
+ 20,
181
+ 21,
182
+ 22,
183
+ 26,
184
+ 27,
185
+ 28,
186
+ ], [
187
+ 11,
48
188
  -4,
189
+ -9,
190
+ -10,
191
+ -11,
192
+ -12,
193
+ -13,
194
+ 11,
195
+ 11,
196
+ 11,
197
+ 11,
198
+ 11,
199
+ -1,
200
+ -3,
201
+ 11,
202
+ -2,
49
203
  ]),
50
204
  'AND': ([
51
205
  1,
52
206
  3,
207
+ 4,
208
+ 5,
53
209
  6,
210
+ 7,
54
211
  8,
55
- 9,
56
- 10,
212
+ 15,
213
+ 18,
214
+ 19,
215
+ 20,
216
+ 21,
217
+ 22,
218
+ 26,
219
+ 27,
220
+ 28,
57
221
  ], [
58
- 5,
222
+ 12,
223
+ -4,
224
+ -9,
225
+ -10,
226
+ -11,
227
+ -12,
228
+ -13,
229
+ 12,
230
+ 12,
231
+ 12,
232
+ 12,
233
+ 12,
234
+ -1,
59
235
  -3,
60
- 5,
61
- 5,
236
+ 12,
62
237
  -2,
63
- -4,
64
238
  ]),
65
- 'RPAREN': ([
239
+ 'NE': ([
240
+ 1,
66
241
  3,
242
+ 4,
243
+ 5,
67
244
  6,
245
+ 7,
68
246
  8,
69
- 9,
70
- 10,
247
+ 15,
248
+ 18,
249
+ 19,
250
+ 20,
251
+ 21,
252
+ 22,
253
+ 26,
254
+ 27,
255
+ 28,
71
256
  ], [
72
- -3,
73
- 9,
257
+ 13,
258
+ -4,
259
+ -9,
260
+ -10,
261
+ -11,
262
+ -12,
263
+ -13,
264
+ 13,
265
+ 13,
266
+ 13,
267
+ 13,
268
+ 13,
74
269
  -1,
270
+ -3,
271
+ 13,
75
272
  -2,
76
- -4,
77
273
  ]),
78
274
  'EQ': ([
275
+ 1,
276
+ 3,
79
277
  4,
80
- ], [
278
+ 5,
279
+ 6,
81
280
  7,
281
+ 8,
282
+ 15,
283
+ 18,
284
+ 19,
285
+ 20,
286
+ 21,
287
+ 22,
288
+ 26,
289
+ 27,
290
+ 28,
291
+ ], [
292
+ 14,
293
+ -4,
294
+ -9,
295
+ -10,
296
+ -11,
297
+ -12,
298
+ -13,
299
+ 14,
300
+ 14,
301
+ 14,
302
+ 14,
303
+ 14,
304
+ -1,
305
+ -3,
306
+ 14,
307
+ -2,
82
308
  ]),
83
- 'STRING': ([
309
+ 'RPAREN': ([
310
+ 3,
311
+ 4,
312
+ 5,
313
+ 6,
84
314
  7,
315
+ 8,
316
+ 15,
317
+ 18,
318
+ 19,
319
+ 20,
320
+ 21,
321
+ 22,
322
+ 24,
323
+ 26,
324
+ 27,
325
+ 28,
85
326
  ], [
86
- 10,
327
+ -4,
328
+ -9,
329
+ -10,
330
+ -11,
331
+ -12,
332
+ -13,
333
+ 22,
334
+ -5,
335
+ -6,
336
+ -7,
337
+ -8,
338
+ -1,
339
+ 26,
340
+ -3,
341
+ 28,
342
+ -2,
343
+ ]),
344
+ 'COMMA': ([
345
+ 23,
346
+ ], [
347
+ 25,
87
348
  ]),
88
349
  }
89
350
 
@@ -98,11 +359,53 @@ _lr_goto_items = {
98
359
  'expression': ([
99
360
  0,
100
361
  2,
101
- 5,
362
+ 11,
363
+ 12,
364
+ 13,
365
+ 14,
366
+ 25,
102
367
  ], [
103
368
  1,
369
+ 15,
370
+ 18,
371
+ 19,
372
+ 20,
373
+ 21,
374
+ 27,
375
+ ]),
376
+ 'substringof': ([
377
+ 0,
378
+ 2,
379
+ 11,
380
+ 12,
381
+ 13,
382
+ 14,
383
+ 25,
384
+ ], [
104
385
  6,
105
- 8,
386
+ 6,
387
+ 6,
388
+ 6,
389
+ 6,
390
+ 6,
391
+ 6,
392
+ ]),
393
+ 'tolower': ([
394
+ 0,
395
+ 2,
396
+ 11,
397
+ 12,
398
+ 13,
399
+ 14,
400
+ 25,
401
+ ], [
402
+ 7,
403
+ 7,
404
+ 7,
405
+ 7,
406
+ 7,
407
+ 7,
408
+ 7,
106
409
  ]),
107
410
  }
108
411
 
@@ -114,11 +417,23 @@ for _k, _v in _lr_goto_items.items():
114
417
  del _lr_goto_items
115
418
  _lr_productions = [
116
419
  ("S' -> expression", "S'", 1, None, None, None),
117
- ('expression -> expression AND expression', 'expression', 3, 'p_expression', 'filteryacc.py',
118
- 16),
119
- ('expression -> LPAREN expression RPAREN', 'expression', 3, 'p_expression', 'filteryacc.py',
120
- 17),
121
- ('expression -> ISLATESTVERSION', 'expression', 1, 'p_islatestversion', 'filteryacc.py', 28),
122
- ('expression -> TOLOWER_ID EQ STRING', 'expression', 3, 'p_tolower_id_eq_package',
123
- 'filteryacc.py', 33),
420
+ ('expression -> LPAREN expression RPAREN', 'expression', 3, 'p_expression_expr',
421
+ 'filteryacc.py', 27),
422
+ ('substringof -> SUBSTRINGOF LPAREN STRING COMMA expression RPAREN', 'substringof', 6,
423
+ 'p_substringof', 'filteryacc.py', 33),
424
+ ('tolower -> TOLOWER LPAREN FIELD RPAREN', 'tolower', 4, 'p_tolower', 'filteryacc.py', 47),
425
+ ('expression -> FIELD', 'expression', 1, 'p_expression_field', 'filteryacc.py', 55),
426
+ ('expression -> expression OR expression', 'expression', 3, 'p_expression_op', 'filteryacc.py',
427
+ 68),
428
+ ('expression -> expression AND expression', 'expression', 3, 'p_expression_op', 'filteryacc.py',
429
+ 69),
430
+ ('expression -> expression NE expression', 'expression', 3, 'p_expression_op', 'filteryacc.py',
431
+ 70),
432
+ ('expression -> expression EQ expression', 'expression', 3, 'p_expression_op', 'filteryacc.py',
433
+ 71),
434
+ ('expression -> STRING', 'expression', 1, 'p_expression_str', 'filteryacc.py', 95),
435
+ ('expression -> NULL', 'expression', 1, 'p_expression', 'filteryacc.py', 108),
436
+ ('expression -> substringof', 'expression', 1, 'p_expression', 'filteryacc.py', 109),
437
+ ('expression -> tolower', 'expression', 1, 'p_expression', 'filteryacc.py', 110),
438
+ ('expression -> ISLATESTVERSION', 'expression', 1, 'p_expression', 'filteryacc.py', 111),
124
439
  ]
minchoc/urls.py CHANGED
@@ -1,3 +1,6 @@
1
+ """URL patterns."""
2
+ from __future__ import annotations
3
+
1
4
  from django.urls import path
2
5
 
3
6
  from . import views
@@ -10,8 +13,7 @@ urlpatterns = [
10
13
  path('FindPackagesById()', views.find_packages_by_id),
11
14
  path('Packages()', views.packages),
12
15
  path("Packages(Id='<name>',Version='<version>')", views.packages_with_args),
13
- path('api/v2/$metadata', views.metadata),
14
- path('api/v2/package/<name>/<version>', views.fetch_package_file),
15
- path('api/v2/package/', views.APIV2PackageView.as_view()),
16
+ path('package/<name>/<version>', views.fetch_package_file),
17
+ path('package/', views.APIV2PackageView.as_view()),
16
18
  path('', views.home)
17
19
  ]
minchoc/utils.py CHANGED
@@ -1,15 +1,23 @@
1
+ """Utility functions."""
2
+ from __future__ import annotations
3
+
4
+ from typing import TYPE_CHECKING
5
+
1
6
  from django.db.models import Sum
2
7
 
3
8
  from .models import Package
4
9
 
5
- __all__ = ('make_entry',)
10
+ if TYPE_CHECKING:
11
+ from xml.etree.ElementTree import Element # noqa: S405
12
+
13
+ __all__ = ('make_entry', 'tag_text_or')
6
14
 
7
15
 
8
16
  def make_entry(host: str, package: Package, ending: str = '\n') -> str:
9
- """Creates a package ``<entry>`` element for a package XML feed."""
10
- total_downloads = Package.objects.filter(nuget_id=package.nuget_id).aggregate(
17
+ """Create a package ``<entry>`` element for a package XML feed."""
18
+ total_downloads = Package._default_manager.filter(nuget_id=package.nuget_id).aggregate(
11
19
  total_downloads=Sum('download_count'))['total_downloads']
12
- return f'''<entry>
20
+ return f"""<entry>
13
21
  <id>{host}/api/v2/Packages(Id='{package.nuget_id}',Version='{package.version}')</id>
14
22
  <category term="NuGetGallery.V2FeedPackage"
15
23
  scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
@@ -53,4 +61,9 @@ def make_entry(host: str, package: Package, ending: str = '\n') -> str:
53
61
  <d:Version>{package.version}</d:Version>
54
62
  <d:VersionDownloadCount m:type="Edm.Int32">{package.download_count}</d:VersionDownloadCount>
55
63
  </m:properties>
56
- </entry>{ending}''' # noqa: E501
64
+ </entry>{ending}""" # noqa: E501
65
+
66
+
67
+ def tag_text_or(tag: Element | None, default: str | None = None) -> str | None:
68
+ """Return text from a tag or the default value specified."""
69
+ return tag.text if tag is not None and tag.text else default