correct pyflake errors

review164003
This commit is contained in:
Nicolas Évrard committed 2011-11-02 15:49:38 +01:00
1 parent b913444fab
commit 0a471486e0
35 files changed
+14 -81

No files matched your search

+2 -2
View File
@@ -12,8 +12,8 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
#
# import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
-1
View File
@@ -4,7 +4,6 @@
from setuptools import setup, find_packages
import os
import sys
execfile(os.path.join('trytond', 'version.py'))
-1
View File
@@ -170,7 +170,6 @@ class Database(DatabaseInterface):
for i in ('ir', 'workflow', 'res', 'webdav'):
root_path = os.path.join(os.path.dirname(__file__), '..', '..')
tryton_file = os.path.join(root_path, i, '__tryton__.py')
mod_path = os.path.join(root_path, i)
with open(tryton_file) as fp:
info = safe_eval(fp.read())
active = info.get('active', False)
-1
View File
@@ -235,7 +235,6 @@ class Database(DatabaseInterface):
for i in ('ir', 'workflow', 'res', 'webdav'):
root_path = os.path.join(os.path.dirname(__file__), '..', '..')
tryton_file = os.path.join(root_path, i, '__tryton__.py')
mod_path = os.path.join(root_path, i)
with open(tryton_file) as fp:
info = safe_eval(fp.read())
active = info.get('active', False)
-1
View File
@@ -220,7 +220,6 @@ class Database(DatabaseInterface):
for i in ('ir', 'workflow', 'res', 'webdav'):
root_path = os.path.join(os.path.dirname(__file__), '..', '..')
tryton_file = os.path.join(root_path, i, '__tryton__.py')
mod_path = os.path.join(root_path, i)
with open(tryton_file) as fp:
info = safe_eval(fp.read())
active = info.get('active', False)
-1
View File
@@ -7,7 +7,6 @@ from trytond.tools import file_open, safe_eval
from trytond.backend import TableHandler
from trytond.pyson import PYSONEncoder, CONTEXT, PYSON
from trytond.transaction import Transaction
from trytond.cache import Cache
from trytond.pool import Pool
from trytond.exceptions import UserError
+2 -3
View File
@@ -6,7 +6,6 @@ from dateutil.relativedelta import relativedelta
import traceback
import sys
import logging
from trytond.backend import Database
from trytond.model import ModelView, ModelSQL, fields
from trytond.tools import safe_eval
from trytond.transaction import Transaction
@@ -136,7 +135,7 @@ class Cron(ModelSQL, ModelView):
model_obj = pool.get(cron.model)
with Transaction().set_user(cron.user.id):
getattr(model_obj, cron.function)(*args)
except Exception, error:
except Exception:
Transaction().cursor.rollback()
request_obj = pool.get('res.request')
@@ -146,7 +145,7 @@ class Cron(ModelSQL, ModelView):
with contextlib.nested(Transaction().set_user(cron.user.id),
Transaction().set_context(language=language)):
values = self._get_request_values(cron)
rid = request_obj.create(values)
request_obj.create(values)
Transaction().cursor.commit()
def run(self, db_name):
-4
View File
@@ -1,6 +1,5 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import time
import datetime
import warnings
@@ -203,9 +202,6 @@ class Lang(ModelSQL, ModelView, Cacheable):
grouping = safe_eval(lang['grouping'])
if not grouping:
return (s, 0)
result = ""
seps = 0
spaces = ""
if s[-1] == ' ':
stripped = s.rstrip()
right_spaces = s[len(stripped):]
+1 -8
View File
@@ -3,9 +3,8 @@
import os
from trytond.model import ModelView, ModelSQL, fields
import trytond.tools as tools
from trytond.modules import MODULES_PATH, create_graph, get_module_list
from trytond.modules import create_graph, get_module_list
from trytond.wizard import Wizard
from trytond.backend import Database
from trytond.pool import Pool
from trytond.transaction import Transaction
@@ -281,12 +280,6 @@ class Module(ModelSQL, ModelView):
self._update_dependencies(mod, tryton.get('depends', []))
continue
if name in ['ir', 'workflow', 'res', 'webdav']:
mod_path = os.path.join(
os.path.dirname(MODULES_PATH), name)
else:
mod_path = os.path.join(MODULES_PATH, name)
tryton = Module.get_module_info(mod_name)
if not tryton:
continue
-5
View File
@@ -45,11 +45,6 @@ class Property(ModelSQL, ModelView):
if res_ids is None:
res_ids = []
model_obj = pool.get(model)
fields = dict((name, field)
for name, field in model_obj._columns.iteritems()
if name in names)
property_ids = self.search([
('field.name', 'in', names),
['OR',
-2
View File
@@ -1,7 +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.
from string import Template
import datetime
import time
from trytond.model import ModelView, ModelSQL, fields
from trytond.tools import datetime_strftime
@@ -148,7 +147,6 @@ class Sequence(ModelSQL, ModelView):
return result
def set_number_next(self, ids, name, value):
cursor = Transaction().cursor
super(Sequence, self).write(ids, {
'number_next_internal': value,
})
-3
View File
@@ -7,9 +7,7 @@ except ImportError:
import StringIO
import zipfile
import polib
import operator
from xml import dom
from xml.dom import minidom
from difflib import SequenceMatcher
import os
try:
@@ -20,7 +18,6 @@ from functools import reduce
from trytond.model import ModelView, ModelSQL, fields
from trytond.model.cacheable import Cacheable
from trytond.wizard import Wizard
from trytond import tools
from trytond.tools import file_open, reduce_ids
from trytond.backend import TableHandler, FIELDS
from trytond.pyson import PYSONEncoder
-2
View File
@@ -137,8 +137,6 @@ class Trigger(ModelSQL, ModelView):
:param record: a BrowseRecord of the tested model
:return: a boolean
"""
pool = Pool()
model_obj = pool.get(trigger.model.model)
env = {}
env['current_date'] = datetime.datetime.today()
env['time'] = time
+1 -3
View File
@@ -6,7 +6,7 @@ from lxml import etree
from difflib import SequenceMatcher
from trytond.model import ModelView, ModelSQL, fields
from trytond.backend import TableHandler
from trytond.pyson import PYSONEncoder, CONTEXT, Eval
from trytond.pyson import CONTEXT, Eval
from trytond.tools import safe_eval
from trytond.transaction import Transaction
from trytond.wizard import Wizard
@@ -267,10 +267,8 @@ class ShowView(Wizard):
view_obj = pool.get('ir.ui.view')
result = super(ShowView, self).execute(wiz_id, data, state=state)
view = view_obj.browse(data['id'])
view_id = view.id
view_type = view.type
if view.inherit:
view_id = view.inherit.id
view_type = view.inherit.type
if view_type != 'form':
self.raise_user_error('view_type')
-3
View File
@@ -4,9 +4,6 @@
import inspect
import copy
from trytond.model.fields.field import Field
from trytond.model.fields.float import digits_validate
from trytond.model.fields.one2many import add_remove_validate
from trytond.pyson import PYSON
class Function(Field):
-1
View File
@@ -2,7 +2,6 @@
#this repository contains the full copyright notices and license terms.
from trytond.model.fields.many2many import Many2Many
from trytond.transaction import Transaction
from trytond.pool import Pool
+1 -2
View File
@@ -9,7 +9,7 @@ from itertools import islice
from trytond.model import ModelStorage
from trytond.model import fields
from trytond.backend import FIELDS, TableHandler
from trytond.backend import DatabaseIntegrityError, Database
from trytond.backend import DatabaseIntegrityError
from trytond.tools import reduce_ids
from trytond.const import OPERATORS, RECORD_CACHE_SIZE
from trytond.transaction import Transaction
@@ -1306,7 +1306,6 @@ class ModelSQL(ModelStorage):
return qu1, qu2, tables, tables_args
def __search_domain_oper(self, domain, tables, tables_args):
pool = Pool()
operator = 'AND'
if len(domain) and isinstance(domain[0], basestring):
if domain[0] not in ('AND', 'OR'):
+1 -4
View File
@@ -1,14 +1,12 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import os, sys, imp
import os, sys
import itertools
import traceback
import logging
import contextlib
from functools import reduce
import imp
import operator
from trytond.backend import Database
import trytond.tools as tools
from trytond.config import CONFIG
from trytond.transaction import Transaction
@@ -216,7 +214,6 @@ def load_module_graph(graph, pool, lang=None):
sys.stdout.flush()
objects = pool.instanciate(module)
package_state = module2state.get(module, 'uninstalled')
idref = {}
if hasattr(package, 'init') \
or hasattr(package, 'update') \
or (package_state in ('to install', 'to upgrade')):
-1
View File
@@ -4,7 +4,6 @@ import errno
import os
import socket
import threading
import select
import sys
import gzip
try:
-1
View File
@@ -3,7 +3,6 @@
from trytond.protocols.sslsocket import SSLSocket
from trytond.protocols.dispatcher import dispatch
from trytond.config import CONFIG
from trytond.protocols.datatype import Float
from trytond.protocols.common import daemon, GZipRequestHandlerMixin
from trytond.exceptions import UserError, UserWarning, NotLogged, \
ConcurrencyException
-1
View File
@@ -2,7 +2,6 @@
#this repository contains the full copyright notices and license terms.
import SocketServer
import socket
import os
import BaseHTTPServer
import urlparse
import time
-1
View File
@@ -14,7 +14,6 @@ import xmlrpclib
import traceback
import socket
import sys
import os
import base64
import datetime
from types import DictType
-1
View File
@@ -1,6 +1,5 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import sys
try:
import simplejson as json
except ImportError:
-3
View File
@@ -1,8 +1,5 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import copy
import xml
import sys
try:
import cStringIO as StringIO
except ImportError:
-1
View File
@@ -1,6 +1,5 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import time
import datetime
from trytond.model import ModelView, ModelSQL, fields
from trytond.pyson import Eval, If
-1
View File
@@ -1,6 +1,5 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.backend import Database
from trytond.session import Session
from trytond.pool import Pool
from trytond.config import CONFIG
+2 -2
View File
@@ -196,7 +196,7 @@ class ModelAccessTestCase(unittest.TestCase):
model_id, = self.model.search([('model', '=', 'test.access')])
# Without model access
test_id = self.test_access.create({})
self.test_access.create({})
# With model access
@@ -277,7 +277,7 @@ class ModelAccessTestCase(unittest.TestCase):
test_ids = [self.test_access.create({}) for x in range(11)]
# Without model access
test_id = self.test_access.delete(test_ids.pop())
self.test_access.delete(test_ids.pop())
# With model access
+2 -2
View File
@@ -300,14 +300,14 @@ class ExportDataTestCase(unittest.TestCase):
'''
with Transaction().start(DB_NAME, USER, CONTEXT) as transaction:
export1_id = self.export_data.create({})
target1_id = self.export_data_target.create({
self.export_data_target.create({
'name': 'Target 1',
'one2many': export1_id,
})
self.assert_(self.export_data.export_data([export1_id],
['one2many/name']) == [['Target 1']])
target2_id = self.export_data_target.create({
self.export_data_target.create({
'name': 'Target 2',
'one2many': export1_id,
})
+1 -2
View File
@@ -102,7 +102,7 @@ class SequenceTestCase(unittest.TestCase):
'''
Test prefix/suffix
'''
with Transaction().start(DB_NAME, USER, CONTEXT) as transaction:
with Transaction().start(DB_NAME, USER, CONTEXT):
sequence_id = self.sequence.create({
'name': 'Test incremental',
'code': 'test',
@@ -117,7 +117,6 @@ class SequenceTestCase(unittest.TestCase):
'prefix': '${year}-${month}-${day}/',
'suffix': '/${day}.${month}.${year}',
})
context = CONTEXT.copy()
with Transaction().set_context(date=datetime.date(2010, 8, 15)):
self.assertEqual(self.sequence.get_id(sequence_id),
'2010-08-15/2/15.08.2010')
-5
View File
@@ -5,15 +5,10 @@
import unittest
import datetime
import socket
import urllib
from trytond.config import CONFIG
from trytond.tools import reduce_ids, safe_eval, datetime_strftime, \
reduce_domain
from trytond.tests.test_tryton import (POOL, DB_NAME, USER, CONTEXT,
install_module)
from trytond.transaction import Transaction
class ToolsTestCase(unittest.TestCase):
-1
View File
@@ -3,7 +3,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.
import unittest
import sys
import time
from xmlrpclib import MAXINT
try:
+1 -2
View File
@@ -14,7 +14,6 @@ import unittest
import doctest
from lxml import etree
import time
import imp
import optparse
_MODULES = False
@@ -201,7 +200,7 @@ def test_depends():
self.fields.add(fname)
return super(Encoder, self).default(obj)
with Transaction().start(DB_NAME, USER, CONTEXT) as transaction:
with Transaction().start(DB_NAME, USER, CONTEXT):
for mname, model in Pool().iterobject():
for fname, field in model._columns.iteritems():
encoder = Encoder()
-7
View File
@@ -8,10 +8,6 @@ import os, sys
import subprocess
from threading import local
import smtplib
try:
import cStringIO as StringIO
except ImportError:
import StringIO
import dis
from decimal import Decimal
from trytond.config import CONFIG
@@ -302,9 +298,6 @@ class LocalDict(local):
def __ge__(self, y):
return self._dict.__ge__(y)
def __getitem__(self, y):
return self._dict.__getitem__(y)
def __gt__(self, y):
return self._dict.__gt__(y)
-1
View File
@@ -3,7 +3,6 @@
import os
import time
from trytond.model import ModelView, ModelSQL, fields
from trytond.version import PACKAGE, VERSION, WEBSITE
from trytond.tools import reduce_ids, safe_eval
from trytond.transaction import Transaction
from trytond.pool import Pool
-2
View File
@@ -1,9 +1,7 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import os
from trytond.model import ModelView, ModelSQL, fields
from trytond.report import Report
from trytond.tools import exec_command_pipe
from trytond.backend import TableHandler
from trytond.pyson import Eval, Bool
from trytond.transaction import Transaction