Str-Case-Util


NameStr-Case-Util JSON
Version 0.1.0b0 PyPI version JSON
download
home_pageNone
SummaryDetect and convert string cases
upload_time2024-10-23 02:24:19
maintainerNone
docs_urlNone
authorNone
requires_python>=2.7
licenseMIT
keywords format detect determine capital capitalize capitalization upper lower title snake pascal camel kebab caterpillar cobol str string util utility case casing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Str Case Util
A lightweight utility library for working with various string casing.

## Supported Cases
| Example     | Case Names                                               | 
|-------------|----------------------------------------------------------|
| HelloWorld  | Pascal Case<br/>Capital Camel Case                       |
| helloWorld  | Camel Case                                               |
| helloworld  | Flat Case<br/>Mumble Case                                |
| HELLOWORLD  | Upper Flat Case                                          |
| Hello World | Title Case                                               |
| Hello world | Sentence Case                                            |
| hello world | Lower Case                                               |
| HELLO WORLD | Upper Case                                               |
| hello_world | Snake Case<br/>C Case                                    |
| HELLO_WORLD | Screaming Snake Case<br/>Constant Case<br/>Macro Case    |
| Hello-World | Train Case                                               |
| hello-world | Kebab Case<br/>Catepillar Case<br/>CSS Case<br>Lisp Case |
| HELLO-WORLD | COBOL Case                                               |

## Features
Each of the above may be accessed within the `Case` Enum
```python
from case_util import Case
```

The `Case` Enum contains functions to format a `str`
```python
Case.SNAKE_CASE.format("Hello World")  # output = hello_world
```
and also to determine if a `str` is said format
```python
Case.CAMEL_CASE.is_formatted("MyClassName")  # output = False
Case.PASCAL_CASE.is_formatted("MyClassName")  # output = True
```
In addition, a class method is available to detect the format of a `str`
```python
Case.detect_format("my-test-string")  # output = Case.KEBAB_CASE
```

## Additional Functionality
While not intended to be used externally, the following functions are available if they are of use.
### Split String Into Words
```python
import case_util

words = case_util.words_of("MyFormattedClassName")
# output = ["My", "Formatted", "Class", "Name"]
```
### Word List Manipulation
If you already have a list of words, you may preform the following actions on each
1. `case_util.capitalize(words)`
2. `case_util.camel(words)` - Capitalizes all but the 1st word
3. `case_util.sentence(words)` - Capitalizes only the 1st word
4. `case_util.lower(words)`
5. `case_util.upper(words)`

## Caveats
Due to the nature of the various string formats, the correct case cannot always be detected.

### Flat Case Trumps All
A single word such as `name` will be detected as Flat Case. Similarly, `NAME` will be Upper Flat Case.
While this functionality may seem obvious, it gets more nuanced.
Perhaps the author wrote it in Camel Case or Snake Case which becomes clear when expanded: `nameClass` or `var_name`.
Without input from the original author, it is impossible to know for certain.

### Acronyms
Acronyms/abbreviations are treated as a single word. So `MyAPIClass` converted to snake case would be `my_api_class`.
Related, acronym case is not preserved which means `MyAPIClass` converted to camel case would result in `myApiClass`.
This unfortunately means that the format of such strings will not be properly detected.

### Multiple Cases Detected
Some strings, such as `the quick_brown-fox` could be one of many formats depending on the intended delimiter.
In these scenarios, `None` is returned

### Special Characters
This library was created with class/variable names in mind. Therefore, extensive test has not been conducted using special characters.
When it comes to Camel Case and Pascal Case, numbers are designed to be seen as uppercase.
This may result in unwanted behavior if placing numbers within the middle of words.
All other special characters are intended to be treated as lowercase.

### Additional Language Support
No design/testing has been conducted for characters outside of ASCII.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "Str-Case-Util",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": null,
    "keywords": "format, detect, determine, capital, capitalize, capitalization, upper, lower, title, snake, pascal, camel, kebab, caterpillar, cobol, str, string, util, utility, case, casing",
    "author": null,
    "author_email": "Cody M Sommer <bassmastacod@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/4a/eb/15d0a09a7b5cb3c04188b688e419b304db4b7a4f7be86646f70bf4f596a1/str_case_util-0.1.0b0.tar.gz",
    "platform": null,
    "description": "# Str Case Util\nA lightweight utility library for working with various string casing.\n\n## Supported Cases\n| Example     | Case Names                                               | \n|-------------|----------------------------------------------------------|\n| HelloWorld  | Pascal Case<br/>Capital Camel Case                       |\n| helloWorld  | Camel Case                                               |\n| helloworld  | Flat Case<br/>Mumble Case                                |\n| HELLOWORLD  | Upper Flat Case                                          |\n| Hello World | Title Case                                               |\n| Hello world | Sentence Case                                            |\n| hello world | Lower Case                                               |\n| HELLO WORLD | Upper Case                                               |\n| hello_world | Snake Case<br/>C Case                                    |\n| HELLO_WORLD | Screaming Snake Case<br/>Constant Case<br/>Macro Case    |\n| Hello-World | Train Case                                               |\n| hello-world | Kebab Case<br/>Catepillar Case<br/>CSS Case<br>Lisp Case |\n| HELLO-WORLD | COBOL Case                                               |\n\n## Features\nEach of the above may be accessed within the `Case` Enum\n```python\nfrom case_util import Case\n```\n\nThe `Case` Enum contains functions to format a `str`\n```python\nCase.SNAKE_CASE.format(\"Hello World\")  # output = hello_world\n```\nand also to determine if a `str` is said format\n```python\nCase.CAMEL_CASE.is_formatted(\"MyClassName\")  # output = False\nCase.PASCAL_CASE.is_formatted(\"MyClassName\")  # output = True\n```\nIn addition, a class method is available to detect the format of a `str`\n```python\nCase.detect_format(\"my-test-string\")  # output = Case.KEBAB_CASE\n```\n\n## Additional Functionality\nWhile not intended to be used externally, the following functions are available if they are of use.\n### Split String Into Words\n```python\nimport case_util\n\nwords = case_util.words_of(\"MyFormattedClassName\")\n# output = [\"My\", \"Formatted\", \"Class\", \"Name\"]\n```\n### Word List Manipulation\nIf you already have a list of words, you may preform the following actions on each\n1. `case_util.capitalize(words)`\n2. `case_util.camel(words)` - Capitalizes all but the 1st word\n3. `case_util.sentence(words)` - Capitalizes only the 1st word\n4. `case_util.lower(words)`\n5. `case_util.upper(words)`\n\n## Caveats\nDue to the nature of the various string formats, the correct case cannot always be detected.\n\n### Flat Case Trumps All\nA single word such as `name` will be detected as Flat Case. Similarly, `NAME` will be Upper Flat Case.\nWhile this functionality may seem obvious, it gets more nuanced.\nPerhaps the author wrote it in Camel Case or Snake Case which becomes clear when expanded: `nameClass` or `var_name`.\nWithout input from the original author, it is impossible to know for certain.\n\n### Acronyms\nAcronyms/abbreviations are treated as a single word. So `MyAPIClass` converted to snake case would be `my_api_class`.\nRelated, acronym case is not preserved which means `MyAPIClass` converted to camel case would result in `myApiClass`.\nThis unfortunately means that the format of such strings will not be properly detected.\n\n### Multiple Cases Detected\nSome strings, such as `the quick_brown-fox` could be one of many formats depending on the intended delimiter.\nIn these scenarios, `None` is returned\n\n### Special Characters\nThis library was created with class/variable names in mind. Therefore, extensive test has not been conducted using special characters.\nWhen it comes to Camel Case and Pascal Case, numbers are designed to be seen as uppercase.\nThis may result in unwanted behavior if placing numbers within the middle of words.\nAll other special characters are intended to be treated as lowercase.\n\n### Additional Language Support\nNo design/testing has been conducted for characters outside of ASCII.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Detect and convert string cases",
    "version": "0.1.0b0",
    "project_urls": {
        "Issues": "https://github.com/BassMastaCod/Str-Case-Util/issues",
        "Repository": "https://github.com/BassMastaCod/Str-Case-Util.git"
    },
    "split_keywords": [
        "format",
        " detect",
        " determine",
        " capital",
        " capitalize",
        " capitalization",
        " upper",
        " lower",
        " title",
        " snake",
        " pascal",
        " camel",
        " kebab",
        " caterpillar",
        " cobol",
        " str",
        " string",
        " util",
        " utility",
        " case",
        " casing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f2f8e2aeae9d4730734eacee19321634e1d49995a577564ad859f0ccf163b6bd",
                "md5": "98e7c2747aff980eadbcd0f3da976fcc",
                "sha256": "1424f277c9e8602fe93d3e62e0f02230122d984e289a4bb410c157a046b44473"
            },
            "downloads": -1,
            "filename": "str_case_util-0.1.0b0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "98e7c2747aff980eadbcd0f3da976fcc",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=2.7",
            "size": 4661,
            "upload_time": "2024-10-23T02:24:17",
            "upload_time_iso_8601": "2024-10-23T02:24:17.799948Z",
            "url": "https://files.pythonhosted.org/packages/f2/f8/e2aeae9d4730734eacee19321634e1d49995a577564ad859f0ccf163b6bd/str_case_util-0.1.0b0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4aeb15d0a09a7b5cb3c04188b688e419b304db4b7a4f7be86646f70bf4f596a1",
                "md5": "b5fd33e761e532c9a9cf97a96e84748f",
                "sha256": "9dac8f7c575df66682495103d591062839b4ed86da7deeb66b155ef1be904254"
            },
            "downloads": -1,
            "filename": "str_case_util-0.1.0b0.tar.gz",
            "has_sig": false,
            "md5_digest": "b5fd33e761e532c9a9cf97a96e84748f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 5163,
            "upload_time": "2024-10-23T02:24:19",
            "upload_time_iso_8601": "2024-10-23T02:24:19.312102Z",
            "url": "https://files.pythonhosted.org/packages/4a/eb/15d0a09a7b5cb3c04188b688e419b304db4b7a4f7be86646f70bf4f596a1/str_case_util-0.1.0b0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-23 02:24:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "BassMastaCod",
    "github_project": "Str-Case-Util",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "str-case-util"
}
        
Elapsed time: 1.73681s