a-n-plus-b


Namea-n-plus-b JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryCSS <An+B> microsyntax parser
upload_time2024-09-29 23:09:53
maintainerNone
docs_urlNone
authorNone
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 toolkit for
working with the `<An+B>` CSS 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)
```

```pycon
>>> from a_n_plus_b import n
>>> 2 * n
ANPlusB(2n)
>>> n * -3 - 1
ANPlusB(-3n-1)
>>> 4 - n * 9
ANPlusB(-9n+4)
```


## 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": null,
    "name": "a-n-plus-b",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "CSS, an+b, parser",
    "author": null,
    "author_email": "InSyncWithFoo <insyncwithfoo@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f3/88/f25c24b21f8cfc5caca363e064a04fb3df89294ac5d888fcfd39279acbc9/a_n_plus_b-0.2.0.tar.gz",
    "platform": null,
    "description": "# ANPlusB\n\nThis tiny package provides a toolkit for\nworking with the `<An+B>` CSS 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```pycon\n>>> from a_n_plus_b import n\n>>> 2 * n\nANPlusB(2n)\n>>> n * -3 - 1\nANPlusB(-3n-1)\n>>> 4 - n * 9\nANPlusB(-9n+4)\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.2.0",
    "project_urls": {
        "Homepage": "https://github.com/InSyncWithFoo/a-n-plus-b"
    },
    "split_keywords": [
        "css",
        " an+b",
        " parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ecb897697f09e2ab2fd05fd86d743316a9f8b7e36fd81dd664b92d63feb80336",
                "md5": "4d84ad6567ddfd60fb24a885eb0033b7",
                "sha256": "823df5f43aadc08b1a002424528269271269c90552b68cb2527c789e1c8e0884"
            },
            "downloads": -1,
            "filename": "a_n_plus_b-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4d84ad6567ddfd60fb24a885eb0033b7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 8312,
            "upload_time": "2024-09-29T23:09:51",
            "upload_time_iso_8601": "2024-09-29T23:09:51.514378Z",
            "url": "https://files.pythonhosted.org/packages/ec/b8/97697f09e2ab2fd05fd86d743316a9f8b7e36fd81dd664b92d63feb80336/a_n_plus_b-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f388f25c24b21f8cfc5caca363e064a04fb3df89294ac5d888fcfd39279acbc9",
                "md5": "ae3961f4dbaf58c544f54e455d058e0f",
                "sha256": "379248ee6e91d974495416929abbe389ae2c8ed901b0b6a9088f1b889381f2b4"
            },
            "downloads": -1,
            "filename": "a_n_plus_b-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ae3961f4dbaf58c544f54e455d058e0f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 8846,
            "upload_time": "2024-09-29T23:09:53",
            "upload_time_iso_8601": "2024-09-29T23:09:53.915262Z",
            "url": "https://files.pythonhosted.org/packages/f3/88/f25c24b21f8cfc5caca363e064a04fb3df89294ac5d888fcfd39279acbc9/a_n_plus_b-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-29 23:09:53",
    "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.34263s