Skip to content

Commit

Permalink
Merge pull request #23 from baseplate-admin/master
Browse files Browse the repository at this point in the history
Use strings instead of `_alphabet`
  • Loading branch information
mariocesar authored Dec 19, 2024
2 parents fbe4518 + d55c1b3 commit 0501fe5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions django_ltree/paths.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import string
from itertools import product

from django_ltree.fields import PathValue


class PathGenerator(object):
_alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
_default_label_size = 6 # Postgres limits this to 256

def __init__(self, prefix=None, skip=None, label_size=None):
self.skip_paths = [] if skip is None else skip[:]
self.path_prefix = prefix if prefix else []
self.product_iterator = product(
self._alphabet, repeat=label_size or self._default_label_size
string.digits + string.ascii_letters,
repeat=label_size or self._default_label_size,
)

def __iter__(self):
Expand Down

0 comments on commit 0501fe5

Please sign in to comment.