From 0fce9c8a4075f2daaeb3716224eaf95fdc304259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 31 Jan 2014 00:05:43 +0100 Subject: [PATCH] Drop support of Python 2.6 review2681004 --- CHANGELOG | 1 + doc/installation.rst | 3 +- setup.py | 7 +-- tryton/common/domain_parser.py | 8 +--- tryton/gui/window/view_form/model/group.py | 5 +- tryton/gui/window/view_form/screen/screen.py | 7 +-- .../window/view_form/view/screen_container.py | 5 -- tryton/jsonrpc.py | 47 ------------------- 8 files changed, 8 insertions(+), 75 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f78ccaa3ed..3da49bbbb6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Drop support of Python 2.6 * Allow to search on rec_name of Reference fields * Use local timezone * Sanitize report file extension diff --git a/doc/installation.rst b/doc/installation.rst index 025455ecab..36b04cf412 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -4,11 +4,10 @@ Installing tryton Prerequisites ------------- - * Python 2.6 or later (http://www.python.org/) + * Python 2.7 or later (http://www.python.org/) * pygtk 2.22 or later (http://www.pygtk.org/) * librsvg (http://librsvg.sourceforge.net/) * python-dateutil (http://labix.org/python-dateutil) - * weakrefset for Python 2.6 (https://code.google.com/p/weakrefset/) * Optional: simplejson (http://undefined.org/python/#simplejson) * Optional: cdecimal (http://www.bytereef.org/mpdecimal/index.html) * Optional: GooCalendar (http://code.google.com/p/goocalendar/) diff --git a/setup.py b/setup.py index 90cfd82d78..922907cbe9 100644 --- a/setup.py +++ b/setup.py @@ -120,10 +120,6 @@ elif sys.platform == 'darwin': execfile(os.path.join('tryton', 'version.py')) -WEAKREF = [] -if sys.version_info < (2, 7): - WEAKREF = ['weakrefset'] - dist = setup(name=PACKAGE, version=VERSION, description='Tryton client', @@ -154,7 +150,6 @@ dist = setup(name=PACKAGE, 'Natural Language :: Slovenian', 'Natural Language :: Japanese', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Topic :: Office/Business', ], @@ -162,7 +157,7 @@ dist = setup(name=PACKAGE, install_requires=[ #"pygtk >= 2.6", "python-dateutil", - ] + WEAKREF, + ], extras_require={ 'simplejson': ['simplejson'], 'cdecimal': ['cdecimal'], diff --git a/tryton/common/domain_parser.py b/tryton/common/domain_parser.py index 65608172a3..bc9be0aa57 100644 --- a/tryton/common/domain_parser.py +++ b/tryton/common/domain_parser.py @@ -9,7 +9,7 @@ from decimal import Decimal import datetime import time import io -import collections +from collections import OrderedDict from tryton.translate import date_format from tryton.common import untimezoned_date, datetime_strftime @@ -774,11 +774,7 @@ class DomainParser(object): "A parser for domain" def __init__(self, fields): - if hasattr(collections, 'OrderedDict'): - odict = collections.OrderedDict - else: - odict = dict - self.fields = odict((name, f) + self.fields = OrderedDict((name, f) for name, f in fields.iteritems() if f.get('searchable', True)) self.strings = dict((f['string'].lower(), f) diff --git a/tryton/gui/window/view_form/model/group.py b/tryton/gui/window/view_form/model/group.py index 145e9f94b1..4c1a29bd32 100644 --- a/tryton/gui/window/view_form/model/group.py +++ b/tryton/gui/window/view_form/model/group.py @@ -1,9 +1,6 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. -try: - from weakref import WeakSet -except ImportError: - from weakrefset import WeakSet +from weakref import WeakSet from record import Record from field import Field, O2MField diff --git a/tryton/gui/window/view_form/screen/screen.py b/tryton/gui/window/view_form/screen/screen.py index 781a501629..0e8f0ed02b 100644 --- a/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/gui/window/view_form/screen/screen.py @@ -126,11 +126,8 @@ class Screen(SignalEvent): xml_fields = [node_attributes(node).get('name') for node in root_node.childNodes if node.nodeName == 'field'] - if hasattr(collections, 'OrderedDict'): - odict = collections.OrderedDict - else: - odict = dict - fields = odict((name, fields[name]) for name in xml_fields) + fields = collections.OrderedDict( + (name, fields[name]) for name in xml_fields) for name, string, type_ in ( ('id', _('ID'), 'integer'), ('create_uid', _('Creation User'), 'many2one'), diff --git a/tryton/gui/window/view_form/view/screen_container.py b/tryton/gui/window/view_form/view/screen_container.py index ca5d47763d..6bd6042c0b 100644 --- a/tryton/gui/window/view_form/view/screen_container.py +++ b/tryton/gui/window/view_form/view/screen_container.py @@ -4,7 +4,6 @@ import gtk import gettext import operator import gobject -import collections import tryton.common as common from tryton.common.domain_parser import quote @@ -434,10 +433,6 @@ class ScreenContainer(object): vbox = gtk.VBox() fields = [f for f in self.screen.domain_parser.fields.itervalues() if f.get('searchable', True)] - if (not hasattr(collections, 'OrderedDict') - or not isinstance(self.screen.domain_parser.fields, - collections.OrderedDict)): - fields.sort(key=operator.itemgetter('string')) self.search_table = gtk.Table(rows=len(fields), columns=2) self.search_table.set_homogeneous(False) self.search_table.set_border_width(5) diff --git a/tryton/jsonrpc.py b/tryton/jsonrpc.py index 5bbe927233..ea414b59f1 100644 --- a/tryton/jsonrpc.py +++ b/tryton/jsonrpc.py @@ -13,7 +13,6 @@ import socket import gzip import StringIO import hashlib -import sys import base64 __all__ = ["ResponseError", "Fault", "ProtocolError", "Transport", @@ -228,52 +227,6 @@ class Transport(xmlrpclib.Transport, xmlrpclib.SafeTransport): self._connection[1].sock.settimeout(DEFAULT_TIMEOUT) return self._connection[1] - if sys.version_info[:2] <= (2, 6): - - def request(self, host, handler, request_body, verbose=0): - h = self.make_connection(host) - if verbose: - h.set_debuglevel(1) - - self.send_request(h, handler, request_body) - self.send_host(h, host) - self.send_user_agent(h) - self.send_content(h, request_body) - - response = h.getresponse() - - if response.status != 200: - raise ProtocolError( - host + handler, - response.status, - response.reason, - response.getheaders() - ) - - self.verbose = verbose - - try: - sock = h._conn.sock - except AttributeError: - sock = None - - if response.getheader("Content-Encoding", "") == "gzip": - response = gzip.GzipFile(mode="rb", - fileobj=StringIO.StringIO(response.read())) - sock = None - - return self._parse_response(response, sock) - - def send_request(self, connection, handler, request_body): - xmlrpclib.Transport.send_request(self, connection, handler, - request_body) - connection.putheader("Accept-Encoding", "gzip") - - def close(self): - if self._connection[1]: - self._connection[1].close() - self._connection = (None, None) - class ServerProxy(xmlrpclib.ServerProxy): __id = 0