File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1212# License for the specific language governing permissions and limitations
1313# under the License.
1414
15- """linebot.http_client module."""
15+ """linebot.utils module."""
1616
1717from __future__ import unicode_literals
1818
1919import logging
2020import re
21+
2122import sys
2223
2324LOGGER = logging .getLogger ('linebot' )
@@ -31,8 +32,10 @@ def to_snake_case(text):
3132 :param str text:
3233 :rtype: str
3334 """
34- s1 = re .sub ('(.)([A-Z0-9][a-z]+)' , r'\1_\2' , text )
35- return re .sub ('([a-z])([A-Z0-9])' , r'\1_\2' , s1 ).lower ()
35+ s1 = re .sub ('(.)([A-Z])' , r'\1_\2' , text )
36+ s2 = re .sub ('(.)([0-9]+)' , r'\1_\2' , s1 )
37+ s3 = re .sub ('([0-9])([a-z])' , r'\1_\2' , s2 )
38+ return s3 .lower ()
3639
3740
3841def to_camel_case (text ):
Original file line number Diff line number Diff line change 2121
2222class TestUtils (unittest .TestCase ):
2323 def test_to_snake_case (self ):
24- self .assertEqual (to_snake_case ('hogeBar ' ), 'hoge_bar ' )
24+ self .assertEqual (to_snake_case ('hogeBarFuga ' ), 'hoge_bar_fuga ' )
2525 self .assertEqual (to_snake_case ('uniqueMediaPlayed100Percent' ), 'unique_media_played_100_percent' )
26+ self .assertEqual (to_snake_case ('festival20Days' ), 'festival_20_days' )
27+ self .assertEqual (to_snake_case ('festival20days' ), 'festival_20_days' )
2628
2729 def test_to_camel_case (self ):
2830 self .assertEqual (to_camel_case ('hoge_bar' ), 'hogeBar' )
31+ self .assertEqual (to_camel_case ('unique_media_played_100_percent' ), 'uniqueMediaPlayed100Percent' )
2932
3033 def test_safe_compare_digest_true (self ):
3134 self .assertTrue (safe_compare_digest ('/gg9a+LvFevTH1sd7' , '/gg9a+LvFevTH1sd7' ))
You can’t perform that action at this time.
0 commit comments