File: 0001-fix-camelcase-normalization.patch

package info (click to toggle)
python-stringcase 1.2.0~git20230617.57aae96-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 148 kB
  • sloc: python: 185; sh: 8; makefile: 3
file content (43 lines) | stat: -rw-r--r-- 1,096 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From: Edward Betts <edward@4angle.com>
Date: Sun, 9 Nov 2025 14:33:45 +0000
Subject: fix camelcase normalization
Forwarded: https://github.com/okunishinishi/python-stringcase/pull/47

---
 stringcase.py | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/stringcase.py b/stringcase.py
index d995ec9..ccee12f 100644
--- a/stringcase.py
+++ b/stringcase.py
@@ -15,19 +15,17 @@ def camelcase(string):
         string: Camel case string.
 
     """
-    
-    if string == "":
-        return string
 
-    string = string.replace("_","-")
-    lst = string.split("-")
-    for i in range(len(lst)):
-        if i == 0:
-            continue
-        else:
-            lst[i] = lst[i].capitalize()
-    
-    return "".join(lst)
+    snake = snakecase(string)
+    if not snake:
+        return snake
+
+    words = [word for word in snake.split("_") if word]
+    if not words:
+        return ''
+
+    head, *tail = words
+    return head + ''.join(word.capitalize() for word in tail)
 
 def capitalcase(string):
     """Convert string into capital case.