New Upstream Snapshot - python-flask-seeder

Ready changes

Summary

Merged new upstream version: 1.2.0+git20210730.1.6d09a2b (was: 1.2.0).

Resulting package

Built on 2023-01-20T01:24 (took 2m18s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots python3-flask-seeder

Lintian Result

Diff

diff --git a/Flask_Seeder.egg-info/PKG-INFO b/Flask_Seeder.egg-info/PKG-INFO
index 979b330..3a1db36 100644
--- a/Flask_Seeder.egg-info/PKG-INFO
+++ b/Flask_Seeder.egg-info/PKG-INFO
@@ -6,157 +6,157 @@ Home-page: https://github.com/diddi-/flask-seeder
 Author: Diddi Oskarsson
 Author-email: diddi@diddi.se
 License: MIT
-Description: # Flask-Seeder
-        [![Build Status](https://travis-ci.org/diddi-/flask-seeder.svg?branch=master)](https://travis-ci.org/diddi-/flask-seeder)
-        [![Coverage Status](https://coveralls.io/repos/github/diddi-/flask-seeder/badge.svg?branch=master)](https://coveralls.io/github/diddi-/flask-seeder?branch=master)
-        
-        Flask-Seeder is a Flask extension to help with seeding database with initial data, for example when deploying an application for the first time.
-        
-        This extensions primary focus is to help populating data once, for example in a demo application where the database might get wiped over and over but you still want users to have some basic data to play around with.
-        
-        
-        # Installation
-        
-        ```
-        pip install Flask-Seeder
-        ```
-        This will install the Flask-Seeder extension and add a `flask seed` subcommand, check it out to see what arguments are supported!
-        
-        # Seeders
-        Flask-Seeder provides a base class `Seeder` that holds a database handle.
-        By subclassing `Seeder` and implementing a `run()` method you get access to the database handle object and can start seeding the database with data.
-        
-        All seeders must be somewhere in the `seeds/` directory and inherit from `Seeder` or else they won't be detected.
-        
-        When all seeders have completed (successfully or not), Flask-Seeder will by default commit all changes to the database. This behaviour can be overridden with `--no-commit` or setting environment variable `FLASK_SEEDER_AUTOCOMMIT=0`.
-        
-        ## Run Order
-        
-        When splitting seeders across multiple classes and files, order of operations is determined by two factors.
-        First the seeders are grouped by `priority` (lower priority will be run first), all seeders with the same priority
-        are then ordered by class name.
-        
-        See example below for setting priority on a seeder.
-        
-        ```python
-        from flask_seeder import Seeder
-        
-        class DemoSeeder(Seeder):
-          def __init__(self, db=None):
-            super().__init__(db=db)
-            self.priority = 10
-        
-          def run(self):
-            ...
-        ```
-        
-        # Faker and Generators
-        Flask-Seeder provides a `Faker` class that controls the creation of fake objects, based on real models. By telling `Faker` how to create the objects, you can easily create many different unique objects to help when seeding the database.
-        
-        There are different generators that help generate values for the fake objects.
-        Currently supported generators are:
-        
-        * Integer: Create a random integer between two values
-        * UUID: Create a random UUID
-        * Sequence: Create integers in sequence if called multiple times
-        * Name: Create a random name from a list `data/names/names.txt`
-        * Email: Create a random email, a combination of the random name generator and a domain from `data/domains/domains.txt`
-        * String: String generation from a pattern
-        
-        Feel free to roll your own generator by subclassing `Generator` and implement a `generate()` method that return the generated value.
-        
-        ## String generator pattern
-        The `String` generator takes a pattern and produces a string that matches the pattern.
-        Currently the generator pattern is very simple and supports only a handful of operations.
-        
-        | Pattern | Produces | Description | Example |
-        | --| -- | -- | -- |
-        | [abc] | String character | Randomly select one of the provided characters | `b` |
-        | [a-k] | String character | Randomly select one character from a range | `i` |
-        | \c | String character | Randomly select any alpha character (a-z, A-Z) | `B` |
-        | (one\|two) | String group | Like `[abc]` but works for strings, not just single characters | `one` |
-        | \d | Digit | Randomly select a single digit (0-9) | `8` |
-        | {x} | Repeater | Repeat the previous pattern `x` times | `\d{5}` |
-        | {m,n} | Repeater | Repeat the previous pattern `x` times where `x` is anywhere between `m` and `n` | `[0-9]{2,8}` |
-        | abc | String literal | No processing, returned as is | `abc` |
-        
-        Patterns can also be combined to produce more complex strings.
-        ```
-        # Produces something like: abc5586oz
-        abc[5-9]{4}\c[xyz]
-        ```
-        
-        # Example usage
-        Examples show only relevant snippets of code
-        
-        **app.py:**
-        ```python
-        from flask import Flask
-        from flask_sqlalchemy import SQLAlchemy
-        from flask_seeder import FlaskSeeder
-        
-        def create_app():
-          app = Flask(__name__)
-        
-          db = SQLAlchemy()
-          db.init_app(app)
-        
-          seeder = FlaskSeeder()
-          seeder.init_app(app, db)
-        
-          return app
-        ```
-        
-        **seeds/demo.py:**
-        ```python
-        from flask_seeder import Seeder, Faker, generator
-        
-        # SQLAlchemy database model
-        class User(Base):
-          def __init__(self, id_num=None, name=None, age=None):
-            self.id_num = id_num
-            self.name = name
-            self.age = age
-        
-          def __str__(self):
-            return "ID=%d, Name=%s, Age=%d" % (self.id_num, self.name, self.age)
-        
-        # All seeders inherit from Seeder
-        class DemoSeeder(Seeder):
-        
-          # run() will be called by Flask-Seeder
-          def run(self):
-            # Create a new Faker and tell it how to create User objects
-            faker = Faker(
-              cls=User,
-              init={
-                "id_num": generator.Sequence(),
-                "name": generator.Name(),
-                "age": generator.Integer(start=20, end=100)
-              }
-            )
-        
-            # Create 5 users
-            for user in faker.create(5):
-              print("Adding user: %s" % user)
-              self.db.session.add(user)
-        ```
-        
-        ***Shell***
-        ```bash
-        $ flask seed run
-        Running database seeders
-        Adding user: ID=1, Name=Fancie, Age=76
-        Adding user: ID=2, Name=Shela, Age=22
-        Adding user: ID=3, Name=Jo, Age=33
-        Adding user: ID=4, Name=Laureen, Age=54
-        Adding user: ID=5, Name=Tandy, Age=66
-        DemoSeeder... [OK]
-        Committing to database!
-        ```
-        
-Platform: UNKNOWN
 Classifier: Programming Language :: Python :: 3
 Classifier: License :: OSI Approved :: MIT License
 Classifier: Operating System :: OS Independent
 Description-Content-Type: text/markdown
+
+# Flask-Seeder
+[![Build Status](https://travis-ci.org/diddi-/flask-seeder.svg?branch=master)](https://travis-ci.org/diddi-/flask-seeder)
+[![Coverage Status](https://coveralls.io/repos/github/diddi-/flask-seeder/badge.svg?branch=master)](https://coveralls.io/github/diddi-/flask-seeder?branch=master)
+
+Flask-Seeder is a Flask extension to help with seeding database with initial data, for example when deploying an application for the first time.
+
+This extensions primary focus is to help populating data once, for example in a demo application where the database might get wiped over and over but you still want users to have some basic data to play around with.
+
+
+# Installation
+
+```
+pip install Flask-Seeder
+```
+This will install the Flask-Seeder extension and add a `flask seed` subcommand, check it out to see what arguments are supported!
+
+# Seeders
+Flask-Seeder provides a base class `Seeder` that holds a database handle.
+By subclassing `Seeder` and implementing a `run()` method you get access to the database handle object and can start seeding the database with data.
+
+All seeders must be somewhere in the `seeds/` directory and inherit from `Seeder` or else they won't be detected.
+
+When all seeders have completed (successfully or not), Flask-Seeder will by default commit all changes to the database. This behaviour can be overridden with `--no-commit` or setting environment variable `FLASK_SEEDER_AUTOCOMMIT=0`.
+
+## Run Order
+
+When splitting seeders across multiple classes and files, order of operations is determined by two factors.
+First the seeders are grouped by `priority` (lower priority will be run first), all seeders with the same priority
+are then ordered by class name.
+
+See example below for setting priority on a seeder.
+
+```python
+from flask_seeder import Seeder
+
+class DemoSeeder(Seeder):
+  def __init__(self, db=None):
+    super().__init__(db=db)
+    self.priority = 10
+
+  def run(self):
+    ...
+```
+
+# Faker and Generators
+Flask-Seeder provides a `Faker` class that controls the creation of fake objects, based on real models. By telling `Faker` how to create the objects, you can easily create many different unique objects to help when seeding the database.
+
+There are different generators that help generate values for the fake objects.
+Currently supported generators are:
+
+* Integer: Create a random integer between two values
+* UUID: Create a random UUID
+* Sequence: Create integers in sequence if called multiple times
+* Name: Create a random name from a list `data/names/names.txt`
+* Email: Create a random email, a combination of the random name generator and a domain from `data/domains/domains.txt`
+* IPv4/IPv6: Create a random IPv4 or Ipv6 address
+* String: String generation from a pattern
+
+Feel free to roll your own generator by subclassing `Generator` and implement a `generate()` method that return the generated value.
+
+## String generator pattern
+The `String` generator takes a pattern and produces a string that matches the pattern.
+Currently the generator pattern is very simple and supports only a handful of operations.
+
+| Pattern | Produces | Description | Example |
+| --| -- | -- | -- |
+| [abc] | String character | Randomly select one of the provided characters | `b` |
+| [a-k] | String character | Randomly select one character from a range | `i` |
+| \c | String character | Randomly select any alpha character (a-z, A-Z) | `B` |
+| (one\|two) | String group | Like `[abc]` but works for strings, not just single characters | `one` |
+| \d | Digit | Randomly select a single digit (0-9) | `8` |
+| {x} | Repeater | Repeat the previous pattern `x` times | `\d{5}` |
+| {m,n} | Repeater | Repeat the previous pattern `x` times where `x` is anywhere between `m` and `n` | `[0-9]{2,8}` |
+| abc | String literal | No processing, returned as is | `abc` |
+
+Patterns can also be combined to produce more complex strings.
+```
+# Produces something like: abc5586oz
+abc[5-9]{4}\c[xyz]
+```
+
+# Example usage
+Examples show only relevant snippets of code
+
+**app.py:**
+```python
+from flask import Flask
+from flask_sqlalchemy import SQLAlchemy
+from flask_seeder import FlaskSeeder
+
+def create_app():
+  app = Flask(__name__)
+
+  db = SQLAlchemy()
+  db.init_app(app)
+
+  seeder = FlaskSeeder()
+  seeder.init_app(app, db)
+
+  return app
+```
+
+**seeds/demo.py:**
+```python
+from flask_seeder import Seeder, Faker, generator
+
+# SQLAlchemy database model
+class User(Base):
+  def __init__(self, id_num=None, name=None, age=None):
+    self.id_num = id_num
+    self.name = name
+    self.age = age
+
+  def __str__(self):
+    return "ID=%d, Name=%s, Age=%d" % (self.id_num, self.name, self.age)
+
+# All seeders inherit from Seeder
+class DemoSeeder(Seeder):
+
+  # run() will be called by Flask-Seeder
+  def run(self):
+    # Create a new Faker and tell it how to create User objects
+    faker = Faker(
+      cls=User,
+      init={
+        "id_num": generator.Sequence(),
+        "name": generator.Name(),
+        "age": generator.Integer(start=20, end=100)
+      }
+    )
+
+    # Create 5 users
+    for user in faker.create(5):
+      print("Adding user: %s" % user)
+      self.db.session.add(user)
+```
+
+***Shell***
+```bash
+$ flask seed run
+Running database seeders
+Adding user: ID=1, Name=Fancie, Age=76
+Adding user: ID=2, Name=Shela, Age=22
+Adding user: ID=3, Name=Jo, Age=33
+Adding user: ID=4, Name=Laureen, Age=54
+Adding user: ID=5, Name=Tandy, Age=66
+DemoSeeder... [OK]
+Committing to database!
+```
diff --git a/Flask_Seeder.egg-info/SOURCES.txt b/Flask_Seeder.egg-info/SOURCES.txt
index 0d478a3..c443972 100644
--- a/Flask_Seeder.egg-info/SOURCES.txt
+++ b/Flask_Seeder.egg-info/SOURCES.txt
@@ -27,6 +27,8 @@ tests/generator/__init__.py
 tests/generator/test_email.py
 tests/generator/test_generator.py
 tests/generator/test_integer.py
+tests/generator/test_ipv4.py
+tests/generator/test_ipv6.py
 tests/generator/test_name.py
 tests/generator/test_sequence.py
 tests/generator/test_string.py
diff --git a/Flask_Seeder.egg-info/entry_points.txt b/Flask_Seeder.egg-info/entry_points.txt
index beaf354..80fac53 100644
--- a/Flask_Seeder.egg-info/entry_points.txt
+++ b/Flask_Seeder.egg-info/entry_points.txt
@@ -1,3 +1,2 @@
 [flask.commands]
 seed = flask_seeder.cli:seed
-
diff --git a/PKG-INFO b/PKG-INFO
index 979b330..3a1db36 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -6,157 +6,157 @@ Home-page: https://github.com/diddi-/flask-seeder
 Author: Diddi Oskarsson
 Author-email: diddi@diddi.se
 License: MIT
-Description: # Flask-Seeder
-        [![Build Status](https://travis-ci.org/diddi-/flask-seeder.svg?branch=master)](https://travis-ci.org/diddi-/flask-seeder)
-        [![Coverage Status](https://coveralls.io/repos/github/diddi-/flask-seeder/badge.svg?branch=master)](https://coveralls.io/github/diddi-/flask-seeder?branch=master)
-        
-        Flask-Seeder is a Flask extension to help with seeding database with initial data, for example when deploying an application for the first time.
-        
-        This extensions primary focus is to help populating data once, for example in a demo application where the database might get wiped over and over but you still want users to have some basic data to play around with.
-        
-        
-        # Installation
-        
-        ```
-        pip install Flask-Seeder
-        ```
-        This will install the Flask-Seeder extension and add a `flask seed` subcommand, check it out to see what arguments are supported!
-        
-        # Seeders
-        Flask-Seeder provides a base class `Seeder` that holds a database handle.
-        By subclassing `Seeder` and implementing a `run()` method you get access to the database handle object and can start seeding the database with data.
-        
-        All seeders must be somewhere in the `seeds/` directory and inherit from `Seeder` or else they won't be detected.
-        
-        When all seeders have completed (successfully or not), Flask-Seeder will by default commit all changes to the database. This behaviour can be overridden with `--no-commit` or setting environment variable `FLASK_SEEDER_AUTOCOMMIT=0`.
-        
-        ## Run Order
-        
-        When splitting seeders across multiple classes and files, order of operations is determined by two factors.
-        First the seeders are grouped by `priority` (lower priority will be run first), all seeders with the same priority
-        are then ordered by class name.
-        
-        See example below for setting priority on a seeder.
-        
-        ```python
-        from flask_seeder import Seeder
-        
-        class DemoSeeder(Seeder):
-          def __init__(self, db=None):
-            super().__init__(db=db)
-            self.priority = 10
-        
-          def run(self):
-            ...
-        ```
-        
-        # Faker and Generators
-        Flask-Seeder provides a `Faker` class that controls the creation of fake objects, based on real models. By telling `Faker` how to create the objects, you can easily create many different unique objects to help when seeding the database.
-        
-        There are different generators that help generate values for the fake objects.
-        Currently supported generators are:
-        
-        * Integer: Create a random integer between two values
-        * UUID: Create a random UUID
-        * Sequence: Create integers in sequence if called multiple times
-        * Name: Create a random name from a list `data/names/names.txt`
-        * Email: Create a random email, a combination of the random name generator and a domain from `data/domains/domains.txt`
-        * String: String generation from a pattern
-        
-        Feel free to roll your own generator by subclassing `Generator` and implement a `generate()` method that return the generated value.
-        
-        ## String generator pattern
-        The `String` generator takes a pattern and produces a string that matches the pattern.
-        Currently the generator pattern is very simple and supports only a handful of operations.
-        
-        | Pattern | Produces | Description | Example |
-        | --| -- | -- | -- |
-        | [abc] | String character | Randomly select one of the provided characters | `b` |
-        | [a-k] | String character | Randomly select one character from a range | `i` |
-        | \c | String character | Randomly select any alpha character (a-z, A-Z) | `B` |
-        | (one\|two) | String group | Like `[abc]` but works for strings, not just single characters | `one` |
-        | \d | Digit | Randomly select a single digit (0-9) | `8` |
-        | {x} | Repeater | Repeat the previous pattern `x` times | `\d{5}` |
-        | {m,n} | Repeater | Repeat the previous pattern `x` times where `x` is anywhere between `m` and `n` | `[0-9]{2,8}` |
-        | abc | String literal | No processing, returned as is | `abc` |
-        
-        Patterns can also be combined to produce more complex strings.
-        ```
-        # Produces something like: abc5586oz
-        abc[5-9]{4}\c[xyz]
-        ```
-        
-        # Example usage
-        Examples show only relevant snippets of code
-        
-        **app.py:**
-        ```python
-        from flask import Flask
-        from flask_sqlalchemy import SQLAlchemy
-        from flask_seeder import FlaskSeeder
-        
-        def create_app():
-          app = Flask(__name__)
-        
-          db = SQLAlchemy()
-          db.init_app(app)
-        
-          seeder = FlaskSeeder()
-          seeder.init_app(app, db)
-        
-          return app
-        ```
-        
-        **seeds/demo.py:**
-        ```python
-        from flask_seeder import Seeder, Faker, generator
-        
-        # SQLAlchemy database model
-        class User(Base):
-          def __init__(self, id_num=None, name=None, age=None):
-            self.id_num = id_num
-            self.name = name
-            self.age = age
-        
-          def __str__(self):
-            return "ID=%d, Name=%s, Age=%d" % (self.id_num, self.name, self.age)
-        
-        # All seeders inherit from Seeder
-        class DemoSeeder(Seeder):
-        
-          # run() will be called by Flask-Seeder
-          def run(self):
-            # Create a new Faker and tell it how to create User objects
-            faker = Faker(
-              cls=User,
-              init={
-                "id_num": generator.Sequence(),
-                "name": generator.Name(),
-                "age": generator.Integer(start=20, end=100)
-              }
-            )
-        
-            # Create 5 users
-            for user in faker.create(5):
-              print("Adding user: %s" % user)
-              self.db.session.add(user)
-        ```
-        
-        ***Shell***
-        ```bash
-        $ flask seed run
-        Running database seeders
-        Adding user: ID=1, Name=Fancie, Age=76
-        Adding user: ID=2, Name=Shela, Age=22
-        Adding user: ID=3, Name=Jo, Age=33
-        Adding user: ID=4, Name=Laureen, Age=54
-        Adding user: ID=5, Name=Tandy, Age=66
-        DemoSeeder... [OK]
-        Committing to database!
-        ```
-        
-Platform: UNKNOWN
 Classifier: Programming Language :: Python :: 3
 Classifier: License :: OSI Approved :: MIT License
 Classifier: Operating System :: OS Independent
 Description-Content-Type: text/markdown
+
+# Flask-Seeder
+[![Build Status](https://travis-ci.org/diddi-/flask-seeder.svg?branch=master)](https://travis-ci.org/diddi-/flask-seeder)
+[![Coverage Status](https://coveralls.io/repos/github/diddi-/flask-seeder/badge.svg?branch=master)](https://coveralls.io/github/diddi-/flask-seeder?branch=master)
+
+Flask-Seeder is a Flask extension to help with seeding database with initial data, for example when deploying an application for the first time.
+
+This extensions primary focus is to help populating data once, for example in a demo application where the database might get wiped over and over but you still want users to have some basic data to play around with.
+
+
+# Installation
+
+```
+pip install Flask-Seeder
+```
+This will install the Flask-Seeder extension and add a `flask seed` subcommand, check it out to see what arguments are supported!
+
+# Seeders
+Flask-Seeder provides a base class `Seeder` that holds a database handle.
+By subclassing `Seeder` and implementing a `run()` method you get access to the database handle object and can start seeding the database with data.
+
+All seeders must be somewhere in the `seeds/` directory and inherit from `Seeder` or else they won't be detected.
+
+When all seeders have completed (successfully or not), Flask-Seeder will by default commit all changes to the database. This behaviour can be overridden with `--no-commit` or setting environment variable `FLASK_SEEDER_AUTOCOMMIT=0`.
+
+## Run Order
+
+When splitting seeders across multiple classes and files, order of operations is determined by two factors.
+First the seeders are grouped by `priority` (lower priority will be run first), all seeders with the same priority
+are then ordered by class name.
+
+See example below for setting priority on a seeder.
+
+```python
+from flask_seeder import Seeder
+
+class DemoSeeder(Seeder):
+  def __init__(self, db=None):
+    super().__init__(db=db)
+    self.priority = 10
+
+  def run(self):
+    ...
+```
+
+# Faker and Generators
+Flask-Seeder provides a `Faker` class that controls the creation of fake objects, based on real models. By telling `Faker` how to create the objects, you can easily create many different unique objects to help when seeding the database.
+
+There are different generators that help generate values for the fake objects.
+Currently supported generators are:
+
+* Integer: Create a random integer between two values
+* UUID: Create a random UUID
+* Sequence: Create integers in sequence if called multiple times
+* Name: Create a random name from a list `data/names/names.txt`
+* Email: Create a random email, a combination of the random name generator and a domain from `data/domains/domains.txt`
+* IPv4/IPv6: Create a random IPv4 or Ipv6 address
+* String: String generation from a pattern
+
+Feel free to roll your own generator by subclassing `Generator` and implement a `generate()` method that return the generated value.
+
+## String generator pattern
+The `String` generator takes a pattern and produces a string that matches the pattern.
+Currently the generator pattern is very simple and supports only a handful of operations.
+
+| Pattern | Produces | Description | Example |
+| --| -- | -- | -- |
+| [abc] | String character | Randomly select one of the provided characters | `b` |
+| [a-k] | String character | Randomly select one character from a range | `i` |
+| \c | String character | Randomly select any alpha character (a-z, A-Z) | `B` |
+| (one\|two) | String group | Like `[abc]` but works for strings, not just single characters | `one` |
+| \d | Digit | Randomly select a single digit (0-9) | `8` |
+| {x} | Repeater | Repeat the previous pattern `x` times | `\d{5}` |
+| {m,n} | Repeater | Repeat the previous pattern `x` times where `x` is anywhere between `m` and `n` | `[0-9]{2,8}` |
+| abc | String literal | No processing, returned as is | `abc` |
+
+Patterns can also be combined to produce more complex strings.
+```
+# Produces something like: abc5586oz
+abc[5-9]{4}\c[xyz]
+```
+
+# Example usage
+Examples show only relevant snippets of code
+
+**app.py:**
+```python
+from flask import Flask
+from flask_sqlalchemy import SQLAlchemy
+from flask_seeder import FlaskSeeder
+
+def create_app():
+  app = Flask(__name__)
+
+  db = SQLAlchemy()
+  db.init_app(app)
+
+  seeder = FlaskSeeder()
+  seeder.init_app(app, db)
+
+  return app
+```
+
+**seeds/demo.py:**
+```python
+from flask_seeder import Seeder, Faker, generator
+
+# SQLAlchemy database model
+class User(Base):
+  def __init__(self, id_num=None, name=None, age=None):
+    self.id_num = id_num
+    self.name = name
+    self.age = age
+
+  def __str__(self):
+    return "ID=%d, Name=%s, Age=%d" % (self.id_num, self.name, self.age)
+
+# All seeders inherit from Seeder
+class DemoSeeder(Seeder):
+
+  # run() will be called by Flask-Seeder
+  def run(self):
+    # Create a new Faker and tell it how to create User objects
+    faker = Faker(
+      cls=User,
+      init={
+        "id_num": generator.Sequence(),
+        "name": generator.Name(),
+        "age": generator.Integer(start=20, end=100)
+      }
+    )
+
+    # Create 5 users
+    for user in faker.create(5):
+      print("Adding user: %s" % user)
+      self.db.session.add(user)
+```
+
+***Shell***
+```bash
+$ flask seed run
+Running database seeders
+Adding user: ID=1, Name=Fancie, Age=76
+Adding user: ID=2, Name=Shela, Age=22
+Adding user: ID=3, Name=Jo, Age=33
+Adding user: ID=4, Name=Laureen, Age=54
+Adding user: ID=5, Name=Tandy, Age=66
+DemoSeeder... [OK]
+Committing to database!
+```
diff --git a/README.md b/README.md
index e2401ee..fcb9108 100755
--- a/README.md
+++ b/README.md
@@ -53,6 +53,7 @@ Currently supported generators are:
 * Sequence: Create integers in sequence if called multiple times
 * Name: Create a random name from a list `data/names/names.txt`
 * Email: Create a random email, a combination of the random name generator and a domain from `data/domains/domains.txt`
+* IPv4/IPv6: Create a random IPv4 or Ipv6 address
 * String: String generation from a pattern
 
 Feel free to roll your own generator by subclassing `Generator` and implement a `generate()` method that return the generated value.
diff --git a/debian/changelog b/debian/changelog
index f13b730..eea266a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+python-flask-seeder (1.2.0+git20210730.1.6d09a2b-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Fri, 20 Jan 2023 01:23:19 -0000
+
 python-flask-seeder (1.2.0-2) unstable; urgency=medium
 
   * Team upload.
diff --git a/flask_seeder/generator.py b/flask_seeder/generator.py
index dc79763..6a94c62 100644
--- a/flask_seeder/generator.py
+++ b/flask_seeder/generator.py
@@ -2,6 +2,7 @@
 
 import uuid
 import random
+from ipaddress import IPv4Address, IPv6Address
 import pkg_resources
 
 from flask_seeder.parser import SGParser, Tokenizer
@@ -338,3 +339,36 @@ class String(Generator):
             result += func(node)
 
         return result
+
+
+class IPv4(Generator):
+    """ Random IPv4 generator """
+    IPV4LENGTH = 32
+    IPV4_MAX_PREFIX_LEN = (2**IPV4LENGTH) - 1
+
+    def __init__(self, rnd=None, **kwargs):
+        super().__init__(**kwargs)
+        self.rnd = rnd or random
+
+    def generate(self):
+        """ Generate a random IPv4 address """
+
+        return str(IPv4Address(
+            self.rnd.randint(0, self.IPV4_MAX_PREFIX_LEN)
+        ))
+
+
+class IPv6(Generator):
+    """ Random IPv6 generator """
+    IPV6LENGTH = 128
+    IPV6_MAX_PREFIX_LEN = (2**IPV6LENGTH) - 1
+
+    def __init__(self, rnd=None, **kwargs):
+        super().__init__(**kwargs)
+        self.rnd = rnd or random
+
+    def generate(self):
+        """ Generate a random IPv6 address """
+        return str(IPv6Address(
+            self.rnd.randint(0, self.IPV6_MAX_PREFIX_LEN)
+        ))
diff --git a/tests/generator/test_ipv4.py b/tests/generator/test_ipv4.py
new file mode 100644
index 0000000..b824e56
--- /dev/null
+++ b/tests/generator/test_ipv4.py
@@ -0,0 +1,27 @@
+from ipaddress import IPv4Address
+
+from unittest import TestCase
+from unittest.mock import MagicMock, patch
+
+from flask_seeder.generator import IPv4
+
+
+class TestIPv4Generator(TestCase):
+    def setUp(self):
+        self.rnd_mock = MagicMock()
+        # return value that will be used inside _string_from_ip_int function
+        self.rnd_mock.randint.side_effect = [IPv4Address._ALL_ONES]
+    
+
+    def test_generate_mock_ipv4_with_default_values(self):
+        self.generator = IPv4(rnd=self.rnd_mock)
+        self.generator.generate()
+        self.rnd_mock.randint.assert_called_once_with(
+            0,
+            IPv4Address._ALL_ONES
+        )
+    
+    def test_generate_mock_ipv4_returns_a_string(self):
+        self.generator = IPv4()
+        result = self.generator.generate()
+        self.assertEqual(type(result), str)
diff --git a/tests/generator/test_ipv6.py b/tests/generator/test_ipv6.py
new file mode 100644
index 0000000..5e7d9cf
--- /dev/null
+++ b/tests/generator/test_ipv6.py
@@ -0,0 +1,27 @@
+from ipaddress import IPv6Address
+
+from unittest import TestCase
+from unittest.mock import MagicMock, patch
+
+from flask_seeder.generator import IPv6
+
+
+class TestIPv6Generator(TestCase):
+    def setUp(self):
+        self.rnd_mock = MagicMock()
+        # return value that will be used inside _string_from_ip_int function
+        self.rnd_mock.randint.side_effect = [IPv6Address._ALL_ONES]
+    
+
+    def test_generate_mock_ipv6_with_default_values(self):
+        self.generator = IPv6(rnd=self.rnd_mock)
+        self.generator.generate()
+        self.rnd_mock.randint.assert_called_once_with(
+            0,
+            IPv6Address._ALL_ONES
+        )
+
+    def test_generate_mock_ipv6_returns_a_string(self):
+        self.generator = IPv6()
+        result = self.generator.generate()
+        self.assertEqual(type(result), str)

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details