{"action":"created","comment":{"url":"https://api.github.com/repos/lsst/daf_butler/pulls/comments/215475003","pull_request_review_id":152747933,"id":215475003,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNTQ3NTAwMw==","diff_hunk":"@@ -349,32 +406,102 @@ def names(self, topLevelOnly=False):\n \n         Returns\n         -------\n-        names : `list`\n-            List of all names present in the `Config`.\n-\n-        Notes\n-        -----\n-        This is different than the built-in method `dict.keys`, which will\n-        return only the first level keys.\n+        names : `list` of `tuple` of `str`\n+            List of all names present in the `Config` where each element\n+            in the list is a `tuple` of strings representing the hierarchy.\n         \"\"\"\n         if topLevelOnly:\n-            return list(self.keys())\n+            return list((k,) for k in self)\n \n-        def getKeys(d, keys, base):\n+        def getKeysAsTuples(d, keys, base):\n             if isinstance(d, collections.Sequence):\n                 theseKeys = range(len(d))\n             else:\n                 theseKeys = d.keys()\n             for key in theseKeys:\n                 val = d[key]\n-                levelKey = f\"{base}.{key}\" if base is not None else key\n+                levelKey = base + (key,) if base is not None else (key,)\n                 keys.append(levelKey)\n                 if isinstance(val, (collections.Mapping, collections.Sequence)) and not isinstance(val, str):\n-                    getKeys(val, keys, levelKey)\n+                    getKeysAsTuples(val, keys, levelKey)\n         keys = []\n-        getKeys(self.data, keys, None)\n+        getKeysAsTuples(self.data, keys, None)\n         return keys\n \n+    def names(self, topLevelOnly=False, delimiter=None):\n+        \"\"\"Get the delimited name of all the keys in the hierarchy.\n+\n+        The values returned from this method are guaranteed to be usable\n+        to access items in the configuration object.\n+\n+        Parameters\n+        ----------\n+        topLevelOnly : `bool`, optional\n+            If False, the default, a full hierarchy of names is returned.\n+            If True, only the top level are returned.\n+        delimiter : `str`, optional\n+            Delimiter to use when forming the keys.  The delimiter must\n+            not be present in any of the keys.  If `None` given the delimiter\n+            will be automatically provided.\n+\n+        Returns\n+        -------\n+        names : `list`\n+            List of all names present in the `Config`.\n+\n+        Notes\n+        -----\n+        This is different than the built-in method `dict.keys`, which will\n+        return only the first level keys.\n+\n+        Raises\n+        ------\n+        ValueError\n+            The externally specified delimiter is unsuitable because a key\n+            clashes with the value.\n+        \"\"\"\n+        if topLevelOnly:\n+            return list(self.keys())\n+\n+        # Get all the tuples of hierarchical keys\n+        nameTuples = self.nameTuples()\n+\n+        # Form big string for easy check of delimiter clash\n+        combined = \"\".join(\"\".join(str(s) for s in k) for k in nameTuples)\n+\n+        if delimiter is not None:\n+            if delimiter in combined:\n+                # For better error message we need to report the clashing key\n+                def findMatch(names, searchStr):\n+                    for n in names:\n+                        for s in n:\n+                            if searchStr in s:\n+                                return s\n+                    return None\n+\n+                raise ValueError(f\"Specified delimiter, {delimiter!r} can not be used.  \"\n+                                 f\"Clashes with key {findMatch(nameTuples, delimiter)!r}\")\n+        else:\n+            # Start with something\n+            delimiter = self._D\n+            ntries = 0\n+            while delimiter in combined:\n+                log.debug(f\"Trying delimiter '{delimiter}'\")","path":"python/lsst/daf/butler/core/config.py","position":274,"original_position":274,"commit_id":"6a330a44bb507ac9219c8fe2be8cd020c43e231f","original_commit_id":"6a330a44bb507ac9219c8fe2be8cd020c43e231f","user":{"login":"ktlim","id":1054393,"node_id":"MDQ6VXNlcjEwNTQzOTM=","avatar_url":"https://avatars3.githubusercontent.com/u/1054393?v=4","gravatar_id":"","url":"https://api.github.com/users/ktlim","html_url":"https://github.com/ktlim","followers_url":"https://api.github.com/users/ktlim/followers","following_url":"https://api.github.com/users/ktlim/following{/other_user}","gists_url":"https://api.github.com/users/ktlim/gists{/gist_id}","starred_url":"https://api.github.com/users/ktlim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktlim/subscriptions","organizations_url":"https://api.github.com/users/ktlim/orgs","repos_url":"https://api.github.com/users/ktlim/repos","events_url":"https://api.github.com/users/ktlim/events{/privacy}","received_events_url":"https://api.github.com/users/ktlim/received_events","type":"User","site_admin":false},"body":"The message here isn't quite accurate; `delimiter` was already tried and found wanting.","created_at":"2018-09-06T01:53:03Z","updated_at":"2018-09-06T01:53:35Z","html_url":"https://github.com/lsst/daf_butler/pull/84#discussion_r215475003","pull_request_url":"https://api.github.com/repos/lsst/daf_butler/pulls/84","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/lsst/daf_butler/pulls/comments/215475003"},"html":{"href":"https://github.com/lsst/daf_butler/pull/84#discussion_r215475003"},"pull_request":{"href":"https://api.github.com/repos/lsst/daf_butler/pulls/84"}}},"pull_request":{"url":"https://api.github.com/repos/lsst/daf_butler/pulls/84","id":212474710,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyNDc0NzEw","html_url":"https://github.com/lsst/daf_butler/pull/84","diff_url":"https://github.com/lsst/daf_butler/pull/84.diff","patch_url":"https://github.com/lsst/daf_butler/pull/84.patch","issue_url":"https://api.github.com/repos/lsst/daf_butler/issues/84","number":84,"state":"open","locked":false,"title":"DM-15614: Allow dynamic hierarchy delimiters for configs","user":{"login":"timj","id":60622,"node_id":"MDQ6VXNlcjYwNjIy","avatar_url":"https://avatars1.githubusercontent.com/u/60622?v=4","gravatar_id":"","url":"https://api.github.com/users/timj","html_url":"https://github.com/timj","followers_url":"https://api.github.com/users/timj/followers","following_url":"https://api.github.com/users/timj/following{/other_user}","gists_url":"https://api.github.com/users/timj/gists{/gist_id}","starred_url":"https://api.github.com/users/timj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timj/subscriptions","organizations_url":"https://api.github.com/users/timj/orgs","repos_url":"https://api.github.com/users/timj/repos","events_url":"https://api.github.com/users/timj/events{/privacy}","received_events_url":"https://api.github.com/users/timj/received_events","type":"User","site_admin":false},"body":"The delimiter for hierarchies no longer defaults to a `.`. The delimiter is now a class variable and can be overridden by starting the string with the delimiter you wish to use.","created_at":"2018-08-31T19:27:04Z","updated_at":"2018-09-06T01:53:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e958f3a8571df9e688534f0fe6bdcc3f7b5ec9ec","assignee":null,"assignees":[],"requested_reviewers":[{"login":"TallJimbo","id":1330720,"node_id":"MDQ6VXNlcjEzMzA3MjA=","avatar_url":"https://avatars0.githubusercontent.com/u/1330720?v=4","gravatar_id":"","url":"https://api.github.com/users/TallJimbo","html_url":"https://github.com/TallJimbo","followers_url":"https://api.github.com/users/TallJimbo/followers","following_url":"https://api.github.com/users/TallJimbo/following{/other_user}","gists_url":"https://api.github.com/users/TallJimbo/gists{/gist_id}","starred_url":"https://api.github.com/users/TallJimbo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TallJimbo/subscriptions","organizations_url":"https://api.github.com/users/TallJimbo/orgs","repos_url":"https://api.github.com/users/TallJimbo/repos","events_url":"https://api.github.com/users/TallJimbo/events{/privacy}","received_events_url":"https://api.github.com/users/TallJimbo/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/lsst/daf_butler/pulls/84/commits","review_comments_url":"https://api.github.com/repos/lsst/daf_butler/pulls/84/comments","review_comment_url":"https://api.github.com/repos/lsst/daf_butler/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lsst/daf_butler/issues/84/comments","statuses_url":"https://api.github.com/repos/lsst/daf_butler/statuses/6a330a44bb507ac9219c8fe2be8cd020c43e231f","head":{"label":"lsst:tickets/DM-15614","ref":"tickets/DM-15614","sha":"6a330a44bb507ac9219c8fe2be8cd020c43e231f","user":{"login":"lsst","id":1134504,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMzQ1MDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1134504?v=4","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":106873149,"node_id":"MDEwOlJlcG9zaXRvcnkxMDY4NzMxNDk=","name":"daf_butler","full_name":"lsst/daf_butler","owner":{"login":"lsst","id":1134504,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMzQ1MDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1134504?v=4","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/daf_butler","description":"Prototype for data access framework described in DMTN-056","fork":false,"url":"https://api.github.com/repos/lsst/daf_butler","forks_url":"https://api.github.com/repos/lsst/daf_butler/forks","keys_url":"https://api.github.com/repos/lsst/daf_butler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/daf_butler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/daf_butler/teams","hooks_url":"https://api.github.com/repos/lsst/daf_butler/hooks","issue_events_url":"https://api.github.com/repos/lsst/daf_butler/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/daf_butler/events","assignees_url":"https://api.github.com/repos/lsst/daf_butler/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/daf_butler/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/daf_butler/tags","blobs_url":"https://api.github.com/repos/lsst/daf_butler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/daf_butler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/daf_butler/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/daf_butler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/daf_butler/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/daf_butler/languages","stargazers_url":"https://api.github.com/repos/lsst/daf_butler/stargazers","contributors_url":"https://api.github.com/repos/lsst/daf_butler/contributors","subscribers_url":"https://api.github.com/repos/lsst/daf_butler/subscribers","subscription_url":"https://api.github.com/repos/lsst/daf_butler/subscription","commits_url":"https://api.github.com/repos/lsst/daf_butler/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/daf_butler/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/daf_butler/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/daf_butler/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/daf_butler/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/daf_butler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/daf_butler/merges","archive_url":"https://api.github.com/repos/lsst/daf_butler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/daf_butler/downloads","issues_url":"https://api.github.com/repos/lsst/daf_butler/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/daf_butler/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/daf_butler/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/daf_butler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/daf_butler/labels{/name}","releases_url":"https://api.github.com/repos/lsst/daf_butler/releases{/id}","deployments_url":"https://api.github.com/repos/lsst/daf_butler/deployments","created_at":"2017-10-13T21:03:25Z","updated_at":"2018-09-01T22:54:01Z","pushed_at":"2018-09-05T21:14:20Z","git_url":"git://github.com/lsst/daf_butler.git","ssh_url":"git@github.com:lsst/daf_butler.git","clone_url":"https://github.com/lsst/daf_butler.git","svn_url":"https://github.com/lsst/daf_butler","homepage":null,"size":1159,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":3,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"lsst:master","ref":"master","sha":"873d001ffec504b78448ce04f8cd0ab4b199b8b9","user":{"login":"lsst","id":1134504,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMzQ1MDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1134504?v=4","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":106873149,"node_id":"MDEwOlJlcG9zaXRvcnkxMDY4NzMxNDk=","name":"daf_butler","full_name":"lsst/daf_butler","owner":{"login":"lsst","id":1134504,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMzQ1MDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1134504?v=4","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/daf_butler","description":"Prototype for data access framework described in DMTN-056","fork":false,"url":"https://api.github.com/repos/lsst/daf_butler","forks_url":"https://api.github.com/repos/lsst/daf_butler/forks","keys_url":"https://api.github.com/repos/lsst/daf_butler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/daf_butler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/daf_butler/teams","hooks_url":"https://api.github.com/repos/lsst/daf_butler/hooks","issue_events_url":"https://api.github.com/repos/lsst/daf_butler/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/daf_butler/events","assignees_url":"https://api.github.com/repos/lsst/daf_butler/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/daf_butler/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/daf_butler/tags","blobs_url":"https://api.github.com/repos/lsst/daf_butler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/daf_butler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/daf_butler/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/daf_butler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/daf_butler/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/daf_butler/languages","stargazers_url":"https://api.github.com/repos/lsst/daf_butler/stargazers","contributors_url":"https://api.github.com/repos/lsst/daf_butler/contributors","subscribers_url":"https://api.github.com/repos/lsst/daf_butler/subscribers","subscription_url":"https://api.github.com/repos/lsst/daf_butler/subscription","commits_url":"https://api.github.com/repos/lsst/daf_butler/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/daf_butler/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/daf_butler/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/daf_butler/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/daf_butler/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/daf_butler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/daf_butler/merges","archive_url":"https://api.github.com/repos/lsst/daf_butler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/daf_butler/downloads","issues_url":"https://api.github.com/repos/lsst/daf_butler/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/daf_butler/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/daf_butler/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/daf_butler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/daf_butler/labels{/name}","releases_url":"https://api.github.com/repos/lsst/daf_butler/releases{/id}","deployments_url":"https://api.github.com/repos/lsst/daf_butler/deployments","created_at":"2017-10-13T21:03:25Z","updated_at":"2018-09-01T22:54:01Z","pushed_at":"2018-09-05T21:14:20Z","git_url":"git://github.com/lsst/daf_butler.git","ssh_url":"git@github.com:lsst/daf_butler.git","clone_url":"https://github.com/lsst/daf_butler.git","svn_url":"https://github.com/lsst/daf_butler","homepage":null,"size":1159,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":3,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lsst/daf_butler/pulls/84"},"html":{"href":"https://github.com/lsst/daf_butler/pull/84"},"issue":{"href":"https://api.github.com/repos/lsst/daf_butler/issues/84"},"comments":{"href":"https://api.github.com/repos/lsst/daf_butler/issues/84/comments"},"review_comments":{"href":"https://api.github.com/repos/lsst/daf_butler/pulls/84/comments"},"review_comment":{"href":"https://api.github.com/repos/lsst/daf_butler/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lsst/daf_butler/pulls/84/commits"},"statuses":{"href":"https://api.github.com/repos/lsst/daf_butler/statuses/6a330a44bb507ac9219c8fe2be8cd020c43e231f"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ktlim"}}