Thanks to visit codestin.com
Credit goes to github.com

Skip to content

No auto load graph reference #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Factor out get_config and get_credentials.
In general, we have cyclic import issues all over the place, this is one
easy fix and will help out in later commits.

Note that this maintains backwards compat due to how the the functions
are imported into `plotly.py`.
  • Loading branch information
theengineear committed Dec 22, 2016
commit c8092f8567f247dc83e3591cc05461a08551d6a3
35 changes: 35 additions & 0 deletions plotly/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Merges and prioritizes file/session config and credentials.

This is promoted to its own module to simplify imports.

"""
from __future__ import absolute_import

from plotly import session, tools


def get_credentials():
"""Returns the credentials that will be sent to plotly."""
credentials = tools.get_credentials_file()
session_credentials = session.get_session_credentials()
for credentials_key in credentials:

# checking for not false, but truthy value here is the desired behavior
session_value = session_credentials.get(credentials_key)
if session_value is False or session_value:
credentials[credentials_key] = session_value
return credentials


def get_config():
"""Returns either module config or file config."""
config = tools.get_config_file()
session_config = session.get_session_config()
for config_key in config:

# checking for not false, but truthy value here is the desired behavior
session_value = session_config.get(config_key)
if session_value is False or session_value:
config[config_key] = session_value
return config
29 changes: 3 additions & 26 deletions plotly/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
get_session_config)
from plotly.grid_objs import Grid, Column

# This is imported like this for backwards compat. Careful if changing.
from plotly.config import get_config, get_credentials

__all__ = None

DEFAULT_PLOT_OPTIONS = {
Expand All @@ -55,32 +58,6 @@
update_plot_options = update_session_plot_options


def get_credentials():
"""Returns the credentials that will be sent to plotly."""
credentials = tools.get_credentials_file()
session_credentials = get_session_credentials()
for credentials_key in credentials:

# checking for not false, but truthy value here is the desired behavior
session_value = session_credentials.get(credentials_key)
if session_value is False or session_value:
credentials[credentials_key] = session_value
return credentials


def get_config():
"""Returns either module config or file config."""
config = tools.get_config_file()
session_config = get_session_config()
for config_key in config:

# checking for not false, but truthy value here is the desired behavior
session_value = session_config.get(config_key)
if session_value is False or session_value:
config[config_key] = session_value
return config


def _plot_option_logic(plot_options_from_call_signature):
"""
Given some plot_options as part of a plot call, decide on final options.
Expand Down