{"action":"created","comment":{"url":"https://api.github.com/repos/bokeh/bokeh/pulls/comments/22620181","id":22620181,"diff_hunk":"@@ -0,0 +1,285 @@\n+from __future__ import print_function\n+\n+import sys\n+from six.moves.urllib import request as urllib2\n+from six.moves import cStringIO as StringIO\n+import pandas as pd\n+import click\n+\n+from . import help_messages as hm\n+from .utils import (get_chart_params, get_charts_mapping,\n+                    get_data_series, keep_source_input_sync, get_data_from_url)\n+from .. import charts as bc\n+\n+# Define a mapping to connect chart types supported arguments and chart classes\n+CHARTS_MAP = get_charts_mapping()\n+\n+@click.command()\n+@click.option('--input', 'input_source', default=None,help=hm.HELP_INPUT)\n+@click.option('--output', default='file://cli_output.html', help=hm.HELP_OUTPUT)\n+@click.option('--title', default='Bokeh CLI')\n+@click.option('--plot_type', default='Line')\n+@click.option('--index', default='', help=hm.HELP_INDEX)\n+@click.option('--series', default='', help=hm.HELP_SERIES)\n+@click.option('--palette')\n+@click.option('--buffer', default='f', help=hm.HELP_BUFFER)\n+@click.option('--sync_with_source', default=False)\n+def cli(input_source, output, title, plot_type, series, palette,\n+        index, buffer, sync_with_source):\n+    \"\"\"Bokeh Command Line Tool is a minimal client to access high level plotting\n+    functionality provided by bokeh.charts API.\n+\n+    Examples:\n+\n+    >> python bokeh-cli.py --title \"My Nice Plot\" --series \"High,Low,Close\"\n+    --plot_type \"Line\" --palette Reds --input sample_data/stocks_data.csv\n+\n+    >> cat sample_data/stocks_data.csv | python bokeh-cli.py --buffer t\n+\n+    >> python bokeh-cli.py --help\n+    \"\"\"\n+    cli = CLI(\n+        input_source, output, title, plot_type, series, palette, index, buffer,\n+        sync_with_source\n+    )\n+    cli.run()\n+\n+\n+class CLI(object):\n+    \"\"\"This is the Bokeh Command Line Interface class and it is in\n+    charge of providing a very high level access to bokeh charts and\n+    extends it with functionality.\n+\n+    \"\"\"\n+    def __init__(self, input_source, output, title, plot_type, series, palette,\n+                 index, buffer, sync_with_source):\n+        \"\"\"Args:\n+        input_source (str): path to the series data file (i.e.:\n+            /source/to/my/data.csv)\n+            NOTE: this can be either a path to a local file or an url\n+        output (str, optional): Selects the plotting output, which\n+            could either be sent to an html file or a bokeh server\n+            instance. Syntax convention for this option is as follows:\n+            <output_type>://<type_arg>\n+\n+            where:\n+              - output_type: 'file' or 'server'\n+              - 'file' type options: path_to_output_file\n+              - 'server' type options syntax: docname[@url][@name]\n+\n+            Defaults to: --output file://cli_output.html\n+\n+            Examples:\n+                --output file://cli_output.html\n+                --output file:///home/someuser/bokeh_rocks/cli_output.html\n+                --output server://clidemo\n+\n+            Default: file://cli_output.html.\n+        title (str, optional): the title of your chart.\n+            Default: None.\n+        plot_type (str, optional): charts classes to use to consume and\n+            render the input data.\n+            Default: Line.\n+        series (str, optional): Name of the series from the input source\n+            to include in the plot. If not specified all source series\n+            will be included.\n+            Defaults to None.\n+        palette (str, optional): name of the colors palette to use.\n+            Default: None.\n+        index (str, optional): Name of the data series to be used as index\n+            when plotting. By default the first series found on the input\n+            file is taken\n+            Default: None\n+        buffer (str, optional): if is `t` reads data source as string from\n+            input buffer using StringIO(sys.stdin.read()) instead of\n+            reading from a file or an url.\n+            Default: \"f\"\n+        sync_with_source (bool, optional): if True keep the charts source\n+            created on bokeh-server sync'ed with the source acting like\n+            `tail -f`.\n+            Default: False\n+\n+\n+        Attributes:\n+            source (obj): datasource object for the created chart.\n+            chart (obj): created chart object.\n+        \"\"\"\n+        self.input = input_source\n+        self.series = series\n+        self.index = index\n+        self.last_byte = -1\n+        self.sync_with_source = sync_with_source\n+\n+        self.source = self.get_input(input_source, buffer)\n+        # get the charts specified by the user\n+        self.factories = create_chart_factories(plot_type)\n+\n+        if palette:\n+            print (\"Sorry, custom palettes not supported yet, coming soon!\")\n+\n+        # define charts init parameters specified from cmd line and create chart\n+        self.chart_args = get_chart_params(title, output)\n+\n+    def run(self):\n+        \"\"\" Start the CLI logic creating the input source, data conversions,\n+        chart instances to show and all other niceties provided by CLI\n+        \"\"\"\n+        try:\n+            self.chart = create_chart(\n+                self.series, self.source, self.index, self.factories, **self.chart_args\n+            )\n+            self.chart.show()\n+\n+            self.has_ranged_x_axis = 'ranged_x_axis' in self.source.columns","path":"bokeh/cli/core.py","position":133,"original_position":133,"commit_id":"381391bd22142a85b8c579db519411eebdad6957","original_commit_id":"381391bd22142a85b8c579db519411eebdad6957","user":{"login":"damianavila","id":1640669,"avatar_url":"https://avatars.githubusercontent.com/u/1640669?v=3","gravatar_id":"","url":"https://api.github.com/users/damianavila","html_url":"https://github.com/damianavila","followers_url":"https://api.github.com/users/damianavila/followers","following_url":"https://api.github.com/users/damianavila/following{/other_user}","gists_url":"https://api.github.com/users/damianavila/gists{/gist_id}","starred_url":"https://api.github.com/users/damianavila/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damianavila/subscriptions","organizations_url":"https://api.github.com/users/damianavila/orgs","repos_url":"https://api.github.com/users/damianavila/repos","events_url":"https://api.github.com/users/damianavila/events{/privacy}","received_events_url":"https://api.github.com/users/damianavila/received_events","type":"User","site_admin":false},"body":"ok... fair enough :-)","created_at":"2015-01-07T22:04:44Z","updated_at":"2015-01-07T22:04:44Z","html_url":"https://github.com/bokeh/bokeh/pull/1565#discussion_r22620181","pull_request_url":"https://api.github.com/repos/bokeh/bokeh/pulls/1565","_links":{"self":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/comments/22620181"},"html":{"href":"https://github.com/bokeh/bokeh/pull/1565#discussion_r22620181"},"pull_request":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/1565"}}},"pull_request":{"url":"https://api.github.com/repos/bokeh/bokeh/pulls/1565","id":26255938,"html_url":"https://github.com/bokeh/bokeh/pull/1565","diff_url":"https://github.com/bokeh/bokeh/pull/1565.diff","patch_url":"https://github.com/bokeh/bokeh/pull/1565.patch","issue_url":"https://api.github.com/repos/bokeh/bokeh/issues/1565","number":1565,"state":"open","locked":false,"title":"Command Line Interface (CLI) Tool ","user":{"login":"fpliger","id":1084690,"avatar_url":"https://avatars.githubusercontent.com/u/1084690?v=3","gravatar_id":"","url":"https://api.github.com/users/fpliger","html_url":"https://github.com/fpliger","followers_url":"https://api.github.com/users/fpliger/followers","following_url":"https://api.github.com/users/fpliger/following{/other_user}","gists_url":"https://api.github.com/users/fpliger/gists{/gist_id}","starred_url":"https://api.github.com/users/fpliger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fpliger/subscriptions","organizations_url":"https://api.github.com/users/fpliger/orgs","repos_url":"https://api.github.com/users/fpliger/repos","events_url":"https://api.github.com/users/fpliger/events{/privacy}","received_events_url":"https://api.github.com/users/fpliger/received_events","type":"User","site_admin":false},"body":"Issues: Fixes #978 \r\n\r\nAdd a command line tool to expose `bokeh.charts` functionality (and hopefully many other niceties) from command line\r\n","created_at":"2014-12-17T20:57:42Z","updated_at":"2015-01-07T22:04:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"244d7d4e1732e5d4f0ba60b1dd69784ba117193b","assignee":{"login":"fpliger","id":1084690,"avatar_url":"https://avatars.githubusercontent.com/u/1084690?v=3","gravatar_id":"","url":"https://api.github.com/users/fpliger","html_url":"https://github.com/fpliger","followers_url":"https://api.github.com/users/fpliger/followers","following_url":"https://api.github.com/users/fpliger/following{/other_user}","gists_url":"https://api.github.com/users/fpliger/gists{/gist_id}","starred_url":"https://api.github.com/users/fpliger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fpliger/subscriptions","organizations_url":"https://api.github.com/users/fpliger/orgs","repos_url":"https://api.github.com/users/fpliger/repos","events_url":"https://api.github.com/users/fpliger/events{/privacy}","received_events_url":"https://api.github.com/users/fpliger/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/bokeh/bokeh/milestones/14","labels_url":"https://api.github.com/repos/bokeh/bokeh/milestones/14/labels","id":895618,"number":14,"title":"0.7.1","description":"","creator":{"login":"mattpap","id":27475,"avatar_url":"https://avatars.githubusercontent.com/u/27475?v=3","gravatar_id":"","url":"https://api.github.com/users/mattpap","html_url":"https://github.com/mattpap","followers_url":"https://api.github.com/users/mattpap/followers","following_url":"https://api.github.com/users/mattpap/following{/other_user}","gists_url":"https://api.github.com/users/mattpap/gists{/gist_id}","starred_url":"https://api.github.com/users/mattpap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattpap/subscriptions","organizations_url":"https://api.github.com/users/mattpap/orgs","repos_url":"https://api.github.com/users/mattpap/repos","events_url":"https://api.github.com/users/mattpap/events{/privacy}","received_events_url":"https://api.github.com/users/mattpap/received_events","type":"User","site_admin":false},"open_issues":24,"closed_issues":77,"state":"open","created_at":"2014-12-08T12:27:33Z","updated_at":"2015-01-07T19:03:38Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/bokeh/bokeh/pulls/1565/commits","review_comments_url":"https://api.github.com/repos/bokeh/bokeh/pulls/1565/comments","review_comment_url":"https://api.github.com/repos/bokeh/bokeh/pulls/comments/{number}","comments_url":"https://api.github.com/repos/bokeh/bokeh/issues/1565/comments","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/381391bd22142a85b8c579db519411eebdad6957","head":{"label":"bokeh:feature/cli","ref":"feature/cli","sha":"381391bd22142a85b8c579db519411eebdad6957","user":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"repo":{"id":3834332,"name":"bokeh","full_name":"bokeh/bokeh","owner":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bokeh/bokeh","description":"Interactive Web Plotting for Python","fork":false,"url":"https://api.github.com/repos/bokeh/bokeh","forks_url":"https://api.github.com/repos/bokeh/bokeh/forks","keys_url":"https://api.github.com/repos/bokeh/bokeh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bokeh/bokeh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bokeh/bokeh/teams","hooks_url":"https://api.github.com/repos/bokeh/bokeh/hooks","issue_events_url":"https://api.github.com/repos/bokeh/bokeh/issues/events{/number}","events_url":"https://api.github.com/repos/bokeh/bokeh/events","assignees_url":"https://api.github.com/repos/bokeh/bokeh/assignees{/user}","branches_url":"https://api.github.com/repos/bokeh/bokeh/branches{/branch}","tags_url":"https://api.github.com/repos/bokeh/bokeh/tags","blobs_url":"https://api.github.com/repos/bokeh/bokeh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bokeh/bokeh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bokeh/bokeh/git/refs{/sha}","trees_url":"https://api.github.com/repos/bokeh/bokeh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/{sha}","languages_url":"https://api.github.com/repos/bokeh/bokeh/languages","stargazers_url":"https://api.github.com/repos/bokeh/bokeh/stargazers","contributors_url":"https://api.github.com/repos/bokeh/bokeh/contributors","subscribers_url":"https://api.github.com/repos/bokeh/bokeh/subscribers","subscription_url":"https://api.github.com/repos/bokeh/bokeh/subscription","commits_url":"https://api.github.com/repos/bokeh/bokeh/commits{/sha}","git_commits_url":"https://api.github.com/repos/bokeh/bokeh/git/commits{/sha}","comments_url":"https://api.github.com/repos/bokeh/bokeh/comments{/number}","issue_comment_url":"https://api.github.com/repos/bokeh/bokeh/issues/comments/{number}","contents_url":"https://api.github.com/repos/bokeh/bokeh/contents/{+path}","compare_url":"https://api.github.com/repos/bokeh/bokeh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bokeh/bokeh/merges","archive_url":"https://api.github.com/repos/bokeh/bokeh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bokeh/bokeh/downloads","issues_url":"https://api.github.com/repos/bokeh/bokeh/issues{/number}","pulls_url":"https://api.github.com/repos/bokeh/bokeh/pulls{/number}","milestones_url":"https://api.github.com/repos/bokeh/bokeh/milestones{/number}","notifications_url":"https://api.github.com/repos/bokeh/bokeh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bokeh/bokeh/labels{/name}","releases_url":"https://api.github.com/repos/bokeh/bokeh/releases{/id}","created_at":"2012-03-26T15:40:01Z","updated_at":"2015-01-07T21:38:03Z","pushed_at":"2015-01-07T21:54:09Z","git_url":"git://github.com/bokeh/bokeh.git","ssh_url":"git@github.com:bokeh/bokeh.git","clone_url":"https://github.com/bokeh/bokeh.git","svn_url":"https://github.com/bokeh/bokeh","homepage":"","size":136144,"stargazers_count":2310,"watchers_count":2310,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":332,"mirror_url":null,"open_issues_count":326,"forks":332,"open_issues":326,"watchers":2310,"default_branch":"master"}},"base":{"label":"bokeh:master","ref":"master","sha":"6cecb7211277b9d838039d0eb15e50a10f9ac3d1","user":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"repo":{"id":3834332,"name":"bokeh","full_name":"bokeh/bokeh","owner":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bokeh/bokeh","description":"Interactive Web Plotting for Python","fork":false,"url":"https://api.github.com/repos/bokeh/bokeh","forks_url":"https://api.github.com/repos/bokeh/bokeh/forks","keys_url":"https://api.github.com/repos/bokeh/bokeh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bokeh/bokeh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bokeh/bokeh/teams","hooks_url":"https://api.github.com/repos/bokeh/bokeh/hooks","issue_events_url":"https://api.github.com/repos/bokeh/bokeh/issues/events{/number}","events_url":"https://api.github.com/repos/bokeh/bokeh/events","assignees_url":"https://api.github.com/repos/bokeh/bokeh/assignees{/user}","branches_url":"https://api.github.com/repos/bokeh/bokeh/branches{/branch}","tags_url":"https://api.github.com/repos/bokeh/bokeh/tags","blobs_url":"https://api.github.com/repos/bokeh/bokeh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bokeh/bokeh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bokeh/bokeh/git/refs{/sha}","trees_url":"https://api.github.com/repos/bokeh/bokeh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/{sha}","languages_url":"https://api.github.com/repos/bokeh/bokeh/languages","stargazers_url":"https://api.github.com/repos/bokeh/bokeh/stargazers","contributors_url":"https://api.github.com/repos/bokeh/bokeh/contributors","subscribers_url":"https://api.github.com/repos/bokeh/bokeh/subscribers","subscription_url":"https://api.github.com/repos/bokeh/bokeh/subscription","commits_url":"https://api.github.com/repos/bokeh/bokeh/commits{/sha}","git_commits_url":"https://api.github.com/repos/bokeh/bokeh/git/commits{/sha}","comments_url":"https://api.github.com/repos/bokeh/bokeh/comments{/number}","issue_comment_url":"https://api.github.com/repos/bokeh/bokeh/issues/comments/{number}","contents_url":"https://api.github.com/repos/bokeh/bokeh/contents/{+path}","compare_url":"https://api.github.com/repos/bokeh/bokeh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bokeh/bokeh/merges","archive_url":"https://api.github.com/repos/bokeh/bokeh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bokeh/bokeh/downloads","issues_url":"https://api.github.com/repos/bokeh/bokeh/issues{/number}","pulls_url":"https://api.github.com/repos/bokeh/bokeh/pulls{/number}","milestones_url":"https://api.github.com/repos/bokeh/bokeh/milestones{/number}","notifications_url":"https://api.github.com/repos/bokeh/bokeh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bokeh/bokeh/labels{/name}","releases_url":"https://api.github.com/repos/bokeh/bokeh/releases{/id}","created_at":"2012-03-26T15:40:01Z","updated_at":"2015-01-07T21:38:03Z","pushed_at":"2015-01-07T21:54:09Z","git_url":"git://github.com/bokeh/bokeh.git","ssh_url":"git@github.com:bokeh/bokeh.git","clone_url":"https://github.com/bokeh/bokeh.git","svn_url":"https://github.com/bokeh/bokeh","homepage":"","size":136144,"stargazers_count":2310,"watchers_count":2310,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":332,"mirror_url":null,"open_issues_count":326,"forks":332,"open_issues":326,"watchers":2310,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/1565"},"html":{"href":"https://github.com/bokeh/bokeh/pull/1565"},"issue":{"href":"https://api.github.com/repos/bokeh/bokeh/issues/1565"},"comments":{"href":"https://api.github.com/repos/bokeh/bokeh/issues/1565/comments"},"review_comments":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/1565/comments"},"review_comment":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/1565/commits"},"statuses":{"href":"https://api.github.com/repos/bokeh/bokeh/statuses/381391bd22142a85b8c579db519411eebdad6957"}}}}