Skip to content

Commit 80c9283

Browse files
committed
refactor: Run pyupgrade with minimal options
find . -name '*.py' -exec pyupgrade --keep-percent-format --keep-mock --py3-plus {} +
1 parent 1038f1c commit 80c9283

7 files changed

Lines changed: 12 additions & 13 deletions

File tree

src/WebAppDIRAC/Core/TemplateLoader.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import os
2-
from io import open
32
from tornado.template import BaseLoader, Template
43

54

65
class TemplateLoader(BaseLoader):
76
def __init__(self, pathList, **kwargs):
8-
super(TemplateLoader, self).__init__(**kwargs)
7+
super().__init__(**kwargs)
98
self.pathList = pathList
109

1110
def resolve_path(self, name, parent_path=None):
@@ -18,7 +17,7 @@ def _create_template(self, name):
1817
for path in self.pathList:
1918
try:
2019
f = open(os.path.abspath(os.path.join(path, name)), "rb")
21-
except IOError:
20+
except OSError:
2221
continue
2322
template = Template(f.read(), name=name, loader=self)
2423
f.close()

src/WebAppDIRAC/Lib/Conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def generateCAFile():
184184
fn = tempfile.mkstemp(prefix="cas.", suffix=".pem")[1]
185185
try:
186186
fd = open(fn, "w")
187-
except IOError:
187+
except OSError:
188188
continue
189189
for caFile in os.listdir(caDir):
190190
caFile = os.path.join(caDir, caFile)
@@ -216,7 +216,7 @@ def generateRevokedCertsFile():
216216
fn = tempfile.mkstemp(prefix="allRevokedCerts", suffix=".pem")[1]
217217
try:
218218
fd = open(fn, "w")
219-
except IOError:
219+
except OSError:
220220
continue
221221
for caFile in os.listdir(caDir):
222222
caFile = os.path.join(caDir, caFile)

src/WebAppDIRAC/WebApp/handler/JobSummaryHandler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,21 +268,21 @@ def web_getSelectionData(self):
268268
if result["OK"]:
269269
result = result["Value"]
270270
if len(result.get("Status", [])) > 0:
271-
status = [[str("All")]]
271+
status = [["All"]]
272272
for i in result["Status"]:
273273
status.append([str(i)])
274274
else:
275275
status = [["Nothing to display"]]
276276
callback["status"] = status
277277
if len(result.get("GridType", [])) > 0:
278-
gridtype = [[str("All")]]
278+
gridtype = [["All"]]
279279
for i in result["GridType"]:
280280
gridtype.append([str(i)])
281281
else:
282282
gridtype = [["Nothing to display"]]
283283
callback["gridtype"] = gridtype
284284
if len(result.get("MaskStatus", [])) > 0:
285-
maskstatus = [[str("All")]]
285+
maskstatus = [["All"]]
286286
for i in result["MaskStatus"]:
287287
maskstatus.append([str(i)])
288288
else:

src/WebAppDIRAC/WebApp/handler/ResourceSummaryHandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _getSelectionData(self, **kwargs) -> dict:
3333

3434
for key, value in callback.items():
3535

36-
callback[key] = sorted([[item] for item in list(value)])
36+
callback[key] = sorted([item] for item in list(value))
3737
callback[key] = [["All"]] + callback[key]
3838

3939
return callback
@@ -54,7 +54,7 @@ def combine(self, elementValues: list) -> dict:
5454

5555
else:
5656

57-
if set(["Active", "Degraded"]) & set(statusSet):
57+
if {"Active", "Degraded"} & set(statusSet):
5858
status = "Degraded"
5959
reason = "Not completely active"
6060

src/WebAppDIRAC/WebApp/handler/RootHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def web_index(self, *, url_state="", theme="crisp", open_app="", **kwargs):
173173
welcomeFile = Conf.getWelcome()
174174
if welcomeFile:
175175
try:
176-
with open(welcomeFile, "r") as f:
176+
with open(welcomeFile) as f:
177177
welcome = f.read().replace("\n", "")
178178
except Exception:
179179
gLogger.warn("Welcome page not found here: %s" % welcomeFile)

src/WebAppDIRAC/WebApp/handler/SystemAdministrationHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def web_hostAction(self, host=None, action=None, version=None):
142142
str(_host), None, delegatedDN=self.getUserDN(), delegatedGroup=self.getUserGroup()
143143
)
144144
if action == "restart":
145-
result = client.restartComponent(str("*"), str("*"))
145+
result = client.restartComponent("*", "*")
146146
elif action == "revert":
147147
result = client.revertSoftware()
148148
elif action == "update":

src/WebAppDIRAC/WebApp/handler/UPHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def web_changeView(self, obj, app, desktop, view):
200200
return result
201201
data = result["Value"]
202202
oDesktop = json.loads(DEncode.decode(zlib.decompress(base64.b64decode(data)))[0])
203-
oDesktop[str("view")] = str(view)
203+
oDesktop["view"] = str(view)
204204
oDesktop = json.dumps(oDesktop)
205205
data = base64.b64encode(zlib.compress(DEncode.encode(oDesktop), 9))
206206
return up.storeVar(desktop, data)

0 commit comments

Comments
 (0)