Skip to content

Commit 5797047

Browse files
committed
Reanme some private members in metadtaObject base
1 parent bf8453b commit 5797047

File tree

9 files changed

+51
-51
lines changed

9 files changed

+51
-51
lines changed

Stoner/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def get_filedialog(what="file", **opts):
129129
funcs = {"file": "OpenFile", "directory": "SelectDirectory", "files": "OpenFiles", "save": "SaveFile"}
130130
if what not in funcs:
131131
raise RuntimeError(f"Unable to recognise required file dialog type:{what}")
132-
return fileDialog.openDialog(mode=funcs[what], **opts)
132+
return fileDialog.open_dialog(mode=funcs[what], **opts)
133133

134134

135135
if np_version.major >= 2:

Stoner/core/base.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,23 @@ class TypeHintedDict(RegexpDict):
259259
Attributes:
260260
_typehints (dict):
261261
The backing store for the type hint information
262-
__regexGetType (re):
262+
_regex_get_type (re):
263263
Used to extract the type hint from a string
264-
__regexSignedInt (re):
264+
_regex_signed_int (re):
265265
matches type hint strings for signed integers
266-
__regexUnsignedInt (re):
266+
_regex_unsigned_int (re):
267267
matches the type hint string for unsigned integers
268-
__regexFloat (re):
268+
_regex_float (re):
269269
matches the type hint strings for floats
270-
__regexBoolean (re):
270+
_regex_boolean (re):
271271
matches the type hint string for a boolean
272-
__regexStrng (re):
272+
_regex_strng (re):
273273
matches the type hint string for a string variable
274-
__regexEvaluatable (re):
274+
_regex_evaluatable (re):
275275
matches the type hint string for a compoind data type
276-
__types (dict):
276+
_types (dict):
277277
mapping of type hinted types to actual Python types
278-
__tests (dict):
278+
_tests (dict):
279279
mapping of the regex patterns to actual python types
280280
281281
Notes:
@@ -287,20 +287,20 @@ class TypeHintedDict(RegexpDict):
287287
allowed_keys: Tuple = string_types
288288
# Force metadata keys to be strings
289289

290-
__regexGetType: RegExp = re.compile(r"([^\{]*)\{([^\}]*)\}")
290+
_regex_get_type: RegExp = re.compile(r"([^\{]*)\{([^\}]*)\}")
291291
# Match the contents of the inner most{}
292-
__regexSignedInt: RegExp = re.compile(r"^I\d+")
292+
_regex_signed_int: RegExp = re.compile(r"^I\d+")
293293
# Matches all signed integers
294294
__regexUnsignedInt: RegExp = re.compile(r"^U / d+")
295295
# Match unsigned integers
296-
__regexFloat: RegExp = re.compile(r"^(Extended|Double|Single)\sFloat")
296+
_regex_float: RegExp = re.compile(r"^(Extended|Double|Single)\sFloat")
297297
# Match floating point types
298-
__regexBoolean: RegExp = re.compile(r"^Boolean")
298+
_regex_boolean: RegExp = re.compile(r"^Boolean")
299299
__regexString = re.compile(r"^(String|Path|Enum)")
300300
__regexTimestamp: RegExp = re.compile(r"Timestamp")
301-
__regexEvaluatable: RegExp = re.compile(r"^(Cluster||\d+D Array|List)")
301+
_regex_evaluatable: RegExp = re.compile(r"^(Cluster||\d+D Array|List)")
302302

303-
__types: Dict[str, Type] = dict(
303+
_types: Dict[str, Type] = dict(
304304
[ # Key order does matter here!
305305
("Boolean", bool),
306306
("I32", int),
@@ -313,17 +313,17 @@ class TypeHintedDict(RegexpDict):
313313
("String", str),
314314
]
315315
)
316-
# This is the inverse of the __tests below - this gives
316+
# This is the inverse of the _tests below - this gives
317317
# the string type for standard Python classes
318318

319-
__tests: List[Tuple] = [
320-
(__regexSignedInt, int),
319+
_tests: List[Tuple] = [
320+
(_regex_signed_int, int),
321321
(__regexUnsignedInt, int),
322-
(__regexFloat, float),
323-
(__regexBoolean, bool),
322+
(_regex_float, float),
323+
(_regex_boolean, bool),
324324
(__regexTimestamp, datetime.datetime),
325325
(__regexString, str),
326-
(__regexEvaluatable, _evaluatable()),
326+
(_regex_evaluatable, _evaluatable()),
327327
]
328328

329329
# This is used to work out the correct python class for
@@ -374,7 +374,7 @@ def findtype(self, value: Any) -> str:
374374
typ = "Invalid Type"
375375
if value is None:
376376
return "Void"
377-
for t, val in self.__types.items():
377+
for t, val in self._types.items():
378378
if isinstance(value, val):
379379
if t in ["Cluster", "AnonCluster"]:
380380
elements = []
@@ -415,7 +415,7 @@ def __mungevalue(self, typ: str, value: Any) -> Any:
415415
"""
416416
if typ == "Invalid Type": # Short circuit here
417417
return repr(value)
418-
for regexp, valuetype in self.__tests:
418+
for regexp, valuetype in self._tests:
419419
if regexp.search(typ) is None:
420420
continue
421421
if isinstance(valuetype, _evaluatable):
@@ -455,7 +455,7 @@ def _get_name_(self, name: Union[str, RegExp]) -> Tuple[str, Optional[str]]:
455455
the type hint string),
456456
"""
457457
search = str(name)
458-
m = self.__regexGetType.search(search)
458+
m = self._regex_get_type.search(search)
459459
if m is not None:
460460
return m.group(1), m.group(2)
461461
if not isinstance(name, string_types + int_types):

Stoner/folders/methods.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def add_group(fldr, key):
8484
return fldr
8585

8686

87-
def all(fldr):
87+
def all(fldr): # pylint: disable=redefined-builtin
8888
"""Iterate over all the files in the Folder and all it's sub Folders recursely.
8989
9090
Args:
@@ -224,9 +224,9 @@ def file(fldr, name, value, create=True, pathsplit=None):
224224
return tmp
225225

226226

227-
def filter(
227+
def filter( # pylint: disable=redefined-builtin
228228
fldr, filter=None, invert=False, copy=False, recurse=False, prune=True
229-
): # pylint: disable=redefined-builtin
229+
):
230230
r"""Filter the current set of files by some criterion.
231231
232232
Args:

Stoner/tools/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def file_dialog(mode: str, filename: Filename, filetype: str) -> Union[pathlib.P
152152
mode = "SaveFile"
153153
else:
154154
mode = "SelectDirectory"
155-
filename = fileDialog.openDialog(start=dirname, mode=mode, patterns=patterns)
155+
filename = fileDialog.open_dialog(start=dirname, mode=mode, patterns=patterns)
156156
return filename if filename else None
157157

158158

Stoner/tools/formatting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,4 +339,4 @@ def ordinal(value: int) -> str:
339339
else:
340340
suffix = ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"][last_digit]
341341

342-
return "{}{}".format(value, suffix)
342+
return f"{value}{suffix}"

Stoner/tools/widgets.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
if QT_VERSION is None:
3232

3333
class App:
34-
"""Mock App that raises an error when you try to call openDialog on it."""
34+
"""Mock App that raises an error when you try to call open_dialog on it."""
3535

3636
modes: Dict = {}
3737

38-
def openDialog(
38+
def open_dialog(
3939
self,
4040
title: Optional[str] = None,
4141
start: Union[str, pathlib.Path] = "",
@@ -80,9 +80,9 @@ def __init__(self, *args: Any, **kargs: Any) -> None:
8080
self.top = 10
8181
self.width = 640
8282
self.height = 480
83-
self.initUI()
83+
self.init_ui()
8484

85-
def initUI(self) -> None:
85+
def init_ui(self) -> None:
8686
"""Initialise the UI and set the dialog box geometry."""
8787
self.dialog = QWidget()
8888
self.dialog.title = "PyQt5 file dialogs - pythonspot.com"
@@ -94,7 +94,7 @@ def initUI(self) -> None:
9494
self.dialog.setWindowTitle(self.title)
9595
self.dialog.setGeometry(self.left, self.top, self.width, self.height)
9696

97-
def openDialog(
97+
def open_dialog(
9898
self,
9999
title: Optional[str] = None,
100100
start: Union[str, pathlib.Path] = "",

doc/samples/Fitting/Quadratic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
d.text(
2424
-9,
2525
450,
26-
"Polynominal co-efficients\n{}".format(d["2nd-order polyfit coefficients"]),
26+
"Polynominal co-efficients\n{d['2nd-order polyfit coefficients']}",
2727
fontdict={"size": "x-small", "color": "magenta"},
2828
)
2929

scripts/VSManalysis_v2.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def editData(Data, operations):
185185
for item in filenames:
186186
print(i, ". ", item)
187187
i += 1
188-
fCounter = int(
188+
f_counter = int(
189189
input(
190190
"Enter the number of the file you wish to start at (program will cycle through files from that point.):\n"
191191
)
@@ -196,8 +196,8 @@ def editData(Data, operations):
196196
timeout = 0
197197
# Main program loop, cycle through selected files
198198
while True:
199-
path = filenames[fCounter]
200-
fCounter += 1
199+
path = filenames[f_counter]
200+
f_counter += 1
201201
with open(path, "r", encoding="utf-8") as fr:
202202
data = fr.readlines() # Get the file into an array
203203
pathsplit = splitFileName(path)
@@ -246,21 +246,21 @@ def editData(Data, operations):
246246
t = Data.clone # edit a copied array.
247247
t = editData(t, operations)
248248
plotmH(t)
249-
whatNext = input(
249+
what_next = input(
250250
"Press enter to save changes, r to restart or q to quit the program: "
251251
)
252-
if whatNext == "r":
252+
if what_next == "r":
253253
continue
254-
if whatNext == "q":
254+
if what_next == "q":
255255
break
256256
Data = t
257257
Data.save(
258258
"EditedFiles/" + pathsplit[0] + "_edit.txt"
259259
) # overwrite the file created earlier
260260
break
261261
if (
262-
whatNext == "q"
263-
or input(f"Press enter to do file {filenames[fCounter]} or q to quit:")
262+
what_next == "q"
263+
or input(f"Press enter to do file {filenames[f_counter]} or q to quit:")
264264
== "q"
265265
):
266266
break

tests/Stoner/tools/test_widgets.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ def dummy(mode="getOpenFileName"):
6060
app = getattr(widgets, "App")
6161
setattr(app, "modes", modes)
6262

63-
assert widgets.fileDialog.openDialog() == ret_pth
64-
assert widgets.fileDialog.openDialog(title="Test", start=".") == ret_pth
65-
assert widgets.fileDialog.openDialog(patterns={"*.bad": "Very bad files"}) == ret_pth
66-
assert widgets.fileDialog.openDialog(mode="OpenFiles") == [ret_pth]
67-
assert widgets.fileDialog.openDialog(mode="SaveFile") is None
68-
assert widgets.fileDialog.openDialog(mode="SelectDirectory") == ret_pth.parent
63+
assert widgets.fileDialog.open_dialog() == ret_pth
64+
assert widgets.fileDialog.open_dialog(title="Test", start=".") == ret_pth
65+
assert widgets.fileDialog.open_dialog(patterns={"*.bad": "Very bad files"}) == ret_pth
66+
assert widgets.fileDialog.open_dialog(mode="OpenFiles") == [ret_pth]
67+
assert widgets.fileDialog.open_dialog(mode="SaveFile") is None
68+
assert widgets.fileDialog.open_dialog(mode="SelectDirectory") == ret_pth.parent
6969
with pytest.raises(ValueError):
70-
widgets.fileDialog.openDialog(mode="Whateve")
70+
widgets.fileDialog.open_dialog(mode="Whateve")
7171

7272

7373
def test_loader():

0 commit comments

Comments
 (0)