import tempfile
import threading
from os.path import join
-import logging
from datetime import datetime
from lxml import etree
-import tools, pooler
+import tools
import netsvc
from tools.misc import UpdateableStr
# find current DB based on thread/worker db name (see netsvc)
db_name = getattr(threading.currentThread(), 'dbname', None)
if db_name:
- dbname = getattr(threading.currentThread(), 'dbname')
- return pooler.get_db_only(dbname)
+ return pooler.get_db_only(db_name)
def _get_cr(self, frame):
is_new_cr = False
logger.debug('no translation language detected, skipping translation for "%r" ', source)
except Exception:
logger.debug('translation went wrong for "%r", skipped', source)
+ # if so, double-check the root/base translations filenames
finally:
if cr and is_new_cr:
cr.close()
self.logger = logging.getLogger('i18n')
self.buffer = buffer
- def warn(self, msg):
- self.logger.warning(msg)
+ def warn(self, msg, *args):
+ self.logger.warning(msg, *args)
def __iter__(self):
self.buffer.seek(0)
path_list = apaths
else :
path_list = [root_path,] + apaths
+
+ # Also scan these non-addon paths
+ for bin_path in ['osv', 'report' ]:
+ path_list.append(os.path.join(tools.config['root_path'], bin_path))
logger.debug("Scanning modules at paths: ", path_list)
if module in installed_modules:
frelativepath = str("addons" + frelativepath)
ite = re_dquotes.finditer(code_string)
+ code_offset = 0
+ code_line = 1
for i in ite:
src = i.group(1)
if src.startswith('""'):
src = src[2:-2]
else:
src = join_dquotes.sub(r'\1', src)
+ # try to count the lines from the last pos to our place:
+ code_line += code_string[code_offset:i.start(1)].count('\n')
# now, since we did a binary read of a python source file, we
# have to expand pythonic escapes like the interpreter does.
src = src.decode('string_escape')
- push_translation(module, terms_type, frelativepath, 0, encode(src))
+ push_translation(module, terms_type, frelativepath, code_line, encode(src))
+ code_line += i.group(1).count('\n')
+ code_offset = i.end() # we have counted newlines up to the match end
+
ite = re_quotes.finditer(code_string)
+ code_offset = 0 #reset counters
+ code_line = 1
for i in ite:
src = i.group(1)
if src.startswith("''"):
src = src[2:-2]
else:
src = join_quotes.sub(r'\1', src)
+ code_line += code_string[code_offset:i.start(1)].count('\n')
src = src.decode('string_escape')
- push_translation(module, terms_type, frelativepath, 0, encode(src))
+ push_translation(module, terms_type, frelativepath, code_line, encode(src))
+ code_line += i.group(1).count('\n')
+ code_offset = i.end() # we have counted newlines up to the match end
for path in path_list:
logger.debug("Scanning files of modules at %s", path)