<commit_before># django imports
from django.utils.translation import ugettext_lazy as _
from django.db import models

# lfs imports
from lfs.plugins import OrderNumberGenerator as Base


class OrderNumberGenerator(Base):
    """Generates order numbers and saves the last one.

    **Attributes:**

    id
        The primary key of the order number.

    last
        The last stored/returned order number.

    format
        The format of the integer part of the order number.
    """
    id = models.CharField(primary_key=True, max_length=20)
    last = models.IntegerField(_(u"Last order number"), default=0)
    format = models.CharField(blank=True, max_length=20)

    def get_next(self, formatted=True):
        """Returns the next order number.

        **Parameters:**

        formatted
            If True the number will be returned within the stored format.
        """
        self.last += 1
        self.save()
        if formatted:
            return self.format % self.last
        else:
            return self.last<commit_msg>Check whether there is a format given (this must be checked for validity though).<commit_after># django imports
from django.utils.translation import ugettext_lazy as _
from django.db import models

# lfs imports
from lfs.plugins import OrderNumberGenerator as Base


class OrderNumberGenerator(Base):
    """Generates order numbers and saves the last one.

    **Attributes:**

    id
        The primary key of the order number.

    last
        The last stored/returned order number.

    format
        The format of the integer part of the order number.
    """
    id = models.CharField(primary_key=True, max_length=20)
    last = models.IntegerField(_(u"Last order number"), default=0)
    format = models.CharField(blank=True, max_length=20)

    def get_next(self, formatted=True):
        """Returns the next order number.

        **Parameters:**

        formatted
            If True the number will be returned within the stored format.
        """
        self.last += 1
        self.save()
        if formatted and self.format:
            return self.format % self.last
        else:
            return self.last
{'fraction_non_alphanumeric': 0.07727690892364306, 'fraction_numerical': 0.005519779208831647, 'mean_word_length': 2.5194174757281553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '489006', 'n_tokens_mistral': 589, 'n_tokens_neox': 561, 'n_words': 212}