[devctl] make i18n custom message extractors work with legacy layouts
distname needs to be "cubicweb_<cubename>", even with legacy layouts
for pkg.load_entry_point() to work
closes #16272177
--- a/cubicweb/devtools/devctl.py Wed Nov 16 17:12:09 2016 +0100
+++ b/cubicweb/devtools/devctl.py Wed Nov 16 14:38:11 2016 +0100
@@ -569,8 +569,12 @@
cubedir = osp.abspath(osp.normpath(cubedir))
workdir = tempfile.mkdtemp()
try:
- distname = osp.basename(cubedir)
- cubename = distname.split('_')[-1]
+ cubename = osp.basename(cubedir)
+ if cubename.startswith('cubicweb_'): # new layout
+ distname = cubename
+ cubename = cubename[len('cubicweb_'):]
+ else:
+ distname = 'cubicweb_' + cubename
print('cubedir', cubedir)
extract_cls = I18nCubeMessageExtractor
try:
--- a/cubicweb/devtools/test/unittest_i18n.py Wed Nov 16 17:12:09 2016 +0100
+++ b/cubicweb/devtools/test/unittest_i18n.py Wed Nov 16 14:38:11 2016 +0100
@@ -136,11 +136,11 @@
@patch('pkg_resources.load_entry_point', return_value=FakeMessageExtractor)
def test_cube_custom_extractor(self, mock_load_entry_point):
- for distname, cubedir in [
- ('cubicweb_i18ntestcube',
- osp.join(DATADIR, 'libpython', 'cubicweb_i18ntestcube')),
+ distname = 'cubicweb_i18ntestcube' # same for new and legacy layout
+ for cubedir in [
+ osp.join(DATADIR, 'libpython', 'cubicweb_i18ntestcube'),
# Legacy cubes.
- ('i18ntestcube', osp.join(DATADIR, 'cubes', 'i18ntestcube')),
+ osp.join(DATADIR, 'cubes', 'i18ntestcube'),
]:
with self.subTest(cubedir=cubedir):
with capture_stdout() as stream: