# Path: scrapebot/configuration.py
# class Configuration:
#     def __init__(self, ini_file='config.ini'):
#         self.config = configparser.ConfigParser()
#         self.config.read(ini_file)
#         self.__dict = {}
# 
#     def get_db_engine_string(self):
#         """
#         Generates the mysql connection string, ready for SQLAlchemy
#         :return:
#         """
#         return self.config.get('Database', 'dialect', fallback='mysql+pymysql') + \
#             '://' + self.get('Database', 'user', fallback='root') + \
#             ':' + self.get('Database', 'password', fallback='password') + \
#             '@' + self.get('Database', 'host', fallback='localhost') + \
#             '/' + self.get('Database', 'database', fallback='scrapebot')
# 
#     def add_section(self, section):
#         if section not in self.config:
#             self.config[section] = {}
# 
#     def add_value(self, section, name, value):
#         self.add_section(section)
#         self.config[section][name] = str(value)
# 
#     def write(self):
#         try:
#             with open('config.ini', 'w') as configfile:
#                 self.config.write(configfile)
#                 return True
#         except:
#             return False
# 
#     def get(self, section, key, fallback=None):
#         if section not in self.__dict:
#             self.__dict[section] = {}
#         key = key.lower()
#         if key not in self.__dict[section]:
#             self.__dict[section][key] = self.config.get(section, key, fallback=fallback)
#         return self.__dict[section][key]
# 
# Path: scrapebot/database.py
# class User(UserMixin, base):
# class UserInstancePrivilege(base):
# class UserRecipePrivilege(base):
# class Instance(base):
# class RecipeOrder(base):
# class Recipe(base):
# class RecipeStep(base):
# class RecipeStepItem(base):
# class RunStatusEnum(enum.Enum):
# class Run(base):
# class LogTypeEnum(enum.Enum):
# class Log(base):
# class Data(base):
#     def __repr__(self):
#     def create_password(self):
#     def check_password(self, password):
#     def get_id(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_active_recipes(self):
#     def is_visible_to_user(self, user):
#     def is_editable_by_user(self, user):
#     def runs_recipe(self, recipe, only_consider_active=True):
#     def get_latest_run(self, recipe=None, only_include_successful_runs=False):
#     def get_latest_runs(self, n=10, recipe=None, only_include_successful_runs=False):
#     def jsonify(self, include_latest_run=False, recipe=None):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_active_steps(self):
#     def get_average_runtime(self):
#     def is_visible_to_user(self, user):
#     def is_editable_by_user(self, user):
#     def runs_on_instance(self, instance):
#     def get_latest_run(self, instance=None, only_include_successful_runs=False):
#     def get_latest_runs(self, n=10, instance=None, only_include_successful_runs=False):
#     def jsonify(self, include_latest_run=False, instance=None):
#     def __repr__(self):
#     def find_random_item(self):
#     def run(self, config, run, prior_step=None):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_recipe_order(self):
#     def process(self, config, step, prior_step=None):
#     def end_session(self):
#     def jsonify(self, include_log=False, include_data=False):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):


import platform
import os
import getpass
import sys
import traceback
from crontab import CronTab
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from scrapebot.configuration import Configuration
from scrapebot.database import base, User, Instance
    email = email.lower()
    user = db.query(User).filter(User.email == email).first()
    if user is None:
        temp_user = User(name=username, email=email)
        password = temp_user.create_password()
        db.add(temp_user)
        db.commit()
        user = db.query(User).filter(User.email == email).one()
        print('- user "' + user.name + '" with password "' + password + '" (no quotes) created')
        return user
    else:
        print('- a user with this email address already exists so no new user was created')
        return user


def get_config(create_if_necessary=True):
    if not os.access('config.ini', os.R_OK) and create_if_necessary:
        config = setup_config()
        print('Reading newly created config.ini')
        return config
    elif not os.access('config.ini', os.R_OK):
        print('Configuration (config.ini) not found (have you tried running "setup.py" first?')
        exit(3)
    else:
        print('Configuration file "config.ini" found')
        return Configuration()


def setup_config():
    print('No configuration file ("config.ini") found, so let\'s create it in six easy steps:')

# Path: scrapebot/configuration.py
# class Configuration:
#     def __init__(self, ini_file='config.ini'):
#         self.config = configparser.ConfigParser()
#         self.config.read(ini_file)
#         self.__dict = {}
# 
#     def get_db_engine_string(self):
#         """
#         Generates the mysql connection string, ready for SQLAlchemy
#         :return:
#         """
#         return self.config.get('Database', 'dialect', fallback='mysql+pymysql') + \
#             '://' + self.get('Database', 'user', fallback='root') + \
#             ':' + self.get('Database', 'password', fallback='password') + \
#             '@' + self.get('Database', 'host', fallback='localhost') + \
#             '/' + self.get('Database', 'database', fallback='scrapebot')
# 
#     def add_section(self, section):
#         if section not in self.config:
#             self.config[section] = {}
# 
#     def add_value(self, section, name, value):
#         self.add_section(section)
#         self.config[section][name] = str(value)
# 
#     def write(self):
#         try:
#             with open('config.ini', 'w') as configfile:
#                 self.config.write(configfile)
#                 return True
#         except:
#             return False
# 
#     def get(self, section, key, fallback=None):
#         if section not in self.__dict:
#             self.__dict[section] = {}
#         key = key.lower()
#         if key not in self.__dict[section]:
#             self.__dict[section][key] = self.config.get(section, key, fallback=fallback)
#         return self.__dict[section][key]
# 
# Path: scrapebot/database.py
# class User(UserMixin, base):
# class UserInstancePrivilege(base):
# class UserRecipePrivilege(base):
# class Instance(base):
# class RecipeOrder(base):
# class Recipe(base):
# class RecipeStep(base):
# class RecipeStepItem(base):
# class RunStatusEnum(enum.Enum):
# class Run(base):
# class LogTypeEnum(enum.Enum):
# class Log(base):
# class Data(base):
#     def __repr__(self):
#     def create_password(self):
#     def check_password(self, password):
#     def get_id(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_active_recipes(self):
#     def is_visible_to_user(self, user):
#     def is_editable_by_user(self, user):
#     def runs_recipe(self, recipe, only_consider_active=True):
#     def get_latest_run(self, recipe=None, only_include_successful_runs=False):
#     def get_latest_runs(self, n=10, recipe=None, only_include_successful_runs=False):
#     def jsonify(self, include_latest_run=False, recipe=None):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_active_steps(self):
#     def get_average_runtime(self):
#     def is_visible_to_user(self, user):
#     def is_editable_by_user(self, user):
#     def runs_on_instance(self, instance):
#     def get_latest_run(self, instance=None, only_include_successful_runs=False):
#     def get_latest_runs(self, n=10, instance=None, only_include_successful_runs=False):
#     def jsonify(self, include_latest_run=False, instance=None):
#     def __repr__(self):
#     def find_random_item(self):
#     def run(self, config, run, prior_step=None):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_recipe_order(self):
#     def process(self, config, step, prior_step=None):
#     def end_session(self):
#     def jsonify(self, include_log=False, include_data=False):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):


# Path: setup.py
import platform
import os
import getpass
import sys
import traceback
from crontab import CronTab
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from scrapebot.configuration import Configuration
from scrapebot.database import base, User, Instance

    email = email.lower()
    user = db.query(User).filter(User.email == email).first()
    if user is None:
        temp_user = User(name=username, email=email)
        password = temp_user.create_password()
        db.add(temp_user)
        db.commit()
        user = db.query(User).filter(User.email == email).one()
        print('- user "' + user.name + '" with password "' + password + '" (no quotes) created')
        return user
    else:
        print('- a user with this email address already exists so no new user was created')
        return user


def get_config(create_if_necessary=True):
    if not os.access('config.ini', os.R_OK) and create_if_necessary:
        config = setup_config()
        print('Reading newly created config.ini')
        return config
    elif not os.access('config.ini', os.R_OK):
        print('Configuration (config.ini) not found (have you tried running "setup.py" first?')
        exit(3)
    else:
        print('Configuration file "config.ini" found')
        return Configuration()


def setup_config():
    print('No configuration file ("config.ini") found, so let\'s create it in six easy steps:')

    config = Configuration()