Skip to content

Commit

Permalink
SIANXKE-401: Updated Python support
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelandzelo173 committed Oct 25, 2024
1 parent 3280a2a commit 7498904
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 36 deletions.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**How to reproduce**
Describe how to reproduce the behavior.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE]"
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Description
Describe your changes or fixes (please link to an issue if applicable)

## Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Refactoring (improvements in base code)
- [ ] Add test (adds test coverage to functionality)

## Checklist
- [ ] Automated tests
- [ ] Extends CHANGELOG.md
- [ ] Requires migrations?
- [ ] Requires dependency update?
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.9'
architecture: 'x64'

- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.egg-info*
__pycache__
db.sqlite3
tests/photos/uploads
tests/photos/uploads
.DS_Store
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace
args: ["--markdown-linebreak-ext=md"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
args: ["--py39-plus"]

- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.2.0] - 2024-10-25

### Added

- Support for Python 3.12 and 3.13.

### Removed

- Support for Python 3.7 and 3.8.

## [1.1.0] - 2023-02-13

### Changed

- Module imports acording to README.md
- Module imports according to README.md
- Simplified setup instructions

## [1.0.0] - 2022-06-23

### Added
- Initial implementation
- Unit tests

[Unreleased]: https://github.com/anexia/python-content-disposition/compare/1.1.0...HEAD
[Unreleased]: https://github.com/anexia/python-content-disposition/compare/1.2.0...HEAD
[1.2.0]: https://github.com/anexia/python-content-disposition/releases/tag/1.2.0
[1.1.0]: https://github.com/anexia/python-content-disposition/releases/tag/1.1.0
[1.0.0]: https://github.com/anexia/python-content-disposition/releases/tag/1.0.0
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2022 ANEXIA Internetdienstleisungs GmbH
Copyright (c) 2024 ANEXIA Internetdienstleisungs GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ from content_disposition import rfc5987_content_disposition
class MyViewSet(viewsets.ModelViewSet):
...
@action(
detail=True,
methods="get",
url_path=r"download",
)
def download_route(self, request, pk=None):
"""
Assuming that self.get_object() returns a model defining
Assuming that self.get_object() returns a model defining
'name = models.CharField(...)', 'file = models.FileField(...)' and 'mime = models.CharField(...)'
whereas 'mime' represents the correct mime_type related to 'file'
"""
Expand Down
2 changes: 1 addition & 1 deletion content_disposition/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .content_disposition import *
from .content_disposition import * # noqa: F403
9 changes: 5 additions & 4 deletions content_disposition/content_disposition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unicodedata
from urllib.parse import quote

Expand All @@ -15,10 +14,12 @@ def rfc5987_content_disposition(file_name, disposition_type="inline"):
:param disposition_type: str
:return:
"""
ascii_name = unicodedata.normalize("NFKD", file_name).encode("ascii", "ignore").decode()
header = '{}; filename="{}"'.format(disposition_type, ascii_name)
ascii_name = (
unicodedata.normalize("NFKD", file_name).encode("ascii", "ignore").decode()
)
header = f'{disposition_type}; filename="{ascii_name}"'
if ascii_name != file_name:
quoted_name = quote(file_name)
header += "; filename*=UTF-8''{}".format(quoted_name)
header += f"; filename*=UTF-8''{quoted_name}"

return header
9 changes: 0 additions & 9 deletions pyproject.toml

This file was deleted.

6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

# TestApp dependencies

django>=3.2,<4
djangorestframework>=3.13,<4
django-userforeignkey>=0.4
django>=4.2,<6
django-userforeignkey>=0.5
djangorestframework>=3.15,<4
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
)
2 changes: 1 addition & 1 deletion tests/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
},
}

# Password validation
Expand Down
4 changes: 2 additions & 2 deletions tests/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
import django # noqa: F401
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
"forget to activate a virtual environment?",
)
raise
execute_from_command_line(sys.argv)
1 change: 0 additions & 1 deletion tests/testapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = []
Expand Down
1 change: 0 additions & 1 deletion tests/testapp/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os

from django.core.files import File
from django.test import TestCase
from rest_framework.status import HTTP_200_OK
from testapp.models import Photo
Expand Down
1 change: 0 additions & 1 deletion tests/testapp/tests/test_setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.apps import apps
from django.conf import settings
from django.test import SimpleTestCase
from testapp.models import Photo

Expand Down
4 changes: 3 additions & 1 deletion tests/testapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def download_route(self, request, pk=None):
open(instance.file.path, "rb").read(),
content_type=instance.mime,
)
response["Content-Disposition"] = rfc5987_content_disposition(instance.file.name)
response["Content-Disposition"] = rfc5987_content_disposition(
instance.file.name,
)

return response

0 comments on commit 7498904

Please sign in to comment.