Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [dev, main, master]
pull_request:
branches: [dev, main, master]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --python ${{ matrix.python-version }}

- name: Run tests
run: uv run pytest --cov-report term-missing --cov=tldr/ -vs tests/
Comment on lines +25 to +29
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

9 changes: 0 additions & 9 deletions Makefile

This file was deleted.

6 changes: 0 additions & 6 deletions dev-requirements.txt

This file was deleted.

48 changes: 48 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[project]
name = "tldr.py"
version = "0.8.0"
description = "A python client for tldr: simplified and community-driven man pages."
readme = "README.rst"
license = "MIT"
authors = [
{ name = "lord63", email = "lord63.j@gmail.com" },
]
requires-python = ">=3.10"
keywords = ["tldr", "cli", "man", "command", "usage"]
classifiers = [
"Development Status :: 4 - Beta",
"Operating System :: POSIX",
"Operating System :: POSIX :: Linux",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"click>=8.0",
"PyYAML>=6.0",
]

[project.scripts]
tldr = "tldr.cli:cli"

[project.urls]
Homepage = "https://github.com/lord63/tldr.py"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["tldr"]

[tool.pytest.ini_options]
testpaths = ["tests"]

[dependency-groups]
dev = [
"pytest>=8.0",
"pytest-cov>=5.0",
]
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

43 changes: 0 additions & 43 deletions setup.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
from os import path
Expand Down
3 changes: 1 addition & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from unittest import mock

Expand All @@ -16,7 +15,7 @@ def test_config_not_exist(self):
)

def test_invalid_yaml_file(self):
with mock.patch('io.open',
with mock.patch('builtins.open',
mock.mock_open(read_data="%YAML:1.0\nname:jhon")):
self._assert_exception_message(
"The config file is not a valid YAML file."
Expand Down
3 changes: 0 additions & 3 deletions tests/test_find.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from basic import BasicTestCase

Expand Down
6 changes: 1 addition & 5 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import io
import os
from os import path

Expand All @@ -25,7 +21,7 @@ def test_init(self):
'platform': 'linux',
'repo_directory': self.repo_dir
}
with io.open(self.config_path, encoding='utf-8') as f:
with open(self.config_path, encoding='utf-8') as f:
config = yaml.safe_load(f)
assert expected_config == config

Expand Down
3 changes: 0 additions & 3 deletions tests/test_list.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from basic import BasicTestCase

Expand Down
3 changes: 0 additions & 3 deletions tests/test_locate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from os import path

Expand Down
3 changes: 1 addition & 2 deletions tests/test_parse.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
from unittest import mock
Expand Down Expand Up @@ -51,6 +50,6 @@ def _assert_mock_read(self, page_content):
'\x1b[0m\n\x1b[0m'
)
with mock.patch('tldr.parser.get_config', return_value=mock_config):
with mock.patch('io.open', mock.mock_open(read_data=page_content)):
with mock.patch('builtins.open', mock.mock_open(read_data=page_content)):
result = parse_page('/repo_directory/pages/common/node.md')
assert ''.join(result) == expected_result
7 changes: 2 additions & 5 deletions tests/test_reindex.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import os
from os import path
Expand All @@ -12,7 +9,7 @@

class TestReindex(BasicTestCase):
def setUp(self):
super(TestReindex, self).setUp()
super().setUp()

# Add a new page.
self.page_path = path.join(self.repo_dir, 'pages')
Expand All @@ -25,7 +22,7 @@ def setUp(self):
path.join(self.page_path, 'index_bak.json'))

def tearDown(self):
super(TestReindex, self).tearDown()
super().tearDown()
if path.exists(self.new_page):
os.remove(self.new_page)
# Restore the index.json.
Expand Down
1 change: 0 additions & 1 deletion tests/test_update.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from unittest import mock

Expand Down
1 change: 0 additions & 1 deletion tldr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
tldr.py
Expand Down
8 changes: 2 additions & 6 deletions tldr/cli.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import io
import json
from operator import itemgetter
import os
Expand All @@ -29,8 +25,8 @@ def parse_man_page(command, platform):
def get_index():
"""Retrieve index in the pages directory."""
repo_directory = get_config()['repo_directory']
with io.open(path.join(repo_directory, 'pages/index.json'),
encoding='utf-8') as f:
with open(path.join(repo_directory, 'pages/index.json'),
encoding='utf-8') as f:
index = json.load(f)
return index

Expand Down
6 changes: 1 addition & 5 deletions tldr/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import io
import os
from os import path
import sys
Expand All @@ -21,7 +17,7 @@ def get_config():
sys.exit("Can't find config file at: {0}. You may use `tldr init` "
"to init the config file.".format(config_path))

with io.open(config_path, encoding='utf-8') as f:
with open(config_path, encoding='utf-8') as f:
try:
config = yaml.safe_load(f)
except yaml.scanner.ScannerError:
Expand Down
6 changes: 1 addition & 5 deletions tldr/parser.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import io
import click

from tldr.config import get_config
Expand All @@ -12,7 +8,7 @@
def parse_page(page):
"""Parse the command man page."""
colors = get_config()['colors']
with io.open(page, encoding='utf-8') as f:
with open(page, encoding='utf-8') as f:
lines = f.readlines()
output_lines = []
for line in lines[1:]:
Expand Down
13 changes: 0 additions & 13 deletions tox.ini

This file was deleted.

Loading
Loading