{"action":"created","comment":{"url":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/comments/50483188","id":50483188,"diff_hunk":"@@ -0,0 +1,219 @@\n+import sys\n+import os\n+import logging\n+from argparse import ArgumentParser\n+\n+from sqlalchemy import create_engine\n+from sqlalchemy.orm import sessionmaker\n+from modelmeta import DataFile, DataFileVariable, Ensemble, EnsembleDataFileVariables\n+\n+from lxml import etree\n+\n+log = logging.getLogger(__name__)\n+\n+def get_variable(id, title, colorScaleRange, palette=\"rainbow\", scaling=\"linear\", numColorBands=\"250\", disabled=\"false\"):\n+    return etree.Element(\n+        \"variable\",\n+        id = id,\n+        title = title,\n+        colorScaleRange = colorScaleRange,\n+        palette = palette,\n+        scaling = scaling,\n+        numColorBands = numColorBands,\n+        disabled = disabled\n+    )\n+\n+\n+def get_dataset(id, location, title, queryable=\"true\", dataReaderClass=\"\", copyrightStatement=\"\", moreInfo=\"\", disabled=\"false\", updateInterval=\"-1\"):\n+    return etree.Element(\n+        \"dataset\",\n+        id = id,\n+        location = location,\n+        title = title,\n+        queryable = queryable,\n+        dataReaderClass = dataReaderClass,\n+        copyrightStatement = copyrightStatement,\n+        moreInfo = moreInfo,\n+        disabled = disabled,\n+        updateInterval = updateInterval\n+    )\n+\n+\n+\n+\n+def get_contact(name = \"\", organization = \"\", telephone = \"\", email = \"\"):\n+    root = etree.Element(\"contact\")\n+    etree.SubElement(root, \"name\").text = name\n+    etree.SubElement(root, \"organization\").text = organization\n+    etree.SubElement(root, \"telephone\").text = telephone\n+    etree.SubElement(root, \"email\").text = email\n+    return root\n+","path":"ncwms_configurator/ncwms_configurator.py","position":51,"original_position":51,"commit_id":"e36b6a28ef0f797d2d7cb376846a97a4425f1247","original_commit_id":"e36b6a28ef0f797d2d7cb376846a97a4425f1247","user":{"login":"jameshiebert","id":3904316,"avatar_url":"https://avatars.githubusercontent.com/u/3904316?v=3","gravatar_id":"","url":"https://api.github.com/users/jameshiebert","html_url":"https://github.com/jameshiebert","followers_url":"https://api.github.com/users/jameshiebert/followers","following_url":"https://api.github.com/users/jameshiebert/following{/other_user}","gists_url":"https://api.github.com/users/jameshiebert/gists{/gist_id}","starred_url":"https://api.github.com/users/jameshiebert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jameshiebert/subscriptions","organizations_url":"https://api.github.com/users/jameshiebert/orgs","repos_url":"https://api.github.com/users/jameshiebert/repos","events_url":"https://api.github.com/users/jameshiebert/events{/privacy}","received_events_url":"https://api.github.com/users/jameshiebert/received_events","type":"User","site_admin":false},"body":"All of these `get_*()` functions are very clear in what they do, but they're a bit verbose and repetitive. For example, `get_contact()` could as easily be:\r\n\r\n```python\r\ndef get_contact(**kwargs):\r\n    root = etree.Element(\"contact\")\r\n    for k, v in kwargs:\r\n        etree.SubElement(root, k).text = v\r\n    return root\r\n```\r\n\r\nAnd you can further generalize that by adding the element type as a parameter and then it covers `get_server()` and `get_cache()` as well. E.g.\r\n\r\n```python\r\ndef get_element(element_name, **kwargs):\r\n    root = etree.Element(element_name)\r\n    ...\r\n```\r\n\r\nDownside is that the required keyword args aren't explicit, but that could easily be included.\r\n\r\nIt might be worth the time to refactor these functions in that way. What do you think?","created_at":"2016-01-21T23:42:23Z","updated_at":"2016-01-21T23:42:23Z","html_url":"https://github.com/pacificclimate/modelmeta/pull/2#discussion_r50483188","pull_request_url":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/comments/50483188"},"html":{"href":"https://github.com/pacificclimate/modelmeta/pull/2#discussion_r50483188"},"pull_request":{"href":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/2","id":56801231,"html_url":"https://github.com/pacificclimate/modelmeta/pull/2","diff_url":"https://github.com/pacificclimate/modelmeta/pull/2.diff","patch_url":"https://github.com/pacificclimate/modelmeta/pull/2.patch","issue_url":"https://api.github.com/repos/pacificclimate/modelmeta/issues/2","number":2,"state":"open","locked":false,"title":"Add ncwms config generator","user":{"login":"basilveerman","id":4664995,"avatar_url":"https://avatars.githubusercontent.com/u/4664995?v=3","gravatar_id":"","url":"https://api.github.com/users/basilveerman","html_url":"https://github.com/basilveerman","followers_url":"https://api.github.com/users/basilveerman/followers","following_url":"https://api.github.com/users/basilveerman/following{/other_user}","gists_url":"https://api.github.com/users/basilveerman/gists{/gist_id}","starred_url":"https://api.github.com/users/basilveerman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basilveerman/subscriptions","organizations_url":"https://api.github.com/users/basilveerman/orgs","repos_url":"https://api.github.com/users/basilveerman/repos","events_url":"https://api.github.com/users/basilveerman/events{/privacy}","received_events_url":"https://api.github.com/users/basilveerman/received_events","type":"User","site_admin":false},"body":"Updating or adding to an existing config is not yet implemented, but possible to add later.\r\n\r\nTested on ncWMS 1.2.","created_at":"2016-01-21T20:03:04Z","updated_at":"2016-01-21T23:42:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db7a19b85e795d48b1324a2379a83611a9399a09","assignee":{"login":"jameshiebert","id":3904316,"avatar_url":"https://avatars.githubusercontent.com/u/3904316?v=3","gravatar_id":"","url":"https://api.github.com/users/jameshiebert","html_url":"https://github.com/jameshiebert","followers_url":"https://api.github.com/users/jameshiebert/followers","following_url":"https://api.github.com/users/jameshiebert/following{/other_user}","gists_url":"https://api.github.com/users/jameshiebert/gists{/gist_id}","starred_url":"https://api.github.com/users/jameshiebert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jameshiebert/subscriptions","organizations_url":"https://api.github.com/users/jameshiebert/orgs","repos_url":"https://api.github.com/users/jameshiebert/repos","events_url":"https://api.github.com/users/jameshiebert/events{/privacy}","received_events_url":"https://api.github.com/users/jameshiebert/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/2/commits","review_comments_url":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/2/comments","review_comment_url":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pacificclimate/modelmeta/issues/2/comments","statuses_url":"https://api.github.com/repos/pacificclimate/modelmeta/statuses/e36b6a28ef0f797d2d7cb376846a97a4425f1247","head":{"label":"pacificclimate:feature/ncwms_config_exporter","ref":"feature/ncwms_config_exporter","sha":"e36b6a28ef0f797d2d7cb376846a97a4425f1247","user":{"login":"pacificclimate","id":7443397,"avatar_url":"https://avatars.githubusercontent.com/u/7443397?v=3","gravatar_id":"","url":"https://api.github.com/users/pacificclimate","html_url":"https://github.com/pacificclimate","followers_url":"https://api.github.com/users/pacificclimate/followers","following_url":"https://api.github.com/users/pacificclimate/following{/other_user}","gists_url":"https://api.github.com/users/pacificclimate/gists{/gist_id}","starred_url":"https://api.github.com/users/pacificclimate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pacificclimate/subscriptions","organizations_url":"https://api.github.com/users/pacificclimate/orgs","repos_url":"https://api.github.com/users/pacificclimate/repos","events_url":"https://api.github.com/users/pacificclimate/events{/privacy}","received_events_url":"https://api.github.com/users/pacificclimate/received_events","type":"Organization","site_admin":false},"repo":{"id":19622573,"name":"modelmeta","full_name":"pacificclimate/modelmeta","owner":{"login":"pacificclimate","id":7443397,"avatar_url":"https://avatars.githubusercontent.com/u/7443397?v=3","gravatar_id":"","url":"https://api.github.com/users/pacificclimate","html_url":"https://github.com/pacificclimate","followers_url":"https://api.github.com/users/pacificclimate/followers","following_url":"https://api.github.com/users/pacificclimate/following{/other_user}","gists_url":"https://api.github.com/users/pacificclimate/gists{/gist_id}","starred_url":"https://api.github.com/users/pacificclimate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pacificclimate/subscriptions","organizations_url":"https://api.github.com/users/pacificclimate/orgs","repos_url":"https://api.github.com/users/pacificclimate/repos","events_url":"https://api.github.com/users/pacificclimate/events{/privacy}","received_events_url":"https://api.github.com/users/pacificclimate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pacificclimate/modelmeta","description":"An ORM representation of the model metadata database","fork":false,"url":"https://api.github.com/repos/pacificclimate/modelmeta","forks_url":"https://api.github.com/repos/pacificclimate/modelmeta/forks","keys_url":"https://api.github.com/repos/pacificclimate/modelmeta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pacificclimate/modelmeta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pacificclimate/modelmeta/teams","hooks_url":"https://api.github.com/repos/pacificclimate/modelmeta/hooks","issue_events_url":"https://api.github.com/repos/pacificclimate/modelmeta/issues/events{/number}","events_url":"https://api.github.com/repos/pacificclimate/modelmeta/events","assignees_url":"https://api.github.com/repos/pacificclimate/modelmeta/assignees{/user}","branches_url":"https://api.github.com/repos/pacificclimate/modelmeta/branches{/branch}","tags_url":"https://api.github.com/repos/pacificclimate/modelmeta/tags","blobs_url":"https://api.github.com/repos/pacificclimate/modelmeta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pacificclimate/modelmeta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pacificclimate/modelmeta/git/refs{/sha}","trees_url":"https://api.github.com/repos/pacificclimate/modelmeta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pacificclimate/modelmeta/statuses/{sha}","languages_url":"https://api.github.com/repos/pacificclimate/modelmeta/languages","stargazers_url":"https://api.github.com/repos/pacificclimate/modelmeta/stargazers","contributors_url":"https://api.github.com/repos/pacificclimate/modelmeta/contributors","subscribers_url":"https://api.github.com/repos/pacificclimate/modelmeta/subscribers","subscription_url":"https://api.github.com/repos/pacificclimate/modelmeta/subscription","commits_url":"https://api.github.com/repos/pacificclimate/modelmeta/commits{/sha}","git_commits_url":"https://api.github.com/repos/pacificclimate/modelmeta/git/commits{/sha}","comments_url":"https://api.github.com/repos/pacificclimate/modelmeta/comments{/number}","issue_comment_url":"https://api.github.com/repos/pacificclimate/modelmeta/issues/comments{/number}","contents_url":"https://api.github.com/repos/pacificclimate/modelmeta/contents/{+path}","compare_url":"https://api.github.com/repos/pacificclimate/modelmeta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pacificclimate/modelmeta/merges","archive_url":"https://api.github.com/repos/pacificclimate/modelmeta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pacificclimate/modelmeta/downloads","issues_url":"https://api.github.com/repos/pacificclimate/modelmeta/issues{/number}","pulls_url":"https://api.github.com/repos/pacificclimate/modelmeta/pulls{/number}","milestones_url":"https://api.github.com/repos/pacificclimate/modelmeta/milestones{/number}","notifications_url":"https://api.github.com/repos/pacificclimate/modelmeta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pacificclimate/modelmeta/labels{/name}","releases_url":"https://api.github.com/repos/pacificclimate/modelmeta/releases{/id}","deployments_url":"https://api.github.com/repos/pacificclimate/modelmeta/deployments","created_at":"2014-05-09T19:18:14Z","updated_at":"2016-01-11T21:09:12Z","pushed_at":"2016-01-21T20:03:04Z","git_url":"git://github.com/pacificclimate/modelmeta.git","ssh_url":"git@github.com:pacificclimate/modelmeta.git","clone_url":"https://github.com/pacificclimate/modelmeta.git","svn_url":"https://github.com/pacificclimate/modelmeta","homepage":null,"size":139,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"pacificclimate:master","ref":"master","sha":"407e0f70c65e6014a30fe4e595b36fa653e99d26","user":{"login":"pacificclimate","id":7443397,"avatar_url":"https://avatars.githubusercontent.com/u/7443397?v=3","gravatar_id":"","url":"https://api.github.com/users/pacificclimate","html_url":"https://github.com/pacificclimate","followers_url":"https://api.github.com/users/pacificclimate/followers","following_url":"https://api.github.com/users/pacificclimate/following{/other_user}","gists_url":"https://api.github.com/users/pacificclimate/gists{/gist_id}","starred_url":"https://api.github.com/users/pacificclimate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pacificclimate/subscriptions","organizations_url":"https://api.github.com/users/pacificclimate/orgs","repos_url":"https://api.github.com/users/pacificclimate/repos","events_url":"https://api.github.com/users/pacificclimate/events{/privacy}","received_events_url":"https://api.github.com/users/pacificclimate/received_events","type":"Organization","site_admin":false},"repo":{"id":19622573,"name":"modelmeta","full_name":"pacificclimate/modelmeta","owner":{"login":"pacificclimate","id":7443397,"avatar_url":"https://avatars.githubusercontent.com/u/7443397?v=3","gravatar_id":"","url":"https://api.github.com/users/pacificclimate","html_url":"https://github.com/pacificclimate","followers_url":"https://api.github.com/users/pacificclimate/followers","following_url":"https://api.github.com/users/pacificclimate/following{/other_user}","gists_url":"https://api.github.com/users/pacificclimate/gists{/gist_id}","starred_url":"https://api.github.com/users/pacificclimate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pacificclimate/subscriptions","organizations_url":"https://api.github.com/users/pacificclimate/orgs","repos_url":"https://api.github.com/users/pacificclimate/repos","events_url":"https://api.github.com/users/pacificclimate/events{/privacy}","received_events_url":"https://api.github.com/users/pacificclimate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pacificclimate/modelmeta","description":"An ORM representation of the model metadata database","fork":false,"url":"https://api.github.com/repos/pacificclimate/modelmeta","forks_url":"https://api.github.com/repos/pacificclimate/modelmeta/forks","keys_url":"https://api.github.com/repos/pacificclimate/modelmeta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pacificclimate/modelmeta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pacificclimate/modelmeta/teams","hooks_url":"https://api.github.com/repos/pacificclimate/modelmeta/hooks","issue_events_url":"https://api.github.com/repos/pacificclimate/modelmeta/issues/events{/number}","events_url":"https://api.github.com/repos/pacificclimate/modelmeta/events","assignees_url":"https://api.github.com/repos/pacificclimate/modelmeta/assignees{/user}","branches_url":"https://api.github.com/repos/pacificclimate/modelmeta/branches{/branch}","tags_url":"https://api.github.com/repos/pacificclimate/modelmeta/tags","blobs_url":"https://api.github.com/repos/pacificclimate/modelmeta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pacificclimate/modelmeta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pacificclimate/modelmeta/git/refs{/sha}","trees_url":"https://api.github.com/repos/pacificclimate/modelmeta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pacificclimate/modelmeta/statuses/{sha}","languages_url":"https://api.github.com/repos/pacificclimate/modelmeta/languages","stargazers_url":"https://api.github.com/repos/pacificclimate/modelmeta/stargazers","contributors_url":"https://api.github.com/repos/pacificclimate/modelmeta/contributors","subscribers_url":"https://api.github.com/repos/pacificclimate/modelmeta/subscribers","subscription_url":"https://api.github.com/repos/pacificclimate/modelmeta/subscription","commits_url":"https://api.github.com/repos/pacificclimate/modelmeta/commits{/sha}","git_commits_url":"https://api.github.com/repos/pacificclimate/modelmeta/git/commits{/sha}","comments_url":"https://api.github.com/repos/pacificclimate/modelmeta/comments{/number}","issue_comment_url":"https://api.github.com/repos/pacificclimate/modelmeta/issues/comments{/number}","contents_url":"https://api.github.com/repos/pacificclimate/modelmeta/contents/{+path}","compare_url":"https://api.github.com/repos/pacificclimate/modelmeta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pacificclimate/modelmeta/merges","archive_url":"https://api.github.com/repos/pacificclimate/modelmeta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pacificclimate/modelmeta/downloads","issues_url":"https://api.github.com/repos/pacificclimate/modelmeta/issues{/number}","pulls_url":"https://api.github.com/repos/pacificclimate/modelmeta/pulls{/number}","milestones_url":"https://api.github.com/repos/pacificclimate/modelmeta/milestones{/number}","notifications_url":"https://api.github.com/repos/pacificclimate/modelmeta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pacificclimate/modelmeta/labels{/name}","releases_url":"https://api.github.com/repos/pacificclimate/modelmeta/releases{/id}","deployments_url":"https://api.github.com/repos/pacificclimate/modelmeta/deployments","created_at":"2014-05-09T19:18:14Z","updated_at":"2016-01-11T21:09:12Z","pushed_at":"2016-01-21T20:03:04Z","git_url":"git://github.com/pacificclimate/modelmeta.git","ssh_url":"git@github.com:pacificclimate/modelmeta.git","clone_url":"https://github.com/pacificclimate/modelmeta.git","svn_url":"https://github.com/pacificclimate/modelmeta","homepage":null,"size":139,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/2"},"html":{"href":"https://github.com/pacificclimate/modelmeta/pull/2"},"issue":{"href":"https://api.github.com/repos/pacificclimate/modelmeta/issues/2"},"comments":{"href":"https://api.github.com/repos/pacificclimate/modelmeta/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pacificclimate/modelmeta/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/pacificclimate/modelmeta/statuses/e36b6a28ef0f797d2d7cb376846a97a4425f1247"}}}}