Little cleanup
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import locale_functions
|
||||
import sys
|
||||
|
||||
|
||||
class MyForm(wx.Frame):
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------
|
||||
def __init__(self):
|
||||
wx.Frame.__init__(self, None, wx.ID_ANY, "Tutorial", size=(500,500))
|
||||
wx.Frame.__init__(self, None, wx.ID_ANY, "Tutorial", size=(500, 500))
|
||||
|
||||
# Add a panel so it looks the correct on all platforms
|
||||
panel = wx.Panel(self, wx.ID_ANY)
|
||||
@@ -18,12 +18,12 @@ class MyForm(wx.Frame):
|
||||
LOAD_FILE_ID = wx.NewId()
|
||||
self.Bind(wx.EVT_MENU, self.loadFile, id=LOAD_FILE_ID)
|
||||
|
||||
accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('O'), LOAD_FILE_ID ),
|
||||
(wx.ACCEL_CTRL, ord('S'), SAVE_FILE_ID )]
|
||||
accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('O'), LOAD_FILE_ID),
|
||||
(wx.ACCEL_CTRL, ord('S'), SAVE_FILE_ID)]
|
||||
)
|
||||
self.SetAcceleratorTable(accel_tbl)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------
|
||||
def loadFile(self, event):
|
||||
openFileDialog = wx.FileDialog(self, "Open", "", "",
|
||||
"Python files (*.py)|*.py",
|
||||
@@ -32,22 +32,22 @@ class MyForm(wx.Frame):
|
||||
path = openFileDialog.GetPath()
|
||||
try:
|
||||
os_walk_without_codec = locale_functions.GetPath(path)
|
||||
except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e:
|
||||
except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e:
|
||||
os_walk_without_codec = e
|
||||
|
||||
try:
|
||||
os_walk_with_system_codec = locale_functions.GetPath(path, None, sys.getdefaultencoding())
|
||||
except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e:
|
||||
except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e:
|
||||
os_walk_with_system_codec = e
|
||||
|
||||
try:
|
||||
os_walk_unicode_without_codec = locale_functions.GetUnicodePath(path)
|
||||
except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e:
|
||||
except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e:
|
||||
os_walk_unicode_without_codec = e
|
||||
|
||||
try:
|
||||
os_walk_unicode_with_system_codec = locale_functions.GetUnicodePath(path, None, sys.getdefaultencoding())
|
||||
except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e:
|
||||
except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e:
|
||||
os_walk_unicode_with_system_codec = e
|
||||
|
||||
print("Simple print:")
|
||||
@@ -69,7 +69,7 @@ class MyForm(wx.Frame):
|
||||
print(os_walk_unicode_with_system_codec)
|
||||
openFileDialog.Destroy()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------
|
||||
def saveFile(self, event):
|
||||
saveFileDialog = wx.FileDialog(self, "Save As", "", "",
|
||||
"Python files (*.py)|*.py",
|
||||
@@ -78,6 +78,7 @@ class MyForm(wx.Frame):
|
||||
saveFileDialog.GetPath()
|
||||
saveFileDialog.Destroy()
|
||||
|
||||
|
||||
# Run the program
|
||||
if __name__ == "__main__":
|
||||
app = wx.App(False)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import os
|
||||
import platform
|
||||
from tests.test_locale.locale_functions import GetPath
|
||||
|
||||
|
||||
def test_os_walk():
|
||||
os_name = platform.system()
|
||||
current_directory = os.path.dirname(os.path.abspath(unicode(__file__)))
|
||||
subfolders = os.listdir(current_directory)
|
||||
subfolders = [e for e in subfolders if not (e.endswith(".py") or e.endswith(".pyc") or e.endswith(".md"))]
|
||||
@@ -13,9 +12,11 @@ def test_os_walk():
|
||||
subdir = GetPath(current_directory, subfolder)
|
||||
testfile = GetPath(subdir, "testcodec")
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
with open(testfile, 'r') as f:
|
||||
read_data = f.read()
|
||||
# noinspection PyStatementEffect
|
||||
f.closed
|
||||
except:
|
||||
assert False, "Failed to read file."
|
||||
@@ -23,4 +24,4 @@ def test_os_walk():
|
||||
assert read_data == "True"
|
||||
subfolder_count += 1
|
||||
|
||||
assert len(subfolders) == subfolder_count
|
||||
assert len(subfolders) == subfolder_count
|
||||
|
||||
Reference in New Issue
Block a user