This is the documentation for the project Stock_Analyzer.
2. HOW TO CREATE CONDA ENVIRONMENT
3. HOW TO CONNECT INTERPRETER TO JETBRAINS GATEWAY
4. HOW TO INSTALL REQUIREMENTS
6. HOW TO INSTALL SELENIUM AND CHROME
A. HOW TO REMOVE CONDA ENVIRONMENT
Documentation For toolbox/ticker_price_analysis.py
Documentation For toolbox/ticker_price_analysis.py
def set_storage_path(database_path: str, make_dir=False):
Note
This function is used to set the path to the database. The database is aParam
database_path: str
Path to the database
make_dir: bool
If True, create the directory if it does not existReturn
NoneExample
from toolbox import ticker_price_analysis
ticker_price_analysis.set_storage_path('~/Desktop/database', make_dir=True)Note
This function is used to get the difference between the price of each datetimeParam
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of pricesReturn
diff_df: pd.DataFrame
Dataframe with datetime index and columns of differences in pricesExample
from toolbox import ticker_price_analysis
import pandas as pd
df = pd.DataFrame({'price': [1, 2, 3, 4, 5]}, index=pd.date_range('2020-01-01', periods=5, freq='1min'))
velocity_df = ticker_price_analysis.diff(df)
print(velocity_df)def get_pct_change(df: pd.DataFrame):
Note
This function is used to get the percent change between the price of each datetimeParam
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of pricesReturn
pct_change_df: pd.DataFrame
Dataframe with datetime index and columns of percent change in pricesExample
from toolbox import ticker_price_analysis
import pandas as pd
df = pd.DataFrame({'price': [1, 2, 3, 4, 5]}, index=pd.date_range('2020-01-01', periods=5, freq='1min'))
pct_change_trend = ticker_price_analysis.get_pct_change(df)
print(pct_change_trend)Note
This function is used to get the velocity of the tickerParam
ters
----------
ticker: str
Ticker symbol
start_date: datetime.datetime
Start date of the data
end_date: datetime.datetime
End date of the data
cooldown: bool
If True, wait 1 second between each request to the API
database_only: bool
If True, only use the database, do not make any requests to the APIReturn
velocity_df: pd.DataFrame
Dataframe with datetime index and columns of velocityExample
from toolbox import ticker_price_analysis
velocity_df = ticker_price_analysis.get_velocity('AAPL')
print(velocity_df)Note
This function is used to get the acceleration of the tickerParam
ters
----------
ticker: str
Ticker symbol
start_date: datetime.datetime
Start date of the data
end_date: datetime.datetime
End date of the data
cooldown: bool
If True, wait 1 second between each request to the API
database_only: bool
If True, only use the database, do not make any requests to the APIReturn
acceleration_df: pd.DataFrame
Dataframe with datetime index and columns of accelerationExample
from toolbox import ticker_price_analysis
acceleration_df = ticker_price_analysis.get_acceleration('AAPL')
print(acceleration_df)Note
This function is used to get the jerk of the tickerParam
ters
----------
ticker: str
Ticker symbol
start_date: datetime.datetime
Start date of the data
end_date: datetime.datetime
End date of the data
cooldown: bool
If True, wait 1 second between each request to the API
database_only: bool
If True, only use the database, do not make any requests to the APIReturn
jerk_df: pd.DataFrame
Dataframe with datetime index and columns of jerkExample
from toolbox import ticker_price_analysis
jerk_df = ticker_price_analysis.get_jerk('AAPL')
print(jerk_df)Note
This function is used to get the percent change velocity of the tickerParam
ters
----------
ticker: str
Ticker symbol
start_date: datetime.datetime
Start date of the data
end_date: datetime.datetime
End date of the data
cooldown: bool
If True, wait 1 second between each request to the API
database_only: bool
If True, only use the database, do not make any requests to the APIReturn
pct_change_velocity_df: pd.DataFrame
Dataframe with datetime index and columns of percent change velocityExample
from toolbox import ticker_price_analysis
pct_change_velocity_df = ticker_price_analysis.get_pct_change_velocity('AAPL')
print(pct_change_velocity_df)Note
This function is used to get the percent change acceleration of the tickerParam
ters
----------
ticker: str
Ticker symbol
start_date: datetime.datetime
Start date of the data
end_date: datetime.datetime
End date of the data
cooldown: bool
If True, wait 1 second between each request to the API
database_only: bool
If True, only use the database, do not make any requests to the APIReturn
pct_change_acceleration_df: pd.DataFrame
Dataframe with datetime index and columns of percent change accelerationExample
from toolbox import ticker_price_analysis
pct_change_acceleration_df = ticker_price_analysis.get_pct_change_acceleration('AAPL')
print(pct_change_acceleration_df)Note
This function is used to get the percent change jerk of the tickerParam
ters
----------
ticker: str
Ticker symbol
start_date: datetime.datetime
Start date of the data
end_date: datetime.datetime
End date of the data
cooldown: bool
If True, wait 1 second between each request to the API
database_only: bool
If True, only use the database, do not make any requests to the APIReturn
pct_change_jerk_df: pd.DataFrame
Dataframe with datetime index and columns of percent change jerkExample
from toolbox import ticker_price_analysis
pct_change_jerk_df = ticker_price_analysis.get_pct_change_jerk('AAPL')
print(pct_change_jerk_df)def interpolate(trend, resample='D', create_dates_column=False):
Note
This function is used to interpolate the dataframe. It will interpolate the dataframe based upon the resample.
This function is an alias for toolbox.ticker_prices.interpolateParam
ters
----------
trend: pd.DataFrame
Dataframe to interpolate
resample: str
Resample the dataframe to this frequency
'H' = Hourly
'D' = DailyReturn
trend: pd.DataFrame
Interpolated dataframeExample
from toolbox import ticker_prices
df = ticker_prices.get_ticker_historical_trend('AAPL', start_date=datetime.datetime(2020, 1, 1), end_date=datetime.datetime(2020, 1, 2))
df = ticker_prices.interpolate(df)
print(df)def average(df: pd.DataFrame):
Note
This function is used to get the average of the dataframeParam
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of percent changeReturn
average_df: pd.DataFrame
Dataframe with datetime index and columns of averageExample
from toolbox import ticker_price_analysis
df = ticker_prices.get_ticker_historical_trend('AAPL')
average_df = ticker_price_analysis.average(df)
print(average_df)def standard_deviation(df: pd.DataFrame, sample=True):
Note
This function is used to get the standard deviation of the dataframeParam
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of percent change
sample: bool
If True, use sample standard deviation, else use population standard deviationReturn
standard_deviation_df: pd.DataFrame
Dataframe with datetime index and columns of standard deviationExample
from toolbox import ticker_price_analysis
df = ticker_prices.get_ticker_historical_trend('AAPL')
standard_deviation_df = ticker_price_analysis.standard_deviation(df)
print(standard_deviation_df)Note
This function is used to get the max of the dataframeParam
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of percent changeReturn
max_df: pd.DataFrame
Dataframe with datetime index and columns of maxExample
from toolbox import ticker_price_analysis
df = ticker_prices.get_ticker_historical_trend('AAPL')
max_df = ticker_price_analysis.max(df)
print(max_df)Note
This function is used to get the min of the dataframeParam
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of percent changeReturn
min_df: pd.DataFrame
Dataframe with datetime index and columns of minExample
from toolbox import ticker_price_analysis
df = ticker_prices.get_ticker_historical_trend('AAPL')
min_df = ticker_price_analysis.min(df)
print(min_df)Note
This function is used to get the skew of the dataframe.
For each skew variable:
skew = 0: normally distributed
skew < 0: more weight in the right tail of the distribution
skew > 0: more weight in the left tail of the distribution
For instance, a skew of -0.35 means that there is more weight in the right tail of the distribution.Param
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of percent changeReturn
skew_df: pd.DataFrame
Dataframe with datetime index and columns of skew.Example
from toolbox import ticker_price_analysis
df = ticker_prices.get_ticker_historical_trend('AAPL')
skew_df = ticker_price_analysis.skew(df)
print(skew_df)def rolling_mean(df: pd.DataFrame, window:int = 12):
Note
This function is used to get the rolling mean of the dataframeParam
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of percent change
window: int
The number of periods to use for calculating the statisticReturn
rolling_mean_df: pd.DataFrame
Dataframe with datetime index and columns of rolling meanExample
from toolbox import ticker_price_analysis
df = ticker_prices.get_ticker_historical_trend('AAPL')
rolling_mean_df = ticker_price_analysis.rolling_mean(df)
print(rolling_mean_df)def rolling_std(df: pd.DataFrame, window:int = 12):
Note
This function is used to get the rolling standard deviation of the dataframeParam
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of percent change
window: int
The number of periods to use for calculating the statisticReturn
rolling_std_df: pd.DataFrame
Dataframe with datetime index and columns of rolling standard deviationExample
from toolbox import ticker_price_analysis
df = ticker_prices.get_ticker_historical_trend('AAPL')
rolling_std_df = ticker_price_analysis.rolling_std(df)
print(rolling_std_df)Note
This function is used to get the log of the dataframeParam
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of percent changeReturn
df_log: pd.DataFrame
Dataframe with datetime index and columns of logExample
from toolbox import ticker_price_analysis
df = ticker_prices.get_ticker_historical_trend('AAPL')
df_log = ticker_price_analysis.df_log(df)
print(df_log)def get_stationary_trend(df: pd.DataFrame, window: int = 12):
Note
This function is used to get the stationary trend of the dataframeParam
ters
----------
df: pd.DataFrame
Dataframe with datetime index and columns of percent change
window: int
The number of periods to use for calculating the statisticReturn
stationary_trend_df: pd.DataFrame
Dataframe with datetime index and columns of stationary trendExample
from toolbox import ticker_price_analysis
df = ticker_prices.get_ticker_historical_trend('AAPL')
stationary_trend_df = ticker_price_analysis.get_stationary_trend(df)
print(stationary_trend_df)
Documentation For toolbox/web_scraping_utility.py
Documentation For toolbox/web_scraping_utility.py
Note
The screenshot will be saved as a .png file
This function is built just to test the headless option of selenium.Param
ters
----------
website: str
The website to take a screenshot of
screenshot_path: str
The path to save the screenshot to
screen_width: int
The width of the screen to take the screenshot of
screen_height: int
The height of the screen to take the screenshot ofReturn
NoneExample
from toolbox import web_scraping_utility
import os
current_dir = os.getcwd()
screenshot_path = os.path.join(current_dir, 'test')
web_scraping_utility.test_headless('https://www.youtube.com', screenshot_path)
Documentation For toolbox/ticker_retreival.py
Documentation For toolbox/ticker_retreival.py
def set_storage_path(database_path: str, make_dir=False):
Note
This function is used to set the path to the database. The database is aParam
database_path: str
Path to the database
make_dir: bool
If True, create the directory if it does not existReturn
NoneExample
from toolbox import ticker_retreival
ticker_retreival.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')def get_tickers(days_reset_frequency=7, request_fresh=False):
Note
This function is used to get the list of tickers. The tickers are saved in the database. If the tickers are olderParam
days_reset_frequency: int
Number of days before the tickers are reset, to avoid making too many API calls
request_fresh: bool
If True, then the tickers are requested fresh from the API, regardless of the last update timeReturn
tickers: list
List of tickersExample
from toolbox import ticker_retreival
ticker_retreival.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')
tickers = ticker_retreival.get_tickers()Reference
https://levelup.gitconnected.com/how-to-get-all-stock-symbols-a73925c16a1bdef get_rejected_tickers(days_reset_frequency=7, request_fresh=False):
Note
This function is used to get the list of rejected tickers.
W = When Issued, or can be arrested for fraud
R = Rights Issue
P = “First Preferred Issue”. Preferred stocks are a separate entity.
Q = BankruptcyParam
days_reset_frequency: int
Number of days before the tickers are reset, to avoid making too many API calls
request_fresh: bool
If True, then the tickers are requested fresh from the API, regardless of the last update timeReturn
rejected_tickers: list
List of rejected tickersExample
from toolbox import ticker_retreival
ticker_retreival.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')
rejected_tickers = ticker_retreival.get_rejected_tickers()Reference
https://levelup.gitconnected.com/how-to-get-all-stock-symbols-a73925c16a1bNote
This function is used to get the information for a given ticker. The information is saved in the database. If theParam
symbol: str
Ticker symbol
days_reset_frequency: int
Number of days before the tickers are reset, to avoid making too many API calls
request_fresh: bool
If True, then the tickers are requested fresh from the API, regardless of the last update timeReturn
stock_info: dict
Dictionary of stock informationExample
from toolbox import ticker_retreival
ticker_retreival.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')
stock_info = ticker_retreival.get_ticker_information('MSFT')
name = stock_info['shortName']
website = stock_info['website']
description = stock_info['longBusinessSummary']def get_all_ticker_information(days_reset_frequency=1, request_fresh=False):
Note
This function is used to get the information for all tickers. The information is saved in the database. If theParam
days_reset_frequency: int
Number of days before the tickers are reset, to avoid making too many API calls
request_fresh: bool
If True, then the tickers are requested fresh from the API, regardless of the last update timeReturn
all_info: dict
Dictionary of stock information for all tickersExample
from toolbox import ticker_retreival
ticker_retreival.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')
all_info = ticker_retreival.get_all_ticker_information()
print(all_info['MSFT']['shortName'])
Documentation For toolbox/ticker_prices.py
Documentation For toolbox/ticker_prices.py
def set_storage_path(database_path: str, make_dir=False):
Note
This function is used to set the path to the database. The database is aParam
database_path: str
Path to the database
make_dir: bool
If True, create the directory if it does not existReturn
NoneExample
from toolbox import ticker_prices
ticker_prices.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')def clean_up_dataframe(df: pd.DataFrame):
Note
This function is used to clean up the dataframe. It will remove duplicate rows based upon the "Date" column.
This is automatically called by the get_ticker_historical_trend function.Param
ters
----------
df: pd.DataFrame
Dataframe to clean upReturn
df: pd.DataFrame
Cleaned up dataframeExample
from toolbox import ticker_prices
df = ticker_prices.get_ticker_historical_trend('AAPL', start_date=datetime.datetime(2020, 1, 1), end_date=datetime.datetime(2020, 1, 2))
df = ticker_prices.clean_up_dataframe(df)
print(df)def interpolate(trend, resample='D', create_dates_column=False):
Note
This function is used to interpolate the dataframe. It will interpolate the dataframe based upon the resampleParam
ters
----------
trend: pd.DataFrame
Dataframe to interpolate
resample: str
Resample the dataframe to this frequency
'H' = Hourly
'D' = DailyReturn
trend: pd.DataFrame
Interpolated dataframeExample
from toolbox import ticker_prices
df = ticker_prices.get_ticker_historical_trend('AAPL', start_date=datetime.datetime(2020, 1, 1), end_date=datetime.datetime(2020, 1, 2))
df = ticker_prices.interpolate(df)
print(df)Note
This function is used to get the historical trend of a ticker. The historical trend is stored in the database. If the
historical trend is not in the database, it will be downloaded from Yahoo Finance and stored in the database.Param
ticker: str
Ticker symbol
start_date: datetime.datetime
Start date
end_date: datetime.datetime
End date
cooldown: bool
If True, wait 3 seconds between requests
database_only: bool
If True, only get the historical trend from the database.
Setting it to True will not download the historical trend from Yahoo Finance,
but it is faster to retrieve the historical trend from the database.
interval: str
Interval of the historical trend. If None, it will be set to "1d" if the time delta is greater than 2 years,
otherwise it will be set to "1h"Return
pd.DataFrame
Historical trend of the tickerExample
from toolbox import ticker_prices
import datetime
date = '09/10/2019'
datetime_object = datetime.datetime.strptime(date, '%m/%d/%Y')
today = datetime.datetime.today()
print(ticker_prices.get_ticker_historical_trend('MSFT', datetime_object, today))
Documentation For toolbox/ticker_plotter.py
Documentation For toolbox/ticker_plotter.py
def set_storage_path(database_path: str, make_dir=False):
Note
This function is used to set the path to the database. The database is aParam
database_path: str
Path to the database
make_dir: bool
If True, create the directory if it does not existReturn
NoneExample
from toolbox import ticker_price_analysis
ticker_price_analysis.set_storage_path('~/Desktop/database', make_dir=True)Note
This function is used to plot the trend of the data. The trend is a dataframe where the index is the date and the
columns are the different types of data. The columns are the different types of data.Param
ters
----------
trend: pd.DataFrame
Dataframe containing the trend
columns: list
List of columns to plot
title: str
Title of the plot
yaxis_name: str
Name of the y-axis
key_name: str
Name of the keyReturn
fig: plotly.graph_objects.Figure
Plotly figureExample
from toolbox import ticker_price_analysis
from toolbox import ticker_prices
ticker_price_analysis.set_storage_path('~/Desktop/database', make_dir=True)
ticker_prices.set_storage_path('~/Desktop/database')
trend = ticker_prices.get_ticker_historical_trend('AAPL')
fig = ticker_price_analysis.get_figure(trend, ['Close', 'Open'], 'AAPL')
fig.show()
fig.write_image(f"AAPL_trend.png")def get_candlestick_figure(trend: pd.DataFrame, title: str, yaxis_name: str = "Price ($)"):
Note
This function is used to plot the trend of the data. The trend is a dataframe where the index is the date and the
columns are the different types of data. The columns are the different types of data.Param
ters
----------
trend: pd.DataFrame
Dataframe containing the trend
title: str
Title of the plot
yaxis_name: str
Name of the y-axisReturn
fig: plotly.graph_objects.Figure
Plotly figureExample
from toolbox import ticker_price_analysis
from toolbox import ticker_prices
ticker_price_analysis.set_storage_path('~/Desktop/database', make_dir=True)
ticker_prices.set_storage_path('~/Desktop/database')
trend = ticker_prices.get_ticker_historical_trend('AAPL')
fig = ticker_price_analysis.get_candlestick_figure(trend, 'AAPL')
fig.show()
fig.write_image(f"AAPL_candlestick.png")
Documentation For toolbox/queue_local.py
Documentation For toolbox/queue_local.py
Note
A queue is a data structure that follows the First In First Out (FIFO) principle.
This means that the first item added to the queue will be the first item removed from the queue.
A queue can be implemented using a list or a linked list.Param
queue_list: list
The list to initialize the queue with
max_size: int
The maximum size of the queueExample
queue = Queue([1, 2, 3, 4, 5], 10)
a = queue.dequeue()
print(a)Reference
https://en.wikipedia.org/wiki/Queue_(abstract_data_type)def init(self, queue_list: list = None, max_size: int = None):
Note
If the queue_list is not None, then the queue will be initialized with the list
If the max_size is not None, then the queue will be initialized with the max_sizeParam
queue_list: list
The list to initialize the queue with
max_size: int
The maximum size of the queueReturn
NoneExample
queue = Queue([1, 2, 3, 4, 5], 10)
a = queue.dequeue()
print(a)Note
Adds the item to the end of the queueParam
item: any
The item to add to the queueReturn
NoneExample
queue = Queue(max_size=10)
queue.enqueue(1)
queue.enqueue(2)
queue.enqueue(3)
print(queue)Note
Removes the first item from the queueParam
NoneReturn
item: any
The item that was removed from the queueExample
queue = Queue(max_size=10)
queue.enqueue(1)
queue.enqueue(2)
queue.enqueue(3)
a = queue.dequeue()
print(a)Note
Returns the size of the queueParam
NoneReturn
size: int
The size of the queueExample
queue = Queue(max_size=10)
queue.enqueue(1)
queue.enqueue(2)
queue.enqueue(3)
print(queue.size())Note
Returns True if the queue is empty, False otherwiseParam
NoneReturn
is_empty: bool
True if the queue is empty, False otherwiseExample
queue = Queue(max_size=10)
queue.enqueue(1)
queue.enqueue(2)
print(queue.is_empty())Note
Returns the first item in the queue without removing itParam
NoneReturn
item: any
The first item in the queueExample
queue = Queue(max_size=10)
queue.enqueue(1)
queue.enqueue(2)
queue.enqueue(3)
a = queue.peek()
print(a)Note
Returns the list of items in the queueParam
NoneReturn
list: list
The list of items in the queueExample
queue = Queue(max_size=10)
queue.enqueue(1)
queue.enqueue(2)
queue.enqueue(3)
a = queue.get_list()
print(a)Note
Returns the size of the queueParam
NoneReturn
size: int
The size of the queueExample
queue = Queue(max_size=10)
queue.enqueue(1)
queue.enqueue(2)
print(len(queue))Note
Returns a copy of the queueParam
NoneReturn
new_queue: Queue
A copy of the queueExample
queue = Queue(max_size=10)
queue.enqueue(1)
queue.enqueue(2)
queue.enqueue(3)
new_queue = queue.copy()
print(new_queue)Note
Returns a copy of the queueParam
NoneReturn
new_queue: Queue
A copy of the queueExample
queue = Queue(max_size=10)
queue.enqueue(1)
queue.enqueue(2)
queue.enqueue(3)
new_queue = queue.copy()
print(new_queue)Note
Returns True if the queues are equal, False otherwiseParam
other: Queue
The other queue to compare toReturn
is_equal: bool
True if the queues are equal, False otherwiseExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
other = Queue([1, 2, 3, 4, 5], max_size=10)
print(queue == other)Note
Returns True if the queues are not equal, False otherwiseParam
other: Queue
The other queue to compare toReturn
is_not_equal: bool
True if the queues are not equal, False otherwiseExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
other = Queue([1, 2, 3, 4, 5], max_size=10)
print(queue != other)Note
Returns the item at the given indexParam
index: int
The index of the item to getReturn
item: any
The item at the given indexExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
print(queue[2])def setitem(self, index, value):
Note
Sets the item at the given index to the given valueParam
index: int
The index of the item to set
value: any
The value to set the item toReturn
NoneExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
queue[2] = 10
print(queue)Note
Deletes the item at the given indexParam
index: int
The index of the item to deleteReturn
NoneExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
del queue[2]
print(queue)Note
Returns an iterator for the queueParam
NoneReturn
iter: iter
An iterator for the queueExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
for item in queue:
print(item)Note
Returns an iterator for the queue in reverse orderParam
NoneReturn
reversed: iter
An iterator for the queue in reverse orderExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
for item in reversed(queue):
print(item)Note
Returns True if the item is in the queue, False otherwiseParam
item: any
The item to check forReturn
is_in: bool
True if the item is in the queue, False otherwiseExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
print(1 in queue)Note
Returns a new queue with the items from both queuesParam
other: Queue
The other queue to add to this queueReturn
new_queue: Queue
A new queue with the items from both queuesExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
other = Queue([6, 7, 8, 9, 10], max_size=10)
new_queue = queue + other
print(new_queue)Note
Returns this queue with the items from both queuesParam
other: Queue
The other queue to add to this queueReturn
self: Queue
This queue with the items from both queuesExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
other = Queue([6, 7, 8, 9, 10], max_size=10)
queue += other
print(queue)Note
Returns a new queue with the items from this queue repeated the given number of timesParam
other: int
The number of times to repeat the queueReturn
new_queue: Queue
A new queue with the items from this queue repeated the given number of timesExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
new_queue = queue * 3
print(new_queue)Note
Returns this queue with the items from this queue repeated the given number of timesParam
other: int
The number of times to repeat the queueReturn
self: Queue
This queue with the items from this queue repeated the given number of timesExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
queue *= 3
print(queue)Note
Returns a string representation of the queueParam
NoneReturn
string: str
A string representation of the queueExample
queue = Queue([1, 2, 3, 4, 5], max_size=10)
print(queue)
Documentation For toolbox/database.py
Documentation For toolbox/database.py
Note
This function is used to set the path to the folder where the database files will be storedParam
ters
----------
path : str
The path to the folder where the database files will be storedReturn
None
This function does not return anythingExample
set_storage_path('C:/Users/JohnDoe/Documents/MyDatabase')Reference
No Linksdef slugify(value, allow_unicode=False):
Note
This function is used to slugify strings, which basically means to remove all special characters and replace them with dashes.
This is useful for creating file names from strings.Param
ters
----------
value : str
The string to be slugified
allow_unicode : bool
Whether or not to allow unicode charactersReturn
str
The slugified stringExample
a = slugify('Hello World')Reference
https://github.com/django/django/blob/master/django/utils/text.pyNote
This function is used to load objects from the database folderParam
ters
----------
name : str
The name of the file to be loadedReturn
object or None
The object loaded from the file, could be anythingExample
spreadsheet_data = get('spreadsheet_people')Reference
No Linksdef get_modified_date(name: str):
Note
This function is used to get the last modified date of a file in the database folderParam
ters
----------
name : str
The name of the file to be loadedReturn
datetime.datetime or None
The datetime object of the last modified dateExample
date = get_modified_date('spreadsheet_people')Reference
No Linksdef save(name: str, data: any) -> None:
Note
This function is used to save objects to the database folderParam
ters
----------
name : str
The name of the file to be saved
data : any
The data to be savedReturn
None
This function does not return anythingExample
spreadsheet_data = {"People": ["Bill", "Kent", "Steve"], "Ages": [20, 30, 40]}
save('spreadsheet_people', spreadsheet_data)Reference
No Linksdef delete_database(name: str) -> object:
Note
This function is used to delete objects from the database folderParam
ters
----------
name : str
The name of the file to be deletedReturn
object or None
The object loaded from the file, could be anythingExample
spreadsheet_data = {"People": ["Bill", "Kent", "Steve"], "Ages": [20, 30, 40]}
save('spreadsheet_people', spreadsheet_data)
delete_database('spreadsheet_people')Reference
No Linksdef save_key(platform: str, key: str, override: bool = False) -> None:
Note
This function is used to save keys in a secure locationParam
ters
----------
platform: str
The name of the platform to be saved (e.g. 'google')
key: str
The key to be saved (e.g. '<google_api_key>')
override: bool
Whether or not to override the key if it already existsReturn
None
This function does not return anythingExample
save_key('google', '<google_api_key>')Reference
https://www.nylas.com/blog/making-use-of-environment-variables-in-python/def load_key(platform: str) -> str:
Note
This function is used to load keys from a secure locationParam
ters
----------
platform: str
The key to be loaded (e.g. '<google_api_key>')Return
str or None
This function returns the key if it exists, otherwise it returns NoneExample
key = load_key('google')Reference
https://www.nylas.com/blog/making-use-of-environment-variables-in-python/