コード例 #1
0
ファイル: test_utils.py プロジェクト: sadmind/plotly.py
    def test_request_with_params(self):

        # urlencode transforms `True` --> `'True'`, which isn't super helpful,
        # Our backend accepts the JS `true`, so we want `True` --> `'true'`.

        params = {'foo': True, 'bar': 'True', 'baz': False, 'zap': 0}
        utils.request(self.method, self.url, params=params)
        args, kwargs = self.request_mock.call_args
        method, url = args
        expected_params = {'foo': 'true', 'bar': 'True', 'baz': 'false',
                           'zap': 0}
        self.assertEqual(method, self.method)
        self.assertEqual(url, self.url)
        self.assertEqual(kwargs['params'], expected_params)
コード例 #2
0
ファイル: test_utils.py プロジェクト: plotly/plotly.py
    def test_request_with_non_native_objects(self):

        # We always send along json, but it may contain non-native objects like
        # a pandas array or a Column reference. Make sure that's handled in one
        # central place.

        class Duck(object):
            def to_plotly_json(self):
                return 'what else floats?'

        utils.request(self.method, self.url, json={'foo': [Duck(), Duck()]})
        args, kwargs = self.request_mock.call_args
        method, url = args
        expected_data = '{"foo": ["what else floats?", "what else floats?"]}'
        self.assertEqual(method, self.method)
        self.assertEqual(url, self.url)
        self.assertEqual(kwargs['data'], expected_data)
        self.assertNotIn('json', kwargs)
コード例 #3
0
    def test_request_with_non_native_objects(self):

        # We always send along json, but it may contain non-native objects like
        # a pandas array or a Column reference. Make sure that's handled in one
        # central place.

        class Duck(object):
            def to_plotly_json(self):
                return 'what else floats?'

        utils.request(self.method, self.url, json={'foo': [Duck(), Duck()]})
        args, kwargs = self.request_mock.call_args
        method, url = args
        expected_data = '{"foo": ["what else floats?", "what else floats?"]}'
        self.assertEqual(method, self.method)
        self.assertEqual(url, self.url)
        self.assertEqual(kwargs['data'], expected_data)
        self.assertNotIn('json', kwargs)
コード例 #4
0
    def test_request_with_params(self):

        # urlencode transforms `True` --> `'True'`, which isn't super helpful,
        # Our backend accepts the JS `true`, so we want `True` --> `'true'`.

        params = {"foo": True, "bar": "True", "baz": False, "zap": 0}
        utils.request(self.method, self.url, params=params)
        args, kwargs = self.request_mock.call_args
        method, url = args
        expected_params = {
            "foo": "true",
            "bar": "True",
            "baz": "false",
            "zap": 0
        }
        self.assertEqual(method, self.method)
        self.assertEqual(url, self.url)
        self.assertEqual(kwargs["params"], expected_params)
コード例 #5
0
def current():
    """
    Retrieve information on the logged-in user from Plotly.

    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, route='current')
    return request('get', url)
コード例 #6
0
def create(body):
    """
    Create a new folder.

    :param (dict) body: A mapping of body param names to values.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE)
    return request("post", url, json=body)
コード例 #7
0
def restore(fid):
    """
    Restore a trashed plot from Plotly. See 'trash'.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route="restore")
    return request("post", url)
コード例 #8
0
def create(body):
    """
    Generate an image (which does not get saved on Plotly).

    :param (dict) body: A mapping of body param names to values.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE)
    return request("post", url, json=body)
コード例 #9
0
ファイル: plots.py プロジェクト: plotly/plotly.py
def permanent_delete(fid, params=None):
    """
    Permanently delete a trashed plot file from Plotly. See 'trash'.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='permanent_delete')
    return request('delete', url, params=params)
コード例 #10
0
ファイル: plots.py プロジェクト: plotly/plotly.py
def create(body):
    """
    Create a new plot.

    :param (dict) body: A mapping of body param names to values.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE)
    return request('post', url, json=body)
コード例 #11
0
def trash(fid):
    """
    Soft-delete a plot from Plotly. (Can be undone with 'restore').

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route="trash")
    return request("post", url)
コード例 #12
0
ファイル: images.py プロジェクト: plotly/plotly.py
def create(body):
    """
    Generate an image (which does not get saved on Plotly).

    :param (dict) body: A mapping of body param names to values.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE)
    return request('post', url, json=body)
コード例 #13
0
def permanent_delete(fid, params=None):
    """
    Permanently delete a trashed plot file from Plotly. See 'trash'.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route="permanent_delete")
    return request("delete", url, params=params)
コード例 #14
0
ファイル: plots.py プロジェクト: plotly/plotly.py
def trash(fid):
    """
    Soft-delete a plot from Plotly. (Can be undone with 'restore').

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='trash')
    return request('post', url)
コード例 #15
0
ファイル: plots.py プロジェクト: plotly/plotly.py
def restore(fid):
    """
    Restore a trashed plot from Plotly. See 'trash'.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='restore')
    return request('post', url)
コード例 #16
0
def destroy(fid):
    """
    Permanently delete a grid file from Plotly.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid)
    return request("delete", url)
コード例 #17
0
def retrieve(sha1, **kwargs):
    """
    Retrieve the most up-to-date copy of the plot-schema wrt the given hash.

    :param (str) sha1: The last-known hash of the plot-schema (or '').
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE)
    params = make_params(sha1=sha1)
    return request("get", url, params=params, **kwargs)
コード例 #18
0
def update(fid, body):
    """
    Update a folder from Plotly.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (dict) body: A mapping of body param names to values.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid)
    return request("put", url, json=body)
コード例 #19
0
def col_create(fid, body):
    """
    Create a new column (or columns) inside a grid.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (dict) body: A mapping of body param names to values.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='col')
    return request('post', url, json=body)
コード例 #20
0
def row(fid, body):
    """
    Append rows to a grid.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (dict) body: A mapping of body param names to values.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='row')
    return request('post', url, json=body)
コード例 #21
0
ファイル: plots.py プロジェクト: plotly/plotly.py
def update(fid, body):
    """
    Update a plot from Plotly.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (dict) body: A mapping of body param names to values.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid)
    return request('put', url, json=body)
コード例 #22
0
ファイル: plot_schema.py プロジェクト: plotly/plotly.py
def retrieve(sha1, **kwargs):
    """
    Retrieve the most up-to-date copy of the plot-schema wrt the given hash.

    :param (str) sha1: The last-known hash of the plot-schema (or '').
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE)
    params = make_params(sha1=sha1)
    return request('get', url, params=params, **kwargs)
コード例 #23
0
ファイル: folders.py プロジェクト: plotly/plotly.py
def permanent_delete(fid):
    """
    Permanently delete a trashed folder file from Plotly. See 'trash'.

    This action is recursively done on files inside the folder.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='permanent_delete')
    return request('delete', url)
コード例 #24
0
def permanent_delete(fid):
    """
    Permanently delete a trashed folder file from Plotly. See 'trash'.

    This action is recursively done on files inside the folder.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route="permanent_delete")
    return request("delete", url)
コード例 #25
0
ファイル: plots.py プロジェクト: plotly/plotly.py
def retrieve(fid, share_key=None):
    """
    Retrieve a plot from Plotly.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (str) share_key: The secret key granting 'read' access if private.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid)
    params = make_params(share_key=share_key)
    return request('get', url, params=params)
コード例 #26
0
ファイル: folders.py プロジェクト: Meet11/StockAnalysis
def trash(fid):
    """
    Soft-delete a folder from Plotly. (Can be undone with 'restore').

    This action is recursively done on files inside the folder.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='trash')
    return request('post', url)
コード例 #27
0
def content(fid, share_key=None):
    """
    Retrieve full content for the grid (normal retrieve only yields preview)

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (str) share_key: The secret key granting 'read' access if private.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='content')
    params = make_params(share_key=share_key)
    return request('get', url, params=params)
コード例 #28
0
def col_delete(fid, uid):
    """
    Permanently delete a column (or columns) from a grid.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (str) uid: A ','-concatenated string of column uids in the grid.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='col')
    params = make_params(uid=uid)
    return request('delete', url, params=params)
コード例 #29
0
def retrieve(fid, share_key=None):
    """
    Retrieve a folder from Plotly.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (str) share_key: The secret key granting 'read' access if private.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid)
    params = make_params(share_key=share_key)
    return request("get", url, params=params)
コード例 #30
0
def col_update(fid, uid, body):
    """
    Update a column (or columns) from a grid.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (str) uid: A ','-concatenated string of column uids in the grid.
    :param (dict) body: A mapping of body param names to values.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='col')
    params = make_params(uid=uid)
    return request('put', url, json=body, params=params)
コード例 #31
0
ファイル: plots.py プロジェクト: plotly/plotly.py
def lookup(path, parent=None, user=None, exists=None):
    """
    Retrieve a plot file from Plotly without needing a fid.

    :param (str) path: The '/'-delimited path specifying the file location.
    :param (int) parent: Parent id, an integer, which the path is relative to.
    :param (str) user: The username to target files for. Defaults to requestor.
    :param (bool) exists: If True, don't return the full file, just a flag.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, route='lookup')
    params = make_params(path=path, parent=parent, user=user, exists=exists)
    return request('get', url, params=params)
コード例 #32
0
def lookup(path, parent=None, user=None, exists=None):
    """
    Retrieve a folder file from Plotly without needing a fid.

    :param (str) path: The '/'-delimited path specifying the file location.
    :param (int) parent: Parent id, an integer, which the path is relative to.
    :param (str) user: The username to target files for. Defaults to requestor.
    :param (bool) exists: If True, don't return the full file, just a flag.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, route="lookup")
    params = make_params(path=path, parent=parent, user=user, exists=exists)
    return request("get", url, params=params)
コード例 #33
0
ファイル: plots.py プロジェクト: plotly/plotly.py
def content(fid, share_key=None, inline_data=None, map_data=None):
    """
    Retrieve the *figure* for a Plotly plot file.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (str) share_key: The secret key granting 'read' access if private.
    :param (bool) inline_data: If True, include the data arrays with the plot.
    :param (str) map_data: Currently only accepts 'unreadable' to return a
                           mapping of grid-fid: grid. This is useful if you
                           want to maintain structure between the plot and
                           referenced grids when you have READ access to the
                           plot, but you don't have READ access to the
                           underlying grids.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route='content')
    params = make_params(share_key=share_key, inline_data=inline_data,
                         map_data=map_data)
    return request('get', url, params=params)
コード例 #34
0
def content(fid, share_key=None, inline_data=None, map_data=None):
    """
    Retrieve the *figure* for a Plotly plot file.

    :param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
    :param (str) share_key: The secret key granting 'read' access if private.
    :param (bool) inline_data: If True, include the data arrays with the plot.
    :param (str) map_data: Currently only accepts 'unreadable' to return a
                           mapping of grid-fid: grid. This is useful if you
                           want to maintain structure between the plot and
                           referenced grids when you have READ access to the
                           plot, but you don't have READ access to the
                           underlying grids.
    :returns: (requests.Response) Returns response directly from requests.

    """
    url = build_url(RESOURCE, id=fid, route="content")
    params = make_params(share_key=share_key,
                         inline_data=inline_data,
                         map_data=map_data)
    return request("get", url, params=params)
コード例 #35
0
def list():
    """Returns the list of all users' presentations."""
    url = build_url(RESOURCE)
    return request('get', url)
コード例 #36
0
def retrieve(fid):
    """Retrieve a presentation from Plotly."""
    url = build_url(RESOURCE, id=fid)
    return request('get', url)
コード例 #37
0
ファイル: test_utils.py プロジェクト: plotly/plotly.py
    def test_request_validate_response(self):

        # Finally, we check details elsewhere, but make sure we do validate.

        utils.request(self.method, self.url)
        assert self.request_mock.call_count == 1
コード例 #38
0
    def test_request_validate_response(self):

        # Finally, we check details elsewhere, but make sure we do validate.

        utils.request(self.method, self.url)
        assert self.request_mock.call_count == 1
コード例 #39
0
def retrieve(fid):
    """Retrieve a dash app from Plotly."""
    url = build_url(RESOURCE, id=fid)
    return request('get', url)
コード例 #40
0
ファイル: dashboards.py プロジェクト: plotly/plotly.py
def create(body):
    """Create a dashboard."""
    url = build_url(RESOURCE)
    return request('post', url, json=body)
コード例 #41
0
ファイル: dashboards.py プロジェクト: plotly/plotly.py
def retrieve(fid):
    """Retrieve a dashboard from Plotly."""
    url = build_url(RESOURCE, id=fid)
    return request('get', url)
コード例 #42
0
ファイル: dashboards.py プロジェクト: Meet11/StockAnalysis
def schema():
    """Retrieve the dashboard schema."""
    url = build_url(RESOURCE, route='schema')
    return request('get', url)
コード例 #43
0
ファイル: dashboards.py プロジェクト: plotly/plotly.py
def update(fid, content):
    """Completely update the writable."""
    url = build_url(RESOURCE, id=fid)
    return request('put', url, json=content)
コード例 #44
0
def create(body):
    """Create a dashboard."""
    url = build_url(RESOURCE)
    return request("post", url, json=body)
コード例 #45
0
def retrieve(fid):
    """Retrieve a dashboard from Plotly."""
    url = build_url(RESOURCE, id=fid)
    return request("get", url)
コード例 #46
0
def update(fid, content):
    """Completely update the writable."""
    url = build_url(RESOURCE, id=fid)
    return request("put", url, json=content)
コード例 #47
0
def create(body):
    """Create a presentation."""
    url = build_url(RESOURCE)
    return request('post', url, json=body)
コード例 #48
0
ファイル: dashboards.py プロジェクト: plotly/plotly.py
def list():
    """Returns the list of all users' dashboards."""
    url = build_url(RESOURCE)
    return request('get', url)
コード例 #49
0
def list():
    """Returns the list of all users' dashboards."""
    url = build_url(RESOURCE)
    return request("get", url)
コード例 #50
0
def schema():
    """Retrieve the dashboard schema."""
    url = build_url(RESOURCE, route="schema")
    return request("get", url)