Name | ldif JSON |
Version |
4.2.4
JSON |
| download |
home_page | https://github.com/abilian/ldif |
Summary | generate and parse LDIF data (see RFC 2849). |
upload_time | 2024-01-05 16:12:26 |
maintainer | |
docs_url | None |
author | Abilian SAS |
requires_python | >=3.9,<4.0 |
license | BSD |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ldif - parse and generate LDIF data (see [RFC 2849](https://tools.ietf.org/html/rfc2849)).
![Commit activity](https://img.shields.io/github/commit-activity/m/abilian/ldif)
![Code size in bytes](https://img.shields.io/github/languages/code-size/abilian/ldif)
![License](https://img.shields.io/github/license/abilian/ldif)
![Latest version](https://img.shields.io/pypi/v/ldif)
![PyPI Downloads](https://img.shields.io/pypi/dm/ldif)
This is a fork of the `ldif` module from
[python-ldap](http://www.python-ldap.org/) with python3/unicode support.
One of its benefits is that it's a pure-python package (you don't
depend on the `libldap2-dev` (or similar) package that needs to be
installed on your laptop / test machine / production server).
See the last entry in [changelog](https://github.com/abilian/ldif/blob/main/CHANGES.rst) for a more complete list of
differences.
This package only support Python 3 (\>= 3.7, actually).
## Usage
Parse LDIF from a file (or `BytesIO`):
```python
from ldif import LDIFParser
from pprint import pprint
parser = LDIFParser(open("data.ldif", "rb"))
for dn, record in parser.parse():
print('got entry record: %s' % dn)
pprint(record)
```
Write LDIF to a file (or `BytesIO`):
```python
from ldif import LDIFWriter
writer = LDIFWriter(open("data.ldif", "wb"))
writer.unparse("mail=alice@example.com", {
"cn": ["Alice Alison"],
"mail": ["alice@example.com"],
"objectclass": ["top", "person"],
})
```
## Unicode support
The stream object that is passed to parser or writer must be an ascii
byte stream.
The spec allows to include arbitrary data in base64 encoding or via URL.
There is no way of knowing the encoding of this data. To handle this,
there are two modes:
By default, the `LDIFParser` will try to interpret all values as UTF-8
and leave only the ones that fail to decode as bytes. But you can also
pass an `encoding` of `None` to the constructor, in which case the
parser will not try to do any conversion and return bytes directly.
## Changelog
See [here](./CHANGES.rst)
Raw data
{
"_id": null,
"home_page": "https://github.com/abilian/ldif",
"name": "ldif",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Abilian SAS",
"author_email": "dev@abilian.com",
"download_url": "https://files.pythonhosted.org/packages/7e/d0/afd316e4b70607941bfdffc31386c3ec29b7ad5f2b9304acea394dc78514/ldif-4.2.4.tar.gz",
"platform": null,
"description": "# ldif - parse and generate LDIF data (see [RFC 2849](https://tools.ietf.org/html/rfc2849)).\n\n![Commit activity](https://img.shields.io/github/commit-activity/m/abilian/ldif)\n![Code size in bytes](https://img.shields.io/github/languages/code-size/abilian/ldif)\n![License](https://img.shields.io/github/license/abilian/ldif)\n![Latest version](https://img.shields.io/pypi/v/ldif)\n![PyPI Downloads](https://img.shields.io/pypi/dm/ldif)\n\nThis is a fork of the `ldif` module from\n[python-ldap](http://www.python-ldap.org/) with python3/unicode support.\n\nOne of its benefits is that it's a pure-python package (you don't\ndepend on the `libldap2-dev` (or similar) package that needs to be\ninstalled on your laptop / test machine / production server).\n\nSee the last entry in [changelog](https://github.com/abilian/ldif/blob/main/CHANGES.rst) for a more complete list of\ndifferences.\n\nThis package only support Python 3 (\\>= 3.7, actually).\n\n\n## Usage\n\nParse LDIF from a file (or `BytesIO`):\n\n```python\nfrom ldif import LDIFParser\nfrom pprint import pprint\n\nparser = LDIFParser(open(\"data.ldif\", \"rb\"))\nfor dn, record in parser.parse():\n print('got entry record: %s' % dn)\n pprint(record)\n```\n\nWrite LDIF to a file (or `BytesIO`):\n\n```python\nfrom ldif import LDIFWriter\n\nwriter = LDIFWriter(open(\"data.ldif\", \"wb\"))\nwriter.unparse(\"mail=alice@example.com\", {\n \"cn\": [\"Alice Alison\"],\n \"mail\": [\"alice@example.com\"],\n \"objectclass\": [\"top\", \"person\"],\n})\n```\n\n\n## Unicode support\n\nThe stream object that is passed to parser or writer must be an ascii\nbyte stream.\n\nThe spec allows to include arbitrary data in base64 encoding or via URL.\nThere is no way of knowing the encoding of this data. To handle this,\nthere are two modes:\n\nBy default, the `LDIFParser` will try to interpret all values as UTF-8\nand leave only the ones that fail to decode as bytes. But you can also\npass an `encoding` of `None` to the constructor, in which case the\nparser will not try to do any conversion and return bytes directly.\n\n\n## Changelog\n\nSee [here](./CHANGES.rst)\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "generate and parse LDIF data (see RFC 2849).",
"version": "4.2.4",
"project_urls": {
"Documentation": "https://ldif.readthedocs.io/en/latest/",
"Homepage": "https://github.com/abilian/ldif"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4c0b7c62ba5e2eb184e2726debcb5e6022abcc99c7f61e9033d0a998c4f021cf",
"md5": "c7d23a111c9fa70ddd76683e61c79e01",
"sha256": "07197e35ca5f6ce74f30d4d3bfb52d5fa76ee4ca059633f483f8be3fbe205227"
},
"downloads": -1,
"filename": "ldif-4.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c7d23a111c9fa70ddd76683e61c79e01",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 6853,
"upload_time": "2024-01-05T16:12:24",
"upload_time_iso_8601": "2024-01-05T16:12:24.869612Z",
"url": "https://files.pythonhosted.org/packages/4c/0b/7c62ba5e2eb184e2726debcb5e6022abcc99c7f61e9033d0a998c4f021cf/ldif-4.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7ed0afd316e4b70607941bfdffc31386c3ec29b7ad5f2b9304acea394dc78514",
"md5": "3a37fcc0109ad88e4705409fa18b7d30",
"sha256": "e5d51ecf613f2304de0aaf5b0f35913fdfda5baf4997124765b26bf80dda207e"
},
"downloads": -1,
"filename": "ldif-4.2.4.tar.gz",
"has_sig": false,
"md5_digest": "3a37fcc0109ad88e4705409fa18b7d30",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 6759,
"upload_time": "2024-01-05T16:12:26",
"upload_time_iso_8601": "2024-01-05T16:12:26.315110Z",
"url": "https://files.pythonhosted.org/packages/7e/d0/afd316e4b70607941bfdffc31386c3ec29b7ad5f2b9304acea394dc78514/ldif-4.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-05 16:12:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "abilian",
"github_project": "ldif",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"circle": true,
"tox": true,
"lcname": "ldif"
}