Skip to content

Commit 434ebac

Browse files
committed
reformat code
1 parent 5d0f53a commit 434ebac

File tree

9 files changed

+19
-13
lines changed

9 files changed

+19
-13
lines changed

pywebio/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from . import output
33
from . import platform
44
from . import session
5+
from . import pin
56

67
from .__version__ import __author__, __author_email__, __license__
78
from .__version__ import __description__, __url__, __version__

pywebio/io_ctrl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
from collections import UserList
88
from functools import partial, wraps
9-
from collections.abc import Mapping
9+
1010
from .session import chose_impl, next_client_event, get_current_task_id, get_current_session
1111
from .utils import random_str
1212

pywebio/output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ def popup(title, content=None, size=PopupSize.NORMAL, implicit_close=True, closa
14611461
"""
14621462
Show a popup.
14631463
1464-
⚠️: In PyWebIO, you can't shoe multiple popup windows at the same time. Before displaying a new pop-up window, the existing popup on the page will be automatically closed. You can use `close_popup()` to close the popup manually.
1464+
⚠️: In PyWebIO, you can't show multiple popup windows at the same time. Before displaying a new pop-up window, the existing popup on the page will be automatically closed. You can use `close_popup()` to close the popup manually.
14651465
14661466
:param str title: The title of the popup.
14671467
:type content: list/str/put_xxx()

pywebio/pin.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120

121121
import string
122122

123-
from pywebio.input import *
124123
from pywebio.input import parse_input_update_spec
125124
from pywebio.output import Scope, OutputPosition, Output
126125
from pywebio.output import _get_output_spec
@@ -147,6 +146,7 @@ def _pin_output(single_input_return, scope, position):
147146
def put_input(name, type='text', *, label='', value=None, placeholder=None, readonly=None, datalist=None,
148147
help_text=None, scope=Scope.Current, position=OutputPosition.BOTTOM) -> Output:
149148
"""Output an input widget. Refer to: `pywebio.input.input()`"""
149+
from pywebio.input import input
150150
check_name(name)
151151
single_input_return = input(name=name, label=label, value=value, type=type, placeholder=placeholder,
152152
readonly=readonly, datalist=datalist, help_text=help_text)
@@ -156,6 +156,7 @@ def put_input(name, type='text', *, label='', value=None, placeholder=None, read
156156
def put_textarea(name, *, label='', rows=6, code=None, maxlength=None, minlength=None, value=None, placeholder=None,
157157
readonly=None, help_text=None, scope=Scope.Current, position=OutputPosition.BOTTOM) -> Output:
158158
"""Output a textarea widget. Refer to: `pywebio.input.textarea()`"""
159+
from pywebio.input import textarea
159160
check_name(name)
160161
single_input_return = textarea(
161162
name=name, label=label, rows=rows, code=code, maxlength=maxlength,
@@ -166,6 +167,7 @@ def put_textarea(name, *, label='', rows=6, code=None, maxlength=None, minlength
166167
def put_select(name, options=None, *, label='', multiple=None, value=None, help_text=None,
167168
scope=Scope.Current, position=OutputPosition.BOTTOM) -> Output:
168169
"""Output a select widget. Refer to: `pywebio.input.select()`"""
170+
from pywebio.input import select
169171
check_name(name)
170172
single_input_return = select(name=name, options=options, label=label, multiple=multiple,
171173
value=value, help_text=help_text)
@@ -175,6 +177,7 @@ def put_select(name, options=None, *, label='', multiple=None, value=None, help_
175177
def put_checkbox(name, options=None, *, label='', inline=None, value=None, help_text=None,
176178
scope=Scope.Current, position=OutputPosition.BOTTOM) -> Output:
177179
"""Output a checkbox widget. Refer to: `pywebio.input.checkbox()`"""
180+
from pywebio.input import checkbox
178181
check_name(name)
179182
single_input_return = checkbox(name=name, options=options, label=label, inline=inline, value=value,
180183
help_text=help_text)
@@ -184,6 +187,7 @@ def put_checkbox(name, options=None, *, label='', inline=None, value=None, help_
184187
def put_radio(name, options=None, *, label='', inline=None, value=None, help_text=None,
185188
scope=Scope.Current, position=OutputPosition.BOTTOM) -> Output:
186189
"""Output a radio widget. Refer to: `pywebio.input.radio()`"""
190+
from pywebio.input import radio
187191
check_name(name)
188192
single_input_return = radio(name=name, options=options, label=label, inline=inline, value=value,
189193
help_text=help_text)
@@ -193,6 +197,7 @@ def put_radio(name, options=None, *, label='', inline=None, value=None, help_tex
193197
def put_slider(name, *, label='', value=0, min_value=0, max_value=100, step=1, required=None, help_text=None,
194198
scope=Scope.Current, position=OutputPosition.BOTTOM) -> Output:
195199
"""Output a slide widget. Refer to: `pywebio.input.slider()`"""
200+
from pywebio.input import slider
196201
check_name(name)
197202
single_input_return = slider(name=name, label=label, value=value, min_value=min_value, max_value=max_value,
198203
step=step, required=required, help_text=help_text)

webiojs/src/handlers/script.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class ScriptHandler implements CommandHandler {
4141
data: value === undefined ? null : value
4242
});
4343
}).catch((error) => {
44+
console.log('Exception occurred in user code of `run_script` command: \n%s', error);
4445
state.CurrentSession.send_message({event: "js_yield", task_id: msg.task_id, data: null});
4546
});
4647
}

webiojs/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {config as appConfig, state} from "./state";
2-
import {ClientEvent, Command, HttpSession, is_http_backend, pushData, Session, WebSocketSession} from "./session";
2+
import {Command, HttpSession, is_http_backend, Session, WebSocketSession} from "./session";
33
import {InputHandler} from "./handlers/input"
44
import {OutputHandler} from "./handlers/output"
5-
import {SessionCtrlHandler, CommandDispatcher} from "./handlers/base"
5+
import {CommandDispatcher, SessionCtrlHandler} from "./handlers/base"
66
import {PopupHandler} from "./handlers/popup";
77
import {openApp} from "./utils";
88
import {ScriptHandler} from "./handlers/script";

webiojs/src/models/pin.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {get_input_item_from_type} from "./input/index"
22
import {InputItem} from "./input/base";
3-
import {error_alert} from "../utils";
43
import {t} from "../i18n";
54

65
let after_show_callbacks: (() => void) [] = [];
@@ -23,7 +22,7 @@ export function GetPinValue(name: string) {
2322
}
2423

2524
export function PinUpdate(name: string, attributes: { [k: string]: any }) {
26-
name2input[name].update_input({attributes:attributes});
25+
name2input[name].update_input({attributes: attributes});
2726
}
2827

2928
let onchange_callbacks: { [name: string]: ((val: any) => void)[] } = {}; // name->[]
@@ -53,7 +52,7 @@ export let PinWidget = {
5352
handle_type: 'pin',
5453
get_element: function (spec: any) {
5554
let input_spec = spec.input;
56-
if(input_spec.name in name2input){
55+
if (input_spec.name in name2input) {
5756
let tip = `<p style="color: grey; border:1px solid #ced4da; padding: .375rem .75rem;">${t("duplicated_pin_name")}</p>`;
5857
name2input[input_spec.name].element.replaceWith(tip);
5958
}
@@ -62,7 +61,7 @@ export let PinWidget = {
6261
input_spec.onblur = true;
6362
let InputClass = get_input_item_from_type(input_spec.type);
6463
let input_item = new InputClass(input_spec, null, (event, input_item) => {
65-
if(event=='change')
64+
if (event == 'change')
6665
trigger_onchange_event(input_spec.name, input_item.get_value());
6766
});
6867

webiojs/src/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ export function is_http_backend(backend_addr: string) {
329329
}
330330

331331

332-
// 向服务端发送数据
332+
// Send data to backend
333333
export function pushData(data: any, callback_id: string) {
334334
if (state.CurrentSession === null)
335335
return console.error("can't invoke PushData when WebIOController is not instantiated");

webiojs/src/state.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import {Session} from "./session";
22

3-
// 运行时状态
3+
// Runtime state
44
export let state = {
55
AutoScrollBottom: false, // 是否有新内容时自动滚动到底部
66
CurrentSession: null as Session, // 当前正在活跃的会话
77
ShowDuration: 200, // ms, 显示表单的过渡动画时长
88
InputPanelMinHeight: 300, // 输入panel的最小高度
99
InputPanelInitHeight: 300, // 输入panel的初始高度
1010
FixedInputPanel:true,
11-
AutoFocusOnInput:true
11+
AutoFocusOnInput:true,
1212
};
1313

14-
// 应用配置
14+
// App config
1515
export let config = {
1616
codeMirrorModeURL: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/%N/%N.min.js",
1717
codeMirrorThemeURL: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/theme/%N.min.css",

0 commit comments

Comments
 (0)