Skip to content
Open
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
17 changes: 0 additions & 17 deletions MANIFEST.in

This file was deleted.

29 changes: 18 additions & 11 deletions changelogs/changelogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import functools
import subprocess
from tempfile import mkdtemp
import imp
from importlib.util import module_from_spec, spec_from_file_location
import requests
import os
import re
Expand Down Expand Up @@ -30,20 +30,27 @@ def _load_custom_functions(vendor, name):
functions = {}
# Some packages have dash in their name, replace them with underscore
# E.g. python-ldap to python_ldap
filename = "{}.py".format(name.replace("-", "_").lower())
filename = f"{name.replace('-', '_').lower()}.py"
path = os.path.join(
os.path.dirname(os.path.realpath(__file__)), # current working dir
"custom", # /dir/parser
vendor, # /dir/parser/pypi
filename # /dir/parser/pypi/django.py
)
if os.path.isfile(path):
module_name = "parser.{vendor}.{name}".format(vendor=vendor, name=name)
module = imp.load_source(module_name, path)
functions = dict(
(function, getattr(module, function, None)) for function in ALLOWED_CUSTOM_FUNCTIONS
module_name = f"parser.{vendor}.{name}"
spec = spec_from_file_location(module_name, path)
if spec is None or spec.loader is None:
return functions

module = module_from_spec(spec)
spec.loader.exec_module(module)

functions = {
function: getattr(module, function)
for function in ALLOWED_CUSTOM_FUNCTIONS
if hasattr(module, function)
)
}
return functions


Expand Down Expand Up @@ -235,7 +242,7 @@ def get_limited_content_entry(session, url, chars_limit):
# Avoid https://github.com/psf/requests/issues/3359
if not resp.encoding:
resp.encoding = 'utf-8'
limited_content = resp.iter_content(chunk_size=chars_limit,
limited_content = resp.iter_content(chunk_size=chars_limit,
decode_unicode=True).__next__()
except StopIteration:
pass
Expand Down Expand Up @@ -280,11 +287,11 @@ def get_content(session, urls, chars_limit):

else:
content += "\n\n" + get_limited_content_entry(session, url, chars_limit)

# To avoid exceeding the content limit by accumulation
if len(content) > chars_limit:
break
break

except requests.ConnectionError:
pass
return content
Expand Down
4 changes: 3 additions & 1 deletion changelogs/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def main():
action="store_true")
parser.add_argument("-c", "--commits", help="",
action="store_true")
parser.add_argument("-r", "--reverse", help="list changelogs from older to newer", action="store_false")
parser.add_argument("-n", help="only show the n first results (defaults to all)", type=int)

args = parser.parse_args()
if args.verbose:
Expand All @@ -25,7 +27,7 @@ def main():
else:
data = changelogs.get(args.package, vendor=args.vendor)

for release in sorted(data.keys(), key=lambda v: parse(v), reverse=True):
for release in sorted(data.keys(), key=lambda v: parse(v), reverse=args.reverse)[:args.n]:
print(release)
print(data[release])

Expand Down
80 changes: 80 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[build-system]
requires = ["setuptools>=69"]
build-backend = "setuptools.build_meta"

[project]
name = "changelogs"
version = "0.15.1-dev"
description = "A changelog finder and parser."
requires-python = ">=3.6"
authors = [
{ name = "pyup.io", email = "support@pyup.io" }
]
# readme = { file = ["README.rst", "HISTORY.rst"], content-type = "text/x-rst" }
readme = "README.rst"
license = "MIT"
license-files=["LICENSE", "AUTHORS.rst"]
keywords = ["changelogs"]
classifiers = [
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
]

dependencies = [
"requests",
"validators",
"packaging",
"lxml",
"gitchangelog",
]

[project.scripts]
changelogs = "changelogs.cli:main"

[project.urls]
Homepage = "https://github.com/pyupio/changelogs"

[project.optional-dependencies]
test = [
"mock",
"pytest",
"pytest-cov",
"betamax",
"betamax-serializers",
]

dev = [
"mock",
"pytest",
"pytest-cov",
"betamax",
"betamax-serializers",
"flake8",
"tox",
]

[tool.setuptools.packages.find]
include = ["changelogs*"]

[tool.setuptools.package-data]
changelogs = [
"custom/pypi/**/*",
"custom/npm/**/*",
"custom/gem/**/*",
]

[tool.flake8]
exclude = [
"docs",
".*",
"vcr",
"*.egg-info",
"build",
"dist",
]
max-line-length = 110
12 changes: 0 additions & 12 deletions setup.cfg

This file was deleted.

75 changes: 0 additions & 75 deletions setup.py

This file was deleted.