Skip to content

Commit 39e83f0

Browse files
committed
style: apply ruff format and lint auto-fixes
1 parent cf21071 commit 39e83f0

41 files changed

Lines changed: 367 additions & 450 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎examples/controller_logic.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
osw_obj.fetch_schema(
1919
fetchSchemaParam=OswExpress.FetchSchemaParam(schema_title="Category:Hardware")
2020
)
21-
from osw.model.entity import Hardware # noqa: E402
21+
from osw.model.entity import Hardware
2222

2323
title = "Item:OSW7d7193567ea14e4e89b74de88983b718"
2424
# title = "Item:OSWe02213b6c4664d04834355dc8eb08b99"

‎examples/database_access.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
osw_obj.install_dependencies(DEPENDENCIES, mode="append")
2424

2525
# Make sure to import controllers after updating the model (ignore linter warning)
26-
import osw.controller as controller # noqa: E402
26+
import osw.controller as controller
2727

2828
# Load database definition
2929
db = osw_obj.load_entity("Item:OSWb8cc7705e17c47b19331fdb045bfbca8") # postgres

‎examples/file_upload_download.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
# Import the controller modules
3131
# Note: since they depend on the data classes, they must be imported after the schemas
3232
# are loaded
33-
from osw.controller.file.local import ( # noqa (ignore flake8 warning)
33+
from osw.controller.file.local import (
3434
LocalFileController,
3535
)
36-
from osw.controller.file.s3 import S3FileController # noqa (ignore flake8 warning)
37-
from osw.controller.file.wiki import WikiFileController # noqa (ignore flake8 warning)
36+
from osw.controller.file.s3 import S3FileController
37+
from osw.controller.file.wiki import WikiFileController
3838

3939

4040
def video_file():

‎examples/get_page_content.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
# getting the page content from the main slot (without info box...)
2121
page_content = (
22-
osw.site.get_page(GetPageParam(titles=[fullpagetitle_to_download]))
22+
osw.site
23+
.get_page(GetPageParam(titles=[fullpagetitle_to_download]))
2324
.pages[0]
2425
.get_slot_content("main")
2526
)

‎examples/gui_local_slot_editing.py‎

Lines changed: 100 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
# Definition of functions
4848
def str_or_none(value):
4949
if str(value) == "" or value is None:
50-
return str("None")
50+
return "None"
5151
else:
5252
return str(value)
5353

@@ -139,7 +139,7 @@ def save_as_page_package(
139139
# Predefining some variables before execution
140140
settings_file_path = SETTINGS_FILE_PATH_DEFAULT
141141
if os.path.exists(settings_file_path):
142-
with open(settings_file_path, "r") as f:
142+
with open(settings_file_path) as f:
143143
settings = json.load(f)
144144
settings_read_from_file = True
145145
else:
@@ -182,54 +182,48 @@ def save_as_page_package(
182182
settings_layout = [
183183
[psg.Text("Settings", font=("Helvetica", 20))],
184184
[
185-
psg.Column(
185+
psg.Column([
186186
[
187-
[
188-
psg.Text("Settings file"),
189-
],
190-
[
191-
psg.Text("Credentials file"),
192-
],
193-
[
194-
psg.Text("Local working directory"),
195-
],
196-
]
197-
),
198-
psg.Column(
187+
psg.Text("Settings file"),
188+
],
199189
[
200-
[
201-
psg.In(
202-
size=(50, 1),
203-
enable_events=True,
204-
key="-SETTINGS-",
205-
default_text=settings["settings_file_path"],
206-
),
207-
psg.FileBrowse(button_text="Browse", key="-BROWSE_SETTINGS-"),
208-
psg.Button("Load", key="-LOAD_SETTINGS-"),
209-
psg.Button("Save", key="-SAVE_SETTINGS-"),
210-
],
211-
[
212-
psg.In(
213-
size=(50, 1),
214-
enable_events=True,
215-
key="-CREDENTIALS-",
216-
default_text=settings["cred_filepath"],
217-
),
218-
psg.FileBrowse(
219-
button_text="Browse", key="-BROWSE_CREDENTIALS-"
220-
),
221-
],
222-
[
223-
psg.In(
224-
size=(50, 1),
225-
enable_events=True,
226-
key="-LWD-",
227-
default_text=settings["local_working_directory"],
228-
),
229-
psg.FolderBrowse(button_text="Browse", key="-BROWSE_LWD-"),
230-
],
231-
]
232-
),
190+
psg.Text("Credentials file"),
191+
],
192+
[
193+
psg.Text("Local working directory"),
194+
],
195+
]),
196+
psg.Column([
197+
[
198+
psg.In(
199+
size=(50, 1),
200+
enable_events=True,
201+
key="-SETTINGS-",
202+
default_text=settings["settings_file_path"],
203+
),
204+
psg.FileBrowse(button_text="Browse", key="-BROWSE_SETTINGS-"),
205+
psg.Button("Load", key="-LOAD_SETTINGS-"),
206+
psg.Button("Save", key="-SAVE_SETTINGS-"),
207+
],
208+
[
209+
psg.In(
210+
size=(50, 1),
211+
enable_events=True,
212+
key="-CREDENTIALS-",
213+
default_text=settings["cred_filepath"],
214+
),
215+
psg.FileBrowse(button_text="Browse", key="-BROWSE_CREDENTIALS-"),
216+
],
217+
[
218+
psg.In(
219+
size=(50, 1),
220+
enable_events=True,
221+
key="-LWD-",
222+
default_text=settings["local_working_directory"],
223+
),
224+
psg.FolderBrowse(button_text="Browse", key="-BROWSE_LWD-"),
225+
],
226+
]),
233227
],
234228
[psg.HSeparator()],
235229
]
@@ -244,84 +238,76 @@ def save_as_page_package(
244238
# Target page
245239
[psg.Text("Target page", font=("Helvetica", 16))],
246240
[
247-
psg.Column(
241+
psg.Column([
242+
[psg.Text("Address, within selected OSW instance")],
243+
[psg.Text("First label of the OSW page:")],
244+
]),
245+
psg.Column([
248246
[
249-
[psg.Text("Address, within selected OSW instance")],
250-
[psg.Text("First label of the OSW page:")],
251-
]
252-
),
253-
psg.Column(
247+
psg.InputText(
248+
size=(50, 1),
249+
default_text=settings["target_page"],
250+
key="-ADDRESS-",
251+
),
252+
psg.Button("Load page"),
253+
],
254254
[
255-
[
256-
psg.InputText(
257-
size=(50, 1),
258-
default_text=settings["target_page"],
259-
key="-ADDRESS-",
260-
),
261-
psg.Button("Load page"),
262-
],
263-
[
264-
# A display element that will show the label of the OSW page
265-
psg.Multiline(size=(50, 1), key="-LABEL-", no_scrollbar=True)
266-
],
267-
]
268-
),
255+
# A display element that will show the label of the OSW page
256+
psg.Multiline(size=(50, 1), key="-LABEL-", no_scrollbar=True)
257+
],
258+
]),
269259
],
270260
# [
271261
# psg.HSeparator()
272262
# ],
273263
# Slots to download
274264
[psg.Text("Slots to download", font=("Helvetica", 16))],
275265
[
276-
psg.Column(
266+
psg.Column([
267+
[
268+
psg.Radio(
269+
"Include empty slots",
270+
group_id="-RADIO1-",
271+
default=settings["dump_empty_slots"],
272+
key="-INC_EMPTY-",
273+
enable_events=True,
274+
)
275+
],
277276
[
278-
[
279-
psg.Radio(
280-
"Include empty slots",
281-
group_id="-RADIO1-",
282-
default=settings["dump_empty_slots"],
283-
key="-INC_EMPTY-",
284-
enable_events=True,
285-
)
286-
],
287-
[
288-
psg.Radio(
289-
"Exclude empty slots",
290-
group_id="-RADIO1-",
291-
default=(not settings["dump_empty_slots"]),
292-
key="-EXC_EMPTY-",
293-
enable_events=True,
294-
)
295-
],
296-
[psg.Button("Download selected", key="-DL-")],
297-
[psg.Multiline(size=(20, 1), key="-DL_RES-", no_scrollbar=True)],
298-
]
299-
),
277+
psg.Radio(
278+
"Exclude empty slots",
279+
group_id="-RADIO1-",
280+
default=(not settings["dump_empty_slots"]),
281+
key="-EXC_EMPTY-",
282+
enable_events=True,
283+
)
284+
],
285+
[psg.Button("Download selected", key="-DL-")],
286+
[psg.Multiline(size=(20, 1), key="-DL_RES-", no_scrollbar=True)],
287+
]),
300288
],
301289
# [
302290
# psg.HSeparator()
303291
# ],
304292
# Slots to upload
305293
[psg.Text("Slots to upload", font=("Helvetica", 16))],
306294
[
307-
psg.Column(
295+
psg.Column([
296+
[psg.Button("(De)Select all", key="-UL_SEL-")],
308297
[
309-
[psg.Button("(De)Select all", key="-UL_SEL-")],
310-
[
311-
psg.Listbox(
312-
values=SLOTS.keys(),
313-
default_values=settings["slots_to_upload"],
314-
size=(20, 10),
315-
key="-UL_LIST-",
316-
select_mode=psg.LISTBOX_SELECT_MODE_MULTIPLE,
317-
enable_events=True,
318-
no_scrollbar=True,
319-
)
320-
],
321-
[psg.Button("Upload selected", key="-UL-")],
322-
[psg.Multiline(size=(20, 1), key="-UL_RES-", no_scrollbar=True)],
323-
]
324-
)
298+
psg.Listbox(
299+
values=SLOTS.keys(),
300+
default_values=settings["slots_to_upload"],
301+
size=(20, 10),
302+
key="-UL_LIST-",
303+
select_mode=psg.LISTBOX_SELECT_MODE_MULTIPLE,
304+
enable_events=True,
305+
no_scrollbar=True,
306+
)
307+
],
308+
[psg.Button("Upload selected", key="-UL-")],
309+
[psg.Multiline(size=(20, 1), key="-UL_RES-", no_scrollbar=True)],
310+
])
325311
],
326312
]
327313
output_layout = [
@@ -347,7 +333,7 @@ def save_as_page_package(
347333
settings["settings_file_path"] = values["-SETTINGS-"]
348334
elif event == "-LOAD_SETTINGS-":
349335
# update settings
350-
with open(settings["settings_file_path"], "r") as f:
336+
with open(settings["settings_file_path"]) as f:
351337
settings = json.load(f)
352338
# update GUI
353339
window["-CREDENTIALS-"].update(settings["cred_filepath"])
@@ -474,13 +460,11 @@ def save_as_page_package(
474460

475461
# Some debugging output functionality
476462
if DEBUG:
477-
values_str = "\n".join(
478-
[
479-
f"{key}: {str_or_none(value)}"
480-
for key, value in values.items()
481-
if key != "-OUTPUT-"
482-
]
483-
)
463+
values_str = "\n".join([
464+
f"{key}: {str_or_none(value)}"
465+
for key, value in values.items()
466+
if key != "-OUTPUT-"
467+
])
484468
listbox_selected_items_str = "\n".join(settings["slots_to_upload"])
485469

486470
window["-OUTPUT-"].update(

‎examples/inter_osw_copy_page.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def set_single_page_content(
7070
changed_slots = []
7171
for slot in SLOTS:
7272
remote_content = wtpage.get_slot_content(slot)
73-
if remote_content != content_dict.get(slot, None):
73+
if remote_content != content_dict.get(slot):
7474
changed_slots.append(slot)
7575
if len(changed_slots) == 0:
7676
print(

‎examples/page_manipulation.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,12 @@ def mass_page_edit():
8989
wtsite.modify_search_results(
9090
"semantic",
9191
"[[Category:labNote]]",
92-
lambda wtpage:
93-
# print("Lambda")#wtpage.title)
94-
wtpage.set_value(
95-
"*.'OslTemplate:ELN/Entry/Header'", {"id": [wtpage.title.split(":")[1]]}
96-
).update_content(),
92+
lambda wtpage: (
93+
# print("Lambda")#wtpage.title)
94+
wtpage.set_value(
95+
"*.'OslTemplate:ELN/Entry/Header'", {"id": [wtpage.title.split(":")[1]]}
96+
).update_content()
97+
),
9798
limit=1,
9899
comment="[bot] set id from title",
99100
log=True,

‎examples/use_express_functions.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import dotenv
55

6-
from osw.express import OswExpress, osw_download_file, osw_upload_file # noqa: E402
6+
from osw.express import OswExpress, osw_download_file, osw_upload_file
77

88
# Best practise load environment variables from .env file
99
dotenv.load_dotenv() # will look for a .env file in CWD and above

‎setup.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"""
2-
Setup file for osw.
3-
Use setup.cfg to configure your project.
2+
Setup file for osw.
3+
Use setup.cfg to configure your project.
44
5-
This file was generated with PyScaffold 4.3.1.
6-
PyScaffold helps you to put up the scaffold of your new Python project.
7-
Learn more under: https://pyscaffold.org/
5+
This file was generated with PyScaffold 4.3.1.
6+
PyScaffold helps you to put up the scaffold of your new Python project.
7+
Learn more under: https://pyscaffold.org/
88
"""
99

1010
from setuptools import setup
1111

1212
if __name__ == "__main__":
1313
try:
1414
setup(use_scm_version={"version_scheme": "no-guess-dev"})
15-
except: # noqa
15+
except:
1616
print(
1717
"\n\nAn error occurred while building the project, "
1818
"please ensure you have the most updated version of setuptools, "

0 commit comments

Comments
 (0)