# Path: packages/config.py

# 
# Path: packages/database.py
# def init_db():
# 
# Path: packages/objects.py
# class User(Base):
#     __tablename__ = 'user'
#     id = Column(Integer, primary_key = True)
#     username = Column(String(128), nullable = False, index = True)
#     email = Column(String(256), nullable = False, index = True)
#     admin = Column(Boolean())
#     password = Column(String)
#     created = Column(DateTime)
#     confirmation = Column(String(128))
#     passwordReset = Column(String(128))
#     passwordResetExpiry = Column(DateTime)
#     packages = relationship('Package', order_by='Package.created')
# 
#     def set_password(self, password):
#         self.password = bcrypt.hashpw(password, bcrypt.gensalt())
# 
#     def __init__(self, username, email, password):
#         self.email = email
#         self.username = username
#         self.password = bcrypt.hashpw(password, bcrypt.gensalt())
#         self.admin = False
#         self.created = datetime.now()
# 
#     def __repr__(self):
#         return '<User %r>' % self.username
# 
#     # Flask.Login stuff
#     # We don't use most of these features
#     def is_authenticated(self):
#         return True
#     def is_active(self):
#         return True
#     def is_anonymous(self):
#         return False
#     def get_id(self):
#         return self.username
# 
# Path: packages/blueprints/api.py
# def login():
# def get_info(repo, name):
# def approve_package(repo, name):
# def unapprove_package(repo, name):
# def set_admin(username):
# def remove_admin(username):
# def confirm_user(username, confirmation):
# def unconfirm_user(username):
# def remove_package(repo, name):
# def transfer_package(repo, name, username):
# def upload_package():
# 
# Path: packages/blueprints/html.py
# def index():
# def register():
# def confirm(confirmation):
# def login():
# def logout():
# def forgot_password():
# def reset_password(username, confirmation):
# def pending():
# def upload():
# def package(repo, name):
# def users():
# def user(username):
# def repo(repo):
# def search():
# def download(repo, name):
# def guidelines():
# def help():
#         PAGE_SIZE = request.args.get('count')
#             PAGE_SIZE = '10'
#         PAGE_SIZE = int(PAGE_SIZE)
#         PAGE_SIZE = 10
#     if PAGE_SIZE <= 0: PAGE_SIZE = 10
#         PAGE_SIZE = request.args.get('count')
#             PAGE_SIZE = '10'
#         PAGE_SIZE = int(PAGE_SIZE)
#         PAGE_SIZE = 10
#     if PAGE_SIZE <= 0: PAGE_SIZE = 10
#         PAGE_SIZE = request.args.get('count')
#             PAGE_SIZE = '10'
#         PAGE_SIZE = int(PAGE_SIZE)
#         PAGE_SIZE = 10
#     if PAGE_SIZE <= 0: PAGE_SIZE = 10


from flask import Flask, render_template, request, g, Response, redirect, session, abort, send_file, url_for
from flask.ext.login import LoginManager, current_user
from jinja2 import FileSystemLoader, ChoiceLoader
from werkzeug.utils import secure_filename
from datetime import datetime, timedelta
from shutil import rmtree, copyfile
from sqlalchemy import desc
from packages.config import _cfg, _cfgi
from packages.database import db, init_db
from packages.objects import User
from packages.common import *
from packages.network import *
from packages.blueprints.api import api
from packages.blueprints.html import html
        from logging.handlers import SMTPHandler
import sys
import os
import subprocess
import urllib
import requests
import json
import zipfile
import locale
import traceback
import xml.etree.ElementTree as ET
        import logging




app = Flask(__name__)
app.secret_key = _cfg("secret-key")
app.jinja_env.cache = None
init_db()
login_manager = LoginManager()
login_manager.init_app(app)

@login_manager.user_loader
def load_user(username):
    return User.query.filter(User.username == username).first()

login_manager.anonymous_user = lambda: None

app.register_blueprint(api)

# Path: packages/config.py

# 
# Path: packages/database.py
# def init_db():
# 
# Path: packages/objects.py
# class User(Base):
#     __tablename__ = 'user'
#     id = Column(Integer, primary_key = True)
#     username = Column(String(128), nullable = False, index = True)
#     email = Column(String(256), nullable = False, index = True)
#     admin = Column(Boolean())
#     password = Column(String)
#     created = Column(DateTime)
#     confirmation = Column(String(128))
#     passwordReset = Column(String(128))
#     passwordResetExpiry = Column(DateTime)
#     packages = relationship('Package', order_by='Package.created')
# 
#     def set_password(self, password):
#         self.password = bcrypt.hashpw(password, bcrypt.gensalt())
# 
#     def __init__(self, username, email, password):
#         self.email = email
#         self.username = username
#         self.password = bcrypt.hashpw(password, bcrypt.gensalt())
#         self.admin = False
#         self.created = datetime.now()
# 
#     def __repr__(self):
#         return '<User %r>' % self.username
# 
#     # Flask.Login stuff
#     # We don't use most of these features
#     def is_authenticated(self):
#         return True
#     def is_active(self):
#         return True
#     def is_anonymous(self):
#         return False
#     def get_id(self):
#         return self.username
# 
# Path: packages/blueprints/api.py
# def login():
# def get_info(repo, name):
# def approve_package(repo, name):
# def unapprove_package(repo, name):
# def set_admin(username):
# def remove_admin(username):
# def confirm_user(username, confirmation):
# def unconfirm_user(username):
# def remove_package(repo, name):
# def transfer_package(repo, name, username):
# def upload_package():
# 
# Path: packages/blueprints/html.py
# def index():
# def register():
# def confirm(confirmation):
# def login():
# def logout():
# def forgot_password():
# def reset_password(username, confirmation):
# def pending():
# def upload():
# def package(repo, name):
# def users():
# def user(username):
# def repo(repo):
# def search():
# def download(repo, name):
# def guidelines():
# def help():
#         PAGE_SIZE = request.args.get('count')
#             PAGE_SIZE = '10'
#         PAGE_SIZE = int(PAGE_SIZE)
#         PAGE_SIZE = 10
#     if PAGE_SIZE <= 0: PAGE_SIZE = 10
#         PAGE_SIZE = request.args.get('count')
#             PAGE_SIZE = '10'
#         PAGE_SIZE = int(PAGE_SIZE)
#         PAGE_SIZE = 10
#     if PAGE_SIZE <= 0: PAGE_SIZE = 10
#         PAGE_SIZE = request.args.get('count')
#             PAGE_SIZE = '10'
#         PAGE_SIZE = int(PAGE_SIZE)
#         PAGE_SIZE = 10
#     if PAGE_SIZE <= 0: PAGE_SIZE = 10


# Path: packages/app.py
from flask import Flask, render_template, request, g, Response, redirect, session, abort, send_file, url_for
from flask.ext.login import LoginManager, current_user
from jinja2 import FileSystemLoader, ChoiceLoader
from werkzeug.utils import secure_filename
from datetime import datetime, timedelta
from shutil import rmtree, copyfile
from sqlalchemy import desc
from packages.config import _cfg, _cfgi
from packages.database import db, init_db
from packages.objects import User
from packages.common import *
from packages.network import *
from packages.blueprints.api import api
from packages.blueprints.html import html
        from logging.handlers import SMTPHandler
import sys
import os
import subprocess
import urllib
import requests
import json
import zipfile
import locale
import traceback
import xml.etree.ElementTree as ET
        import logging





app = Flask(__name__)
app.secret_key = _cfg("secret-key")
app.jinja_env.cache = None
init_db()
login_manager = LoginManager()
login_manager.init_app(app)

@login_manager.user_loader
def load_user(username):
    return User.query.filter(User.username == username).first()

login_manager.anonymous_user = lambda: None

app.register_blueprint(api)

app.register_blueprint(html)