STRling 0.0.1__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 STRling might be problematic. Click here for more details.

STRling/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from . import lib
STRling/lib.py ADDED
@@ -0,0 +1,136 @@
1
+ import re
2
+
3
+
4
+ # Decorators
5
+ def repetition(func):
6
+ def wrapper(*args, min=None, max=None, **kwargs):
7
+ pattern = func(*args, **kwargs)
8
+ pattern += repeat(min, max)
9
+ return pattern
10
+ return wrapper
11
+
12
+
13
+ # Range syntax
14
+ def repeat(min=None, max=None):
15
+ """Create a range for the preceding symbol"""
16
+ if min is not None and max is not None:
17
+ if min > max:
18
+ raise ValueError('min cannot be greater than max')
19
+ return f'{{{min},{max}}}'
20
+ elif min is not None:
21
+ return f'{{{min}}}'
22
+ return ''
23
+
24
+
25
+ # Literals
26
+ @repetition
27
+ def lit(text):
28
+ """Match the literal string `text`, optionally specifying repeat."""
29
+ return re.escape(text)
30
+
31
+ @repetition
32
+ def digit(min=None, max=None):
33
+ """Match a digit, optionally specifying repeat."""
34
+ return r'\d'
35
+
36
+ @repetition
37
+ def letter(min=None, max=None):
38
+ """Match a letter."""
39
+ return r'[A-Za-z]'
40
+
41
+ @repetition
42
+ def between(start_char, end_char):
43
+ """Match any character between `start_char` and `end_char`."""
44
+ return f'[{start_char}-{end_char}]'
45
+
46
+ @repetition
47
+ def in_(chars):
48
+ """Match any character in `chars`."""
49
+ return f'[{chars}]'
50
+
51
+ @repetition
52
+ def notin(chars):
53
+ """Match any character not in `chars`."""
54
+ return f'[^{chars}]'
55
+
56
+ @repetition
57
+ def space():
58
+ """Match a space."""
59
+ return r'\s'
60
+
61
+ @repetition
62
+ def any():
63
+ """Match any character."""
64
+ return r'.'
65
+
66
+
67
+ # Whitespace characters
68
+ @repetition
69
+ def newline():
70
+ """Match a newline."""
71
+ return r'\n'
72
+
73
+ @repetition
74
+ def tab():
75
+ """Match a tab."""
76
+ return r'\t'
77
+
78
+ @repetition
79
+ def carriage():
80
+ """Match a carriage return."""
81
+ return r'\r'
82
+
83
+
84
+ # Conditionals
85
+ def or_(*patterns):
86
+ """Match any of the given patterns."""
87
+ joined = '|'.join(patterns)
88
+ return f'({joined})'
89
+
90
+ def may(pattern):
91
+ """Match zero or one occurrence of the pattern."""
92
+ return f'{pattern}?'
93
+
94
+
95
+ # Anchors
96
+ def start():
97
+ """Match the start of the string."""
98
+ return r'^'
99
+
100
+ def end():
101
+ """Match the end of the string."""
102
+ return r'$'
103
+
104
+ def bound(text):
105
+ """Match the exact word `text`."""
106
+ return r'\b'
107
+
108
+
109
+ # Lookarounds
110
+ def ahead(pattern):
111
+ """Match if the pattern matches ahead."""
112
+ return f'(?={pattern})'
113
+
114
+ def behind(pattern):
115
+ """Match if the pattern matches behind."""
116
+ return f'(?<={pattern})'
117
+
118
+ def notahead(pattern):
119
+ """Match if the pattern does not match ahead."""
120
+ return f'(?!{pattern})'
121
+
122
+ def notbehind(pattern):
123
+ """Match if the pattern does not match behind."""
124
+ return f'(?<!{pattern})'
125
+
126
+
127
+ # Grouping
128
+ def group(name, *patterns):
129
+ """Create a named capture group with the given patterns."""
130
+ joined = ''.join(patterns)
131
+ return f'(?P<{name}>{joined})'
132
+
133
+ def merge(*patterns):
134
+ """Create a non-capturing group with the given patterns."""
135
+ joined = ''.join(patterns)
136
+ return f'(?:{joined})'
@@ -0,0 +1,75 @@
1
+ Metadata-Version: 2.1
2
+ Name: STRling
3
+ Version: 0.0.1
4
+ Description-Content-Type: text/markdown
5
+
6
+ # STRling
7
+
8
+ ## The Next Generation of Regular Expressions
9
+
10
+ STRling is a powerful next-generation syntax designed as a user interface for writing regular expressions (RegEx) with an object-oriented approach. STRling is a simpler syntax than RegEx while maintaining the same underlying power and flexibility, making string validation more intuitive and less error-prone.
11
+
12
+ ### Why STRling?
13
+
14
+ STRling recognizes the cryptic nature of RegEx can be challenging and susceptibility to errors. We provide a well-structured syntax that promotes readability and maintainability, empowering developers to focus on application logic rather than wrestling over difficult development tools. Most of all, we aim for a reliable product, which is why we only depend on built-in Python libraries.
15
+
16
+
17
+ ### STRling's Mission
18
+
19
+ Our mission is to make RegEx a distant and outdated syntax by abstracting the complexities of RegEx into a clean, readable, and powerful interface. We strive to simplify string operations and ensure that developers can focus on building their applications without the steep learning curve of traditional RegEx. The previous alternative to RegEx was to learn the string validation syntax specific to each user input library, but STRling aims to unify the disparate syntaxes found across various libraries and frameworks into one simple library using only built-in Python packages.
20
+
21
+ ### Key Features
22
+
23
+ - **High-Level Template Validation**: Quickly and easily validate common patterns using our template library.
24
+ - **Low-Level Pattern Construction**: Build complex regex patterns using a readable and maintainable, object-oriented syntax.
25
+ - **Escaping RegEx Jargon**: No longer write RegEx using complex jargon.
26
+ - **Dependencies**: Depends solely on built-in python libraries, fostering dependability and compatibility.
27
+
28
+ ### Installation
29
+
30
+ Install STRling via pip:
31
+
32
+ ```sh
33
+ pip install STRling
34
+ ```
35
+
36
+ ### Documentation - Developmental Guide
37
+
38
+ Here's a quick example to demonstrate how easy it is to get started with STRling:
39
+
40
+ ```python
41
+ from STRling import match, group, lib, test
42
+ import re
43
+
44
+ # Define a group of 3 digits followed by a hyphen
45
+ num3hyp = group('group3', lib.num(3), lib.lit('-'))
46
+
47
+ # Define a group of 4 digits
48
+ num4 = group('group4', lib.num(4))
49
+
50
+ # Create a custom number group
51
+ custom = group('custom', num3hyp(2), num4())
52
+
53
+ # Define a group of 10 digits
54
+ num10 = group('group10', lib.num(10))
55
+
56
+ # Create a phone number group using either custom or num10
57
+ phone_number = group('phone_number', lib.or_(custom, num10))
58
+
59
+ # Compile the pattern and match against a string
60
+ compiled_pattern = re.compile(phone_number)
61
+ input_string = "123-456-7890"
62
+ match = compiled_pattern.match(input_string)
63
+ ```
64
+
65
+ ### License
66
+
67
+ STRling is licensed under the MIT License. See the [LICENSE](https://github.com/TheCyberLocal/STRling/blob/main/LICENSE) file for more information.
68
+
69
+ ---
70
+
71
+ Simplify your string validation and matching tasks with STRling, the all-in-one solution for developers who need powerful yet user-friendly tools for working with strings. Download and start using STRling today!
72
+
73
+ ---
74
+
75
+ Feel free to adjust the links and other details as per your project specifics.
@@ -0,0 +1,6 @@
1
+ STRling/__init__.py,sha256=01NNzSGDkqRWNE81ASE-ZmWyZXgk0mlLSfz2vsILVSc,18
2
+ STRling/lib.py,sha256=u5taMOyrR7VZuZgHbwQ3tMfCUNcVffRoCnEG6AVYpFA,2812
3
+ STRling-0.0.1.dist-info/METADATA,sha256=Y5NAG74-gDanAFos6ncsx_NiVv4JYixyzXbieMAxTeY,3246
4
+ STRling-0.0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
5
+ STRling-0.0.1.dist-info/top_level.txt,sha256=ggIuR5TsvdZlmPnnOfcZLcSWIM7Cl9tpbdKPCiXtrlI,8
6
+ STRling-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.43.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ STRling