A modular Python toolkit housing various utility functions for:
- Gmail (sending, authentication, handling)
- Google Sheets (creating/updating sheets, reading data)
- Salesforce (OAuth, query, reporting)
- SharePoint (authentication, file explorer, file uploader)
- Genesys (authentication, conversation/user queries, transformations)
Each utility is cleanly separated into its own package under src/utility_functions/.
py_toolkit/
├── README.md
├── google_oauth_token.json
├── google_oauth_access_token.json
├── google_service_account.json
├── pyproject.toml
├── requirements.txt
├── src
│ ├── __init__.py
│ └── utility_functions
│ ├── __init__.py
│ ├── genesys_utility
│ │ ├── __init__.py
│ │ ├── auth.py
│ │ ├── common.py
│ │ ├── conversation.py
│ │ ├── conversation_details_query.py
│ │ ├── transformations.py
│ │ └── users.py
│ ├── gmail_utility
│ │ ├── __init__.py
│ │ ├── auth.py
│ │ ├── common.py
│ │ ├── file_handling.py
│ │ ├── inbox.py
│ │ └── send.py
│ ├── google_sheets_utility
│ │ ├── __init__.py
│ │ ├── common.py
│ │ └── sheets.py
│ ├── salesforce_utility
│ │ ├── __init__.py
│ │ ├── auth.py
│ │ ├── common.py
│ │ ├── query.py
│ │ ├── reporting.py
│ │ └── transformations.py
│ └── sharepoint_utility
│ ├── __init__.py
│ ├── auth.py
│ ├── common.py
│ ├── explorer.py
│ └── uploader.py
└── tests
├── test_genesys_utility.py
├── test_gmail_utility.py
├── test_google_sheets_utility.py
├── test_salesforce_utility.py
└── test_sharepoint_utility.pygmail_utility:- Sending emails with attachments via Gmail API.
- Reviewing Inbox emails and attachments therein.
google_sheets_utility: Creating, reading, updating Google Sheetssalesforce_utility: OAuth flows, SOQL queries, Analytics reportingsharepoint_utility: Auth, file explorer, and uploadinggenesys_utility: Auth, conversation/user queries, transformations
- Clone this repository:
git clone https://github.com/your-org/py_toolkit.git
cd py_toolkit
# Using pip + requirements.txt
pip install -r requirements.txt- Install Dependencies (either via requirements.txt or pyproject.toml):
# Using pip + requirements.txt
pip install -r requirements.txt
# OR using Poetry
poetry install- Environment Variables Many utilities rely on .env files or environment variables for credentials (e.g. SF_REFRESH, MAIN_USER, GENESYS_ACCESS_TOKEN, etc.). By default, the .env is expected at ~/Documents/py_toolkit/.env. Adjust or overwrite paths as needed.
- Gmail Utility
from src.utility_functions.gmail_utility.send import gmail_send_message
gmail_send_message(
data="/path/to/file.csv", # or pd.DataFrame
receivers="someone@example.com",
file_titles="report.csv",
subject="Daily Report",
content="Please see attached."
)from src.utility_functions.gmail_utility.inbox import gmail_reports_inbox
gmail_reports_inbox(
search_query='subject: Super Unique Subject',
stored_file_path=os.path.join(os.path.expanduser('~'), 'Downloads'),
multiple_files=False
)- Google Sheets Utility
from src.utility_functions.google_sheets_utility.sheets import create_or_update_google_sheet
create_or_update_google_sheet(
share_with="user@example.com",
df=my_dataframe,
workbook_name="MyWorkbook",
sheet_name="Sheet1",
interactive=False
)- Salesforce Utility
from src.utility_functions.salesforce_utility.query import query_salesforce_soql
# Assuming SF_REFRESH token is stored in .env
df = query_salesforce_soql("SELECT Id, Name FROM Account LIMIT 10")
print(df.head())
- Sharepoint Utility
from src.utility_functions.sharepoint_utility.uploader import upload_file_to_sharepoint
result = upload_file_to_sharepoint(
base_url="https://mycompany.sharepoint.com",
site_path="/sites/MySite",
username="myuser@company.com",
password="SecretPassword",
library_title="Documents",
root_subfolder="General",
local_file_path="/path/to/file.xlsx"
)
print(result)- Genesys Utility
from src.utility_functions.genesys_utility.auth import get_genesys_access_token
get_genesys_access_token("CLIENT_ID", "CLIENT_SECRET", "mypurecloud.com")
# This sets genesys.configuration.access_token internallyI used pytest for testing. All tests reside under tests/, grouped by integration type (e.g., test_gmail_utility.py for Gmail, etc.).
Run the full test suite:
python -m pytest tests- Each external API call is mocked. No real network calls occur.
- Credentials and environment variables are mocked or read from .env.
- Fork the repo & create a new branch.
- Implement new features or bugfixes in the appropriate utility directory.
- Add/Update Tests in tests/.
- Open a Pull Request and link to any related issues.
This project is licensed under the MIT License. Please see LICENSE for details.