Git Product home page Git Product logo

vbml's Introduction

VBML - perfect pythonistic parser / string manipulator ✨

PyPI - License PyPI - Downloads GitHub repo size GitHub issues by-label

Features

  • Clean regex-based parser
  • Easy-to-understand validators / Custom validators
  • Lots of features out-of-box

I am <name>, i am <age:int> years old + I am Steven, i am 20 years old = {"name": "Steven", "age": 20}

Installation

Install with pip:

pip install vbml

Or with poetry:

poetry add vbml

Run tests

Clone repo from git:

git clone https://github.com/tesseradecade/vbml.git

Go to repository and run tests with poetry:

cd vbml
poetry install
poetry run pytest

📖 Documentation

Full documentation contents are available in docs/index.md

Simple example

from vbml import Patcher, Pattern

patcher = Patcher()
pattern = Pattern("I have <amount:int> apples. They are <adj>")

result1 = patcher.check(pattern, "I have 3 apples. They are green")
result2 = patcher.check(pattern, "I have three apples. They are green")
result3 = patcher.check(pattern, "Something irrelevant")

result1 # {"amount": 3, "adj": "green"}
result2 # None
result3 # None

Leave a star if this project helped you
Made by timoniq

vbml's People

Contributors

timoniq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vbml's Issues

Не работают regexp группы в паттернах

Без групп все работает как и ожидалось

patcher.check(Pattern(r"<(word1)$>"), "word1")
# {}

С добавлением групп в паттерн, не матчит совсем

patcher.check(Pattern(r"<((word1))$>"), "word1")
# False

Пробовал эскейпить, все равно не матчит

patcher.check(Pattern(r"<(((word1)))$>"), "word1")
# False

patcher.check(Pattern(r"<(\(word1\))$>"), "word1")
# False

patcher.check(Pattern(r"<(\\(word1\\))$>"), "word1")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.