darlog-py23


Namedarlog-py23 JSON
Version 1.2.1 PyPI version JSON
download
home_pagehttps://github.com/Lex-DRL/darlog-py23
SummaryA tiny compatibility module for cross-Python2/3 code.
upload_time2022-11-30 07:58:40
maintainerLex Darlog (Lex-DRL)
docs_urlNone
authorLex Darlog (Lex-DRL)
requires_python!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,<4,>=2.7
licenseLGPL-3.0-only
keywords 2to3 3to2 six compatibility wrapper
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # [darlog-py23](https://github.com/Lex-DRL/darlog-py23)

A tiny compatibility module for cross-Python2/3 code.
It's not a replacement for neither ``six`` nor ``__future__`` modules but is more of an extension to them.

Defines the very basic stuff:

## Python version booleans
`PY2`, `PY3`, `PY310` - simple flags indicating whether you're running under Python 2, 3 or 3.10+.

## Strings
### `str_types`
A tuple containing all the string types - ready to be passed to `isinstance()`:

* Python 2 - `(str, unicode)`
* Python 3 - `(str, )`

### `unicode`
Type alias:

* Python 2 - `unicode`
* Python 3 - `str`

### `to_least_str()`
Converts the given value to a string:

* Python 2: tries to turn to a `str`, `unicode` if fails.
* Python 3: just an alias for `str()`.

### `str_format()`
Formats a string and doesn't throw an error if any of the given arguments is unicode under Python 2. The resulting string is simply turned to unicode, too.

## DataClasses
### `@attrs` decorator
Tries to use `attr.s` and if it's not found, falls back to built-in decorator from Py3.10 and, finally to 3.7 implementation if available.

If none of those is found, applies the included dataclass implementation, the simplest possible one (`@dataclass_fallback`, see below) - as the last resort, just to avoid exceptions.

### `@dataclass` decorator
Similar to `@attrs`, but tries built-in `@dataclass` first.

I'd recommend using `@attrs` anyway, but here it is.

Tries to use the built-in decorator from Py3.10, falls back to 3.7 implementation, then to `attr.s`. And, finally, to the included `@dataclass_fallback`.

### `@dataclass_fallback` decorator
The minimal implementation of `dataclass` working in any Python version above 2.7. Implements only `init`, `repr` and `eq` features.

It doesn't do any "attribute is `Field` instance" stuff or any other `getattr`/`setattr` magic.

This is what both `@dataclass` and `@attrs` fall back to as the last resort. I don't know why would you need it explicitly, though - but here it is.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Lex-DRL/darlog-py23",
    "name": "darlog-py23",
    "maintainer": "Lex Darlog (Lex-DRL)",
    "docs_url": null,
    "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,<4,>=2.7",
    "maintainer_email": "",
    "keywords": "2to3,3to2,six,compatibility,wrapper",
    "author": "Lex Darlog (Lex-DRL)",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/26/a5/f5bc57070bce70362b38d450a108abc8e1d1b40159bff2ae3eacf5fc3035/darlog-py23-1.2.1.tar.gz",
    "platform": null,
    "description": "# [darlog-py23](https://github.com/Lex-DRL/darlog-py23)\r\n\r\nA tiny compatibility module for cross-Python2/3 code.\r\nIt's not a replacement for neither ``six`` nor ``__future__`` modules but is more of an extension to them.\r\n\r\nDefines the very basic stuff:\r\n\r\n## Python version booleans\r\n`PY2`, `PY3`, `PY310` - simple flags indicating whether you're running under Python 2, 3 or 3.10+.\r\n\r\n## Strings\r\n### `str_types`\r\nA tuple containing all the string types - ready to be passed to `isinstance()`:\r\n\r\n* Python 2 - `(str, unicode)`\r\n* Python 3 - `(str, )`\r\n\r\n### `unicode`\r\nType alias:\r\n\r\n* Python 2 - `unicode`\r\n* Python 3 - `str`\r\n\r\n### `to_least_str()`\r\nConverts the given value to a string:\r\n\r\n* Python 2: tries to turn to a `str`, `unicode` if fails.\r\n* Python 3: just an alias for `str()`.\r\n\r\n### `str_format()`\r\nFormats a string and doesn't throw an error if any of the given arguments is unicode under Python 2. The resulting string is simply turned to unicode, too.\r\n\r\n## DataClasses\r\n### `@attrs` decorator\r\nTries to use `attr.s` and if it's not found, falls back to built-in decorator from Py3.10 and, finally to 3.7 implementation if available.\r\n\r\nIf none of those is found, applies the included dataclass implementation, the simplest possible one (`@dataclass_fallback`, see below) - as the last resort, just to avoid exceptions.\r\n\r\n### `@dataclass` decorator\r\nSimilar to `@attrs`, but tries built-in `@dataclass` first.\r\n\r\nI'd recommend using `@attrs` anyway, but here it is.\r\n\r\nTries to use the built-in decorator from Py3.10, falls back to 3.7 implementation, then to `attr.s`. And, finally, to the included `@dataclass_fallback`.\r\n\r\n### `@dataclass_fallback` decorator\r\nThe minimal implementation of `dataclass` working in any Python version above 2.7. Implements only `init`, `repr` and `eq` features.\r\n\r\nIt doesn't do any \"attribute is `Field` instance\" stuff or any other `getattr`/`setattr` magic.\r\n\r\nThis is what both `@dataclass` and `@attrs` fall back to as the last resort. I don't know why would you need it explicitly, though - but here it is.\r\n",
    "bugtrack_url": null,
    "license": "LGPL-3.0-only",
    "summary": "A tiny compatibility module for cross-Python2/3 code.",
    "version": "1.2.1",
    "split_keywords": [
        "2to3",
        "3to2",
        "six",
        "compatibility",
        "wrapper"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "07ed18c6bd89d843ee54bfc0dffe8063",
                "sha256": "b5d6306040c13c8865e2772909bd3b3d7cec28fb7788d525d1e9e59c6d277a22"
            },
            "downloads": -1,
            "filename": "darlog_py23-1.2.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "07ed18c6bd89d843ee54bfc0dffe8063",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,<4,>=2.7",
            "size": 10887,
            "upload_time": "2022-11-30T07:58:38",
            "upload_time_iso_8601": "2022-11-30T07:58:38.921411Z",
            "url": "https://files.pythonhosted.org/packages/87/e7/805bf9c6b23084b1ce5a1ce2d764a2b75f1b68674b4224dc337a3515d24c/darlog_py23-1.2.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "348115f5c4dc6d9b9a8d985a7a091481",
                "sha256": "da00c3080c886d37b4fb9b3fdea0a6b87fe3a50f4157b9321e08a8209359d87b"
            },
            "downloads": -1,
            "filename": "darlog-py23-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "348115f5c4dc6d9b9a8d985a7a091481",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,<4,>=2.7",
            "size": 9019,
            "upload_time": "2022-11-30T07:58:40",
            "upload_time_iso_8601": "2022-11-30T07:58:40.364459Z",
            "url": "https://files.pythonhosted.org/packages/26/a5/f5bc57070bce70362b38d450a108abc8e1d1b40159bff2ae3eacf5fc3035/darlog-py23-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-11-30 07:58:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Lex-DRL",
    "github_project": "darlog-py23",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "darlog-py23"
}
        
Elapsed time: 0.03273s