Skip to content

Commit

Permalink
Add CLI using github.com/simonw/click-app (#58)
Browse files Browse the repository at this point in the history
I want a CLI tool to download any issue from Il Fatto Quotidiano (IFQ) website.

Mix the current implementation with https://github.com/simonw/click-app
  • Loading branch information
zmoog authored Jan 2, 2025
1 parent f3a1117 commit 066170a
Show file tree
Hide file tree
Showing 14 changed files with 274 additions and 215 deletions.
17 changes: 0 additions & 17 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/ci.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish Python Package

on:
release:
types: [created]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install '.[test]'
- name: Run tests
run: |
python -m pytest
deploy:
runs-on: ubuntu-latest
needs: [test]
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install setuptools wheel build
- name: Build
run: |
python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1

29 changes: 0 additions & 29 deletions .github/workflows/release.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test

on: [push, pull_request]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install '.[test]'
- name: Run tests
run: |
python -m pytest
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.PHONY:

sources = ifq tests
line_length = 79
black_options = --line-length=${line_length} ${sources}
isort_options = --line-length=${line_length} --py 39 --profile black ${sources}
line_length = 80
black_options = --line-length=${line_length} ifq tests
isort_options = **/*.py -l ${line_length}

lint: lint-black lint-isort lint-flake8 ## Lint the project on the host

Expand Down
115 changes: 41 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,101 +1,68 @@
# IFQ
# ifq

Library to download www.ilfattoquotidiano.it issues in PDF.
[![PyPI](https://img.shields.io/pypi/v/ifq.svg)](https://pypi.org/project/ifq/)
[![Changelog](https://img.shields.io/github/v/release/zmoog/ifq?include_prereleases&label=changelog)](https://github.com/zmoog/ifq/releases)
[![Tests](https://github.com/zmoog/ifq/actions/workflows/test.yml/badge.svg)](https://github.com/zmoog/ifq/actions/workflows/test.yml)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/zmoog/ifq/blob/master/LICENSE)

```python
from datetime import date
from ifq import Scraper
CLI tool and Python library to download PDF issues of ilfattoquotidiano.it

username = '' # your ifq username
password = '' # your ifq password
## Installation

scraper = Scraper(username, password)
Install this tool using `pip`:

path_to_pdf_file = scraper.download_pdf(date.today())
```bash
pip install ifq
```

## Getting Started
## Usage

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Download the IFQ issue for Jan, 2nd 2025:

### Prerequisites
```sh
# Requires a valid subscription to the newspaper
export IFQ_USERNAME="[your username]"
export IFQ_PASSWORD="[your password]"

What things you need to install the software and how to install them
$ ifq issues download 2025-01-02

```
Give examples
```

### Installing

A step by step series of examples that tell you how to get a development env running
Downloading issue for 2025-01-02 00:00:00 to /Users/zmoog/code/projects/zmoog/ifq
Downloaded issue to /Users/zmoog/code/projects/zmoog/ifq/2025-01-02.pdf

Say what the step will be

```
Give the example
$ file 2025-01-02.pdf
2025-01-02.pdf: PDF document, version 1.7
```

And repeat
For help, run:

```
until finished
```bash
ifq --help
```

End with an example of getting some data out of the system or using it for a little demo

## Running the tests

Explain how to run the automated tests for this system

### Break down into end to end tests

Explain what these tests test and why
You can also use:

```
Give an example
```bash
python -m ifq --help
```

### And coding style tests
## Development

Explain what these tests test and why
To contribute to this tool, first checkout the code. Then create a new virtual environment:

```bash
cd ifq
python -m venv venv
source venv/bin/activate
```
Give an example
```

## Deployment

Add additional notes about how to deploy this on a live system
Now install the dependencies and test dependencies:

## Built With

* [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used
* [Maven](https://maven.apache.org/) - Dependency Management
* [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds

## Contributing

Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).

## Authors

* **Billie Thompson** - *Initial work* - [PurpleBooth](https://github.com/PurpleBooth)

See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

## Acknowledgments
```bash
pip install -e '.[test]'
```

* Hat tip to anyone whose code was used
* Inspiration
* etc
To run the tests:

https://gist.github.com/PurpleBooth/109311bb0361f32d87a2
```bash
python -m pytest
```
Loading

0 comments on commit 066170a

Please sign in to comment.