{"action":"created","comment":{"url":"https://api.github.com/repos/yast/yast-yast2/pulls/comments/68189707","id":68189707,"diff_hunk":"@@ -693,79 +708,78 @@ def ConcealSecrets(devs)\n       \"IP_OPTIONS\"\n     ]\n \n-    # Read devices from files\n+    def generate_config(pth, values)\n+      config = {}\n+      values.each do |val|\n+        item = SCR.Read(path(\"#{pth}.#{val}\"))\n+        log.debug(\"item=#{item}\")\n+        next if item.nil?\n+        # No underscore '_' -> global\n+        # Also temporarily standard globals\n+        if !val.include?(\"_\") || LOCALS.include?(val)\n+          config[val] = item\n+          next\n+        end\n+\n+        # Try to strip _suffix\n+        # @example \"IP_OPTIONS_1\".rpartition(\"_\") => [\"IP_OPTIONS\", \"_\", \"1\"]\n+        v, _j, s = val.rpartition(\"_\")\n+        log.info(\"#{val}:#{v}:#{s}\")\n+        # Global\n+        if !LOCALS.include?(v)\n+          config[val] = item\n+        else\n+          config[\"_aliases\"] ||= {}\n+          config[\"_aliases\"][s] ||= {}\n+          config[\"_aliases\"][s][v] = item\n+        end\n+      end\n+      log.info(\"config=#{ConcealSecrets1(config)}\")\n+      config = canonicalize_config(config)\n+      filter_interfacetype(config)\n+    end\n+\n+    def set_devtype_config(device, config)\n+      devtype = GetTypeFromIfcfg(config) || GetType(device)\n+      @Devices[devtype] ||= {}\n+      @Devices[devtype][device] = config\n+    end\n+\n+    # Read devices from files and cache it\n     # @return true if sucess\n     def Read\n       return true if @initialized == true\n \n       @Devices = {}\n \n       # preparation\n-      allfiles = SCR.Dir(path(\".network.section\"))\n-      allfiles = [] if allfiles.nil?\n-      devices = Builtins.filter(allfiles) do |file|\n-        !Builtins.regexpmatch(file, \"[~]\")\n-      end\n-      Builtins.y2debug(\"devices=%1\", devices)\n+      devices = get_devices\n \n       # Read devices\n-      Builtins.maplist(devices) do |d|\n-        pth = Ops.add(Ops.add(\".network.value.\\\"\", d), \"\\\"\")\n-        Builtins.y2debug(\"pth=%1\", pth)\n-        values = SCR.Dir(Builtins.topath(pth))\n-        Builtins.y2debug(\"values=%1\", values)\n-        config = {}\n-        Builtins.maplist(values) do |val|\n-          item = Convert.to_string(\n-            SCR.Read(Builtins.topath(Ops.add(Ops.add(pth, \".\"), val)))\n-          )\n-          Builtins.y2debug(\"item=%1\", item)\n-          next if item.nil?\n-          # No underscore '_' -> global\n-          # Also temporarily standard globals\n-          if Ops.less_than(Builtins.find(val, \"_\"), 0) ||\n-              LOCALS.include?(val)\n-            Ops.set(config, val, item)\n-            next\n-          end\n-          # Try to strip _suffix\n-          v = Builtins.substring(val, 0, Builtins.findlastof(val, \"_\"))\n-          s = Builtins.substring(val, Builtins.findlastof(val, \"_\"))\n-          s = Builtins.substring(s, 1) if Ops.greater_than(Builtins.size(s), 1)\n-          Builtins.y2milestone(\"%1:%2:%3\", val, v, s)\n-          # Global\n-          if !LOCALS.include?(v)\n-            Ops.set(config, val, item)\n-          else\n-            aliases = Ops.get_map(config, \"_aliases\", {})\n-            suf = Ops.get_map(aliases, s, {})\n-            Ops.set(suf, v, item)\n-            Ops.set(aliases, s, suf)\n-            Ops.set(config, \"_aliases\", aliases)\n-          end\n-        end\n-        Builtins.y2milestone(\"config=%1\", ConcealSecrets1(config))\n-        # canonicalize, #46885\n-        caliases = Builtins.mapmap(Ops.get_map(config, \"_aliases\", {})) do |a, c|\n-          { a => CanonicalizeIP(c) }\n-        end\n-        config[\"_aliases\"] = caliases if caliases != {}\n-        config = CanonicalizeIP(config)\n-        config = CanonicalizeStartmode(config)\n-        config = filter_interfacetype(config)\n+      devices.each do |d|\n+        pth = \".network.value.\\\"#{d}\\\"\"\n+        log.debug(\"pth=#{pth}\")\n+\n+        values = SCR.Dir(path(pth))\n+        log.debug(\"values=#{values}\")\n \n-        devtype = GetTypeFromIfcfg(config)\n-        devtype = GetType(d) if devtype.nil?\n+        config = generate_config(pth, values)\n \n-        dev = @Devices[devtype] || {}\n-        dev[d] = config\n-        @Devices[devtype] = dev\n+        set_devtype_config(d, config)\n       end\n-      Builtins.y2debug(\"Devices=%1\", @Devices)\n+      log.debug(\"Devices=#{@Devices}\")\n \n       @OriginalDevices = deep_copy(@Devices)\n       @initialized = true\n-      true\n+    end\n+\n+    def Reset","path":"library/network/src/modules/NetworkInterfaces.rb","position":322,"original_position":322,"commit_id":"bf58da6d91294f1703d0b74df6d29026da294a12","original_commit_id":"bf58da6d91294f1703d0b74df6d29026da294a12","user":{"login":"mchf","id":1579239,"avatar_url":"https://avatars.githubusercontent.com/u/1579239?v=3","gravatar_id":"","url":"https://api.github.com/users/mchf","html_url":"https://github.com/mchf","followers_url":"https://api.github.com/users/mchf/followers","following_url":"https://api.github.com/users/mchf/following{/other_user}","gists_url":"https://api.github.com/users/mchf/gists{/gist_id}","starred_url":"https://api.github.com/users/mchf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mchf/subscriptions","organizations_url":"https://api.github.com/users/mchf/orgs","repos_url":"https://api.github.com/users/mchf/repos","events_url":"https://api.github.com/users/mchf/events{/privacy}","received_events_url":"https://api.github.com/users/mchf/received_events","type":"User","site_admin":false},"body":"I'm not that sure that creating method which is used only in test is good idea. Or did I overlooked something again?","created_at":"2016-06-23T07:49:58Z","updated_at":"2016-06-23T07:49:58Z","html_url":"https://github.com/yast/yast-yast2/pull/433#discussion_r68189707","pull_request_url":"https://api.github.com/repos/yast/yast-yast2/pulls/433","_links":{"self":{"href":"https://api.github.com/repos/yast/yast-yast2/pulls/comments/68189707"},"html":{"href":"https://github.com/yast/yast-yast2/pull/433#discussion_r68189707"},"pull_request":{"href":"https://api.github.com/repos/yast/yast-yast2/pulls/433"}}},"pull_request":{"url":"https://api.github.com/repos/yast/yast-yast2/pulls/433","id":58120474,"html_url":"https://github.com/yast/yast-yast2/pull/433","diff_url":"https://github.com/yast/yast-yast2/pull/433.diff","patch_url":"https://github.com/yast/yast-yast2/pull/433.patch","issue_url":"https://api.github.com/repos/yast/yast-yast2/issues/433","number":433,"state":"open","locked":false,"title":"Cleanup NetworkInterfaces.Read (bsc#982850)","user":{"login":"teclator","id":7056681,"avatar_url":"https://avatars.githubusercontent.com/u/7056681?v=3","gravatar_id":"","url":"https://api.github.com/users/teclator","html_url":"https://github.com/teclator","followers_url":"https://api.github.com/users/teclator/followers","following_url":"https://api.github.com/users/teclator/following{/other_user}","gists_url":"https://api.github.com/users/teclator/gists{/gist_id}","starred_url":"https://api.github.com/users/teclator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teclator/subscriptions","organizations_url":"https://api.github.com/users/teclator/orgs","repos_url":"https://api.github.com/users/teclator/repos","events_url":"https://api.github.com/users/teclator/events{/privacy}","received_events_url":"https://api.github.com/users/teclator/received_events","type":"User","site_admin":false},"body":"In general the goal of this PR is to improve the readability of ```NetworkInterfaces.Read``` and also take the opportunity to clean up some code.\r\n\r\nhttps://trello.com/c/FXPO8MLz","created_at":"2016-02-03T10:53:57Z","updated_at":"2016-06-23T07:49:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"462764083fcfecf52e6ec59463140fd8c9fac973","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yast/yast-yast2/pulls/433/commits","review_comments_url":"https://api.github.com/repos/yast/yast-yast2/pulls/433/comments","review_comment_url":"https://api.github.com/repos/yast/yast-yast2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yast/yast-yast2/issues/433/comments","statuses_url":"https://api.github.com/repos/yast/yast-yast2/statuses/bf58da6d91294f1703d0b74df6d29026da294a12","head":{"label":"teclator:network-test","ref":"network-test","sha":"bf58da6d91294f1703d0b74df6d29026da294a12","user":{"login":"teclator","id":7056681,"avatar_url":"https://avatars.githubusercontent.com/u/7056681?v=3","gravatar_id":"","url":"https://api.github.com/users/teclator","html_url":"https://github.com/teclator","followers_url":"https://api.github.com/users/teclator/followers","following_url":"https://api.github.com/users/teclator/following{/other_user}","gists_url":"https://api.github.com/users/teclator/gists{/gist_id}","starred_url":"https://api.github.com/users/teclator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teclator/subscriptions","organizations_url":"https://api.github.com/users/teclator/orgs","repos_url":"https://api.github.com/users/teclator/repos","events_url":"https://api.github.com/users/teclator/events{/privacy}","received_events_url":"https://api.github.com/users/teclator/received_events","type":"User","site_admin":false},"repo":{"id":49513012,"name":"yast-yast2","full_name":"teclator/yast-yast2","owner":{"login":"teclator","id":7056681,"avatar_url":"https://avatars.githubusercontent.com/u/7056681?v=3","gravatar_id":"","url":"https://api.github.com/users/teclator","html_url":"https://github.com/teclator","followers_url":"https://api.github.com/users/teclator/followers","following_url":"https://api.github.com/users/teclator/following{/other_user}","gists_url":"https://api.github.com/users/teclator/gists{/gist_id}","starred_url":"https://api.github.com/users/teclator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teclator/subscriptions","organizations_url":"https://api.github.com/users/teclator/orgs","repos_url":"https://api.github.com/users/teclator/repos","events_url":"https://api.github.com/users/teclator/events{/privacy}","received_events_url":"https://api.github.com/users/teclator/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/teclator/yast-yast2","description":"YaST module yast2","fork":true,"url":"https://api.github.com/repos/teclator/yast-yast2","forks_url":"https://api.github.com/repos/teclator/yast-yast2/forks","keys_url":"https://api.github.com/repos/teclator/yast-yast2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teclator/yast-yast2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teclator/yast-yast2/teams","hooks_url":"https://api.github.com/repos/teclator/yast-yast2/hooks","issue_events_url":"https://api.github.com/repos/teclator/yast-yast2/issues/events{/number}","events_url":"https://api.github.com/repos/teclator/yast-yast2/events","assignees_url":"https://api.github.com/repos/teclator/yast-yast2/assignees{/user}","branches_url":"https://api.github.com/repos/teclator/yast-yast2/branches{/branch}","tags_url":"https://api.github.com/repos/teclator/yast-yast2/tags","blobs_url":"https://api.github.com/repos/teclator/yast-yast2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teclator/yast-yast2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teclator/yast-yast2/git/refs{/sha}","trees_url":"https://api.github.com/repos/teclator/yast-yast2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teclator/yast-yast2/statuses/{sha}","languages_url":"https://api.github.com/repos/teclator/yast-yast2/languages","stargazers_url":"https://api.github.com/repos/teclator/yast-yast2/stargazers","contributors_url":"https://api.github.com/repos/teclator/yast-yast2/contributors","subscribers_url":"https://api.github.com/repos/teclator/yast-yast2/subscribers","subscription_url":"https://api.github.com/repos/teclator/yast-yast2/subscription","commits_url":"https://api.github.com/repos/teclator/yast-yast2/commits{/sha}","git_commits_url":"https://api.github.com/repos/teclator/yast-yast2/git/commits{/sha}","comments_url":"https://api.github.com/repos/teclator/yast-yast2/comments{/number}","issue_comment_url":"https://api.github.com/repos/teclator/yast-yast2/issues/comments{/number}","contents_url":"https://api.github.com/repos/teclator/yast-yast2/contents/{+path}","compare_url":"https://api.github.com/repos/teclator/yast-yast2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teclator/yast-yast2/merges","archive_url":"https://api.github.com/repos/teclator/yast-yast2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teclator/yast-yast2/downloads","issues_url":"https://api.github.com/repos/teclator/yast-yast2/issues{/number}","pulls_url":"https://api.github.com/repos/teclator/yast-yast2/pulls{/number}","milestones_url":"https://api.github.com/repos/teclator/yast-yast2/milestones{/number}","notifications_url":"https://api.github.com/repos/teclator/yast-yast2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teclator/yast-yast2/labels{/name}","releases_url":"https://api.github.com/repos/teclator/yast-yast2/releases{/id}","deployments_url":"https://api.github.com/repos/teclator/yast-yast2/deployments","created_at":"2016-01-12T16:27:36Z","updated_at":"2016-01-12T16:27:38Z","pushed_at":"2016-06-21T09:08:56Z","git_url":"git://github.com/teclator/yast-yast2.git","ssh_url":"git@github.com:teclator/yast-yast2.git","clone_url":"https://github.com/teclator/yast-yast2.git","svn_url":"https://github.com/teclator/yast-yast2","homepage":"http://en.opensuse.org/Portal:YaST","size":23825,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"yast:master","ref":"master","sha":"905a522beee822be2ccbc0d8f6fb07ab4b165885","user":{"login":"yast","id":909990,"avatar_url":"https://avatars.githubusercontent.com/u/909990?v=3","gravatar_id":"","url":"https://api.github.com/users/yast","html_url":"https://github.com/yast","followers_url":"https://api.github.com/users/yast/followers","following_url":"https://api.github.com/users/yast/following{/other_user}","gists_url":"https://api.github.com/users/yast/gists{/gist_id}","starred_url":"https://api.github.com/users/yast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yast/subscriptions","organizations_url":"https://api.github.com/users/yast/orgs","repos_url":"https://api.github.com/users/yast/repos","events_url":"https://api.github.com/users/yast/events{/privacy}","received_events_url":"https://api.github.com/users/yast/received_events","type":"Organization","site_admin":false},"repo":{"id":4368244,"name":"yast-yast2","full_name":"yast/yast-yast2","owner":{"login":"yast","id":909990,"avatar_url":"https://avatars.githubusercontent.com/u/909990?v=3","gravatar_id":"","url":"https://api.github.com/users/yast","html_url":"https://github.com/yast","followers_url":"https://api.github.com/users/yast/followers","following_url":"https://api.github.com/users/yast/following{/other_user}","gists_url":"https://api.github.com/users/yast/gists{/gist_id}","starred_url":"https://api.github.com/users/yast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yast/subscriptions","organizations_url":"https://api.github.com/users/yast/orgs","repos_url":"https://api.github.com/users/yast/repos","events_url":"https://api.github.com/users/yast/events{/privacy}","received_events_url":"https://api.github.com/users/yast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yast/yast-yast2","description":"YaST module yast2","fork":false,"url":"https://api.github.com/repos/yast/yast-yast2","forks_url":"https://api.github.com/repos/yast/yast-yast2/forks","keys_url":"https://api.github.com/repos/yast/yast-yast2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yast/yast-yast2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yast/yast-yast2/teams","hooks_url":"https://api.github.com/repos/yast/yast-yast2/hooks","issue_events_url":"https://api.github.com/repos/yast/yast-yast2/issues/events{/number}","events_url":"https://api.github.com/repos/yast/yast-yast2/events","assignees_url":"https://api.github.com/repos/yast/yast-yast2/assignees{/user}","branches_url":"https://api.github.com/repos/yast/yast-yast2/branches{/branch}","tags_url":"https://api.github.com/repos/yast/yast-yast2/tags","blobs_url":"https://api.github.com/repos/yast/yast-yast2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yast/yast-yast2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yast/yast-yast2/git/refs{/sha}","trees_url":"https://api.github.com/repos/yast/yast-yast2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yast/yast-yast2/statuses/{sha}","languages_url":"https://api.github.com/repos/yast/yast-yast2/languages","stargazers_url":"https://api.github.com/repos/yast/yast-yast2/stargazers","contributors_url":"https://api.github.com/repos/yast/yast-yast2/contributors","subscribers_url":"https://api.github.com/repos/yast/yast-yast2/subscribers","subscription_url":"https://api.github.com/repos/yast/yast-yast2/subscription","commits_url":"https://api.github.com/repos/yast/yast-yast2/commits{/sha}","git_commits_url":"https://api.github.com/repos/yast/yast-yast2/git/commits{/sha}","comments_url":"https://api.github.com/repos/yast/yast-yast2/comments{/number}","issue_comment_url":"https://api.github.com/repos/yast/yast-yast2/issues/comments{/number}","contents_url":"https://api.github.com/repos/yast/yast-yast2/contents/{+path}","compare_url":"https://api.github.com/repos/yast/yast-yast2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yast/yast-yast2/merges","archive_url":"https://api.github.com/repos/yast/yast-yast2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yast/yast-yast2/downloads","issues_url":"https://api.github.com/repos/yast/yast-yast2/issues{/number}","pulls_url":"https://api.github.com/repos/yast/yast-yast2/pulls{/number}","milestones_url":"https://api.github.com/repos/yast/yast-yast2/milestones{/number}","notifications_url":"https://api.github.com/repos/yast/yast-yast2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yast/yast-yast2/labels{/name}","releases_url":"https://api.github.com/repos/yast/yast-yast2/releases{/id}","deployments_url":"https://api.github.com/repos/yast/yast-yast2/deployments","created_at":"2012-05-18T10:27:22Z","updated_at":"2016-06-14T20:49:12Z","pushed_at":"2016-06-22T09:23:35Z","git_url":"git://github.com/yast/yast-yast2.git","ssh_url":"git@github.com:yast/yast-yast2.git","clone_url":"https://github.com/yast/yast-yast2.git","svn_url":"https://github.com/yast/yast-yast2","homepage":"http://en.opensuse.org/Portal:YaST","size":25086,"stargazers_count":16,"watchers_count":16,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":7,"forks":27,"open_issues":7,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yast/yast-yast2/pulls/433"},"html":{"href":"https://github.com/yast/yast-yast2/pull/433"},"issue":{"href":"https://api.github.com/repos/yast/yast-yast2/issues/433"},"comments":{"href":"https://api.github.com/repos/yast/yast-yast2/issues/433/comments"},"review_comments":{"href":"https://api.github.com/repos/yast/yast-yast2/pulls/433/comments"},"review_comment":{"href":"https://api.github.com/repos/yast/yast-yast2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yast/yast-yast2/pulls/433/commits"},"statuses":{"href":"https://api.github.com/repos/yast/yast-yast2/statuses/bf58da6d91294f1703d0b74df6d29026da294a12"}}}}
{"actor":{"display_login":"mchf"}}