Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMili committed Dec 5, 2024
0 parents commit 2b2f1b4
Show file tree
Hide file tree
Showing 14 changed files with 622 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix:
# Python
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"
commit-message:
prefix:
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Github actions init
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Update Pip
run: pip install --upgrade pip

- name: Install Dependencies
run: pip install ruff mypy

- name: Install
run: pip install -e .

- name: Lint
run: bash scripts/lint.sh
33 changes: 33 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish

on:
workflow_dispatch:
release:
types:
- created

jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Github actions init
uses: actions/checkout@v4
with:
# To force fetching tags
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Install build dependencies
run: pip install build

- name: Build distribution
run: python -m build

- name: Publish
uses: pypa/[email protected]
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

on:
workflow_dispatch:

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Github actions init
uses: actions/checkout@v4
with:
# To force fetching tags
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Install build dependencies
run: pip install build

- name: Build
run: python -m build

- name: Read VERSION file
id: getversion
run: echo "version=$(cat src/extract_favicon/VERSION.md)" >> $GITHUB_OUTPUT

- name: Changelog
run: git log $(git describe --tags --abbrev=0)..HEAD --format="%s %h" > LATEST-CHANGES.md

- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/extract_favicon-${{ steps.getversion.outputs.version }}-py3-none-any.whl
dist/extract_favicon-${{ steps.getversion.outputs.version }}.tar.gz
tag_name: v${{ steps.getversion.outputs.version }}
body_path: LATEST-CHANGES.md
token: ${{ secrets.PAT_EXTRACT_FAVICON }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.venv
__pycache__
*.pyc
.ruff_cache
.mypy_cache
.pytest_cache
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Extract Favicon

`extract-favicon` is a Python library to find and extract the favicon of any website.

## Installation

```bash
pip install favicon-extract
```

## Usage

```console
>>> import extract_favicon
>>> icons = extract_favicon.from_html(my_html, root_url="https://www.python.org/static/")
Icon(url='https://www.python.org/static/apple-touch-icon-144x144-precomposed.png', width=144, height=144, format='png')
Icon(url='https://www.python.org/static/apple-touch-icon-114x114-precomposed.png', width=114, height=114, format='png')
Icon(url='https://www.python.org/static/apple-touch-icon-72x72-precomposed.png', width=72, height=72, format='png')
Icon(url='https://www.python.org/static/apple-touch-icon-precomposed.png', width=0, height=0, format='png')
Icon(url='https://www.python.org/static/favicon.ico', width=0, height=0, format='ico')
```

## Inspiration
This library is an extension of the [favicon](https://github.com/scottwernervt/favicon/) package.
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "extract-favicon"
description = "Find and extract the favicon of any website"
dynamic = ["version"]
readme = "README.md"
authors = [{ name = "Alex Mili" }]
license = { file = "LICENSE" }
requires-python = ">=3.9"
classifiers = [
"License :: OSI Approved :: MIT License",
"Intended Audience :: Developers",
]
keywords = []
dependencies = [
"bs4",
"pillow"
]

[project.urls]
Homepage = "https://github.com/AlexMili/Extract_Favicon"
Issues = "https://github.com/AlexMili/Extract_Favicon/issues"
Repository = "https://github.com/AlexMili/Extract_Favicon"
Documentation = "https://github.com/AlexMili/Extract_Favicon"


[tool.hatch.build.targets.wheel]
packages = ["./src/extract_favicon/"]

[tool.hatch.version]
path = "src/extract_favicon/VERSION.md"
pattern = "(?P<version>.*)"

[tool.ruff.lint.isort]
lines-after-imports = 2
known-first-party = ["extract_favicon"]

[tool.mypy]
strict = true
exclude = [".venv", "test", "build", "dist"]
ignore_missing_imports = true
show_error_codes = true
7 changes: 7 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e
set -x

mypy src/extract_favicon
ruff check src/extract_favicon
1 change: 1 addition & 0 deletions src/extract_favicon/VERSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
11 changes: 11 additions & 0 deletions src/extract_favicon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os.path as osp

from .main import from_html


__all__ = ["from_html"]

version_path = osp.join(osp.dirname(__file__), "VERSION.md")
if osp.exists(version_path):
with open(version_path, "r") as f:
__version__ = f.readline()
Loading

0 comments on commit 2b2f1b4

Please sign in to comment.