Skip to content

Commit

Permalink
pb: reorder imports
Browse files Browse the repository at this point in the history
  • Loading branch information
buhman committed Jun 10, 2017
1 parent 51d24c0 commit 527226e
Show file tree
Hide file tree
Showing 23 changed files with 75 additions and 74 deletions.
7 changes: 3 additions & 4 deletions pb/__main__.py
Expand Up @@ -26,12 +26,11 @@

import os

from pb.pb import create_app
from pb.runonce import add_indexes
from pb import db

from werkzeug.serving import run_simple

from pb import db
from pb.pb import create_app
from pb.runonce import add_indexes

app = create_app()

Expand Down
10 changes: 4 additions & 6 deletions pb/cache.py
Expand Up @@ -9,17 +9,15 @@
:license: GPLv3, see LICENSE for details.
"""

from os import path
from functools import wraps
from concurrent.futures import ThreadPoolExecutor

from functools import wraps
from hashlib import sha1

from os import path
from urllib.parse import urljoin, urlsplit
from requests.sessions import Session

from flask import current_app, g, request
from requests.sessions import Session
from werkzeug.wrappers import get_host
from flask import request, current_app, g

from pb.paste import model

Expand Down
5 changes: 3 additions & 2 deletions pb/converters.py
Expand Up @@ -10,9 +10,10 @@
"""

import re
from base64 import urlsafe_b64decode, urlsafe_b64encode
from binascii import Error as BinError
from binascii import hexlify, unhexlify
from os import path
from binascii import unhexlify, hexlify, Error as BinError
from base64 import urlsafe_b64encode, urlsafe_b64decode

from flask import current_app, request
from werkzeug.routing import BaseConverter
Expand Down
4 changes: 2 additions & 2 deletions pb/db.py
Expand Up @@ -9,9 +9,9 @@
:license: GPLv3, see LICENSE for details.
"""

from flask import g, request, current_app
from pymongo import MongoClient
from flask import current_app, g, request
from gridfs import GridFS
from pymongo import MongoClient


def get_db():
Expand Down
1 change: 0 additions & 1 deletion pb/logging.py
@@ -1,6 +1,5 @@
import logging


logging.basicConfig(level=logging.DEBUG)


Expand Down
2 changes: 1 addition & 1 deletion pb/namespace/model.py
Expand Up @@ -9,8 +9,8 @@
:license: GPLv3, see LICENSE for details.
"""

from uuid import uuid4, UUID
from datetime import datetime
from uuid import UUID, uuid4

from pb.db import get_db

Expand Down
8 changes: 4 additions & 4 deletions pb/paste/handler.py
Expand Up @@ -10,13 +10,13 @@
"""

from json import dumps
from flask import render_template, url_for, request
from mimetypes import add_type

from flask import render_template, request, url_for
from werkzeug.routing import BaseConverter

from pb.util import rst, markdown, style_args
from pb.responses import StatusResponse

from mimetypes import add_type
from pb.util import markdown, rst, style_args

add_type('text/x-markdown', '.md')
add_type('text/x-rst', '.rst')
Expand Down
6 changes: 3 additions & 3 deletions pb/paste/model.py
Expand Up @@ -9,12 +9,12 @@
:license: GPLv3, see LICENSE for details.
"""

from uuid import uuid4
from hashlib import sha1
from datetime import datetime
from hashlib import sha1
from uuid import uuid4

from pymongo import DESCENDING
from bson import ObjectId
from pymongo import DESCENDING

from pb.db import get_db, get_fs

Expand Down
20 changes: 11 additions & 9 deletions pb/paste/views.py
Expand Up @@ -9,25 +9,27 @@
:license: GPLv3, see LICENSE for details.
"""

from uuid import UUID
from mimetypes import guess_type
from datetime import datetime, timedelta
from io import BytesIO
from mimetypes import guess_type
from uuid import UUID

from datetime import timedelta, datetime

from flask import Blueprint, request, render_template, current_app
from flask import Blueprint, current_app, render_template, request
from jinja2 import Markup
from pygments.formatters import HtmlFormatter, get_all_formatters
from pygments.lexers import get_all_lexers
from pygments.styles import get_all_styles
from pygments.util import ClassNotFound
from pymongo import errors

from pb.namespace import model as ns_model
from pb.paste import model, handler as _handler
from pb.util import highlight, request_content, request_keys, rst, markdown, absolute_url, get_host_name, parse_sunset
from pb.cache import invalidate
from pb.responses import BaseResponse, StatusResponse, PasteResponse, DictResponse, redirect
from pb.namespace import model as ns_model
from pb.paste import handler as _handler
from pb.paste import model
from pb.responses import (BaseResponse, DictResponse, PasteResponse,
StatusResponse, redirect)
from pb.util import (absolute_url, get_host_name, highlight, markdown,
parse_sunset, request_content, request_keys, rst)

paste = Blueprint('paste', __name__)

Expand Down
17 changes: 9 additions & 8 deletions pb/pb.py
Expand Up @@ -12,17 +12,18 @@
from flask import Flask, request
from xdg import BaseDirectory

from pb.paste.views import paste
from pb.namespace.views import namespace
from pb.db import init_db
from pb.cache import init_cache
from pb.template import init_template
from pb.converters import SIDConverter, SHA1Converter, LabelConverter, NamespaceConverter
from pb.paste.handler import HandlerConverter
from pb.responses import BaseResponse
from pb.routing import Rule, RequestContext
from pb.config import load_config
from pb.converters import (LabelConverter, NamespaceConverter, SHA1Converter,
SIDConverter)
from pb.db import init_db
from pb.logging import init_logging
from pb.namespace.views import namespace
from pb.paste.handler import HandlerConverter
from pb.paste.views import paste
from pb.responses import BaseResponse
from pb.routing import RequestContext, Rule
from pb.template import init_template


def cors(response):
Expand Down
11 changes: 5 additions & 6 deletions pb/responses.py
@@ -1,14 +1,13 @@
import yaml
from yaml.dumper import SafeDumper
import json
from datetime import datetime, timedelta
from uuid import UUID

from datetime import timedelta, datetime
import yaml
from flask import current_app, request
from pytz import utc

from werkzeug.wrappers import Response
from werkzeug.http import parse_list_header
from flask import request, current_app
from werkzeug.wrappers import Response
from yaml.dumper import SafeDumper

from pb.converters import SIDConverter
from pb.util import absolute_url
Expand Down
10 changes: 5 additions & 5 deletions pb/routing.py
@@ -1,10 +1,10 @@
from werkzeug.routing import Rule as BaseRule, \
MapAdapter as BaseMapAdapter
from flask.ctx import RequestContext as BaseRequestContext
from werkzeug import routing
from werkzeug.routing import RequestSlash, RequestAliasRedirect, RequestRedirect, MethodNotAllowed, NotFound
from werkzeug.exceptions import HTTPException

from flask.ctx import RequestContext as BaseRequestContext
from werkzeug.routing import MapAdapter as BaseMapAdapter
from werkzeug.routing import Rule as BaseRule
from werkzeug.routing import (MethodNotAllowed, NotFound, RequestAliasRedirect,
RequestRedirect, RequestSlash)

from pb.config import config
from pb.util import get_host_name
Expand Down
3 changes: 2 additions & 1 deletion pb/runonce.py
Expand Up @@ -11,8 +11,9 @@
"""

from urllib import parse
from pymongo import MongoClient

import pymongo
from pymongo import MongoClient

from pb.config import load_config

Expand Down
18 changes: 8 additions & 10 deletions pb/util.py
Expand Up @@ -9,24 +9,22 @@
:license: GPLv3, see LICENSE for details.
"""

from io import BytesIO
from datetime import datetime, timedelta
from dateutil.parser import parse as datetime_parse
from io import BytesIO

from dateutil.parser import parse as datetime_parse
from docutils import core
from flask import render_template, request, url_for

from pygments import highlight as _highlight, format as _format
from pygments.token import Token
from pygments.lexers import get_lexer_by_name
from markdown import markdown as _markdown
from pygments import format as _format
from pygments import highlight as _highlight
from pygments.formatters import HtmlFormatter, get_formatter_by_name
from pygments.lexers import get_lexer_by_name
from pygments.token import Token
from pygments.util import ClassNotFound

from werkzeug import http
from werkzeug.wrappers import get_host

from docutils import core
from markdown import markdown as _markdown


def style_args():
return {k: request.args[k] for k in ['style', 'css'] if k in request.args}
Expand Down
2 changes: 1 addition & 1 deletion runonce.py
Expand Up @@ -12,7 +12,7 @@

from argparse import ArgumentParser

from pb.runonce import main, _admin
from pb.runonce import _admin, main

parser = ArgumentParser(description='Initial pb database setup')
sub = parser.add_subparsers(metavar='[admin]')
Expand Down
4 changes: 2 additions & 2 deletions tests/test_paste.py
@@ -1,6 +1,6 @@
from time import time, monotonic
from io import BytesIO
from os import urandom, path
from os import path, urandom
from time import monotonic, time
from urllib import parse

from yaml import load
Expand Down
3 changes: 2 additions & 1 deletion tests/test_paste_handler.py
@@ -1,7 +1,8 @@
from flask import url_for
from time import time

from flask import url_for
from yaml import load

from pb.pb import create_app


Expand Down
3 changes: 2 additions & 1 deletion tests/test_paste_highlight.py
@@ -1,7 +1,8 @@
from flask import url_for
from time import time

from flask import url_for
from yaml import load

from pb.pb import create_app


Expand Down
2 changes: 1 addition & 1 deletion tests/test_paste_mangle.py
@@ -1,5 +1,5 @@
from time import time
from os import path
from time import time
from urllib import parse

from flask import url_for
Expand Down
4 changes: 2 additions & 2 deletions tests/test_paste_private.py
@@ -1,8 +1,8 @@
from time import time
from hashlib import sha1
from yaml import load
from time import time

from flask import url_for
from yaml import load

from pb.pb import create_app

Expand Down
2 changes: 1 addition & 1 deletion tests/test_paste_sha1.py
@@ -1,5 +1,5 @@
from time import time
from hashlib import sha1
from time import time

from flask import url_for

Expand Down
5 changes: 3 additions & 2 deletions tests/test_paste_sunset.py
@@ -1,7 +1,8 @@
from flask import url_for
from time import time, sleep
from time import sleep, time

from flask import url_for
from yaml import load

from pb.pb import create_app


Expand Down
2 changes: 1 addition & 1 deletion tests/test_paste_vanity.py
@@ -1,7 +1,7 @@
from time import time
from yaml import load

from flask import url_for
from yaml import load

from pb.pb import create_app

Expand Down

0 comments on commit 527226e

Please sign in to comment.