Skip to content

Commit

Permalink
pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed May 16, 2024
1 parent 846199f commit a46eff6
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 82 deletions.
15 changes: 2 additions & 13 deletions py4web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,5 @@ def _maybe_gevent():
from .core import Translator # from pluralize
from .core import action # main py4web decorator
from .core import render # yatl
from .core import (
DAL,
Cache,
Condition,
Flash,
Session,
abort,
check_compatible,
redirect,
request,
response,
safely,
)
from .core import (DAL, Cache, Condition, Flash, Session, abort,
check_compatible, redirect, request, response, safely)
3 changes: 1 addition & 2 deletions py4web/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import datetime
import enum
import functools
import html as sanitize_html
import http.client
import http.cookies
import importlib.machinery
Expand All @@ -34,7 +35,6 @@
import zipfile
from collections import OrderedDict
from contextlib import redirect_stderr, redirect_stdout
import html as sanitize_html

import portalocker
from watchgod import awatch
Expand All @@ -48,7 +48,6 @@
gunicorn = None

import click

# Third party modules
import ombott as bottle
import pluralize
Expand Down
9 changes: 5 additions & 4 deletions py4web/server_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def get_workers(opts, default=10):


def check_port(host="127.0.0.1", port=8000):
import socket
import errno
import socket
import subprocess

def os_cmd(run_cmd):
Expand Down Expand Up @@ -177,9 +177,10 @@ def os_cmd(run_cmd):


def gunicorn():
from gevent import local # pip install gevent gunicorn setproctitle
import threading

from gevent import local # pip install gevent gunicorn setproctitle

if isinstance(threading.local(), local.local):
print("gunicorn: monkey.patch_all() applied")

Expand Down Expand Up @@ -386,7 +387,6 @@ def run(self, app_handler):

def geventWebSocketServer():
from gevent import pywsgi

# from geventwebsocket.handler import WebSocketHandler # pip install gevent-websocket
from gevent_ws import WebSocketHandler # pip install gevent gevent-ws

Expand Down Expand Up @@ -445,7 +445,8 @@ def wsgirefThreadingServer():
import socket
from concurrent.futures import ThreadPoolExecutor # pip install futures
from socketserver import ThreadingMixIn
from wsgiref.simple_server import WSGIRequestHandler, WSGIServer, make_server
from wsgiref.simple_server import (WSGIRequestHandler, WSGIServer,
make_server)

class WSGIRefThreadingServer(ServerAdapter):
def run(self, app_handler):
Expand Down
11 changes: 2 additions & 9 deletions py4web/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@
import time
import uuid

from pydal.validators import (
CRYPT,
IS_EMAIL,
IS_EQUAL_TO,
IS_MATCH,
IS_NOT_EMPTY,
IS_NOT_IN_DB,
IS_STRONG,
)
from pydal.validators import (CRYPT, IS_EMAIL, IS_EQUAL_TO, IS_MATCH,
IS_NOT_EMPTY, IS_NOT_IN_DB, IS_STRONG)
from yatl.helpers import DIV, A

from py4web import HTTP, URL, Field, action, redirect, request, response
Expand Down
3 changes: 2 additions & 1 deletion py4web/utils/auth_plugins/oauth2facebook.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from . import OAuth2
import requests

from . import OAuth2


class OAuth2Facebook(OAuth2):
name = "oauth2facebook"
Expand Down
16 changes: 2 additions & 14 deletions py4web/utils/auth_plugins/pam.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,8 @@
__all__ = ["authenticate"]

import sys
from ctypes import (
CDLL,
CFUNCTYPE,
POINTER,
Structure,
byref,
c_char,
c_char_p,
c_int,
c_uint,
c_void_p,
cast,
sizeof,
)
from ctypes import (CDLL, CFUNCTYPE, POINTER, Structure, byref, c_char,
c_char_p, c_int, c_uint, c_void_p, cast, sizeof)
from ctypes.util import find_library

libpam = CDLL(find_library("pam"))
Expand Down
1 change: 0 additions & 1 deletion py4web/utils/auth_plugins/x509_auth_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from gluon.globals import current
from gluon.storage import Storage

# requires M2Crypto
from M2Crypto import X509

Expand Down
16 changes: 2 additions & 14 deletions py4web/utils/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,8 @@
import jwt
from pydal._compat import to_native
from pydal.objects import FieldVirtual
from yatl.helpers import (
CAT,
DIV,
FORM,
INPUT,
LABEL,
OPTION,
SELECT,
SPAN,
TEXTAREA,
XML,
A,
P,
)
from yatl.helpers import (CAT, DIV, FORM, INPUT, LABEL, OPTION, SELECT, SPAN,
TEXTAREA, XML, A, P)

from py4web import HTTP, request, response
from py4web.utils.param import Param
Expand Down
26 changes: 3 additions & 23 deletions py4web/utils/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,8 @@
from urllib.parse import urlparse

from pydal.objects import Expression, Field, FieldVirtual
from yatl.helpers import (
CAT,
DIV,
FORM,
INPUT,
OPTION,
SELECT,
SPAN,
TABLE,
TAG,
TBODY,
TD,
TH,
THEAD,
TR,
XML,
A,
I,
)
from yatl.helpers import (CAT, DIV, FORM, INPUT, OPTION, SELECT, SPAN, TABLE,
TAG, TBODY, TD, TH, THEAD, TR, XML, A, I)

from py4web import HTTP, URL, redirect, request, safely
from py4web.utils.form import Form, FormStyleDefault, join_classes
Expand Down Expand Up @@ -758,10 +741,7 @@ def process(self):
self.form.param.submit_value = self.param.edit_submit_value

# redirect to the referrer
if (
self.form.accepted
or (readonly and request.method == "POST")
):
if self.form.accepted or (readonly and request.method == "POST"):
referrer = request.query.get("_referrer")
if referrer:
redirect(base64.b16decode(referrer.encode("utf8")).decode("utf8"))
Expand Down
1 change: 0 additions & 1 deletion py4web/utils/tags.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging


logging.warning(
"Deprecation notice: replace py4web.utils.tags with pydal.tools.tags in your code."
)

0 comments on commit a46eff6

Please sign in to comment.