Skip to content

Commit

Permalink
Constants now persist
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedamen committed Apr 15, 2021
1 parent a780ee7 commit c6feaed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ In chartpy/examples you will find several demos

# Coding log

* 15 Apr 2021
* Constant overrides now persist
* 13 Apr 2021
* Can add second y-axis labels for Plotly
* 22 Mar 2021
Expand Down
8 changes: 8 additions & 0 deletions chartpy/chartconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ class ChartConstants(object):
'yellowgreen': '#9ACD32'
}

override_fields = {}

# or we can store credentials in a file "chartcred.py" in the same folder, which will overwrite the above
# eg. TWITTER_APP_KEY, TWITTER_APP_SECRET, TWITTER_OAUTH_TOKEN, TWITTER_TOKEN_SECRET
# overwrite field variables with those listed in ChartCred or we can pass through an dictionary to override any fields
Expand All @@ -323,6 +325,12 @@ def __init__(self, override_fields={}):
except:
pass

# Store overrided fields
if override_fields == {}:
override_fields = ChartConstants.override_fields
else:
ChartConstants.override_fields = override_fields

for k in override_fields.keys():
if '__' not in k:
setattr(ChartConstants, k, override_fields[k])

0 comments on commit c6feaed

Please sign in to comment.