[ 
https://issues.apache.org/jira/browse/TINKERPOP-2966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17928469#comment-17928469
 ] 

ASF GitHub Bot commented on TINKERPOP-2966:
-------------------------------------------

flora-jin commented on code in PR #3039:
URL: https://github.com/apache/tinkerpop/pull/3039#discussion_r1961951019


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslator.java:
##########
@@ -479,9 +467,28 @@ private SymbolHelper() {
         }
 
         public static String toPython(final String symbol) {
-            // at some point we will want a camel to snake case converter 
here. for now the only step that needs
-            // this conversion is mergeE/V related as the rest still continue 
use in their deprecated forms.
-            return TO_PYTHON_MAP.getOrDefault(symbol, symbol);
+            return TO_PYTHON_MAP.getOrDefault(symbol, 
convertCamelCaseToSnakeCase(symbol));
+        }
+
+        public static String convertCamelCaseToSnakeCase(final String 
camelCase) {
+            if (camelCase == null || camelCase.isEmpty())
+                return camelCase;
+
+            // skip if this is a class/enum indicated by the first letter 
being upper case
+            if (Character.isUpperCase(camelCase.charAt(0)))
+                return camelCase;
+
+            final StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < camelCase.length(); i++) {

Review Comment:
   Yes I was thinking a similar thing but this is following the changes that 
were completed on 4.0. I wasn't sure if it would be okay for 3.7 to have a 
different implementation than 4.0. If alright though, I also think it would be 
easier to use the `replaceAll`





> Change PythonTranslator to generate underscore based step naming
> ----------------------------------------------------------------
>
>                 Key: TINKERPOP-2966
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2966
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: translator
>    Affects Versions: 3.5.6
>            Reporter: Stephen Mallette
>            Priority: Minor
>
> The more idiomatic underscore based step naming was introduced a long time 
> ago but the {{PythonTranslator}}} still produces the old camelcase style.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to