Skip to content

Commit ef84d18

Browse files
pre-commit-ci[bot]codingjoe
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 260fe4f commit ef84d18

File tree

4 files changed

+52
-48
lines changed

4 files changed

+52
-48
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2
22
updates:
3-
- package-ecosystem: pip
4-
directory: "/"
5-
schedule:
6-
interval: daily
7-
- package-ecosystem: github-actions
8-
directory: "/"
9-
schedule:
10-
interval: daily
3+
- package-ecosystem: pip
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
- package-ecosystem: github-actions
8+
directory: "/"
9+
schedule:
10+
interval: daily

README.md

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ from django.db import models
2020
from dynamic_filenames import FilePattern
2121

2222
upload_to_pattern = FilePattern(
23-
filename_pattern='{app_label:.25}/{model_name:.30}/{instance.created:%Y-%m-%d}/{uuid:base32}{ext}'
23+
filename_pattern="{app_label:.25}/{model_name:.30}/{instance.created:%Y-%m-%d}/{uuid:base32}{ext}"
2424
)
2525

26+
2627
class FileModel(models.Model):
2728
my_file = models.FileField(upload_to=upload_to_pattern)
2829
created = models.DateTimeField(auto_now_add=True)
@@ -36,73 +37,75 @@ Auto slug example:
3637

3738
`ext`
3839

39-
: File extension including the dot.
40+
: File extension including the dot.
4041

4142
`name`
4243

43-
: Filename excluding the folders.
44+
: Filename excluding the folders.
4445

4546
`model_name`
4647

47-
: Name of the Django model.
48+
: Name of the Django model.
4849

4950
`app_label`
5051

51-
: App label of the Django model.
52+
: App label of the Django model.
5253

5354
`instance`
5455

55-
: Instance of the model before it has been saved. You may not have a
56-
primary key at this point.
56+
: Instance of the model before it has been saved. You may not have a
57+
primary key at this point.
5758

5859
`uuid`
5960

60-
: UUID version 4 that supports multiple type specifiers. The UUID will
61-
be the same should you use it twice in the same string, but
62-
different on each invocation of the `upload_to` callable.
61+
: UUID version 4 that supports multiple type specifiers. The UUID will
62+
be the same should you use it twice in the same string, but
63+
different on each invocation of the `upload_to` callable.
6364

64-
The type specifiers allow you to format the UUID in different ways,
65-
e.g. `{uuid:x}` will give you a with a hexadecimal UUID.
65+
```
66+
The type specifiers allow you to format the UUID in different ways,
67+
e.g. `{uuid:x}` will give you a with a hexadecimal UUID.
6668
67-
The supported type specifiers are:
69+
The supported type specifiers are:
6870
69-
`s`
71+
`s`
7072
71-
: String representation of a UUID including dashes.
73+
: String representation of a UUID including dashes.
7274
73-
`i`
75+
`i`
7476
75-
: Integer representation of a UUID. Like to `UUID.int`.
77+
: Integer representation of a UUID. Like to `UUID.int`.
7678
77-
`x`
79+
`x`
7880
79-
: Hexadecimal (Base16) representation of a UUID. Like to
80-
`UUID.hex`.
81+
: Hexadecimal (Base16) representation of a UUID. Like to
82+
`UUID.hex`.
8183
82-
`X`
84+
`X`
8385
84-
: Upper case hexadecimal representation of a UUID. Like to
85-
`UUID.hex`.
86+
: Upper case hexadecimal representation of a UUID. Like to
87+
`UUID.hex`.
8688
87-
`base32`
89+
`base32`
8890
89-
: Base32 representation of a UUID without padding.
91+
: Base32 representation of a UUID without padding.
9092
91-
`base64`
93+
`base64`
9294
93-
: Base64 representation of a UUID without padding.
95+
: Base64 representation of a UUID without padding.
9496
95-
:::: warning
96-
::: title
97-
Warning
98-
:::
97+
:::: warning
98+
::: title
99+
Warning
100+
:::
99101
100-
Not all file systems support Base64 file names.
101-
::::
102+
Not all file systems support Base64 file names.
103+
::::
102104
103-
All type specifiers also support precisions to cut the string, e.g.
104-
`{{uuid:.2base32}}` would only return the first 2 characters of a
105-
Base32 encoded UUID.
105+
All type specifiers also support precisions to cut the string, e.g.
106+
`{{uuid:.2base32}}` would only return the first 2 characters of a
107+
Base32 encoded UUID.
108+
```
106109

107110
### Type specifiers
108111

@@ -115,9 +118,10 @@ from django.db import models
115118
from dynamic_filenames import FilePattern
116119

117120
upload_to_pattern = FilePattern(
118-
filename_pattern='{app_label:.25}/{model_name:.30}/{instance.title:.40slug}{ext}'
121+
filename_pattern="{app_label:.25}/{model_name:.30}/{instance.title:.40slug}{ext}"
119122
)
120123

124+
121125
class FileModel(models.Model):
122126
title = models.CharField(max_length=100)
123127
my_file = models.FileField(upload_to=upload_to_pattern)

dynamic_filenames/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from django.utils.text import slugify
1010

11-
from . import _version # noqa
11+
from . import _version
1212

1313
__version__ = _version.__version__
1414
VERSION = _version.VERSION_TUPLE
@@ -132,7 +132,7 @@ def __init__(self, **kwargs):
132132

133133
def deconstruct(self):
134134
"""Destruct callable to support Django migrations."""
135-
path = "%s.%s" % (self.__class__.__module__, self.__class__.__name__)
135+
path = f"{self.__class__.__module__}.{self.__class__.__name__}"
136136
return path, [], self.kwargs
137137

138138
@staticmethod

tests/testapp/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
migrations/
1+
migrations/

0 commit comments

Comments
 (0)