Skip to content

Commit

Permalink
Add Poetry configuration
Browse files Browse the repository at this point in the history
* Remove manifest.in and setup.py--both of these are replaced by
  pyproject.toml
* Separate dependencies from dev dependencies
* I've used the ^ to specify all dependencies, allowing for semver-
  compatible upgrades
* Change author from Parker to FPF
* Add Harris and Erik as maintainers
* Add development instructions to readme
* Move all sample files to sample_project/ directory
  • Loading branch information
harrislapiroff committed Jul 20, 2023
1 parent 2679fd9 commit 0eaaa27
Show file tree
Hide file tree
Showing 9 changed files with 895 additions and 49 deletions.
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
config.yaml
rssfeeds.json
matchwords.txt
__pycache__/*
*.db
ttnconfig/*
*.egg-info
*.egg-info
sample_project/rssfeeds.json
sample_project/matchlist.txt
sample_project/matchlist_case_sensitive.txt
sample_project/config.yaml
sample_project/blocklist.py
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,49 @@ All articles are recorded in a sqlite database.

In some cases, you may wish to suppress articles from being posted, even though they would otherwise match. You can do so by writing a new function, `check`, and placing it in a file named `blocklist.py` in the configuration directory. `check` takes an Article (and so has access to its `outlet`, `title`, and `url`) and should return `true` for any article that should be skipped.

## Development

### Quick Start

```bash
poetry install
poetry run trackthenews sample_project
# Follow the setup script instructions
cat sample_project/matchlist-sample.txt > sample_project/matchlist.txt
cat sample_project/rssfeeds-sample.json > sample_project/rssfeeds.json
poetry run trackthenews sample_project
```

### Detailed Instructions

To develop `trackthenews`, clone the repository and install the package using [poetry][] and run the CLI tool:

```bash
# This will create a virtual environment and install trackthenews and its dependencies
poetry install
# This will run the setup script
poetry run trackthenews sample_project
```

On first run this will take you through the interactive setup process. Follow the instructions. You will need a Twitter account with application keys and/or a Mastodon account.

When the setup process is complete, the configuration for your bot will live in the `sample_project` directory. Fill out the `matchlist.txt`, `matchlist_case_sensitive.txt`, and `rssfeeds.json` files or copy configuration from the provided samples:

```bash
cat sample_project/matchlist-sample.txt > sample_project/matchlist.txt
cat sample_project/rssfeeds-sample.json > sample_project/rssfeeds.json
```

`matchlist_case_sensitive.txt` is optional and we don't provide a sample.

Now run the bot:

```bash
poetry run trackthenews sample_project
```

[poetry]: https://python-poetry.org/

## License

MIT.
807 changes: 807 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

40 changes: 39 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
[tool.black]
line-length = 100
target-version = ['py39']
target-version = ['py39']

[tool.poetry]
name = "trackthenews"
version = "0.2"
description = "Monitor RSS feeds for keywords and act on matching results. A special project of the Freedom of the Press Foundation."
authors = ["Freedom of the Press Foundation <[email protected]>"]
maintainers = [
"Harris Lapiroff <[email protected]>",
"Erik Möller <[email protected]>",
]
license = "MIT"
readme = "README.md"
repository = "https://github.com/freedomofpress/trackthenews"
include = ["trackthenews/fonts/*"]

[tool.poetry.dependencies]
python = "^3.9"
feedparser = "^6.0"
future = "^0.17.1"
html2text = "2018.1.9"
Pillow = "^8.4"
pyaml = "^18.11.0"
readability-lxml = "^0.8.1"
requests = "^2.31.0"
tweepy = "^4.14.0"
"Mastodon.py" = "^1.8.1"

[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
flake8 = "^6.0.0"
isort = "^5.12.0"

[tool.poetry.scripts]
trackthenews = 'trackthenews:main'

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
12 changes: 0 additions & 12 deletions requirements.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
31 changes: 0 additions & 31 deletions setup.py

This file was deleted.

0 comments on commit 0eaaa27

Please sign in to comment.