Created
September 27, 2022 15:58
-
-
Save CodePint/fba5154d70b2ac572fb9240f47cea79b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import humps | |
def detect_case(value): | |
for case in ['snake', 'camel', 'pascal', 'kebab']: | |
if getattr(humps, f"is_{case}case")(value): | |
return case | |
return 'unknown' | |
detect_case("im_in_this_big_ass_coat") # snake | |
detect_case"illWearYourGranddadsClothes") # camel | |
detect_case("ILookIncredible") # pascal | |
detect_case('from-that-thrift-shop') # kebab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment