random-slugs


Namerandom-slugs JSON
Version 1.0.4 PyPI version JSON
download
home_pageNone
SummaryA Python package for generating random slugs using a customizable vocabulary of words.
upload_time2024-05-26 15:45:42
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseThe MIT License (MIT) Copyright (c) 2024 Fabio Kapsahili Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords development sample setuptools
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Random Slugs

`random-slugs` is a user-friendly Python package that generates those random word slugs. This package is customizable and allows users to specify the parts of speech, categories of words, and the reproducibility.

## Features
- Generate slugs with a specified number of words
- Customize the parts of speech and categories of words used
- Choose the format of the slug (`kebab-case`, `snake_case` or `camelCase`)
- Set a random seed for reproducibility
- Handle errors gracefully with custom exceptions

## Installation
You can install `random-slugs` using pip:

```bash
pip install random-slugs
```

## Usage
Here is a basic example of how to use the package:
```python
from random_slugs import generate_slug

slug = generate_slug()
print(slug) # E.g. 'quick-brown-fox'
```

### Customize the Slug
You can customize the slug generation by passing an `options` dictionary to the `generate_slug` function:
```python
options = {
    "parts_of_speech": ["adjectives", "nouns"],
    "categories": {"adjectives": ["color"], "nouns": ["animal"]},
    "format": "snake",
    "seed": 42
}

slug = generate_slug(num_of_words=2, options=options)
print(slug)  # E.g. : 'brown_fox'
```

## API
`generate_slug`
```python
generate_slug(num_of_words: int = 3, options: Options = None) -> str
```
Generates a random slug.

**Parameters**:
- `num_of_words` (int): The number of words to include in the slug. Defaults to 3.
- `options` (Options): A dictionary of options to customize the slug generation.

**Options**:
- `parts_of_speech` (List[str]): List of parts of speech to use. Must be one of: `adjectives`, `nouns`.
- `categories` (Dict): A dictionary mapping parts of speech to categories of words. E.g. `{"adjectives": ["color"], "nouns": ["animal"]}`.
    - **Adjective Categories:**
        - `color`
        - `condition`
        - `emotion`
        - `size`
        - `quantity`
    - **Noun Categories:**
        - `animal`
        - `color`
        - `pokemon`
        - `profession`
        - `technology`
        - `thing`
        - `transport`

- `format` (str): The format of the slug. Must be one of: `kebab`, `snake`, `camel`. Defaults to `kebab`.
- `seed` (int): The random seed value to use for reproducibility.

**Returns**:
- `str`: The generated slug.

### Total Unique Slugs
The total number of unique slugs that can be generated is calculated as follows:
```python
from random_slugs import get_total_unique_slugs

total = get_total_unique_slugs()
print(total)  # 6254859
```

### Exceptions
- `RandomSlugsError`: Base class for all exceptions in the package.
- `RandomSlugConfigError`: Exception for configuration errors.

## Example
Here is a complete example that includes custom options and error handling:
```python
from random_slugs import generate_slug, RandomSlugConfigError

options = {
    "parts_of_speech": ["adjectives", "nouns"],
    "categories": {"adjectives": ["size"], "nouns": ["animal"]},
    "format": "camel",
    "seed": "example_seed"
}

try:
    slug = generate_slug(num_of_words=2, options=options)
    print(slug)  # E.g. "bigCat"
except RandomSlugConfigError as e:
    print(f"Configuration error: {e}")
except RandomSlugsError as e:
    print(f"Slug generation error: {e}")
```

# Testing
You can run the test suite using the following command:
```bash
pytest tests
```

# Contributing
Contributions are welcome! Please open an issue or submit a pull request.

# License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "random-slugs",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Fabio Kapsahili <fabio.kapsahili@protonmail.com>",
    "keywords": "development, sample, setuptools",
    "author": null,
    "author_email": "Fabio Kapsahili <fabio.kapsahili@protonmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/e6/ff/0a5ad66016febee440f73ed4786e750040e8119a67da05c5f3036b416b49/random_slugs-1.0.4.tar.gz",
    "platform": null,
    "description": "# Random Slugs\n\n`random-slugs` is a user-friendly Python package that generates those random word slugs. This package is customizable and allows users to specify the parts of speech, categories of words, and the reproducibility.\n\n## Features\n- Generate slugs with a specified number of words\n- Customize the parts of speech and categories of words used\n- Choose the format of the slug (`kebab-case`, `snake_case` or `camelCase`)\n- Set a random seed for reproducibility\n- Handle errors gracefully with custom exceptions\n\n## Installation\nYou can install `random-slugs` using pip:\n\n```bash\npip install random-slugs\n```\n\n## Usage\nHere is a basic example of how to use the package:\n```python\nfrom random_slugs import generate_slug\n\nslug = generate_slug()\nprint(slug) # E.g. 'quick-brown-fox'\n```\n\n### Customize the Slug\nYou can customize the slug generation by passing an `options` dictionary to the `generate_slug` function:\n```python\noptions = {\n    \"parts_of_speech\": [\"adjectives\", \"nouns\"],\n    \"categories\": {\"adjectives\": [\"color\"], \"nouns\": [\"animal\"]},\n    \"format\": \"snake\",\n    \"seed\": 42\n}\n\nslug = generate_slug(num_of_words=2, options=options)\nprint(slug)  # E.g. : 'brown_fox'\n```\n\n## API\n`generate_slug`\n```python\ngenerate_slug(num_of_words: int = 3, options: Options = None) -> str\n```\nGenerates a random slug.\n\n**Parameters**:\n- `num_of_words` (int): The number of words to include in the slug. Defaults to 3.\n- `options` (Options): A dictionary of options to customize the slug generation.\n\n**Options**:\n- `parts_of_speech` (List[str]): List of parts of speech to use. Must be one of: `adjectives`, `nouns`.\n- `categories` (Dict): A dictionary mapping parts of speech to categories of words. E.g. `{\"adjectives\": [\"color\"], \"nouns\": [\"animal\"]}`.\n    - **Adjective Categories:**\n        - `color`\n        - `condition`\n        - `emotion`\n        - `size`\n        - `quantity`\n    - **Noun Categories:**\n        - `animal`\n        - `color`\n        - `pokemon`\n        - `profession`\n        - `technology`\n        - `thing`\n        - `transport`\n\n- `format` (str): The format of the slug. Must be one of: `kebab`, `snake`, `camel`. Defaults to `kebab`.\n- `seed` (int): The random seed value to use for reproducibility.\n\n**Returns**:\n- `str`: The generated slug.\n\n### Total Unique Slugs\nThe total number of unique slugs that can be generated is calculated as follows:\n```python\nfrom random_slugs import get_total_unique_slugs\n\ntotal = get_total_unique_slugs()\nprint(total)  # 6254859\n```\n\n### Exceptions\n- `RandomSlugsError`: Base class for all exceptions in the package.\n- `RandomSlugConfigError`: Exception for configuration errors.\n\n## Example\nHere is a complete example that includes custom options and error handling:\n```python\nfrom random_slugs import generate_slug, RandomSlugConfigError\n\noptions = {\n    \"parts_of_speech\": [\"adjectives\", \"nouns\"],\n    \"categories\": {\"adjectives\": [\"size\"], \"nouns\": [\"animal\"]},\n    \"format\": \"camel\",\n    \"seed\": \"example_seed\"\n}\n\ntry:\n    slug = generate_slug(num_of_words=2, options=options)\n    print(slug)  # E.g. \"bigCat\"\nexcept RandomSlugConfigError as e:\n    print(f\"Configuration error: {e}\")\nexcept RandomSlugsError as e:\n    print(f\"Slug generation error: {e}\")\n```\n\n# Testing\nYou can run the test suite using the following command:\n```bash\npytest tests\n```\n\n# Contributing\nContributions are welcome! Please open an issue or submit a pull request.\n\n# License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)\n        \n        Copyright (c) 2024 Fabio Kapsahili\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in\n        all copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n        THE SOFTWARE.",
    "summary": "A Python package for generating random slugs using a customizable vocabulary of words.",
    "version": "1.0.4",
    "project_urls": {
        "Bug Reports": "https://github.com/fkapsahili/random-slugs/issues",
        "Homepage": "https://github.com/fkapsahili/random-slugs",
        "Source": "https://github.com/fkapsahili/random-slugs/"
    },
    "split_keywords": [
        "development",
        " sample",
        " setuptools"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "936828009fdeea1c7f80ad25b36e363bfc73cc7ea3c3afeeb612c0214140210d",
                "md5": "b7b917039280a1ff6ec86551c769c837",
                "sha256": "0573169c01cd9e7dd5b024cb6c7d1c18b0ca13f4d0d48d977e02c8848febf7c8"
            },
            "downloads": -1,
            "filename": "random_slugs-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b7b917039280a1ff6ec86551c769c837",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 8416,
            "upload_time": "2024-05-26T15:45:43",
            "upload_time_iso_8601": "2024-05-26T15:45:43.245022Z",
            "url": "https://files.pythonhosted.org/packages/93/68/28009fdeea1c7f80ad25b36e363bfc73cc7ea3c3afeeb612c0214140210d/random_slugs-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e6ff0a5ad66016febee440f73ed4786e750040e8119a67da05c5f3036b416b49",
                "md5": "22db32f4584fac04fe4e8086a0e3351a",
                "sha256": "71e4e0708fa3e225e56cbe187d6e2fd97e910922368ff01b228c1eca7aea93ae"
            },
            "downloads": -1,
            "filename": "random_slugs-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "22db32f4584fac04fe4e8086a0e3351a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 9273,
            "upload_time": "2024-05-26T15:45:42",
            "upload_time_iso_8601": "2024-05-26T15:45:42.387030Z",
            "url": "https://files.pythonhosted.org/packages/e6/ff/0a5ad66016febee440f73ed4786e750040e8119a67da05c5f3036b416b49/random_slugs-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-26 15:45:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fkapsahili",
    "github_project": "random-slugs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "random-slugs"
}
        
Elapsed time: 0.43356s