{"id":18043258,"url":"https://github.com/gabriellopesdesouza2002/funcspy","last_synced_at":"2026-02-15T21:04:44.468Z","repository":{"id":260088664,"uuid":"878599932","full_name":"gabriellopesdesouza2002/funcspy","owner":"gabriellopesdesouza2002","description":"Functions to help you develop any program or script you want","archived":false,"fork":false,"pushed_at":"2024-11-03T17:56:45.000Z","size":97159,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-05T13:58:08.097Z","etag":null,"topics":["automation","chatbot","dall-e","email","email-library","ocr","openai-api","openai-chatgpt","openai-whisper","pdf","pdf-tools","python","regex","selenium","selenium-webdriver","whisper"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gabriellopesdesouza2002.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-25T17:32:48.000Z","updated_at":"2024-11-03T17:56:48.000Z","dependencies_parsed_at":"2025-04-09T22:15:45.152Z","dependency_job_id":null,"html_url":"https://github.com/gabriellopesdesouza2002/funcspy","commit_stats":null,"previous_names":["gabriellopesdesouza2002/funcspy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gabriellopesdesouza2002/funcspy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabriellopesdesouza2002%2Ffuncspy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabriellopesdesouza2002%2Ffuncspy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabriellopesdesouza2002%2Ffuncspy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabriellopesdesouza2002%2Ffuncspy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabriellopesdesouza2002","download_url":"https://codeload.github.com/gabriellopesdesouza2002/funcspy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabriellopesdesouza2002%2Ffuncspy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29489370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T19:29:10.908Z","status":"ssl_error","status_checked_at":"2026-02-15T19:29:10.419Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","chatbot","dall-e","email","email-library","ocr","openai-api","openai-chatgpt","openai-whisper","pdf","pdf-tools","python","regex","selenium","selenium-webdriver","whisper"],"created_at":"2024-10-30T17:07:44.279Z","updated_at":"2026-02-15T21:04:44.438Z","avatar_url":"https://github.com/gabriellopesdesouza2002.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# funcspy - Functions to help you develop any program or script you want\n## Functions for the main technologies\n\n* Functions for your any project with **Python**, for any moments\n* Functions for send emails easly with **Outlook** and **Gmail**\n* Functions for used in your **GUI** with **Tkinter**\n* Functions for use in your projects with **Openai**\n* Functions most used in projects with **PDF**, exemple, **OCR**\n* Functions for auxiliary in your projects with **Selenium** and **BeautifulSoup**\n\n## Instalation\n\n`pip install -U funcspy`\n\n### Automatically installed libraries\n* selenium\n* bs4\n* requests\n* html5lib\n* webdriver-manager\n* pretty-html-table\n* xlsxwriter\n* pandas\n* sqlalchemy\n* rich\n* pyinstaller\n* filetype\n* pytesseract\n* tqdm\n* pillow\n* PyMuPDF\n* holidays\n* numpy==1.26.0\n\n## Example of using some of the most important functions\n\n### Emails\n\n#### Example Usage of `send_email_gmail` Function\n\nBelow is an example of how to use the `send_email_gmail` function to send an email with multiple recipients and attachments.\n\n```python\nfrom funcspy.emails_funcs.emails_funcs import send_email_gmail\n\n# Email settings\nemail_app_google = \"your_email@gmail.com\"\npasswd_app_gmail = \"your_app_password\"\nemails_to = [\"recipient1@example.com\", \"recipient2@example.com\"]\nsubject = \"Email subject\"\nbody_msg = \"Email body in HTML format\"\n\n# Attachments (optional)\nattachments = [\"path/to/file1.pdf\", \"path/to/file2.docx\"]\n\n# Send the email\nsend_email_gmail(email_app_google, passwd_app_gmail, emails_to, subject, body_msg, attachments)\n\n```\n\n#### Example Usage of `send_email_outlook` Function\n\nBelow is an example of how to use the `send_email_outlook` function to send an email with Outlook, including options for recipients, subject, HTML body, attachments, and embedding a DataFrame.\n\n```python\nfrom funcspy.emails_funcs.emails_funcs import send_email_outlook\n\n# Email settings\nto = [\"recipient1@example.com\", \"recipient2@example.com\"]\nsubject = \"E-mail Subject\"\nbody = \"\u003cp\u003eHello!\u003c/p\u003e\"\n\n# Attachments (optional)\nattachments = [\"path/to/file1.pdf\", \"path/to/file2.docx\"]\n\n# DataFrame to be embedded in email body (optional)\n# Example format: [df, 'theme_on_pretty_html_table']\nsend_dateframe_on_body = False  # Set to [dataframe, 'theme'] if using pretty_html_table\n\n# Send the email\nsend_email_outlook(to, subject, body, attachments, send_dateframe_on_body)\n```\n\n### GUI\n\n#### Example Usage of `show_popup` Function\n\nBelow is an example of how to use the `show_popup` function to display a popup window with a specified title and message text.\n\n```python\nfrom funcspy.gui_funcs.gui_funcs import show_popup\n\n# Popup settings\ntitle = \"Popup Title\"\ntext = \"This is the message displayed in the popup.\"\n\n# Show the popup\nshow_popup(title, text)\n```\n\n### OpenAI (GPT/DALL-E/Whisper)\n\n#### Example Usage of `api_chat_completions` Function\n\nBelow is an example of how to use the `api_chat_completions` function to send a chat completion request to the OpenAI API.\n\n```python\nfrom funcspy.openai_funcs.openai_funcs import api_chat_completions\n\n# API settings\napi_key = 'your_api_key'\nmodel = 'gpt-4-turbo'\nmessages = [\n    {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n    {\"role\": \"user\", \"content\": \"Who won the world series in 2020?\"},\n    {\"role\": \"assistant\", \"content\": \"The Los Angeles Dodgers won the World Series in 2020.\"},\n    {\"role\": \"user\", \"content\": \"Where was it played?\"}\n]\n\n# Send the request\nresponse = api_chat_completions(api_key, model, messages)\nprint(response)\n```\n\n#### Example Usage of `api_image_generation` Function\n\nBelow is an example of how to use the `api_image_generation` function to generate images via the OpenAI API.\n\n```python\nfrom funcspy.openai_funcs.openai_funcs import api_image_generation\n\n# API settings\napi_key = 'your_api_key'\nmodel = 'dall-e-3'\nprompt = 'a photograph of an astronaut riding a horse'\nsize = '1024x1024'\nquality = 'standard'\n\n# Send the request\nresponse = api_image_generation(api_key, prompt, model, size, quality)\nprint(response)\n```\n\n#### Example Usage of `api_vision` Function\n\nBelow is an example of how to use the `api_vision` function to process images and answer questions about them using GPT-4 Turbo with Vision.\n\n```python\nfrom funcspy.openai_funcs.openai_funcs import api_vision\n\n# API settings\napi_key = 'your_api_key'\nmodel = 'gpt-4-turbo'\nmessages = {\n    \"role\": \"user\",\n    \"content\": [\n        {\"type\": \"text\", \"text\": \"What’s in this image?\"},\n        {\n            \"type\": \"image_url\",\n            \"image_url\": {\n                \"url\": \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\",\n            },\n        },\n    ],\n}\n\n# Send the request\nresponse = api_vision(api_key, messages, model)\nprint(response)\n```\n\n#### Example Usage of `api_audio_transcription` Function\n\nBelow is an example of how to use the `api_audio_transcription` function to transcribe audio using the OpenAI API.\n\n```python\nfrom funcspy.openai_funcs.openai_funcs import api_audio_transcription\n\n# API settings\napi_key = 'your_api_key'\nfile_path = 'audio_file.mp3'\nmodel = 'whisper-1'\n\n# Send the request\nresponse = api_audio_transcription(api_key, file_path, model)\nprint(response)\n```\n\n### PDF (OCR/Google Vision/Others)\n\n#### Example Usage of `ocr_tesseract` Function\n\n***It is very important to download the tesseract binaries available in the root of our library on Github***\n\nBelow is an example of how to use the `ocr_tesseract` function to perform OCR on a PDF file using Tesseract with customizable settings.\n\n```python\nfrom funcspy.pdf_funcs.ocr_funcs import ocr_tesseract\n\n# OCR settings\npdf = 'path/to/your_pdf_file.pdf'\ndpi = 300\nfile_output = 'output_filename'\nreturn_text = True\nconfig_tesseract = ''\nlimit_pages = None\nlang = 'eng'\ntimeout = 120\n\n# Perform OCR on the PDF\nresult = ocr_tesseract(\n    pdf=pdf,\n    dpi=dpi,\n    file_output=file_output,\n    return_text=return_text,\n    config_tesseract=config_tesseract,\n    limit_pages=limit_pages,\n    lang=lang,\n    timeout=timeout\n)\n\n# Output the result\nprint(result)\n```\n\n#### Example Usage of `ocr_google_vision` Function\n\nBelow is an example of how to use the `ocr_google_vision` function to perform OCR on a PDF file using Google Vision API with customizable settings.\n\n```python\nfrom funcspy.pdf_funcs.ocr_funcs import ocr_google_vision\n\n# OCR settings\npdf = 'path/to/your_pdf_file.pdf'\napi_key = 'your_google_api_key'\ndpi = 300\nfile_output = 'output_filename'\nreturn_text = True\nlimit_pages = None\nis_image = False\n\n# Perform OCR on the PDF\nresult = ocr_google_vision(\n    pdf=pdf,\n    api_key=api_key,\n    dpi=dpi,\n    file_output=file_output,\n    return_text=return_text,\n    limit_pages=limit_pages,\n    is_image=is_image\n)\n\n# Output the result\nprint(result)\n```\n\n#### Example Usage of `make_ocr_in_pdf_offline` Function\n\nBelow is an example of how to use the `make_ocr_in_pdf_offline` function to extract text from a PDF file offline. This function only works with PDFs where the text is selectable.\n\n```python\nfrom funcspy.pdf_funcs.ocr_funcs import make_ocr_in_pdf_offline\n\n# OCR settings\npath_pdf = 'path/to/your_pdf_file.pdf'\nexport_from_file_txt = 'output_text_file.txt'  # Set to False if you do not want to export to a file\n\n# Perform OCR on the PDF\nresult = make_ocr_in_pdf_offline(path_pdf, export_from_file_txt)\n\n# Output the result\nprint(result)\n```\n\n#### Example Usage of `extract_pages` Function\n\nBelow is an example of how to use the `extract_pages` function to extract a specified number of pages from a PDF file and create a new PDF file.\n\n```python\nfrom funcspy.pdf_funcs.pdfutils.pdfutils import extract_pages\n\n# PDF settings\noriginal_pdf_path = 'path/to/original_pdf_file.pdf'\nnew_pdf_path = 'path/to/new_pdf_file.pdf'\nnum_pages = 10  # Number of pages to extract\n\n# Extract pages from the original PDF\nextract_pages(original_pdf_path, new_pdf_path, num_pages)\n```\n\n#### Example Usage of `split_pdf` Function\n\nBelow is an example of how to use the `split_pdf` function to split a PDF file into multiple files based on a specified page interval.\n\n```python\nfrom funcspy.pdf_funcs.pdfutils.pdfutils import split_pdf\n\n# PDF settings\ninput_path = 'path/to/input_pdf_file.pdf'\noutput_dir = 'output_split'\ninterval = 30  # Number of pages in each split PDF\n\n# Split the PDF\nsplit_pdf(input_path, output_dir, interval)\n```\n\n#### Example Usage of `text_to_pdf` Function\n\nBelow is an example of how to use the `text_to_pdf` function to convert text into a PDF file with specified margins, font, and font size.\n\n```python\nfrom funcspy.pdf_funcs.pdfutils.pdfutils import text_to_pdf\n\n# PDF settings\ntext = \"\"\"This is a sample text to be converted into a PDF file.\nYou can customize the left and bottom margins, font, and font size.\"\"\"\nfilename = 'output_text_pdf.pdf'\nleft_margin = 70\nbottom_margin = 40\nfont = 'Helvetica'\nfont_size = 12\n\n# Convert text to PDF\ntext_to_pdf(text, filename, left_margin, bottom_margin, font, font_size)\n```\n\n### Utils for any moments\n\n#### Example Usage of `remove_accents` Function\n\nBelow is an example of how to use the `remove_accents` function to remove accents from a given text string.\n\n```python\nfrom funcspy.python_funcs.python_funcs import remove_accents\n\n# Text settings\ntext = \"Olá, como você está?\"\n\n# Remove accents from text\nresult = remove_accents(text)\nprint(result)\n```\n\n#### Example Usage of `random_sleep` Function\n\nBelow is an example of how to use the `random_sleep` function to pause execution for a random amount of time between specified minimum and maximum values.\n\n```python\nfrom funcspy.python_funcs.python_funcs import random_sleep\n\n# Sleep settings\nmin_time = 1  # Minimum sleep time in seconds\nmax_time = 5  # Maximum sleep time in seconds\n\n# Execute random sleep\nrandom_sleep(min_time, max_time)\n```\n\n#### Example Usage of `create_dir_in_current_work_dir` Function\n\nBelow is an example of how to use the `create_dir_in_current_work_dir` function to create a directory in the current working directory.\n\n```python\nfrom funcspy.python_funcs.python_funcs import create_dir_in_current_work_dir\n\n# Directory settings\ndir_name = 'new_directory'\nprint_value = True\ncreate_directory = True\n\n# Create directory in the current working directory\nresult = create_dir_in_current_work_dir(dir_name, print_value, create_directory)\nprint(result)\n```\n\n#### Example Usage of `files_with_absolute_file_path` Function\n\nBelow is an example of how to use the `files_with_absolute_file_path` function to get a tuple of absolute file paths from a specified directory.\n\n```python\nfrom funcspy.python_funcs.python_funcs import files_with_absolute_file_path\n\n# Directory path\npath_dir = 'your_directory'\n\n# Get absolute file paths\nresult = files_with_absolute_file_path(path_dir)\nprint(result)\n```\n\n#### Example Usage of `download_file_via_link` Function\n\nBelow is an example of how to use the `download_file_via_link` function to download a file from a specified link.\n\n```python\nfrom funcspy.python_funcs.python_funcs import download_file_via_link\n\n# Download settings\nlink = 'https://filesamples.com/samples/document/xlsx/sample3.xlsx'\nfile_path = 'myplan.xlsx'\ndirectory = 'downloads'  # Set to False if no directory is needed\n\n# Download the file\ndownload_file_via_link(link, file_path, directory)\n```\n\n#### Example Usage of `take_only_numbers` Function\n\nBelow is an example of how to use the `take_only_numbers` function to extract only the numeric characters from a given string.\n\n```python\nfrom funcspy.python_funcs.python_funcs import take_only_numbers\n\n# String with numbers and other characters\nstring = \"2122 asfs 245\"\n\n# Extract only numbers\nresult = take_only_numbers(string)\nprint(result)\n```\n\n#### Example Usage of `read_json` Function\n\nBelow is an example of how to use the `read_json` function to read a JSON file and return its contents as a dictionary.\n\n```python\nfrom funcspy.python_funcs.python_funcs import read_json\n\n# JSON file path\nfile_json = 'path/to/your_file.json'\n\n# Read JSON file\nresult = read_json(file_json)\nprint(result)\n```\n\n#### Example Usage of `zip_dirs` Function\n\nBelow is an example of how to use the `zip_dirs` function to zip multiple directories into a single zip file.\n\n```python\nfrom funcspy.python_funcs.python_funcs import zip_dirs\n\n# Folders to be zipped\nfolders = ['folder1', 'folder_with_files2', 'folder3']\nzip_filename = 'myzip.zip'\n\n# Zip the directories\nzip_dirs(folders, zip_filename)\n```\n\n#### Example Usage of `log` Function\n\nBelow is an example of how to use the `log` function to log messages with various levels, colors, and formats.\n\n```python\nfrom funcspy.python_funcs.python_funcs import log\n\n# Basic log message with color\nlog('This is an informational message', color='green')\n\n# Log message with color and format\nlog('This is a formatted message', color='red', format='b')\n\n# Warning level log with custom styling\nlog('This is a warning message!', level='w', color='yellow on black b i')\n\n# Critical level log\nlog('Critical error occurred!', level='c', color='red on yellow b i s blink')\n\n# Error level log\nlog('An error has been encountered', level='e', color='purple')\n```\n\n#### Example Usage of `support_long_paths` Function\n\nBelow is an example of how to use the `support_long_paths` function to adjust a path for long filename support on Windows.\n\n```python\nfrom funcspy.python_funcs.python_funcs import support_long_paths\n\n# Path settings\ndos_path = 'your/very/long/path/to/a/directory/or/file'\nencoding = None  # Set to specific encoding if needed\n\n# Get long path support\nresult = support_long_paths(dos_path, encoding)\nprint(result)\n```\n\n#### Example Usage of `humanize_time` Function\n\nBelow is an example of how to use the `humanize_time` function to get a human-readable string representing the time elapsed from a given datetime or timestamp.\n\n```python\nfrom funcspy.python_funcs.python_funcs import humanize_time\nfrom datetime import datetime, timedelta\n\n# Time settings\ntime = datetime.now() - timedelta(days=1, hours=5)  # Example: 1 day and 5 hours ago\n\n# Get human-readable time\nresult = humanize_time(time)\nprint(result)\n```\n\n#### Example Usage of `clean_directory` Function\n\nBelow is an example of how to use the `clean_directory` function to delete all contents of a specified directory, with options for handling files with long names and retrying on permission errors.\n\n```python\nfrom funcspy.python_funcs.python_funcs import clean_directory\nimport os\n\n# Define the directory to clean\ndirectory_to_clean = os.path.join(os.getcwd(), \"example_directory\")\n\n# Clean the directory with default settings\nclean_directory(directory_to_clean)\n\n# Clean the directory with custom settings\nclean_directory(directory_to_clean, timeout_for_clear=10, max_attempts=5, support_long_names=True)\n```\n\n## References\n\n* [Rich Formatting for Colors](https://chatgpt.com/c/671e9e2b-8e9c-8008-83aa-61459c33d0ef#:~:text=Rich%20Formatting%20for%20Colors)\n* [Tesseract OCR](https://github.com/tesseract-ocr/tesseract)\n* [Google Vision API](https://cloud.google.com/vision/docs)\n\n# License\n\nMIT License\n\n# Contact\n\nQuestions, thanks and even financial help? Just call me on\n\n* Linkedin:\n  * [in/gabriel-lopes2002](https://www.linkedin.com/in/gabriel-lopes2002/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabriellopesdesouza2002%2Ffuncspy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabriellopesdesouza2002%2Ffuncspy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabriellopesdesouza2002%2Ffuncspy/lists"}