| Name | MoreUtilspy JSON |
| Version |
0.13
JSON |
| download |
| home_page | None |
| Summary | a package containing more utilities for python |
| upload_time | 2024-10-04 12:08:39 |
| maintainer | None |
| docs_url | None |
| author | oussama errafif |
| requires_python | None |
| license | None |
| keywords |
python
utils
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# MoreUtilspy
`moreutils` is a Python utility package designed to handle a variety of text, number, and data transformations. It includes features for converting between different formats (e.g., numbers, dates, Roman numerals), working with text (e.g., anagrams, palindromes), and handling JSON/CSV conversions.
## Installation
To install `moreutilspy`, use pip:
```bash
pip install moreutilspy
```
## Usage
After installation, you can import and use the functions directly:
```python
from moreutils import text_to_number, is_palindrome
```
### Module: `converter_utils`
This module provides functions for converting numbers, dates, bytes, and more.
#### Functions
##### `text_to_number(text: str) -> int`
Converts a textual representation of a number into its numerical value.
**Example:**
```python
text_to_number("one hundred twenty-three") # Returns: 123
```
##### `number_to_text(num: int) -> str`
Converts a number to its textual representation.
**Example:**
```python
number_to_text(123) # Returns: "one hundred twenty-three"
```
##### `int_to_roman(num: int) -> str`
Converts an integer to a Roman numeral.
**Example:**
```python
int_to_roman(2024) # Returns: "MMXXIV"
```
##### `roman_to_int(roman: str) -> int`
Converts a Roman numeral to an integer.
**Example:**
```python
roman_to_int("MMXXIV") # Returns: 2024
```
##### `snake_to_camel(snake_str: str) -> str`
Converts a snake_case string to camelCase.
**Example:**
```python
snake_to_camel("hello_world") # Returns: "helloWorld"
```
##### `camel_to_snake(camel_str: str) -> str`
Converts a camelCase string to snake_case.
**Example:**
```python
camel_to_snake("helloWorld") # Returns: "hello_world"
```
##### `seconds_to_text(seconds: int) -> str`
Converts seconds into a human-readable format.
**Example:**
```python
seconds_to_text(3665) # Returns: "1 hours, 1 minutes, 5 seconds"
```
##### `text_to_seconds(time_str: str) -> int`
Converts a text representation of time to seconds.
**Example:**
```python
text_to_seconds("1 hour, 1 minute, 5 seconds") # Returns: 3665
```
##### `date_to_text(date_str: str) -> str`
Converts a date in `YYYY-MM-DD` format to a human-readable text.
**Example:**
```python
date_to_text("2024-01-01") # Returns: "January 1, 2024"
```
##### `text_to_date(text: str) -> str`
Converts a text representation of a date into `YYYY-MM-DD` format.
**Example:**
```python
text_to_date("January 1 2024") # Returns: "2024-01-01"
```
##### `bytes_to_text(num_bytes: int) -> str`
Converts bytes into a human-readable string.
**Example:**
```python
bytes_to_text(10240) # Returns: "10.00 KB"
```
##### `text_to_bytes(size_str: str) -> int`
Converts a string representation of file size into bytes.
**Example:**
```python
text_to_bytes("10 KB") # Returns: 10240
```
---
### Module: `text_utils`
This module contains utilities for working with text strings, including palindromes, anagrams, and generating random passwords.
#### Functions
##### `is_palindrome(s: str) -> bool`
Checks if a string is a palindrome.
**Example:**
```python
is_palindrome("racecar") # Returns: True
```
##### `are_anagrams(str1: str, str2: str) -> bool`
Checks if two strings are anagrams.
**Example:**
```python
are_anagrams("listen", "silent") # Returns: True
```
##### `count_vowels(s: str) -> int`
Counts the number of vowels in a string.
**Example:**
```python
count_vowels("hello world") # Returns: 3
```
##### `count_consonants(s: str) -> int`
Counts the number of consonants in a string.
**Example:**
```python
count_consonants("hello world") # Returns: 7
```
##### `reverse_words(s: str) -> str`
Reverses the words in a string.
**Example:**
```python
reverse_words("hello world") # Returns: "olleh dlrow"
```
##### `reverse_string(s: str) -> str`
Reverses a string.
**Example:**
```python
reverse_string("hello") # Returns: "olleh"
```
##### `remove_duplicates(s: str) -> str`
Removes duplicate characters from a string.
**Example:**
```python
remove_duplicates("mississippi") # Returns: "misp"
```
##### `is_pangram(s: str) -> bool`
Checks if a string contains all letters of the alphabet.
**Example:**
```python
is_pangram("The quick brown fox jumps over the lazy dog") # Returns: True
```
##### `levenshtein_distance(s1: str, s2: str) -> int`
Calculates the Levenshtein distance (edit distance) between two strings.
**Example:**
```python
levenshtein_distance("kitten", "sitting") # Returns: 3
```
##### `generate_password(length: int = 12) -> str`
Generates a random password of the specified length.
**Example:**
```python
generate_password(16) # Returns: A 16-character random password
```
##### `json_to_csv(json_data: list[dict], csv_file: str)`
Converts JSON data to CSV and writes it to a file.
**Example:**
```python
json_to_csv(json_data, "output.csv")
```
##### `csv_to_json(csv_file: str) -> list[dict]`
Converts a CSV file into JSON format.
**Example:**
```python
data = csv_to_json("input.csv")
```
---
### Examples
Here are a few quick examples to demonstrate how to use `moreutils`:
```python
from moreutils import text_to_number, is_palindrome, generate_password
# Convert text to number
print(text_to_number("one hundred twenty-three")) # Output: 123
# Check if a string is a palindrome
print(is_palindrome("A man a plan a canal Panama")) # Output: True
# Generate a random password
print(generate_password(16)) # Output: A randomly generated password
```
---
## License
`moreutils` is open source and licensed under the [MIT License](https://opensource.org/licenses/MIT).
Raw data
{
"_id": null,
"home_page": null,
"name": "MoreUtilspy",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, utils",
"author": "oussama errafif",
"author_email": "oussamaerra2002@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8d/e8/29fa7b22714b5f70f81c20aad2a79321f7bc1ac60eab5d076a3409762959/moreutilspy-0.13.tar.gz",
"platform": null,
"description": "\r\n# MoreUtilspy\r\n\r\n`moreutils` is a Python utility package designed to handle a variety of text, number, and data transformations. It includes features for converting between different formats (e.g., numbers, dates, Roman numerals), working with text (e.g., anagrams, palindromes), and handling JSON/CSV conversions.\r\n\r\n## Installation\r\n\r\nTo install `moreutilspy`, use pip:\r\n\r\n```bash\r\npip install moreutilspy\r\n```\r\n\r\n## Usage\r\n\r\nAfter installation, you can import and use the functions directly:\r\n\r\n```python\r\nfrom moreutils import text_to_number, is_palindrome\r\n```\r\n\r\n### Module: `converter_utils`\r\n\r\nThis module provides functions for converting numbers, dates, bytes, and more.\r\n\r\n#### Functions\r\n\r\n##### `text_to_number(text: str) -> int`\r\nConverts a textual representation of a number into its numerical value.\r\n\r\n**Example:**\r\n```python\r\ntext_to_number(\"one hundred twenty-three\") # Returns: 123\r\n```\r\n\r\n##### `number_to_text(num: int) -> str`\r\nConverts a number to its textual representation.\r\n\r\n**Example:**\r\n```python\r\nnumber_to_text(123) # Returns: \"one hundred twenty-three\"\r\n```\r\n\r\n##### `int_to_roman(num: int) -> str`\r\nConverts an integer to a Roman numeral.\r\n\r\n**Example:**\r\n```python\r\nint_to_roman(2024) # Returns: \"MMXXIV\"\r\n```\r\n\r\n##### `roman_to_int(roman: str) -> int`\r\nConverts a Roman numeral to an integer.\r\n\r\n**Example:**\r\n```python\r\nroman_to_int(\"MMXXIV\") # Returns: 2024\r\n```\r\n\r\n##### `snake_to_camel(snake_str: str) -> str`\r\nConverts a snake_case string to camelCase.\r\n\r\n**Example:**\r\n```python\r\nsnake_to_camel(\"hello_world\") # Returns: \"helloWorld\"\r\n```\r\n\r\n##### `camel_to_snake(camel_str: str) -> str`\r\nConverts a camelCase string to snake_case.\r\n\r\n**Example:**\r\n```python\r\ncamel_to_snake(\"helloWorld\") # Returns: \"hello_world\"\r\n```\r\n\r\n##### `seconds_to_text(seconds: int) -> str`\r\nConverts seconds into a human-readable format.\r\n\r\n**Example:**\r\n```python\r\nseconds_to_text(3665) # Returns: \"1 hours, 1 minutes, 5 seconds\"\r\n```\r\n\r\n##### `text_to_seconds(time_str: str) -> int`\r\nConverts a text representation of time to seconds.\r\n\r\n**Example:**\r\n```python\r\ntext_to_seconds(\"1 hour, 1 minute, 5 seconds\") # Returns: 3665\r\n```\r\n\r\n##### `date_to_text(date_str: str) -> str`\r\nConverts a date in `YYYY-MM-DD` format to a human-readable text.\r\n\r\n**Example:**\r\n```python\r\ndate_to_text(\"2024-01-01\") # Returns: \"January 1, 2024\"\r\n```\r\n\r\n##### `text_to_date(text: str) -> str`\r\nConverts a text representation of a date into `YYYY-MM-DD` format.\r\n\r\n**Example:**\r\n```python\r\ntext_to_date(\"January 1 2024\") # Returns: \"2024-01-01\"\r\n```\r\n\r\n##### `bytes_to_text(num_bytes: int) -> str`\r\nConverts bytes into a human-readable string.\r\n\r\n**Example:**\r\n```python\r\nbytes_to_text(10240) # Returns: \"10.00 KB\"\r\n```\r\n\r\n##### `text_to_bytes(size_str: str) -> int`\r\nConverts a string representation of file size into bytes.\r\n\r\n**Example:**\r\n```python\r\ntext_to_bytes(\"10 KB\") # Returns: 10240\r\n```\r\n\r\n---\r\n\r\n### Module: `text_utils`\r\n\r\nThis module contains utilities for working with text strings, including palindromes, anagrams, and generating random passwords.\r\n\r\n#### Functions\r\n\r\n##### `is_palindrome(s: str) -> bool`\r\nChecks if a string is a palindrome.\r\n\r\n**Example:**\r\n```python\r\nis_palindrome(\"racecar\") # Returns: True\r\n```\r\n\r\n##### `are_anagrams(str1: str, str2: str) -> bool`\r\nChecks if two strings are anagrams.\r\n\r\n**Example:**\r\n```python\r\nare_anagrams(\"listen\", \"silent\") # Returns: True\r\n```\r\n\r\n##### `count_vowels(s: str) -> int`\r\nCounts the number of vowels in a string.\r\n\r\n**Example:**\r\n```python\r\ncount_vowels(\"hello world\") # Returns: 3\r\n```\r\n\r\n##### `count_consonants(s: str) -> int`\r\nCounts the number of consonants in a string.\r\n\r\n**Example:**\r\n```python\r\ncount_consonants(\"hello world\") # Returns: 7\r\n```\r\n\r\n##### `reverse_words(s: str) -> str`\r\nReverses the words in a string.\r\n\r\n**Example:**\r\n```python\r\nreverse_words(\"hello world\") # Returns: \"olleh dlrow\"\r\n```\r\n\r\n##### `reverse_string(s: str) -> str`\r\nReverses a string.\r\n\r\n**Example:**\r\n```python\r\nreverse_string(\"hello\") # Returns: \"olleh\"\r\n```\r\n\r\n##### `remove_duplicates(s: str) -> str`\r\nRemoves duplicate characters from a string.\r\n\r\n**Example:**\r\n```python\r\nremove_duplicates(\"mississippi\") # Returns: \"misp\"\r\n```\r\n\r\n##### `is_pangram(s: str) -> bool`\r\nChecks if a string contains all letters of the alphabet.\r\n\r\n**Example:**\r\n```python\r\nis_pangram(\"The quick brown fox jumps over the lazy dog\") # Returns: True\r\n```\r\n\r\n##### `levenshtein_distance(s1: str, s2: str) -> int`\r\nCalculates the Levenshtein distance (edit distance) between two strings.\r\n\r\n**Example:**\r\n```python\r\nlevenshtein_distance(\"kitten\", \"sitting\") # Returns: 3\r\n```\r\n\r\n##### `generate_password(length: int = 12) -> str`\r\nGenerates a random password of the specified length.\r\n\r\n**Example:**\r\n```python\r\ngenerate_password(16) # Returns: A 16-character random password\r\n```\r\n\r\n##### `json_to_csv(json_data: list[dict], csv_file: str)`\r\nConverts JSON data to CSV and writes it to a file.\r\n\r\n**Example:**\r\n```python\r\njson_to_csv(json_data, \"output.csv\")\r\n```\r\n\r\n##### `csv_to_json(csv_file: str) -> list[dict]`\r\nConverts a CSV file into JSON format.\r\n\r\n**Example:**\r\n```python\r\ndata = csv_to_json(\"input.csv\")\r\n```\r\n\r\n---\r\n\r\n### Examples\r\n\r\nHere are a few quick examples to demonstrate how to use `moreutils`:\r\n\r\n```python\r\nfrom moreutils import text_to_number, is_palindrome, generate_password\r\n\r\n# Convert text to number\r\nprint(text_to_number(\"one hundred twenty-three\")) # Output: 123\r\n\r\n# Check if a string is a palindrome\r\nprint(is_palindrome(\"A man a plan a canal Panama\")) # Output: True\r\n\r\n# Generate a random password\r\nprint(generate_password(16)) # Output: A randomly generated password\r\n```\r\n\r\n---\r\n\r\n## License\r\n\r\n`moreutils` is open source and licensed under the [MIT License](https://opensource.org/licenses/MIT).\r\n\r\n\r\n",
"bugtrack_url": null,
"license": null,
"summary": "a package containing more utilities for python",
"version": "0.13",
"project_urls": null,
"split_keywords": [
"python",
" utils"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5ca248933bc0e99207032bf7bb05e429b130e0d89459814297829fe97dfac002",
"md5": "1ce86b74dc637536f145ce6d81533f5c",
"sha256": "0156648aca4b345d76b5ca7ce39a6d3c3d8aeb5bb4f55b42470c1863c6ff800f"
},
"downloads": -1,
"filename": "MoreUtilspy-0.13-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1ce86b74dc637536f145ce6d81533f5c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9615,
"upload_time": "2024-10-04T12:08:37",
"upload_time_iso_8601": "2024-10-04T12:08:37.853459Z",
"url": "https://files.pythonhosted.org/packages/5c/a2/48933bc0e99207032bf7bb05e429b130e0d89459814297829fe97dfac002/MoreUtilspy-0.13-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8de829fa7b22714b5f70f81c20aad2a79321f7bc1ac60eab5d076a3409762959",
"md5": "858d76333bbd9519f712172145c38ce4",
"sha256": "e21d80c54768230b88e6631475d5ad2604b4ab24a0400fa0f87bf4c56bbc1a1c"
},
"downloads": -1,
"filename": "moreutilspy-0.13.tar.gz",
"has_sig": false,
"md5_digest": "858d76333bbd9519f712172145c38ce4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12409,
"upload_time": "2024-10-04T12:08:39",
"upload_time_iso_8601": "2024-10-04T12:08:39.496089Z",
"url": "https://files.pythonhosted.org/packages/8d/e8/29fa7b22714b5f70f81c20aad2a79321f7bc1ac60eab5d076a3409762959/moreutilspy-0.13.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-04 12:08:39",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "moreutilspy"
}