equal
deleted
inserted
replaced
424 |
424 |
425 def __str___(self): |
425 def __str___(self): |
426 return self.name |
426 return self.name |
427 |
427 |
428 |
428 |
429 def eq(a,b): |
429 def eq(a, b): |
430 JS(""" |
430 JS(""" |
431 if (pyjslib.hasattr(a, "__cmp__")) { |
431 if (pyjslib.hasattr(a, "__cmp__")) { |
432 return a.__cmp__(b) == 0; |
432 return a.__cmp__(b) == 0; |
433 } else if (pyjslib.hasattr(b, "__cmp__")) { |
433 } else if (pyjslib.hasattr(b, "__cmp__")) { |
434 return b.__cmp__(a) == 0; |
434 return b.__cmp__(a) == 0; |
435 } |
435 } |
436 return a == b; |
436 return a == b; |
437 """) |
437 """) |
438 |
438 |
439 |
439 |
440 def cmp(a,b): |
440 def cmp(a, b): |
441 if hasattr(a, "__cmp__"): |
441 if hasattr(a, "__cmp__"): |
442 return a.__cmp__(b) |
442 return a.__cmp__(b) |
443 elif hasattr(b, "__cmp__"): |
443 elif hasattr(b, "__cmp__"): |
444 return -b.__cmp__(a) |
444 return -b.__cmp__(a) |
445 if a > b: |
445 if a > b: |
593 def sort(self, compareFunc=None, keyFunc=None, reverse=False): |
593 def sort(self, compareFunc=None, keyFunc=None, reverse=False): |
594 if not compareFunc: |
594 if not compareFunc: |
595 global cmp |
595 global cmp |
596 compareFunc = cmp |
596 compareFunc = cmp |
597 if keyFunc and reverse: |
597 if keyFunc and reverse: |
598 def thisSort1(a,b): |
598 def thisSort1(a, b): |
599 return -compareFunc(keyFunc(a), keyFunc(b)) |
599 return -compareFunc(keyFunc(a), keyFunc(b)) |
600 self.l.sort(thisSort1) |
600 self.l.sort(thisSort1) |
601 elif keyFunc: |
601 elif keyFunc: |
602 def thisSort2(a,b): |
602 def thisSort2(a, b): |
603 return compareFunc(keyFunc(a), keyFunc(b)) |
603 return compareFunc(keyFunc(a), keyFunc(b)) |
604 self.l.sort(thisSort2) |
604 self.l.sort(thisSort2) |
605 elif reverse: |
605 elif reverse: |
606 def thisSort3(a,b): |
606 def thisSort3(a, b): |
607 return -compareFunc(a, b) |
607 return -compareFunc(a, b) |
608 self.l.sort(thisSort3) |
608 self.l.sort(thisSort3) |
609 else: |
609 else: |
610 self.l.sort(compareFunc) |
610 self.l.sort(compareFunc) |
611 |
611 |
743 def sort(self, compareFunc=None, keyFunc=None, reverse=False): |
743 def sort(self, compareFunc=None, keyFunc=None, reverse=False): |
744 if not compareFunc: |
744 if not compareFunc: |
745 global cmp |
745 global cmp |
746 compareFunc = cmp |
746 compareFunc = cmp |
747 if keyFunc and reverse: |
747 if keyFunc and reverse: |
748 def thisSort1(a,b): |
748 def thisSort1(a, b): |
749 return -compareFunc(keyFunc(a), keyFunc(b)) |
749 return -compareFunc(keyFunc(a), keyFunc(b)) |
750 self.l.sort(thisSort1) |
750 self.l.sort(thisSort1) |
751 elif keyFunc: |
751 elif keyFunc: |
752 def thisSort2(a,b): |
752 def thisSort2(a, b): |
753 return compareFunc(keyFunc(a), keyFunc(b)) |
753 return compareFunc(keyFunc(a), keyFunc(b)) |
754 self.l.sort(thisSort2) |
754 self.l.sort(thisSort2) |
755 elif reverse: |
755 elif reverse: |
756 def thisSort3(a,b): |
756 def thisSort3(a, b): |
757 return -compareFunc(a, b) |
757 return -compareFunc(a, b) |
758 self.l.sort(thisSort3) |
758 self.l.sort(thisSort3) |
759 else: |
759 else: |
760 self.l.sort(compareFunc) |
760 self.l.sort(compareFunc) |
761 |
761 |
895 if not self.has_key(key): |
895 if not self.has_key(key): |
896 return default_ |
896 return default_ |
897 return self[key] |
897 return self[key] |
898 |
898 |
899 def update(self, d): |
899 def update(self, d): |
900 for k,v in d.iteritems(): |
900 for k, v in d.iteritems(): |
901 self[k] = v |
901 self[k] = v |
902 |
902 |
903 def getObject(self): |
903 def getObject(self): |
904 """ |
904 """ |
905 Return the javascript Object which this class uses to store |
905 Return the javascript Object which this class uses to store |