### Install humps from source Source: https://github.com/nficano/humps/blob/master/docs/user/install.md Install humps into your site-packages after cloning the source code. ```bash cd humps $ pipenv install . ``` -------------------------------- ### Install pyhumps Source: https://github.com/nficano/humps/blob/master/README.md Install the pyhumps package using pipenv or pip. ```bash pipenv install pyhumps ``` -------------------------------- ### Install humps with pipenv Source: https://github.com/nficano/humps/blob/master/docs/user/install.md Use this command to install the humps package using pipenv. ```bash $ pipenv install pyhumps ``` -------------------------------- ### String Case Conversion Examples Source: https://github.com/nficano/humps/blob/master/docs/index.md Demonstrates various string case conversions including decamelize, camelize, kebabize, pascalize, and dekebabize. Also shows recursive conversion of dictionaries and lists. ```python import humps humps.decamelize('illWearYourGranddadsClothes') # 'ill_wear_your_granddads_clothes' ``` ```python import humps humps.camelize('i_look_incredible') # 'iLookIncredible' ``` ```python import humps humps.kebabize('i_look_incredible') # 'i-look-incredible' ``` ```python import humps humps.pascalize('im_in_this_big_ass_coat') # 'ImInThisBigAssCoat' ``` ```python import humps humps.decamelize('FROMThatThriftShop') # 'from_that_thrift_shop' ``` ```python import humps humps.decamelize([{'downTheRoad': True}]) # [{'down_the_road': True}] ``` ```python import humps humps.dekebabize('FROM-That-Thrift-Shop') # 'FROM_That_Thrift_Shop' ``` -------------------------------- ### Pythonic Boto3 wrapper using humps for AWS SDK integration Source: https://context7.com/nficano/humps/llms.txt This cookbook example demonstrates how to create a Pythonic wrapper for the Boto3 AWS SDK using humps. It converts Python snake_case arguments to PascalCase for AWS API calls and converts the PascalCase AWS responses back to snake_case. ```python # Cookbook: Pythonic Boto3 wrapper using humps import humps import boto3 def api(service, decamelize=True, *args, **kwargs): service_name, func_name = service.split(":") client = boto3.client(service_name) # Convert Python snake_case kwargs to PascalCase for AWS aws_kwargs = humps.pascalize(kwargs) response = getattr(client, func_name)(*args, **aws_kwargs) # Convert PascalCase AWS response back to snake_case return humps.depascalize(response) if decamelize else response # Usage — all arguments written in Pythonic snake_case result = api("s3:download_file", bucket="my-bucket", key="hello.png", filename="hello.png") ``` -------------------------------- ### Clone humps repository Source: https://github.com/nficano/humps/blob/master/docs/user/install.md Clone the humps repository from GitHub to get the source code. ```bash $ git clone git://github.com/nficano/humps.git ``` -------------------------------- ### Pythonic Boto3 API Wrapper with Humps Source: https://github.com/nficano/humps/blob/master/README.md Example of creating a Pythonic wrapper for Boto3 AWS client methods using humps for case conversion. This function automatically handles case conversion for request parameters and responses. ```python # aws.py import humps import boto3 def api(service, decamelize=True, *args, **kwargs): service, func = service.split(":") client = boto3.client(service) kwargs = humps.pascalize(kwargs) response = getattr(client, func)(*args, **kwargs) return (depascalize(response) if decamelize else response) # usage api("s3:download_file", bucket="bucket", key="hello.png", filename="hello.png") ``` -------------------------------- ### Convert Strings with Humps Source: https://github.com/nficano/humps/blob/master/docs/user/quickstart.md Import the humps library to perform string conversions. Use camelize for camelCase, decamelize for snake_case, and pascalize for PascalCase. ```python >>> import humps >>> humps.camelize('jack_in_the_box') # jackInTheBox >>> humps.decamelize('rubyTuesdays') # ruby_tuesdays >>> humps.pascalize('red_robin') # RedRobin ``` -------------------------------- ### Humps for API Data Normalization and SDK Wrapping Source: https://context7.com/nficano/humps/llms.txt Demonstrates how humps can be used to normalize API boundary data by converting between camelCase and snake_case, and how it can simplify wrapping non-Pythonic SDKs by converting casing conventions. ```APIDOC ## Cookbook: Pythonic Boto3 wrapper using humps ### Description This example shows how to create a Pythonic wrapper around an SDK like Boto3 using humps. It converts Python snake_case arguments to the casing convention expected by the SDK (e.g., PascalCase for AWS) and then converts the SDK's response back to snake_case. ### Usage Define a wrapper function that takes a service identifier and arguments. Inside the function, use `humps.pascalize` to convert keyword arguments before calling the SDK method, and `humps.depascalize` to convert the response back to snake_case. ### Code Example ```python import humps import boto3 def api(service, decamelize=True, *args, **kwargs): service_name, func_name = service.split(":") client = boto3.client(service_name) # Convert Python snake_case kwargs to PascalCase for AWS aws_kwargs = humps.pascalize(kwargs) response = getattr(client, func_name)(*args, **aws_kwargs) # Convert PascalCase AWS response back to snake_case return humps.depascalize(response) if decamelize else response # Example call with Pythonic snake_case arguments # result = api("s3:download_file", bucket="my-bucket", key="hello.png", filename="hello.png") ``` ``` -------------------------------- ### Check String Casing Source: https://github.com/nficano/humps/blob/master/README.md Verify if a string conforms to camelCase, PascalCase, snake_case, or kebab-case conventions. Includes checks for abbreviations. ```python import humps humps.is_camelcase("illWearYourGranddadsClothes") # True humps.is_pascalcase("ILookIncredible") # True humps.is_snakecase("im_in_this_big_ass_coat") # True humps.is_kebabcase('from-that-thrift-shop') # True humps.is_camelcase("down_the_road") # False humps.is_snakecase("imGonnaPopSomeTags") # False humps.is_kebabcase('only_got_twenty_dollars_in_my_pocket') # False # what about abbrevations, acronyms, and initialisms? No problem! humps.decamelize("APIResponse") # api_response ``` -------------------------------- ### Download humps tarball Source: https://github.com/nficano/humps/blob/master/docs/user/install.md Download the humps source code tarball from GitHub. ```bash $ curl -OL https://github.com/nficano/humps/tarball/master ``` -------------------------------- ### Convert Dictionary Keys to KebabCase and PascalCase Source: https://github.com/nficano/humps/blob/master/README.md Convert keys within dictionaries and lists of dictionaries to kebab-case and PascalCase. Supports kebabize and pascalize. ```python import humps array = [{'attr_one': 'foo'}, {'attr_one': 'bar'}] humps.kebabize(array) # [{'attr-one': 'foo'}, {'attr-one': 'bar'}] array = [{"attr_one": "foo"}, {"attr_one": "bar"}] humps.pascalize(array) # [{"AttrOne": "foo"}, {"AttrOne": "bar"}] ``` -------------------------------- ### Convert kebab-case to snake_case with humps.dekebabize Source: https://context7.com/nficano/humps/llms.txt Use humps.dekebabize to convert kebab-case strings or dictionary keys to snake_case. Underscores are preserved, and purely numeric strings are returned unchanged. ```python import humps # String conversion humps.dekebabize("taco-bell") # "taco_bell" humps.dekebabize("last-price") # "last_price" humps.dekebabize("API-Response") # "API_Response" humps.dekebabize("_last-price__") # "_last_price__" (underscores preserved) humps.dekebabize("12345") # "12345" (numeric passthrough) # List-of-dicts conversion records = [ {"symbol": "AAL", "last-price": 31.78, "Change-Pct": 2.8146, "implied-Volatility": 0.482}, {"symbol": "LBTYA", "last-price": 25.95, "Change-Pct": 2.6503, "implied-Volatility": 0.7287}, ] result = humps.dekebabize(records) # [ # {"symbol": "AAL", "last_price": 31.78, "Change_Pct": 2.8146, "implied_Volatility": 0.482}, # {"symbol": "LBTYA", "last_price": 25.95, "Change_Pct": 2.6503, "implied_Volatility": 0.7287}, # ] ``` -------------------------------- ### humps.pascalize Source: https://context7.com/nficano/humps/llms.txt Converts snake_case strings or dictionary keys to PascalCase. It behaves like `camelize` but capitalizes the first character. All-uppercase strings are returned unchanged, and leading underscores are preserved. ```APIDOC ## humps.pascalize — Convert snake_case to PascalCase ### Description Converts a snake_case string (or dict keys) to PascalCase. Behaves like `camelize` but capitalizes the first character as well. All-uppercase strings are returned unchanged. ### Method `humps.pascalize(string_or_dict)` ### Parameters - **string_or_dict**: (string | dict) - The input string or dictionary to convert. ### Request Example ```python import humps # String conversion humps.pascalize("red_robin") # "RedRobin" humps.pascalize("_fallback_url") # "_FallbackUrl" humps.pascalize("API") # "API" # Dict conversion snake_params = { "videos": [{"fallback_url": "https://media.io/video"}] } humps.pascalize(snake_params) ``` ### Response - **string | dict**: The converted string or dictionary with keys in PascalCase. ``` -------------------------------- ### Convert Strings to CamelCase, SnakeCase, and PascalCase Source: https://github.com/nficano/humps/blob/master/README.md Use humps functions to convert strings between different casing conventions. Supports camelize, decamelize, pascalize, and kebabize. ```python import humps humps.camelize("jack_in_the_box") # jackInTheBox humps.decamelize("rubyTuesdays") # ruby_tuesdays humps.pascalize("red_robin") # RedRobin humps.kebabize("white_castle") # white-castle ``` -------------------------------- ### Convert snake_case to kebab-case with humps.kebabize Source: https://context7.com/nficano/humps/llms.txt Use humps.kebabize to convert snake_case strings or dictionary keys to kebab-case. Leading/trailing underscores and all-uppercase strings are preserved. Non-string inputs are passed through. ```python import humps # String conversion humps.kebabize("white_castle") # "white-castle" humps.kebabize("fallback_url") # "fallback-url" humps.kebabize("scrubber_media_url") # "scrubber-media-url" humps.kebabize("_fallback_url") # "_fallback-url" (leading underscore preserved) humps.kebabize("API") # "API" (all-uppercase unchanged) humps.kebabize(123) # 123 (numeric passthrough) # Dict / list-of-dicts conversion payload = [ {"attr_one": "foo"}, {"attr_one": "bar"}, ] result = humps.kebabize(payload) # [{"attr-one": "foo"}, {"attr-one": "bar"}] # Full nested dict example data = { "videos": [{"fallback_url": "https://media.io/video", "dash_url": "https://media.io/video"}], "images": [{"fallback_url": "https://media.io/image", "url": "https://media.io/image"}], } result = humps.kebabize(data) # { # "videos": [{"fallback-url": "https://media.io/video", "dash-url": "https://media.io/video"}], # "images": [{"fallback-url": "https://media.io/image", "url": "https://media.io/image"}] # } ``` -------------------------------- ### Convert snake_case to PascalCase with humps.pascalize Source: https://context7.com/nficano/humps/llms.txt Use humps.pascalize to convert snake_case strings or dictionary keys to PascalCase. It capitalizes the first character and preserves leading underscores. All-uppercase strings remain unchanged. ```python import humps # String conversion humps.pascalize("red_robin") # "RedRobin" humps.pascalize("fallback_url") # "FallbackUrl" humps.pascalize("scrubber_media_url") # "ScrubberMediaUrl" humps.pascalize("_fallback_url") # "_FallbackUrl" (leading underscore preserved) humps.pascalize("API") # "API" (all-uppercase unchanged) humps.pascalize(None) # "" ``` ```python # Dict conversion — useful when calling PascalCase APIs (e.g., AWS Boto3) snake_params = { "videos": [ {"fallback_url": "https://media.io/video", "dash_url": "https://media.io/video"} ], "images": [ {"fallback_url": "https://media.io/image", "url": "https://media.io/image"} ], } result = humps.pascalize(snake_params) # { # "Videos": [{"FallbackUrl": "https://media.io/video", "DashUrl": "https://media.io/video"}], ``` -------------------------------- ### humps.kebabize Source: https://context7.com/nficano/humps/llms.txt Converts snake_case strings or dictionary keys to kebab-case by replacing underscores with hyphens. Preserves leading/trailing underscores and all-uppercase strings. ```APIDOC ## humps.kebabize — Convert snake_case to kebab-case ### Description Converts a snake_case string (or dict keys) to kebab-case by replacing underscores with hyphens. Leading/trailing underscores and all-uppercase strings are preserved as-is. ### Method Signature `humps.kebabize(input)` ### Parameters - `input`: The string or dictionary/list of dictionaries to convert. ### Examples ```python import humps # String conversion humps.kebabize("white_castle") # "white-castle" humps.kebabize("fallback_url") # "fallback-url" humps.kebabize("scrubber_media_url") # "scrubber-media-url" humps.kebabize("_fallback_url") # "_fallback-url" (leading underscore preserved) humps.kebabize("API") # "API" (all-uppercase unchanged) humps.kebabize(123) # 123 (numeric passthrough) # Dict / list-of-dicts conversion payload = [ {"attr_one": "foo"}, {"attr_one": "bar"}, ] result = humps.kebabize(payload) # [{"attr-one": "foo"}, {"attr-one": "bar"}] # Full nested dict example data = { "videos": [{"fallback_url": "https://media.io/video", "dash_url": "https://media.io/video"}], "images": [{"fallback_url": "https://media.io/image", "url": "https://media.io/image"}], } result = humps.kebabize(data) # { # "videos": [{"fallback-url": "https://media.io/video", "dash-url": "https://media.io/video"}], # "images": [{"fallback-url": "https://media.io/image", "url": "https://media.io/image"}] # } ``` ``` -------------------------------- ### humps.dekebabize Source: https://context7.com/nficano/humps/llms.txt Converts kebab-case strings or dictionary keys to snake_case by replacing hyphens with underscores. Preserves existing underscores and numeric strings. ```APIDOC ## humps.dekebabize — Convert kebab-case to snake_case ### Description Converts a kebab-case string (or dict keys) to snake_case by replacing hyphens with underscores. Purely numeric strings are returned unchanged. ### Method Signature `humps.dekebabize(input)` ### Parameters - `input`: The string or dictionary/list of dictionaries to convert. ### Examples ```python import humps # String conversion humps.dekebabize("taco-bell") # "taco_bell" humps.dekebabize("last-price") # "last_price" humps.dekebabize("API-Response") # "API_Response" humps.dekebabize("_last-price__") # "_last_price__" (underscores preserved) humps.dekebabize("12345") # "12345" (numeric passthrough) # List-of-dicts conversion records = [ {"symbol": "AAL", "last-price": 31.78, "Change-Pct": 2.8146, "implied-Volatility": 0.482}, {"symbol": "LBTYA", "last-price": 25.95, "Change-Pct": 2.6503, "implied-Volatility": 0.7287}, ] result = humps.dekebabize(records) # [ # {"symbol": "AAL", "last_price": 31.78, "Change_Pct": 2.8146, "implied_Volatility": 0.482}, # {"symbol": "LBTYA", "last_price": 25.95, "Change_Pct": 2.6503, "implied_Volatility": 0.7287}, # ] ``` ``` -------------------------------- ### Check for PascalCase with humps.is_pascalcase Source: https://context7.com/nficano/humps/llms.txt Use humps.is_pascalcase to check if a string adheres to PascalCase conventions. All-uppercase strings are considered valid PascalCase. ```python import humps humps.is_pascalcase("ILookIncredible") # True humps.is_pascalcase("RedRobin") # True humps.is_pascalcase("API") # True humps.is_pascalcase("jackInTheBox") # False humps.is_pascalcase("ruby_tuesdays") # False humps.is_pascalcase("white-castle") # False ``` -------------------------------- ### Convert Dictionary Keys to CamelCase and SnakeCase Source: https://github.com/nficano/humps/blob/master/README.md Convert keys within dictionaries and lists of dictionaries to different casing conventions. Supports decamelize and camelize. ```python import humps array = [{"attrOne": "foo"}, {"attrOne": "bar"}] humps.decamelize(array) # [{"attr_one": "foo"}, {"attr_one": "bar"}] array = [{"attr_one": "foo"}, {"attr_one": "bar"}] humps.camelize(array) # [{"attrOne": "foo"}, {"attrOne": "bar"}] ``` -------------------------------- ### Convert camelCase/PascalCase to snake_case with humps.decamelize Source: https://context7.com/nficano/humps/llms.txt Use humps.decamelize to convert camelCase or PascalCase strings or dictionary keys to snake_case. It correctly handles acronyms and preserves underscores. Non-string inputs like numbers are passed through unchanged. ```python import humps # String conversion humps.decamelize("rubyTuesdays") # "ruby_tuesdays" humps.decamelize("lastPrice") # "last_price" humps.decamelize("APIResponse") # "api_response" (acronym handled correctly) humps.decamelize("HTTPResponse") # "http_response" humps.decamelize("memMB") # "mem_mb" humps.decamelize("sizeX") # "size_x" humps.decamelize("_lastPrice__") # "_last_price__" (underscores preserved) humps.decamelize("API") # "API" (all-uppercase unchanged) humps.decamelize(123) # 123 (numeric passthrough) ``` ```python # List-of-dicts conversion records = [ {"symbol": "AAL", "lastPrice": 31.78, "changePct": 2.8146, "impliedVolatility": 0.482}, {"symbol": "LBTYA", "lastPrice": 25.95, "changePct": 2.6503, "impliedVolatility": 0.7287}, ] result = humps.decamelize(records) # [ # {"symbol": "AAL", "last_price": 31.78, "change_pct": 2.8146, "implied_volatility": 0.482}, # {"symbol": "LBTYA", "last_price": 25.95, "change_pct": 2.6503, "implied_volatility": 0.7287}, # ] ``` -------------------------------- ### humps.is_kebabcase Source: https://context7.com/nficano/humps/llms.txt Checks if a given string is in kebab-case format. This is useful for validating input or ensuring consistency before processing. ```APIDOC ## humps.is_kebabcase ### Description Returns `True` if the input string is already in kebab-case format (i.e., it would be unchanged by `kebabize`). ### Method `humps.is_kebabcase(string)` ### Parameters - **string** (str) - The input string to check. ### Returns - **bool** - `True` if the string is kebab-case, `False` otherwise. ### Examples ```python import humps humps.is_kebabcase("from-that-thrift-shop") # True humps.is_kebabcase("white-castle") # True humps.is_kebabcase("API") # True humps.is_kebabcase("only_got_twenty_dollars_in_my_pocket") # False humps.is_kebabcase("jackInTheBox") # False humps.is_kebabcase("RedRobin") # False ``` ``` -------------------------------- ### humps.decamelize Source: https://context7.com/nficano/humps/llms.txt Converts camelCase or PascalCase strings or dictionary keys to snake_case. It correctly handles acronyms and initialisms, and preserves underscores. All-uppercase strings are returned unchanged. ```APIDOC ## humps.decamelize — Convert camelCase / PascalCase to snake_case ### Description Converts a camelCase or PascalCase string (or all keys in a dict/list) to snake_case. Correctly handles acronyms and initialisms so that `APIResponse` becomes `api_response` (not `a_p_i_response`). All-uppercase strings are returned unchanged. ### Method `humps.decamelize(string_or_dict_or_list)` ### Parameters - **string_or_dict_or_list**: (string | dict | list) - The input string, dictionary, or list to convert. ### Request Example ```python import humps # String conversion humps.decamelize("rubyTuesdays") # "ruby_tuesdays" humps.decamelize("APIResponse") # "api_response" humps.decamelize("_lastPrice__") # "_last_price__" humps.decamelize("API") # "API" # List-of-dicts conversion records = [ {"symbol": "AAL", "lastPrice": 31.78}, {"symbol": "LBTYA", "lastPrice": 25.95}, ] humps.decamelize(records) ``` ### Response - **string | dict | list**: The converted string, dictionary, or list with keys in snake_case. ``` -------------------------------- ### Convert snake_case to camelCase with humps.camelize Source: https://context7.com/nficano/humps/llms.txt Use humps.camelize for converting snake_case strings or dictionary keys to camelCase. It preserves leading/trailing underscores and handles all-uppercase strings and None inputs. ```python import humps # String conversion humps.camelize("jack_in_the_box") # "jackInTheBox" humps.camelize("fallback_url") # "fallbackUrl" humps.camelize("field_value_2_type") # "fieldValue2Type" humps.camelize("_fallback_url") # "_fallbackUrl" (leading underscore preserved) humps.camelize("API") # "API" (all-uppercase unchanged) humps.camelize("APIResponse") # "APIResponse" (already camelCase acronym) humps.camelize(None) # "" humps.camelize("") # "" ``` ```python # Dict / list-of-dicts conversion (keys are transformed, values are untouched) payload = { "videos": [ { "fallback_url": "https://media.io/video", "scrubber_media_url": "https://media.io/video", "dash_url": "https://media.io/video", } ], "images": [ { "fallback_url": "https://media.io/image", "url": "https://media.io/image", } ], } result = humps.camelize(payload) # { # "videos": [{"fallbackUrl": "...", "scrubberMediaUrl": "...", "dashUrl": "..."}], # "images": [{"fallbackUrl": "...", "url": "..."}] # } ``` -------------------------------- ### Check if a string is snake_case with humps.is_snakecase Source: https://context7.com/nficano/humps/llms.txt Use `humps.is_snakecase` to verify if a string adheres to the snake_case format. This is useful for validating input or ensuring consistency before processing. ```python import humps humps.is_snakecase("im_in_this_big_ass_coat") # True humps.is_snakecase("ruby_tuesdays") # True humps.is_snakecase("API") # True humps.is_snakecase("whatever_10") # True humps.is_snakecase("imGonnaPopSomeTags") # False humps.is_snakecase("RedRobin") # False humps.is_snakecase("white-castle") # False ``` -------------------------------- ### Check if a string is kebab-case with humps.is_kebabcase Source: https://context7.com/nficano/humps/llms.txt Use `humps.is_kebabcase` to determine if a string follows the kebab-case convention. This function is helpful for validating data formats from sources that use kebab-case. ```python import humps humps.is_kebabcase("from-that-thrift-shop") # True humps.is_kebabcase("white-castle") # True humps.is_kebabcase("API") # True humps.is_kebabcase("only_got_twenty_dollars_in_my_pocket") # False humps.is_kebabcase("jackInTheBox") # False humps.is_kebabcase("RedRobin") # False ``` -------------------------------- ### Convert PascalCase to snake_case with humps.depascalize Source: https://context7.com/nficano/humps/llms.txt Use humps.depascalize to convert PascalCase strings or dictionary keys to snake_case. This is useful for processing API responses or data structures that use PascalCase. ```python import humps humps.depascalize("UnosPizza") # "unos_pizza" humps.depascalize("RedRobin") # "red_robin" # List-of-dicts (e.g., a PascalCase API response) response = [ {"Symbol": "AAL", "LastPrice": 31.78, "ChangePct": 2.8146, "ImpliedVolatality": 0.482}, {"Symbol": "LBTYA", "LastPrice": 25.95, "ChangePct": 2.6503, "ImpliedVolatality": 0.7287}, {"_Symbol": "LBTYK", "ChangePct_": 2.5827, "_LastPrice__": 25.42}, ] result = humps.depascalize(response) # [ # {"symbol": "AAL", "last_price": 31.78, "change_pct": 2.8146, "implied_volatality": 0.482}, # {"symbol": "LBTYA", "last_price": 25.95, "change_pct": 2.6503, "implied_volatality": 0.7287}, # {"_symbol": "LBTYK", "change_pct_": 2.5827, "_last_price__": 25.42}, # ] ``` -------------------------------- ### humps.is_pascalcase Source: https://context7.com/nficano/humps/llms.txt Checks if a string is in PascalCase format. Returns True if the string would remain unchanged by the `pascalize` function. ```APIDOC ## humps.is_pascalcase — Check if a string is PascalCase ### Description Returns `True` if the input string is already in PascalCase format (i.e., it would be unchanged by `pascalize`). ### Method Signature `humps.is_pascalcase(input)` ### Parameters - `input`: The string to check. ### Returns - `True` if the string is PascalCase, `False` otherwise. ### Examples ```python import humps humps.is_pascalcase("ILookIncredible") # True humps.is_pascalcase("RedRobin") # True humps.is_pascalcase("API") # True humps.is_pascalcase("jackInTheBox") # False humps.is_pascalcase("ruby_tuesdays") # False humps.is_pascalcase("white-castle") # False ``` ``` -------------------------------- ### humps.camelize Source: https://context7.com/nficano/humps/llms.txt Converts snake_case strings or dictionary keys to camelCase. It handles nested dictionaries and lists of dictionaries, preserving leading/trailing underscores and leaving all-uppercase strings unchanged. ```APIDOC ## humps.camelize — Convert snake_case to camelCase ### Description Converts a snake_case string, or all keys of a dict / list of dicts, to camelCase. All-uppercase strings and purely numeric values are returned unchanged. Leading/trailing underscores are preserved. ### Method `humps.camelize(string_or_dict_or_list)` ### Parameters - **string_or_dict_or_list**: (string | dict | list) - The input string, dictionary, or list to convert. ### Request Example ```python import humps # String conversion humps.camelize("jack_in_the_box") # "jackInTheBox" humps.camelize("_fallback_url") # "_fallbackUrl" humps.camelize("API") # "API" humps.camelize(None) # "" # Dict / list-of-dicts conversion payload = { "videos": [ { "fallback_url": "https://media.io/video", "scrubber_media_url": "https://media.io/video", "dash_url": "https://media.io/video", } ] } humps.camelize(payload) ``` ### Response - **string | dict | list**: The converted string, dictionary, or list with keys in camelCase. ``` -------------------------------- ### humps.depascalize Source: https://context7.com/nficano/humps/llms.txt Converts PascalCase strings or dictionary keys to snake_case. It's an alias for decamelize, useful when the input is known to be PascalCase. ```APIDOC ## humps.depascalize — Convert PascalCase to snake_case ### Description An alias for `decamelize`. Converts PascalCase strings or dict keys to snake_case. Provided for semantic clarity when the input is known to be PascalCase. ### Method Signature `humps.depascalize(input)` ### Parameters - `input`: The string or dictionary/list of dictionaries to convert. ### Examples ```python import humps humps.depascalize("UnosPizza") # "unos_pizza" humps.depascalize("RedRobin") # "red_robin" # List-of-dicts (e.g., a PascalCase API response) response = [ {"Symbol": "AAL", "LastPrice": 31.78, "ChangePct": 2.8146, "ImpliedVolatality": 0.482}, {"Symbol": "LBTYA", "LastPrice": 25.95, "ChangePct": 2.6503, "ImpliedVolatality": 0.7287}, {"_Symbol": "LBTYK", "ChangePct_": 2.5827, "_LastPrice__": 25.42}, ] result = humps.depascalize(response) # [ # {"symbol": "AAL", "last_price": 31.78, "change_pct": 2.8146, "implied_volatality": 0.482}, # {"symbol": "LBTYA", "last_price": 25.95, "change_pct": 2.6503, "implied_volatality": 0.482}, # {"_symbol": "LBTYK", "change_pct_": 2.5827, "_last_price__": 25.42}, # ] ``` ``` -------------------------------- ### humps.is_camelcase Source: https://context7.com/nficano/humps/llms.txt Checks if a string is in camelCase format. Returns True if the string would remain unchanged by the `camelize` function. ```APIDOC ## humps.is_camelcase — Check if a string is camelCase ### Description Returns `True` if the input string is already in camelCase format (i.e., it would be unchanged by `camelize`). ### Method Signature `humps.is_camelcase(input)` ### Parameters - `input`: The string to check. ### Returns - `True` if the string is camelCase, `False` otherwise. ### Examples ```python import humps humps.is_camelcase("illWearYourGranddadsClothes") # True humps.is_camelcase("jackInTheBox") # True humps.is_camelcase("API") # True (all-uppercase is valid in all cases) humps.is_camelcase("down_the_road") # False humps.is_camelcase("RedRobin") # False (PascalCase, not camelCase) humps.is_camelcase("white-castle") # False humps.is_camelcase("whatever_10") # False ``` ``` -------------------------------- ### Check for camelCase with humps.is_camelcase Source: https://context7.com/nficano/humps/llms.txt Use humps.is_camelcase to determine if a string is in camelCase format. All-uppercase strings are considered valid camelCase. ```python import humps humps.is_camelcase("illWearYourGranddadsClothes") # True humps.is_camelcase("jackInTheBox") # True humps.is_camelcase("API") # True (all-uppercase is valid in all cases) humps.is_camelcase("down_the_road") # False humps.is_camelcase("RedRobin") # False (PascalCase, not camelCase) humps.is_camelcase("white-castle") # False humps.is_camelcase("whatever_10") # False ``` -------------------------------- ### humps.is_snakecase Source: https://context7.com/nficano/humps/llms.txt Checks if a given string is in snake_case format. This is useful for validating input or ensuring consistency before processing. ```APIDOC ## humps.is_snakecase ### Description Returns `True` if the input string is already in snake_case format (i.e., it would be unchanged by `decamelize`). ### Method `humps.is_snakecase(string)` ### Parameters - **string** (str) - The input string to check. ### Returns - **bool** - `True` if the string is snake_case, `False` otherwise. ### Examples ```python import humps humps.is_snakecase("im_in_this_big_ass_coat") # True humps.is_snakecase("ruby_tuesdays") # True humps.is_snakecase("API") # True humps.is_snakecase("whatever_10") # True humps.is_snakecase("imGonnaPopSomeTags") # False humps.is_snakecase("RedRobin") # False humps.is_snakecase("white-castle") # False ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.