Skip to content

Commit b01fba1

Browse files
Use string instead of writing alphabets manually (#3)
* add * Update paths.py
1 parent dbfaecb commit b01fba1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

django_ltree/paths.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
import string
12
from itertools import product
23

34
from django_ltree.fields import PathValue
45

56

67
class PathGenerator(object):
7-
_alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
88
_default_label_size = 6 # Postgres limits this to 256
99

1010
def __init__(self, prefix=None, skip=None, label_size=None):
1111
self.skip_paths = [] if skip is None else skip[:]
1212
self.path_prefix = prefix if prefix else []
1313
self.product_iterator = product(
14-
self._alphabet, repeat=label_size or self._default_label_size
14+
string.digits + string.ascii_letters,
15+
repeat=label_size or self._default_label_size,
1516
)
1617

1718
def __iter__(self):

0 commit comments

Comments
 (0)