Generate Module

Generate valid data for an inator_data.json file.

This module can be run as a library or as a program. It contains variables and functions that can be used to generate a random inator_data.json.

Note that this program does not write data to a file. Instead, it prints the data to standard out. If you would like to save the generated data to a file, consider using file redirection like so:

python3.5 generate.py --inators=5 > data.json

The > data.json part tells your shell to redirect output from the standard out pipe to a file instead.

generate.random_timeline()

Return a generator that yields datetime s.

The generator yields randomly spaced datetime s in reverse chronological order. That is, every yielded datetime represents a time that is further in the past than the one yielded before it. The difference between two successive datetime s is a random value between 24 to 72 hours.

generate.inator_record(name, added)

Return an inator record.

Return a dictionary that represents data for an inator. Each record contains a randomly generated identifier, a random location, a random condition, and a random description. The name of the inator and the date/time it was added are requried as parameters.

Parameters:
  • name (str) – The name of the inator
  • added (datetime.datetime) – The date/time the inator record was added to the searchinator.
Returns:

A dictionary representing an inator

Return type:

dict

generate.random_inators(num)

Generate num random inators.

Parameters:num (int) – The number of inators to generate
Returns:A dict mapping an inator’s identifier to its record
Return type:dict
generate.credentials(lst)

Return credential information.

Format the credential data in lst so that it works with the searchinator. lst should contain strings of the format:

username:password
Parameters:lst (list) – A list of colon-separated username/password pairs
Returns:A dict mapping usernames to their username/passwords
Return type:dict
generate.main()

Generate data suitable for use in the searchinator.

For usage information, try running this module as a program like so:

python3.5 generate.py --help