a-n-plus-b


Namea-n-plus-b JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryCSS <An+B> microsyntax parser
upload_time2024-02-04 13:25:32
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT
keywords css an+b parser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ANPlusB

This tiny package provides a handy parser
for parsing the CSS `<An+B>` microsyntax.


## Installation

This package is available [on PyPI][1]:

```shell
$ pip install a-n-plus-b
```


## Usage

This package only ever parses [the `<An+B>` microsyntax][2].
It does not support [the `of <selector>` syntax][3].

### Examples

```pycon
>>> from a_n_plus_b import ANPlusB
>>> ANPlusB(2, 1)
ANPlusB(2n+1)
>>> str(_)
'2n+1'
>>> ANPlusB(4)
ANPlusB(4)
>>> ANPlusB(4, 0)
ANPlusB(4n)
>>> {ANPlusB(1, 0), ANPlusB(True, False)}
{ANPlusB(n)}
```

```pycon
>>> from itertools import islice
>>> ANPlusB(3, 2)
ANPlusB(3n+2)
>>> values = _.values()
>>> values
_InfiniteRange(start = 2, step = 3)
>>> list(islice(values, 10))
[2, 5, 8, 11, 14, 17, 20, 23, 26, 29]
>>> 6405429723686292014 in values
True
```

```pycon
>>> instance = ANPlusB(4, -7)
>>> list(instance.indices(40))
[1, 5, 9, 13, 17, 21, 25, 29, 33, 37]
>>> list(instance.indices(40, from_last = True))
[40, 36, 32, 28, 24, 20, 16, 12, 8, 4]
>>> list(instance.indices(40, order = 'descending'))
[37, 33, 29, 25, 21, 17, 13, 9, 5, 1]
>>> list(instance.indices(40, from_last = True, order = 'ascending'))
[4, 8, 12, 16, 20, 24, 28, 32, 36, 40]
```

```pycon
>>> ANPlusB.parse('odd')
ANPlusB(2n+1)
>>> ANPlusB.parse('even')
ANPlusB(2n)
>>> ANPlusB.parse('4')
ANPlusB(4)
>>> ANPlusB.parse('-1n')
ANPlusB(-n)
>>> ANPlusB.parse('+0n-8')
ANPlusB(-8)
>>> ANPlusB.parse('0n+0124')
ANPlusB(124)
```

```pycon
>>> ANPlusB.from_complex(5j - 2)
ANPlusB(5n-2)
```


## Contributing

Please see _[Contributing][4]_ for more information.


  [1]: https://pypi.org/project/a-n-plus-b
  [2]: https://drafts.csswg.org/css-syntax-3/#anb-microsyntax
  [3]: https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child#the_of_selector_syntax
  [4]: ./CONTRIBUTING.md

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "a-n-plus-b",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "CSS,an+b,parser",
    "author": "",
    "author_email": "InSyncWithFoo <insyncwithfoo@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/be/ff/2979f0ad3d70dcbddc932b85c5be2af7a92ed1bd900712b25a0d34da8057/a_n_plus_b-0.1.0.tar.gz",
    "platform": null,
    "description": "# ANPlusB\n\nThis tiny package provides a handy parser\nfor parsing the CSS `<An+B>` microsyntax.\n\n\n## Installation\n\nThis package is available [on PyPI][1]:\n\n```shell\n$ pip install a-n-plus-b\n```\n\n\n## Usage\n\nThis package only ever parses [the `<An+B>` microsyntax][2].\nIt does not support [the `of <selector>` syntax][3].\n\n### Examples\n\n```pycon\n>>> from a_n_plus_b import ANPlusB\n>>> ANPlusB(2, 1)\nANPlusB(2n+1)\n>>> str(_)\n'2n+1'\n>>> ANPlusB(4)\nANPlusB(4)\n>>> ANPlusB(4, 0)\nANPlusB(4n)\n>>> {ANPlusB(1, 0), ANPlusB(True, False)}\n{ANPlusB(n)}\n```\n\n```pycon\n>>> from itertools import islice\n>>> ANPlusB(3, 2)\nANPlusB(3n+2)\n>>> values = _.values()\n>>> values\n_InfiniteRange(start = 2, step = 3)\n>>> list(islice(values, 10))\n[2, 5, 8, 11, 14, 17, 20, 23, 26, 29]\n>>> 6405429723686292014 in values\nTrue\n```\n\n```pycon\n>>> instance = ANPlusB(4, -7)\n>>> list(instance.indices(40))\n[1, 5, 9, 13, 17, 21, 25, 29, 33, 37]\n>>> list(instance.indices(40, from_last = True))\n[40, 36, 32, 28, 24, 20, 16, 12, 8, 4]\n>>> list(instance.indices(40, order = 'descending'))\n[37, 33, 29, 25, 21, 17, 13, 9, 5, 1]\n>>> list(instance.indices(40, from_last = True, order = 'ascending'))\n[4, 8, 12, 16, 20, 24, 28, 32, 36, 40]\n```\n\n```pycon\n>>> ANPlusB.parse('odd')\nANPlusB(2n+1)\n>>> ANPlusB.parse('even')\nANPlusB(2n)\n>>> ANPlusB.parse('4')\nANPlusB(4)\n>>> ANPlusB.parse('-1n')\nANPlusB(-n)\n>>> ANPlusB.parse('+0n-8')\nANPlusB(-8)\n>>> ANPlusB.parse('0n+0124')\nANPlusB(124)\n```\n\n```pycon\n>>> ANPlusB.from_complex(5j - 2)\nANPlusB(5n-2)\n```\n\n\n## Contributing\n\nPlease see _[Contributing][4]_ for more information.\n\n\n  [1]: https://pypi.org/project/a-n-plus-b\n  [2]: https://drafts.csswg.org/css-syntax-3/#anb-microsyntax\n  [3]: https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child#the_of_selector_syntax\n  [4]: ./CONTRIBUTING.md\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "CSS <An+B> microsyntax parser",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/InSyncWithFoo/a-n-plus-b"
    },
    "split_keywords": [
        "css",
        "an+b",
        "parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ad16e0dcad7e39f8ef25e535ca2071a755d6801e8920d1f68957b53f2a53a3c3",
                "md5": "11467195ea7ae323b2f0e23d49f1e4e8",
                "sha256": "22b4d8d464e28c53399599064fc4e061e0eacfc7cc8a10218fb2cd91bb435d67"
            },
            "downloads": -1,
            "filename": "a_n_plus_b-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "11467195ea7ae323b2f0e23d49f1e4e8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 7114,
            "upload_time": "2024-02-04T13:25:30",
            "upload_time_iso_8601": "2024-02-04T13:25:30.969353Z",
            "url": "https://files.pythonhosted.org/packages/ad/16/e0dcad7e39f8ef25e535ca2071a755d6801e8920d1f68957b53f2a53a3c3/a_n_plus_b-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "beff2979f0ad3d70dcbddc932b85c5be2af7a92ed1bd900712b25a0d34da8057",
                "md5": "9740a53ad69f59eca2a0756a5ac875a1",
                "sha256": "c70a51cffd049ac5c9e55b2d6d4ecc73d09cd103f22bbe9723dbe128912bfa20"
            },
            "downloads": -1,
            "filename": "a_n_plus_b-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9740a53ad69f59eca2a0756a5ac875a1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 8088,
            "upload_time": "2024-02-04T13:25:32",
            "upload_time_iso_8601": "2024-02-04T13:25:32.574866Z",
            "url": "https://files.pythonhosted.org/packages/be/ff/2979f0ad3d70dcbddc932b85c5be2af7a92ed1bd900712b25a0d34da8057/a_n_plus_b-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-04 13:25:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "InSyncWithFoo",
    "github_project": "a-n-plus-b",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "a-n-plus-b"
}
        
Elapsed time: 0.17538s