Esempio n. 1
0
    def pystruct(self, count=10, *value_types):

        value_types = [t if isinstance(t, string_types) else getattr(t, '__name__', type(t).__name__).lower()
                      for t in value_types
                      # avoid recursion
                      if t != 'struct']
        if not value_types:
            value_types = ['str', 'str', 'str', 'str', 'float', 'int', 'int', 'decimal', 'date_time', 'uri', 'email']

        l = []
        d = {}
        nd = {}
        for i in range(count):
            d[Lorem.word()] = self._random_type(value_types)
            l.append(self._random_type(value_types))
            nd[Lorem.word()] = {
                i: self._random_type(value_types),
                i + 1: [self._random_type(value_types), self._random_type(value_types), self._random_type(value_types)],
                i + 2: {
                    i: self._random_type(value_types),
                    i + 1: self._random_type(value_types),
                    i + 2: [
                        self._random_type(value_types),
                        self._random_type(value_types)
                    ]
                }
            }
        return l, d, nd
Esempio n. 2
0
    def pystruct(self, count=10, *value_types):

        value_types = [t if isinstance(t, basestring) else getattr(t, '__name__', type(t).__name__).lower()
                      for t in value_types
                      # avoid recursion
                      if t != 'struct']
        if not value_types:
            value_types = ['str', 'str', 'str', 'str', 'float', 'int', 'int', 'decimal', 'date_time', 'uri', 'email']

        l = []
        d = {}
        nd = {}
        for i in range(count):
            d[Lorem.word()] = self._random_type(value_types)
            l.append(self._random_type(value_types))
            nd[Lorem.word()] = {
                i: self._random_type(value_types),
                i + 1: [self._random_type(value_types), self._random_type(value_types), self._random_type(value_types)],
                i + 2: {
                    i: self._random_type(value_types),
                    i + 1: self._random_type(value_types),
                    i + 2: [
                        self._random_type(value_types),
                        self._random_type(value_types)
                    ]
                }
            }
        return l, d, nd
Esempio n. 3
0
 def slug(cls, value=None):
     """
     Django algorithm
     """
     if value is None:
         value = Lorem.text(20)
     return value
Esempio n. 4
0
 def slug(cls, value=None):
     """
     Django algorithm
     """
     if value is None:
         value = Lorem.text(20)
     return value
Esempio n. 5
0
    def pydict(self, nb_elements=10, variable_nb_elements=True, *value_types):
        """
         Use this function to generate data, returns a touple containing
         a list, a dictionary and a nested dictionary.
         """
        if variable_nb_elements:
            nb_elements = self.randomize_nb_elements(nb_elements)

        return dict(
            zip(Lorem.words(nb_elements),
                self._pyiterable(nb_elements, False, *value_types)))
Esempio n. 6
0
    def pydict(self, nb_elements=10, variable_nb_elements=True, *value_types):
        """
         Use this function to generate data, returns a touple containing
         a list, a dictionary and a nested dictionary.
         """
        if variable_nb_elements:
            nb_elements = self.randomize_nb_elements(nb_elements)

        return dict(zip(
            Lorem.words(nb_elements),
            self._pyiterable(nb_elements, False, *value_types)
        ))
Esempio n. 7
0
    def pydict(self, nb_elements=10, variable_nb_elements=True, *value_types):
        """
        Returns a dictionary.

        :nb_elements: number of elements for dictionary
        :variable_nb_elements: is use variable number of elements for dictionary
        :value_types: type of dictionary values
        """
        if variable_nb_elements:
            nb_elements = self.randomize_nb_elements(nb_elements)

        return dict(
            zip(Lorem.words(nb_elements),
                self._pyiterable(nb_elements, False, *value_types)))
Esempio n. 8
0
    def pydict(self, nb_elements=10, variable_nb_elements=True, *value_types):
        """
        Returns a dictionary.

        :nb_elements: number of elements for dictionary
        :variable_nb_elements: is use variable number of elements for dictionary
        :value_types: type of dictionary values
        """
        if variable_nb_elements:
            nb_elements = self.randomize_nb_elements(nb_elements)

        return dict(zip(
            Lorem.words(nb_elements),
            self._pyiterable(nb_elements, False, *value_types)
        ))
Esempio n. 9
0
 def pystr(cls, max_chars=20):
     return Lorem.text(max_chars)
Esempio n. 10
0
 def pystr(cls, max_chars=20):
     return Lorem.text(max_chars)