formatparse 0.5.1__cp310-cp310-manylinux_2_28_x86_64.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.
_formatparse/__init__.py
ADDED
|
Binary file
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: formatparse
|
|
3
|
+
Version: 0.5.1
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
|
+
Requires-Dist: hypothesis>=6.0 ; extra == 'test'
|
|
8
|
+
Requires-Dist: pytest-cov>=4.0 ; extra == 'test'
|
|
9
|
+
Requires-Dist: pytest-benchmark>=4.0 ; extra == 'test'
|
|
10
|
+
Requires-Dist: pympler>=0.9 ; extra == 'test'
|
|
11
|
+
Requires-Dist: memory-profiler>=0.60 ; extra == 'test'
|
|
12
|
+
Requires-Dist: mutmut>=2.0 ; extra == 'dev'
|
|
13
|
+
Provides-Extra: test
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Summary: Parse strings using a specification based on the Python format() syntax (Rust implementation)
|
|
17
|
+
Keywords: parse,format,string,parsing
|
|
18
|
+
Author-email: Odos Matthews <odosmatthews@gmail.com>
|
|
19
|
+
License: MIT
|
|
20
|
+
Requires-Python: >=3.8
|
|
21
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
22
|
+
Project-URL: Homepage, https://github.com/eddiethedean/formatparse
|
|
23
|
+
Project-URL: Repository, https://github.com/eddiethedean/formatparse
|
|
24
|
+
|
|
25
|
+
# formatparse
|
|
26
|
+
|
|
27
|
+
[](https://badge.fury.io/py/formatparse)
|
|
28
|
+
[](https://www.python.org/downloads/)
|
|
29
|
+
[](https://opensource.org/licenses/MIT)
|
|
30
|
+
[](https://www.rust-lang.org/)
|
|
31
|
+
[](https://formatparse.readthedocs.io/)
|
|
32
|
+
|
|
33
|
+
A high-performance, Rust-backed implementation of the [parse](https://github.com/r1chardj0n3s/parse) library for Python. `formatparse` provides the same API as the original `parse` library but with **significant performance improvements** (up to **80x faster**) thanks to Rust's zero-cost abstractions and optimized regex engine.
|
|
34
|
+
|
|
35
|
+
## 📖 Documentation
|
|
36
|
+
|
|
37
|
+
**Full documentation is available at [https://formatparse.readthedocs.io/](https://formatparse.readthedocs.io/)**
|
|
38
|
+
|
|
39
|
+
The documentation includes:
|
|
40
|
+
- **Getting Started Guide** - Quick introduction and basic usage
|
|
41
|
+
- **User Guides** - Comprehensive guides on patterns, datetime parsing, custom types, and bidirectional patterns
|
|
42
|
+
- **API Reference** - Complete API documentation for all functions and classes
|
|
43
|
+
- **Examples & Cookbook** - Practical examples and common use cases
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- 🚀 **Blazing Fast**: Up to 80x faster than the original Python implementation
|
|
48
|
+
- 🔄 **Drop-in Replacement**: Compatible API with the original `parse` library
|
|
49
|
+
- 🎯 **Type-Safe**: Rust backend ensures reliability and correctness
|
|
50
|
+
- 🔍 **Advanced Pattern Matching**: Support for named fields, positional fields, and custom types
|
|
51
|
+
- 📅 **DateTime Parsing**: Built-in support for various datetime formats (ISO 8601, RFC 2822, HTTP dates, etc.)
|
|
52
|
+
- 🎨 **Flexible**: Case-sensitive and case-insensitive matching options
|
|
53
|
+
- 💾 **Optimized**: Pattern caching, lazy evaluation, and batch operations for maximum performance
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
### From PyPI
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install formatparse
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### From Source
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Clone the repository
|
|
67
|
+
git clone https://github.com/eddiethedean/formatparse.git
|
|
68
|
+
cd formatparse
|
|
69
|
+
|
|
70
|
+
# Install maturin (build tool)
|
|
71
|
+
pip install maturin
|
|
72
|
+
|
|
73
|
+
# Build and install in development mode
|
|
74
|
+
maturin develop --manifest-path formatparse-pyo3/Cargo.toml --release
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Quick Start
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from formatparse import parse, search, findall
|
|
81
|
+
|
|
82
|
+
# Basic parsing with named fields
|
|
83
|
+
result = parse("{name}: {age:d}", "Alice: 30")
|
|
84
|
+
print(result.named['name']) # 'Alice'
|
|
85
|
+
print(result.named['age']) # 30
|
|
86
|
+
|
|
87
|
+
# Search for patterns in text
|
|
88
|
+
result = search("age: {age:d}", "Name: Alice, age: 30, City: NYC")
|
|
89
|
+
if result:
|
|
90
|
+
print(result.named['age']) # 30
|
|
91
|
+
|
|
92
|
+
# Find all matches
|
|
93
|
+
results = findall("ID:{id:d}", "ID:1 ID:2 ID:3")
|
|
94
|
+
for result in results:
|
|
95
|
+
print(result.named['id'])
|
|
96
|
+
# Output: 1, 2, 3
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
For more examples and detailed usage, see the [documentation](https://formatparse.readthedocs.io/).
|
|
100
|
+
|
|
101
|
+
## Performance
|
|
102
|
+
|
|
103
|
+
formatparse is significantly faster than the original Python `parse` library, with speedups ranging from **3x to 80x** depending on the use case. The Rust backend provides:
|
|
104
|
+
|
|
105
|
+
- Pattern caching to eliminate regex compilation overhead
|
|
106
|
+
- Optimized type conversion paths for common types
|
|
107
|
+
- Efficient memory management with pre-allocated data structures
|
|
108
|
+
- Reduced Python GIL overhead through batched operations
|
|
109
|
+
|
|
110
|
+
For detailed benchmark results and performance analysis, see the [documentation](https://formatparse.readthedocs.io/).
|
|
111
|
+
|
|
112
|
+
## Contributing
|
|
113
|
+
|
|
114
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
115
|
+
|
|
116
|
+
1. Fork the repository
|
|
117
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
118
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
119
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
120
|
+
5. Open a Pull Request
|
|
121
|
+
|
|
122
|
+
For detailed contribution guidelines, including testing requirements and development setup, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
123
|
+
|
|
124
|
+
## Testing
|
|
125
|
+
|
|
126
|
+
The project includes comprehensive test coverage:
|
|
127
|
+
|
|
128
|
+
- **Unit Tests**: ~436 Python tests + 50 Rust tests
|
|
129
|
+
- **Property-Based Tests**: 32 Hypothesis-based tests
|
|
130
|
+
- **Performance Benchmarks**: Automated regression testing
|
|
131
|
+
- **Stress Tests**: Large input and scalability testing
|
|
132
|
+
- **Fuzz Tests**: Crash-free input testing
|
|
133
|
+
- **Coverage**: >90% code coverage target
|
|
134
|
+
|
|
135
|
+
Run tests with:
|
|
136
|
+
```bash
|
|
137
|
+
# All tests
|
|
138
|
+
pytest tests/
|
|
139
|
+
|
|
140
|
+
# With coverage
|
|
141
|
+
pytest tests/ --cov=formatparse --cov-report=html
|
|
142
|
+
|
|
143
|
+
# Benchmarks
|
|
144
|
+
pytest tests/test_performance.py --benchmark-only
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for more testing information.
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
MIT License - see [LICENSE](LICENSE) file for details
|
|
152
|
+
|
|
153
|
+
## Credits
|
|
154
|
+
|
|
155
|
+
Based on the [parse](https://github.com/r1chardj0n3s/parse) library by Richard Jones.
|
|
156
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
_formatparse/__init__.py,sha256=zd2laF10JI9oyBQyTHX10eP4AFaRbhKYr2o_d2yRlAA,131
|
|
2
|
+
_formatparse/_formatparse.cpython-310-x86_64-linux-gnu.so,sha256=pr3iQoJgSfV9-vDu6IN1E0bFHahZrZViCA2KJXmH874,2853360
|
|
3
|
+
formatparse-0.5.1.dist-info/METADATA,sha256=UlSW1qo2Wg0A0EmC1MVl9OxZd7Bi5wcWrwe4b19C5hI,5820
|
|
4
|
+
formatparse-0.5.1.dist-info/WHEEL,sha256=ic5tDgU_G5rT7StWm6RiS5Up5wV4RhurQV82NllAXnE,109
|
|
5
|
+
formatparse-0.5.1.dist-info/licenses/LICENSE,sha256=7d2e2UstJQ5UphPnHa3djO30rYc3Q92LascNZuSM4J0,1071
|
|
6
|
+
formatparse-0.5.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Odos Matthews
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|