#8 unicode issues with file*box

v 0.97
fixed
Robert Lugg
5
2015-02-05
2012-03-25
Stephen Ferg
No

PATCH CODE
=== ver�ndert Datei easygui.py
--- easygui.py 2012-01-24 14:35:01 +0000
+++ easygui.py 2012-01-24 14:35:05 +0000
@@ -1489,10 +1489,10 @@

self.masks = []

- if type(filemask) == type("abc"): # a string
+ if isinstance(filemask, (str, unicode)): # a string (or unicode)
self.initializeFromString(filemask)

- elif type(filemask) == type([]): # a list
+ elif isinstance(filemask, list): # a list
if len(filemask) < 2:
raise AssertionError('Invalid filemask.\n'
+'List contains less than 2 members: "%s"' % filemask)
@@ -1503,7 +1503,7 @@
raise AssertionError('Invalid filemask: "%s"' % filemask)

def __eq__(self,other):
- if self.name == other.name: return True
+ if set(self.masks).issubset(other.masks): return True
return False

def add(self,other):
@@ -1512,10 +1512,10 @@
else: self.masks.append(mask)

def toTuple(self):
- return (self.name,tuple(self.masks))
+ return (self.name, tuple(self.masks))

def isAll(self):
- if self.name == "All files": return True
+ if "*.*" in self.masks: return True
return False

def initializeFromString(self, filemask):
@@ -1692,10 +1692,10 @@
if fto.isAll():
ALL_filetypes_was_specified = True # remember this

- if fto == initialFileTypeObject:
- initialFileTypeObject.add(fto) # add fto to initialFileTypeObject
- else:
- filetypeObjects.append(fto)
+## if fto == initialFileTypeObject:
+## initialFileTypeObject.add(fto) # add fto to initialFileTypeObject
+## else:
+ filetypeObjects.append(fto)

#------------------------------------------------------------------
# make sure that the list of filetypes includes the ALL FILES type.

[message from Johannes Haberl via ferg.org contact page]

Discussion

  • Stephen Ferg
    Stephen Ferg
    2012-03-25

    • status: open --> open-accepted
     
  • Robert Lugg
    Robert Lugg
    2014-11-16

    Thank you Johannas. I've modified the string check to isinstance(filemask, basestring) which should be equivalent to your change (http://stackoverflow.com/questions/1979004/what-is-the-difference-between-isinstanceaaa-basestring-and-isinstanceaaa).
    I haven't addressed the other changes in your diff but will try to and add them to a 0.97 release. Please feel free to offer additional changes. I have a GitHub of the working code. Since it is likely temporary, feel free to contact us if you want a preview. I would really appreciate that!

     
  • Robert Lugg
    Robert Lugg
    2014-11-18

    • Owner: Stephen Ferg --> Robert Lugg
    • Group: --> v 0.97
     
  • Robert Lugg
    Robert Lugg
    2015-02-05

    • status: open-accepted --> fixed