gitignore File Downloader

0.1.4 · maintenance · verified Thu Apr 16

The Python `ignore` library (pypi-slug `ignore`) is a utility that fetches `.gitignore` file templates for various languages and operating systems directly from the official `github/gitignore` repository. It offers both a simple command-line interface and a programmatic API for integrating .gitignore file retrieval into Python projects. The latest version is 0.1.4, released in 2017, indicating it is in maintenance mode with infrequent updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically fetch a .gitignore file for a specific language (e.g., 'python') or multiple languages using the `Ignore` class, and print its content. It also illustrates how to handle cases where fetching might fail. Alternatively, use the CLI: `ignore python`.

import os
from ignore import Ignore

# Initialize the Ignore client
client = Ignore()

# Fetch the .gitignore content for Python
python_gitignore = client.fetch('python')

if python_gitignore:
    print("--- .gitignore for Python ---")
    print(python_gitignore)
    # Example: Save to a file
    # with open('.gitignore', 'w') as f:
    #     f.write(python_gitignore)
else:
    print("Could not fetch .gitignore for Python. Check language name or network connection.")

# You can also fetch multiple languages (e.g., 'java' and 'node')
# Combined content is returned as a single string
java_and_node_gitignore = client.fetch(['java', 'node'])
if java_and_node_gitignore:
    print("\n--- .gitignore for Java and Node ---")
    print(java_and_node_gitignore)

view raw JSON →