rdblue commented on code in PR #5488:
URL: https://github.com/apache/iceberg/pull/5488#discussion_r942653696


##########
python/pyiceberg/utils/config.py:
##########
@@ -0,0 +1,125 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import logging
+import os
+import site
+import sys
+from typing import Any, List
+
+import yaml
+
+from pyiceberg.typedef import EMPTY_DICT, Configuration, FrozenDict
+
+PYICEBERG = "pyiceberg__"
+CATALOG = "catalog"
+
+PATHS = [
+    f"{os.environ.get('ICEBERG_ROOT_CONFIG', 
'/etc/pyiceberg').rstrip('/')}/pyiceberg",
+    *[f"{prefix}/etc/pyiceberg" for prefix in site.PREFIXES],
+    f"{sys.prefix}/etc/pyiceberg",
+    "~/config/pyiceberg",
+]
+
+
+def merge_dicts(lhs: Configuration, rhs: Configuration) -> Configuration:
+    """merges left-hand side into the right-hand side"""
+    for lhs_key, lhs_value in lhs.items():
+        if lhs_key in rhs:
+            rhs_value = rhs[lhs_key]
+            if isinstance(lhs_value, dict) and isinstance(rhs_value, dict):
+                lhs[lhs_key] = merge_dicts(lhs_value, rhs_value)
+            elif lhs_value != lhs_value:
+                lhs[lhs_key] = rhs_value
+
+    # Add the keys from the rhs that are not in the lhs
+    for rhs_key, rhs_value in rhs.items():
+        if rhs_key not in lhs:
+            lhs[rhs_key] = rhs_value
+
+    return lhs
+
+
+logger = logging.getLogger(__name__)
+
+
+def _lowercase_dictionary_keys(input_dict: Configuration) -> Configuration:
+    """Lowers all the keys of a dictionary in a recursive manner, to make the 
lookup case-insensitive"""
+    return {k.lower(): _lowercase_dictionary_keys(v) if isinstance(v, dict) 
else v for k, v in input_dict.items()}
+
+
+class Config:
+    config: Configuration

Review Comment:
   Using both `Configuration` and `Config` is a bit confusing. What about using 
a `RecursiveDict` instead of `Configuration`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to