backrefs 5.8__py313-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.
Files changed (40) hide show
  1. backrefs/__init__.py +2 -0
  2. backrefs/__meta__.py +197 -0
  3. backrefs/_bre_parse.py +1529 -0
  4. backrefs/_bregex_parse.py +1362 -0
  5. backrefs/_bregex_typing.py +6 -0
  6. backrefs/bre.py +652 -0
  7. backrefs/bregex.py +726 -0
  8. backrefs/py.typed +0 -0
  9. backrefs/uniprops/__init__.py +592 -0
  10. backrefs/uniprops/unidata/__init__.py +26 -0
  11. backrefs/uniprops/unidata/age.py +115 -0
  12. backrefs/uniprops/unidata/alias.py +771 -0
  13. backrefs/uniprops/unidata/bidiclass.py +99 -0
  14. backrefs/uniprops/unidata/bidipairedbrackettype.py +19 -0
  15. backrefs/uniprops/unidata/binary.py +331 -0
  16. backrefs/uniprops/unidata/block.py +1323 -0
  17. backrefs/uniprops/unidata/canonicalcombiningclass.py +1031 -0
  18. backrefs/uniprops/unidata/decompositiontype.py +79 -0
  19. backrefs/uniprops/unidata/eastasianwidth.py +31 -0
  20. backrefs/uniprops/unidata/generalcategory.py +173 -0
  21. backrefs/uniprops/unidata/graphemeclusterbreak.py +79 -0
  22. backrefs/uniprops/unidata/hangulsyllabletype.py +31 -0
  23. backrefs/uniprops/unidata/indicpositionalcategory.py +71 -0
  24. backrefs/uniprops/unidata/indicsyllabiccategory.py +151 -0
  25. backrefs/uniprops/unidata/joininggroup.py +423 -0
  26. backrefs/uniprops/unidata/joiningtype.py +31 -0
  27. backrefs/uniprops/unidata/linebreak.py +199 -0
  28. backrefs/uniprops/unidata/numerictype.py +23 -0
  29. backrefs/uniprops/unidata/numericvalue.py +583 -0
  30. backrefs/uniprops/unidata/quickcheck.py +59 -0
  31. backrefs/uniprops/unidata/script.py +667 -0
  32. backrefs/uniprops/unidata/scriptextensions.py +667 -0
  33. backrefs/uniprops/unidata/sentencebreak.py +67 -0
  34. backrefs/uniprops/unidata/verticalorientation.py +23 -0
  35. backrefs/uniprops/unidata/wordbreak.py +99 -0
  36. backrefs/util.py +163 -0
  37. backrefs-5.8.dist-info/METADATA +74 -0
  38. backrefs-5.8.dist-info/RECORD +40 -0
  39. backrefs-5.8.dist-info/WHEEL +4 -0
  40. backrefs-5.8.dist-info/licenses/LICENSE.md +21 -0
backrefs/py.typed ADDED
File without changes
@@ -0,0 +1,592 @@
1
+ """Unicode Properties."""
2
+ from __future__ import annotations
3
+ from . import unidata
4
+
5
+ UNICODE_RANGE = '\u0000-\U0010ffff'
6
+ ASCII_RANGE = '\x00-\xff'
7
+
8
+ MODE_NORMAL = 0
9
+ MODE_ASCII = 1
10
+ MODE_UNICODE = 2
11
+
12
+
13
+ def fmt_string(value: str, is_bytes: bool) -> str:
14
+ """Format for bytes string."""
15
+
16
+ if is_bytes:
17
+ return value[:-1] + '\xff' if value.endswith('\U0010ffff') else value
18
+ else:
19
+ return value
20
+
21
+
22
+ def get_gc_property(value: str, mode: int = MODE_UNICODE) -> str:
23
+ """Get `GC` property."""
24
+
25
+ obj = unidata.ascii_properties if mode != MODE_UNICODE else unidata.unicode_properties
26
+
27
+ if value.startswith('^'):
28
+ negate = True
29
+ value = value[1:]
30
+ else:
31
+ negate = False
32
+
33
+ value = unidata.unicode_alias['generalcategory'].get(value, value)
34
+ is_binary = mode == MODE_ASCII
35
+
36
+ length = len(value)
37
+ if length < 1 or length > 2:
38
+ raise ValueError('Invalid property')
39
+ elif length == 1 and value not in obj:
40
+ raise ValueError('Invalid property')
41
+ elif length == 2 and (value[0] not in obj or value[1] not in obj[value[0]]):
42
+ raise ValueError('Invalid property')
43
+
44
+ if not negate:
45
+ p1, p2 = (value[0], value[1]) if len(value) > 1 else (value[0], None)
46
+ value = ''.join(
47
+ [fmt_string(v, is_binary) for k, v in obj.get(p1, {}).items() if not k.startswith('^')]
48
+ ) if p2 is None else fmt_string(obj.get(p1, {}).get(p2, ''), is_binary)
49
+ else:
50
+ p1, p2 = (value[0], value[1]) if len(value) > 1 else (value[0], '')
51
+ value = fmt_string(obj.get(p1, {}).get('^' + p2, ''), is_binary)
52
+ return value
53
+
54
+
55
+ def get_binary_property(value: str, mode: int = MODE_UNICODE) -> str:
56
+ """Get `BINARY` property."""
57
+
58
+ obj = unidata.ascii_binary if mode != MODE_UNICODE else unidata.unicode_binary
59
+
60
+ if value.startswith('^'):
61
+ negated = value[1:]
62
+ value = '^' + unidata.unicode_alias['binary'].get(negated, negated)
63
+ else:
64
+ value = unidata.unicode_alias['binary'].get(value, value)
65
+
66
+ return fmt_string(obj[value], mode == MODE_ASCII)
67
+
68
+
69
+ def get_canonical_combining_class_property(value: str, mode: int = MODE_UNICODE) -> str:
70
+ """Get `CANONICAL COMBINING CLASS` property."""
71
+
72
+ obj = unidata.ascii_canonical_combining_class if mode != MODE_UNICODE else unidata.unicode_canonical_combining_class
73
+
74
+ if value.startswith('^'):
75
+ negated = value[1:]
76
+ value = '^' + unidata.unicode_alias['canonicalcombiningclass'].get(negated, negated)
77
+ else:
78
+ value = unidata.unicode_alias['canonicalcombiningclass'].get(value, value)
79
+
80
+ return fmt_string(obj[value], mode == MODE_ASCII)
81
+
82
+
83
+ def get_east_asian_width_property(value: str, mode: int = MODE_UNICODE) -> str:
84
+ """Get `EAST ASIAN WIDTH` property."""
85
+
86
+ obj = unidata.ascii_east_asian_width if mode != MODE_UNICODE else unidata.unicode_east_asian_width
87
+
88
+ if value.startswith('^'):
89
+ negated = value[1:]
90
+ value = '^' + unidata.unicode_alias['eastasianwidth'].get(negated, negated)
91
+ else:
92
+ value = unidata.unicode_alias['eastasianwidth'].get(value, value)
93
+
94
+ return fmt_string(obj[value], mode == MODE_ASCII)
95
+
96
+
97
+ def get_grapheme_cluster_break_property(value: str, mode: int = MODE_UNICODE) -> str:
98
+ """Get `GRAPHEME CLUSTER BREAK` property."""
99
+
100
+ obj = unidata.ascii_grapheme_cluster_break if mode != MODE_UNICODE else unidata.unicode_grapheme_cluster_break
101
+
102
+ if value.startswith('^'):
103
+ negated = value[1:]
104
+ value = '^' + unidata.unicode_alias['graphemeclusterbreak'].get(negated, negated)
105
+ else:
106
+ value = unidata.unicode_alias['graphemeclusterbreak'].get(value, value)
107
+
108
+ return fmt_string(obj[value], mode == MODE_ASCII)
109
+
110
+
111
+ def get_line_break_property(value: str, mode: int = MODE_UNICODE) -> str:
112
+ """Get `LINE BREAK` property."""
113
+
114
+ obj = unidata.ascii_line_break if mode != MODE_UNICODE else unidata.unicode_line_break
115
+
116
+ if value.startswith('^'):
117
+ negated = value[1:]
118
+ value = '^' + unidata.unicode_alias['linebreak'].get(negated, negated)
119
+ else:
120
+ value = unidata.unicode_alias['linebreak'].get(value, value)
121
+
122
+ return fmt_string(obj[value], mode == MODE_ASCII)
123
+
124
+
125
+ def get_sentence_break_property(value: str, mode: int = MODE_UNICODE) -> str:
126
+ """Get `SENTENCE BREAK` property."""
127
+
128
+ obj = unidata.ascii_sentence_break if mode != MODE_UNICODE else unidata.unicode_sentence_break
129
+
130
+ if value.startswith('^'):
131
+ negated = value[1:]
132
+ value = '^' + unidata.unicode_alias['sentencebreak'].get(negated, negated)
133
+ else:
134
+ value = unidata.unicode_alias['sentencebreak'].get(value, value)
135
+
136
+ return fmt_string(obj[value], mode == MODE_ASCII)
137
+
138
+
139
+ def get_word_break_property(value: str, mode: int = MODE_UNICODE) -> str:
140
+ """Get `WORD BREAK` property."""
141
+
142
+ obj = unidata.ascii_word_break if mode != MODE_UNICODE else unidata.unicode_word_break
143
+
144
+ if value.startswith('^'):
145
+ negated = value[1:]
146
+ value = '^' + unidata.unicode_alias['wordbreak'].get(negated, negated)
147
+ else:
148
+ value = unidata.unicode_alias['wordbreak'].get(value, value)
149
+
150
+ return fmt_string(obj[value], mode == MODE_ASCII)
151
+
152
+
153
+ def get_hangul_syllable_type_property(value: str, mode: int = MODE_UNICODE) -> str:
154
+ """Get `HANGUL SYLLABLE TYPE` property."""
155
+
156
+ obj = unidata.ascii_hangul_syllable_type if mode != MODE_UNICODE else unidata.unicode_hangul_syllable_type
157
+
158
+ if value.startswith('^'):
159
+ negated = value[1:]
160
+ value = '^' + unidata.unicode_alias['hangulsyllabletype'].get(negated, negated)
161
+ else:
162
+ value = unidata.unicode_alias['hangulsyllabletype'].get(value, value)
163
+
164
+ return fmt_string(obj[value], mode == MODE_ASCII)
165
+
166
+
167
+ def get_indic_positional_category_property(value: str, mode: int = MODE_UNICODE) -> str:
168
+ """Get `INDIC POSITIONAL/MATRA CATEGORY` property."""
169
+
170
+ obj = unidata.ascii_indic_positional_category if mode != MODE_UNICODE else unidata.unicode_indic_positional_category
171
+ alias_key = 'indicpositionalcategory'
172
+
173
+ if value.startswith('^'):
174
+ negated = value[1:]
175
+ value = '^' + unidata.unicode_alias[alias_key].get(negated, negated)
176
+ else:
177
+ value = unidata.unicode_alias[alias_key].get(value, value)
178
+
179
+ return fmt_string(obj[value], mode == MODE_ASCII)
180
+
181
+
182
+ def get_indic_syllabic_category_property(value: str, mode: int = MODE_UNICODE) -> str:
183
+ """Get `INDIC SYLLABIC CATEGORY` property."""
184
+
185
+ obj = unidata.ascii_indic_syllabic_category if mode != MODE_UNICODE else unidata.unicode_indic_syllabic_category
186
+
187
+ if value.startswith('^'):
188
+ negated = value[1:]
189
+ value = '^' + unidata.unicode_alias['indicsyllabiccategory'].get(negated, negated)
190
+ else:
191
+ value = unidata.unicode_alias['indicsyllabiccategory'].get(value, value)
192
+
193
+ return fmt_string(obj[value], mode == MODE_ASCII)
194
+
195
+
196
+ def get_decomposition_type_property(value: str, mode: int = MODE_UNICODE) -> str:
197
+ """Get `DECOMPOSITION TYPE` property."""
198
+
199
+ obj = unidata.ascii_decomposition_type if mode != MODE_UNICODE else unidata.unicode_decomposition_type
200
+
201
+ if value.startswith('^'):
202
+ negated = value[1:]
203
+ value = '^' + unidata.unicode_alias['decompositiontype'].get(negated, negated)
204
+ else:
205
+ value = unidata.unicode_alias['decompositiontype'].get(value, value)
206
+
207
+ return fmt_string(obj[value], mode == MODE_ASCII)
208
+
209
+
210
+ def get_nfc_quick_check_property(value: str, mode: int = MODE_UNICODE) -> str:
211
+ """Get `NFC QUICK CHECK` property."""
212
+
213
+ obj = unidata.ascii_nfc_quick_check if mode != MODE_UNICODE else unidata.unicode_nfc_quick_check
214
+
215
+ if value.startswith('^'):
216
+ negated = value[1:]
217
+ value = '^' + unidata.unicode_alias['nfcquickcheck'].get(negated, negated)
218
+ else:
219
+ value = unidata.unicode_alias['nfcquickcheck'].get(value, value)
220
+
221
+ return fmt_string(obj[value], mode == MODE_ASCII)
222
+
223
+
224
+ def get_nfd_quick_check_property(value: str, mode: int = MODE_UNICODE) -> str:
225
+ """Get `NFD QUICK CHECK` property."""
226
+
227
+ obj = unidata.ascii_nfd_quick_check if mode != MODE_UNICODE else unidata.unicode_nfd_quick_check
228
+
229
+ if value.startswith('^'):
230
+ negated = value[1:]
231
+ value = '^' + unidata.unicode_alias['nfdquickcheck'].get(negated, negated)
232
+ else:
233
+ value = unidata.unicode_alias['nfdquickcheck'].get(value, value)
234
+
235
+ return fmt_string(obj[value], mode == MODE_ASCII)
236
+
237
+
238
+ def get_nfkc_quick_check_property(value: str, mode: int = MODE_UNICODE) -> str:
239
+ """Get `NFKC QUICK CHECK` property."""
240
+
241
+ obj = unidata.ascii_nfkc_quick_check if mode != MODE_UNICODE else unidata.unicode_nfkc_quick_check
242
+
243
+ if value.startswith('^'):
244
+ negated = value[1:]
245
+ value = '^' + unidata.unicode_alias['nfkcquickcheck'].get(negated, negated)
246
+ else:
247
+ value = unidata.unicode_alias['nfkcquickcheck'].get(value, value)
248
+
249
+ return fmt_string(obj[value], mode == MODE_ASCII)
250
+
251
+
252
+ def get_nfkd_quick_check_property(value: str, mode: int = MODE_UNICODE) -> str:
253
+ """Get `NFKD QUICK CHECK` property."""
254
+
255
+ obj = unidata.ascii_nfkd_quick_check if mode != MODE_UNICODE else unidata.unicode_nfkd_quick_check
256
+
257
+ if value.startswith('^'):
258
+ negated = value[1:]
259
+ value = '^' + unidata.unicode_alias['nfkdquickcheck'].get(negated, negated)
260
+ else:
261
+ value = unidata.unicode_alias['nfkdquickcheck'].get(value, value)
262
+
263
+ return fmt_string(obj[value], mode == MODE_ASCII)
264
+
265
+
266
+ def get_numeric_type_property(value: str, mode: int = MODE_UNICODE) -> str:
267
+ """Get `NUMERIC TYPE` property."""
268
+
269
+ obj = unidata.ascii_numeric_type if mode != MODE_UNICODE else unidata.unicode_numeric_type
270
+
271
+ if value.startswith('^'):
272
+ negated = value[1:]
273
+ value = '^' + unidata.unicode_alias['numerictype'].get(negated, negated)
274
+ else:
275
+ value = unidata.unicode_alias['numerictype'].get(value, value)
276
+
277
+ return fmt_string(obj[value], mode == MODE_ASCII)
278
+
279
+
280
+ def get_numeric_value_property(value: str, mode: int = MODE_UNICODE) -> str:
281
+ """Get `NUMERIC VALUE` property."""
282
+
283
+ obj = unidata.ascii_numeric_values if mode != MODE_UNICODE else unidata.unicode_numeric_values
284
+
285
+ if value.startswith('^'):
286
+ negated = value[1:]
287
+ value = '^' + unidata.unicode_alias['numericvalue'].get(negated, negated)
288
+ else:
289
+ value = unidata.unicode_alias['numericvalue'].get(value, value)
290
+
291
+ return fmt_string(obj[value], mode == MODE_ASCII)
292
+
293
+
294
+ def get_age_property(value: str, mode: int = MODE_UNICODE) -> str:
295
+ """Get `AGE` property."""
296
+
297
+ obj = unidata.ascii_age if mode != MODE_UNICODE else unidata.unicode_age
298
+
299
+ if value.startswith('^'):
300
+ negated = value[1:]
301
+ value = '^' + unidata.unicode_alias['age'].get(negated, negated)
302
+ else:
303
+ value = unidata.unicode_alias['age'].get(value, value)
304
+
305
+ return fmt_string(obj[value], mode == MODE_ASCII)
306
+
307
+
308
+ def get_joining_type_property(value: str, mode: int = MODE_UNICODE) -> str:
309
+ """Get `JOINING TYPE` property."""
310
+
311
+ obj = unidata.ascii_joining_type if mode != MODE_UNICODE else unidata.unicode_joining_type
312
+
313
+ if value.startswith('^'):
314
+ negated = value[1:]
315
+ value = '^' + unidata.unicode_alias['joiningtype'].get(negated, negated)
316
+ else:
317
+ value = unidata.unicode_alias['joiningtype'].get(value, value)
318
+
319
+ return fmt_string(obj[value], mode == MODE_ASCII)
320
+
321
+
322
+ def get_joining_group_property(value: str, mode: int = MODE_UNICODE) -> str:
323
+ """Get `JOINING GROUP` property."""
324
+
325
+ obj = unidata.ascii_joining_group if mode != MODE_UNICODE else unidata.unicode_joining_group
326
+
327
+ if value.startswith('^'):
328
+ negated = value[1:]
329
+ value = '^' + unidata.unicode_alias['joininggroup'].get(negated, negated)
330
+ else:
331
+ value = unidata.unicode_alias['joininggroup'].get(value, value)
332
+
333
+ return fmt_string(obj[value], mode == MODE_ASCII)
334
+
335
+
336
+ def get_script_property(value: str, mode: int = MODE_UNICODE) -> str:
337
+ """Get `SC` property."""
338
+
339
+ obj = unidata.ascii_scripts if mode != MODE_UNICODE else unidata.unicode_scripts
340
+
341
+ if value.startswith('^'):
342
+ negated = value[1:]
343
+ value = '^' + unidata.unicode_alias['script'].get(negated, negated)
344
+ else:
345
+ value = unidata.unicode_alias['script'].get(value, value)
346
+
347
+ return fmt_string(obj[value], mode == MODE_ASCII)
348
+
349
+
350
+ def get_script_extension_property(value: str, mode: int = MODE_UNICODE) -> str:
351
+ """Get `SCX` property."""
352
+
353
+ obj = unidata.ascii_script_extensions if mode != MODE_UNICODE else unidata.unicode_script_extensions
354
+
355
+ if value.startswith('^'):
356
+ negated = value[1:]
357
+ value = '^' + unidata.unicode_alias['script'].get(negated, negated)
358
+ else:
359
+ value = unidata.unicode_alias['script'].get(value, value)
360
+
361
+ return fmt_string(obj[value], mode == MODE_ASCII)
362
+
363
+
364
+ def get_block_property(value: str, mode: int = MODE_UNICODE) -> str:
365
+ """Get `BLK` property."""
366
+
367
+ obj = unidata.ascii_blocks if mode != MODE_UNICODE else unidata.unicode_blocks
368
+
369
+ if value.startswith('^'):
370
+ negated = value[1:]
371
+ value = '^' + unidata.unicode_alias['block'].get(negated, negated)
372
+ else:
373
+ value = unidata.unicode_alias['block'].get(value, value)
374
+
375
+ return fmt_string(obj[value], mode == MODE_ASCII)
376
+
377
+
378
+ def get_bidi_property(value: str, mode: int = MODE_UNICODE) -> str:
379
+ """Get `BC` property."""
380
+
381
+ obj = unidata.ascii_bidi_classes if mode != MODE_UNICODE else unidata.unicode_bidi_classes
382
+
383
+ if value.startswith('^'):
384
+ negated = value[1:]
385
+ value = '^' + unidata.unicode_alias['bidiclass'].get(negated, negated)
386
+ else:
387
+ value = unidata.unicode_alias['bidiclass'].get(value, value)
388
+
389
+ return fmt_string(obj[value], mode == MODE_ASCII)
390
+
391
+
392
+ def get_bidi_paired_bracket_type_property(value: str, mode: int = MODE_UNICODE) -> str:
393
+ """Get `BPT` property."""
394
+
395
+ obj = unidata.ascii_bidi_paired_bracket_type if mode != MODE_UNICODE else unidata.unicode_bidi_paired_bracket_type
396
+
397
+ if value.startswith('^'):
398
+ negated = value[1:]
399
+ value = '^' + unidata.unicode_alias['bidipairedbrackettype'].get(negated, negated)
400
+ else:
401
+ value = unidata.unicode_alias['bidipairedbrackettype'].get(value, value)
402
+
403
+ return fmt_string(obj[value], mode == MODE_ASCII)
404
+
405
+
406
+ def get_vertical_orientation_property(value: str, mode: int = MODE_UNICODE) -> str:
407
+ """Get `VO` property."""
408
+
409
+ if mode != MODE_UNICODE:
410
+ obj = unidata.ascii_vertical_orientation # type: ignore[attr-defined]
411
+ else:
412
+ obj = unidata.unicode_vertical_orientation # type: ignore[attr-defined]
413
+
414
+ if value.startswith('^'):
415
+ negated = value[1:]
416
+ value = '^' + unidata.unicode_alias['verticalorientation'].get(negated, negated)
417
+ else:
418
+ value = unidata.unicode_alias['verticalorientation'].get(value, value)
419
+
420
+ return fmt_string(obj[value], mode == MODE_ASCII)
421
+
422
+
423
+ def get_is_property(value: str, mode: int = MODE_UNICODE) -> str:
424
+ """Get shortcut for `SC` or `Binary` property."""
425
+
426
+ if value.startswith('^'):
427
+ prefix = value[1:3]
428
+ temp = value[3:]
429
+ negate = '^'
430
+ else:
431
+ prefix = value[:2]
432
+ temp = value[2:]
433
+ negate = ''
434
+
435
+ if prefix != 'is':
436
+ raise ValueError("Does not start with 'is'!")
437
+
438
+ script_obj = unidata.ascii_script_extensions if mode != MODE_UNICODE else unidata.unicode_script_extensions
439
+ bin_obj = unidata.ascii_binary if mode != MODE_UNICODE else unidata.unicode_binary
440
+
441
+ value = negate + unidata.unicode_alias['script'].get(temp, temp)
442
+
443
+ if value not in script_obj:
444
+ value = negate + unidata.unicode_alias['binary'].get(temp, temp)
445
+ obj = bin_obj
446
+ else:
447
+ obj = script_obj
448
+
449
+ return fmt_string(obj[value], mode == MODE_ASCII)
450
+
451
+
452
+ def get_in_property(value: str, mode: int = MODE_UNICODE) -> str:
453
+ """Get shortcut for `Block` property."""
454
+
455
+ if value.startswith('^'):
456
+ prefix = value[1:3]
457
+ temp = value[3:]
458
+ negate = '^'
459
+ else:
460
+ prefix = value[:2]
461
+ temp = value[2:]
462
+ negate = ''
463
+
464
+ if prefix != 'in':
465
+ raise ValueError("Does not start with 'in'!")
466
+
467
+ value = negate + unidata.unicode_alias['block'].get(temp, temp)
468
+ obj = unidata.ascii_blocks if mode != MODE_UNICODE else unidata.unicode_blocks
469
+
470
+ return fmt_string(obj[value], mode == MODE_ASCII)
471
+
472
+
473
+ def _is_binary(name: str) -> bool:
474
+ """Check if name is an enum (not a binary) property."""
475
+
476
+ return name in unidata.unicode_binary or name in unidata.unicode_alias['binary']
477
+
478
+
479
+ def get_unicode_property(prop: str, value: str | None = None, mode: int = MODE_UNICODE) -> str:
480
+ """Retrieve the Unicode category from the table."""
481
+
482
+ if value is not None:
483
+
484
+ negate = prop.startswith('^')
485
+
486
+ # Normalize binary true/false input so we can handle it properly
487
+ if _is_binary(prop):
488
+ name = prop[1:] if negate else prop
489
+
490
+ if value in ('n', 'no', 'f', 'false'):
491
+ negate = not negate
492
+ elif value not in ('y', 'yes', 't', 'true'):
493
+ raise ValueError(f"'{value}' is not a valid value for the binary property '{prop}'")
494
+
495
+ return get_binary_property('^' + name if negate else name, mode)
496
+ else:
497
+ if negate:
498
+ value = '^' + value
499
+ name = prop[1:]
500
+ else:
501
+ name = prop
502
+
503
+ name = unidata.unicode_alias['_'].get(name, name)
504
+ try:
505
+ if name == 'generalcategory':
506
+ return get_gc_property(value, mode)
507
+ elif name == 'script':
508
+ return get_script_property(value, mode)
509
+ elif name == 'scriptextensions':
510
+ return get_script_extension_property(value, mode)
511
+ elif name == 'block':
512
+ return get_block_property(value, mode)
513
+ elif name == 'bidiclass':
514
+ return get_bidi_property(value, mode)
515
+ elif name == 'bidipairedbrackettype':
516
+ return get_bidi_paired_bracket_type_property(value, mode)
517
+ elif name == 'age':
518
+ return get_age_property(value, mode)
519
+ elif name == 'eastasianwidth':
520
+ return get_east_asian_width_property(value, mode)
521
+ elif name == 'indicpositionalcategory':
522
+ return get_indic_positional_category_property(value, mode)
523
+ elif name == 'indicsyllabiccategory':
524
+ return get_indic_syllabic_category_property(value, mode)
525
+ elif name == 'hangulsyllabletype':
526
+ return get_hangul_syllable_type_property(value, mode)
527
+ elif name == 'decompositiontype':
528
+ return get_decomposition_type_property(value, mode)
529
+ elif name == 'canonicalcombiningclass':
530
+ return get_canonical_combining_class_property(value, mode)
531
+ elif name == 'numerictype':
532
+ return get_numeric_type_property(value, mode)
533
+ elif name == 'numericvalue':
534
+ return get_numeric_value_property(value, mode)
535
+ elif name == 'joiningtype':
536
+ return get_joining_type_property(value, mode)
537
+ elif name == 'joininggroup':
538
+ return get_joining_group_property(value, mode)
539
+ elif name == 'graphemeclusterbreak':
540
+ return get_grapheme_cluster_break_property(value, mode)
541
+ elif name == 'linebreak':
542
+ return get_line_break_property(value, mode)
543
+ elif name == 'sentencebreak':
544
+ return get_sentence_break_property(value, mode)
545
+ elif name == 'wordbreak':
546
+ return get_word_break_property(value, mode)
547
+ elif name == 'nfcquickcheck':
548
+ return get_nfc_quick_check_property(value, mode)
549
+ elif name == 'nfdquickcheck':
550
+ return get_nfd_quick_check_property(value, mode)
551
+ elif name == 'nfkcquickcheck':
552
+ return get_nfkc_quick_check_property(value, mode)
553
+ elif name == 'nfkdquickcheck':
554
+ return get_nfkd_quick_check_property(value, mode)
555
+ elif name == 'verticalorientation':
556
+ return get_vertical_orientation_property(value, mode)
557
+ else:
558
+ raise ValueError(f"'{prop}={value}' does not have a valid property name")
559
+ except Exception as e:
560
+ raise ValueError(f"'{prop}={value}' does not appear to be a valid property") from e
561
+
562
+ try:
563
+ return get_gc_property(prop, mode)
564
+ except Exception:
565
+ pass
566
+
567
+ try:
568
+ return get_script_extension_property(prop, mode)
569
+ except Exception:
570
+ pass
571
+
572
+ try:
573
+ return get_binary_property(prop, mode)
574
+ except Exception:
575
+ pass
576
+
577
+ try:
578
+ return get_block_property(prop, mode)
579
+ except Exception:
580
+ pass
581
+
582
+ try:
583
+ return get_is_property(prop, mode)
584
+ except Exception:
585
+ pass
586
+
587
+ try:
588
+ return get_in_property(prop, mode)
589
+ except Exception:
590
+ pass
591
+
592
+ raise ValueError(f"'{prop}' does not appear to be a valid property")
@@ -0,0 +1,26 @@
1
+ """Unicode Properties from Unicode version 15.1.0 (autogen)."""
2
+ from .age import * # noqa
3
+ from .alias import * # noqa
4
+ from .bidiclass import * # noqa
5
+ from .binary import * # noqa
6
+ from .block import * # noqa
7
+ from .bidipairedbrackettype import * # noqa
8
+ from .canonicalcombiningclass import * # noqa
9
+ from .decompositiontype import * # noqa
10
+ from .eastasianwidth import * # noqa
11
+ from .generalcategory import * # noqa
12
+ from .graphemeclusterbreak import * # noqa
13
+ from .hangulsyllabletype import * # noqa
14
+ from .indicpositionalcategory import * # noqa
15
+ from .indicsyllabiccategory import * # noqa
16
+ from .joininggroup import * # noqa
17
+ from .joiningtype import * # noqa
18
+ from .linebreak import * # noqa
19
+ from .numerictype import * # noqa
20
+ from .numericvalue import * # noqa
21
+ from .quickcheck import * # noqa
22
+ from .sentencebreak import * # noqa
23
+ from .script import * # noqa
24
+ from .scriptextensions import * # noqa
25
+ from .verticalorientation import * # noqa
26
+ from .wordbreak import * # noqa