author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Tue, 30 Nov 2010 15:05:07 +0100 | |
changeset 6712 | 3e6cd6048be8 |
parent 6481 | 103774c8c215 |
child 6750 | ef513c03a224 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5375
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5545
diff
changeset
|
18 |
"""additional cubicweb-ctl commands and command handlers for cubicweb and |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5545
diff
changeset
|
19 |
cubicweb's cubes development |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5545
diff
changeset
|
20 |
""" |
0 | 21 |
|
22 |
__docformat__ = "restructuredtext en" |
|
23 |
||
4718
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
24 |
# *ctl module should limit the number of import to be imported as quickly as |
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
25 |
# possible (for cubicweb-ctl reactivity, necessary for instance for usable bash |
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
26 |
# completion). So import locally in command helpers. |
0 | 27 |
import sys |
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
396
diff
changeset
|
28 |
from datetime import datetime |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
29 |
from os import mkdir, chdir, listdir, path as osp |
2551
91f579b7a1e1
[F bw compat] warn if entities.pot exists but consider it anyway
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2534
diff
changeset
|
30 |
from warnings import warn |
0 | 31 |
|
32 |
from logilab.common import STD_BLACKLIST |
|
4428
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
33 |
|
3978
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3858
diff
changeset
|
34 |
from cubicweb.__pkginfo__ import version as cubicwebversion |
2790
968108e16066
move underline_title to toolsutils
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2773
diff
changeset
|
35 |
from cubicweb import CW_SOFTWARE_ROOT as BASEDIR, BadCommandUsage |
6138
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
36 |
from cubicweb.cwctl import CWCTL |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
37 |
from cubicweb.toolsutils import (SKEL_EXCLUDE, Command, copy_skeleton, |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
38 |
underline_title) |
0 | 39 |
from cubicweb.web.webconfig import WebConfiguration |
40 |
from cubicweb.server.serverconfig import ServerConfiguration |
|
41 |
||
2790
968108e16066
move underline_title to toolsutils
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2773
diff
changeset
|
42 |
|
4479
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
43 |
class DevConfiguration(ServerConfiguration, WebConfiguration): |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
44 |
"""dummy config to get full library schema and appobjects for |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
45 |
a cube or for cubicweb (without a home) |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
46 |
""" |
0 | 47 |
creating = True |
4479
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
48 |
cleanup_interface_sobjects = False |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
49 |
|
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
50 |
cubicweb_appobject_path = (ServerConfiguration.cubicweb_appobject_path |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
51 |
| WebConfiguration.cubicweb_appobject_path) |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
52 |
cube_appobject_path = (ServerConfiguration.cube_appobject_path |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
53 |
| WebConfiguration.cube_appobject_path) |
373
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
54 |
|
4428
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
55 |
def __init__(self, *cubes): |
4479
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
56 |
super(DevConfiguration, self).__init__(cubes and cubes[0] or None) |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
57 |
if cubes: |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
58 |
self._cubes = self.reorder_cubes( |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
59 |
self.expand_cubes(cubes, with_recommends=True)) |
5534
b75aa6ce0c04
[i18ncube] we must load site_cubicweb file before calling set_schema, else we may miss some options or other initialization stuff necessary to appobject loading
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
60 |
self.load_site_cubicweb() |
4479
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
61 |
else: |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
62 |
self._cubes = () |
1451 | 63 |
|
0 | 64 |
@property |
65 |
def apphome(self): |
|
373
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
66 |
return None |
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
67 |
def main_config_file(self): |
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
68 |
return None |
5442
3ed8afbbdf70
[webconfig] refactor/cleanup debug mode management on startup: simply use config.debugmode instead of debug argument everywhere...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
69 |
def init_log(self): |
0 | 70 |
pass |
71 |
def load_configuration(self): |
|
72 |
pass |
|
373
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
73 |
def default_log_file(self): |
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
74 |
return None |
0 | 75 |
|
76 |
||
373
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
77 |
def cleanup_sys_modules(config): |
0 | 78 |
# cleanup sys.modules, required when we're updating multiple cubes |
79 |
for name, mod in sys.modules.items(): |
|
80 |
if mod is None: |
|
81 |
# duh ? logilab.common.os for instance |
|
82 |
del sys.modules[name] |
|
83 |
continue |
|
84 |
if not hasattr(mod, '__file__'): |
|
85 |
continue |
|
86 |
for path in config.vregistry_path(): |
|
87 |
if mod.__file__.startswith(path): |
|
88 |
del sys.modules[name] |
|
89 |
break |
|
1850
75661f0a691b
should be outside the loop
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1774
diff
changeset
|
90 |
# fresh rtags |
75661f0a691b
should be outside the loop
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1774
diff
changeset
|
91 |
from cubicweb import rtags |
75661f0a691b
should be outside the loop
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1774
diff
changeset
|
92 |
from cubicweb.web import uicfg |
75661f0a691b
should be outside the loop
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1774
diff
changeset
|
93 |
rtags.RTAGS[:] = [] |
75661f0a691b
should be outside the loop
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1774
diff
changeset
|
94 |
reload(uicfg) |
1451 | 95 |
|
373
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
96 |
def generate_schema_pot(w, cubedir=None): |
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
97 |
"""generate a pot file with schema specific i18n messages |
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
98 |
|
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
99 |
notice that relation definitions description and static vocabulary |
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
100 |
should be marked using '_' and extracted using xgettext |
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
101 |
""" |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2633
diff
changeset
|
102 |
from cubicweb.cwvreg import CubicWebVRegistry |
373
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
103 |
if cubedir: |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
104 |
cube = osp.split(cubedir)[-1] |
4479
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
105 |
config = DevConfiguration(cube) |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
106 |
depcubes = list(config._cubes) |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
107 |
depcubes.remove(cube) |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
108 |
libconfig = DevConfiguration(*depcubes) |
373
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
109 |
else: |
4479
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
110 |
config = DevConfiguration() |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
111 |
cube = libconfig = None |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
112 |
cleanup_sys_modules(config) |
1665 | 113 |
schema = config.load_schema(remove_unused_rtypes=False) |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2633
diff
changeset
|
114 |
vreg = CubicWebVRegistry(config) |
373
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
115 |
# set_schema triggers objects registrations |
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
116 |
vreg.set_schema(schema) |
0c931b2e2a68
fix i18n catalog generation
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
365
diff
changeset
|
117 |
w(DEFAULT_POT_HEAD) |
4722
9c13d5db03d9
pylint suggested refactorings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
118 |
_generate_schema_pot(w, vreg, schema, libconfig=libconfig) |
1451 | 119 |
|
120 |
||
4718
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
121 |
def _generate_schema_pot(w, vreg, schema, libconfig=None): |
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
122 |
from copy import deepcopy |
4021
280c910c8710
move i18n / migration modules from cw.common to cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3998
diff
changeset
|
123 |
from cubicweb.i18n import add_msg |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
124 |
from cubicweb.web import uicfg |
6481
103774c8c215
[schema categorization] new NO_I18NCONTEXT set usable to somewhat control c-c i18n
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6460
diff
changeset
|
125 |
from cubicweb.schema import NO_I18NCONTEXT, CONSTRAINTS |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
126 |
w('# schema pot file, generated on %s\n' |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
127 |
% datetime.now().strftime('%Y-%m-%d %H:%M:%S')) |
0 | 128 |
w('# \n') |
129 |
w('# singular and plural forms for each entity type\n') |
|
130 |
w('\n') |
|
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
131 |
vregdone = set() |
1470
fbdf66a08fbb
don't add to cube i18n catalog msg id for components redefined from cw or from a depending cube
sylvain.thenault@logilab.fr
parents:
1451
diff
changeset
|
132 |
if libconfig is not None: |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
133 |
from cubicweb.cwvreg import CubicWebVRegistry, clear_rtag_objects |
1665 | 134 |
libschema = libconfig.load_schema(remove_unused_rtypes=False) |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
135 |
afs = deepcopy(uicfg.autoform_section) |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
136 |
appearsin_addmenu = deepcopy(uicfg.actionbox_appearsin_addmenu) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
137 |
clear_rtag_objects() |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
138 |
cleanup_sys_modules(libconfig) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
139 |
libvreg = CubicWebVRegistry(libconfig) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
140 |
libvreg.set_schema(libschema) # trigger objects registration |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
141 |
libafs = uicfg.autoform_section |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
142 |
libappearsin_addmenu = uicfg.actionbox_appearsin_addmenu |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
143 |
# prefill vregdone set |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
144 |
list(_iter_vreg_objids(libvreg, vregdone)) |
0 | 145 |
else: |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
146 |
libschema = {} |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
147 |
afs = uicfg.autoform_section |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
148 |
appearsin_addmenu = uicfg.actionbox_appearsin_addmenu |
3978
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3858
diff
changeset
|
149 |
for cstrtype in CONSTRAINTS: |
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3858
diff
changeset
|
150 |
add_msg(w, cstrtype) |
0 | 151 |
done = set() |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
152 |
for eschema in sorted(schema.entities()): |
0 | 153 |
etype = eschema.type |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
154 |
if etype not in libschema: |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
155 |
add_msg(w, etype) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
156 |
add_msg(w, '%s_plural' % etype) |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3638
diff
changeset
|
157 |
if not eschema.final: |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
158 |
add_msg(w, 'This %s' % etype) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
159 |
add_msg(w, 'New %s' % etype) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
160 |
if eschema.description and not eschema.description in done: |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
161 |
done.add(eschema.description) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
162 |
add_msg(w, eschema.description) |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3638
diff
changeset
|
163 |
if eschema.final: |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
164 |
continue |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
165 |
for rschema, targetschemas, role in eschema.relation_definitions(True): |
4399
bc8d7ac70347
skip final relations at this point
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4380
diff
changeset
|
166 |
if rschema.final: |
bc8d7ac70347
skip final relations at this point
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4380
diff
changeset
|
167 |
continue |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
168 |
for tschema in targetschemas: |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
169 |
fsections = afs.etype_get(eschema, rschema, role, tschema) |
4400
4d36e0e93fdb
must check for relation inlined in main form type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4399
diff
changeset
|
170 |
if 'main_inlined' in fsections and \ |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
171 |
(libconfig is None or not |
4400
4d36e0e93fdb
must check for relation inlined in main form type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4399
diff
changeset
|
172 |
'main_inlined' in libafs.etype_get( |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
173 |
eschema, rschema, role, tschema)): |
3275
5247789df541
[gettext] provide GNU contexts to avoid translations ambiguities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3221
diff
changeset
|
174 |
add_msg(w, 'add a %s' % tschema, |
5247789df541
[gettext] provide GNU contexts to avoid translations ambiguities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3221
diff
changeset
|
175 |
'inlined:%s.%s.%s' % (etype, rschema, role)) |
4380
5613d7c06339
simplify messages used for inlined forms
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
176 |
add_msg(w, str(tschema), |
3327
44efba78afac
fix/enhance i18n context usage for inlined forms
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3287
diff
changeset
|
177 |
'inlined:%s.%s.%s' % (etype, rschema, role)) |
5431
84d8b4357528
fix i18ncube for pegase where we do strange things by redefining relations
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5424
diff
changeset
|
178 |
if appearsin_addmenu.etype_get(eschema, rschema, role, tschema): |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
179 |
if libconfig is not None and libappearsin_addmenu.etype_get( |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
180 |
eschema, rschema, role, tschema): |
5431
84d8b4357528
fix i18ncube for pegase where we do strange things by redefining relations
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5424
diff
changeset
|
181 |
if eschema in libschema and tschema in libschema: |
84d8b4357528
fix i18ncube for pegase where we do strange things by redefining relations
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5424
diff
changeset
|
182 |
continue |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
183 |
if role == 'subject': |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
184 |
label = 'add %s %s %s %s' % (eschema, rschema, |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
185 |
tschema, role) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
186 |
label2 = "creating %s (%s %%(linkto)s %s %s)" % ( |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
187 |
tschema, eschema, rschema, tschema) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
188 |
else: |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
189 |
label = 'add %s %s %s %s' % (tschema, rschema, |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
190 |
eschema, role) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
191 |
label2 = "creating %s (%s %s %s %%(linkto)s)" % ( |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
192 |
tschema, tschema, rschema, eschema) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
193 |
add_msg(w, label) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
194 |
add_msg(w, label2) |
3858
ba96e4607e67
add XX reminder
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
195 |
# XXX also generate "creating ...' messages for actions in the |
ba96e4607e67
add XX reminder
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
196 |
# addrelated submenu |
0 | 197 |
w('# subject and object forms for each relation type\n') |
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4439
diff
changeset
|
198 |
w('# (no object form for final or symmetric relation types)\n') |
0 | 199 |
w('\n') |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
200 |
for rschema in sorted(schema.relations()): |
0 | 201 |
rtype = rschema.type |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
202 |
if rtype not in libschema: |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
203 |
# bw compat, necessary until all translation of relation are done |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
204 |
# properly... |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
205 |
add_msg(w, rtype) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
206 |
if rschema.description and rschema.description not in done: |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
207 |
done.add(rschema.description) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
208 |
add_msg(w, rschema.description) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
209 |
done.add(rtype) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
210 |
librschema = None |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
211 |
else: |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
212 |
librschema = libschema.rschema(rtype) |
3281
bea1bde00fbc
[i18n] do not add context information for metadata relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3280
diff
changeset
|
213 |
# add context information only for non-metadata rtypes |
6481
103774c8c215
[schema categorization] new NO_I18NCONTEXT set usable to somewhat control c-c i18n
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6460
diff
changeset
|
214 |
if rschema not in NO_I18NCONTEXT: |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
215 |
libsubjects = librschema and librschema.subjects() or () |
3281
bea1bde00fbc
[i18n] do not add context information for metadata relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3280
diff
changeset
|
216 |
for subjschema in rschema.subjects(): |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
217 |
if not subjschema in libsubjects: |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
218 |
add_msg(w, rtype, subjschema.type) |
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4439
diff
changeset
|
219 |
if not (schema.rschema(rtype).final or rschema.symmetric): |
6481
103774c8c215
[schema categorization] new NO_I18NCONTEXT set usable to somewhat control c-c i18n
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6460
diff
changeset
|
220 |
if rschema not in NO_I18NCONTEXT: |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
221 |
libobjects = librschema and librschema.objects() or () |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
222 |
for objschema in rschema.objects(): |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
223 |
if not objschema in libobjects: |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
224 |
add_msg(w, '%s_object' % rtype, objschema.type) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
225 |
if rtype not in libschema: |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
226 |
# bw compat, necessary until all translation of relation are |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
227 |
# done properly... |
3285
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
228 |
add_msg(w, '%s_object' % rtype) |
fa3dc35b564f
fix .po generation: ensure we get all msgids when building a cube catalog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3281
diff
changeset
|
229 |
for objid in _iter_vreg_objids(vreg, vregdone): |
1470
fbdf66a08fbb
don't add to cube i18n catalog msg id for components redefined from cw or from a depending cube
sylvain.thenault@logilab.fr
parents:
1451
diff
changeset
|
230 |
add_msg(w, '%s_description' % objid) |
fbdf66a08fbb
don't add to cube i18n catalog msg id for components redefined from cw or from a depending cube
sylvain.thenault@logilab.fr
parents:
1451
diff
changeset
|
231 |
add_msg(w, objid) |
fbdf66a08fbb
don't add to cube i18n catalog msg id for components redefined from cw or from a depending cube
sylvain.thenault@logilab.fr
parents:
1451
diff
changeset
|
232 |
|
3293 | 233 |
|
4722
9c13d5db03d9
pylint suggested refactorings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
234 |
def _iter_vreg_objids(vreg, done): |
0 | 235 |
for reg, objdict in vreg.items(): |
6443
a5bed0cd3956
[i18n cube] skip bw compat registries boxes and contentnavigation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6356
diff
changeset
|
236 |
if reg in ('boxes', 'contentnavigation'): |
a5bed0cd3956
[i18n cube] skip bw compat registries boxes and contentnavigation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6356
diff
changeset
|
237 |
continue |
0 | 238 |
for objects in objdict.values(): |
239 |
for obj in objects: |
|
3677
acdba524bb8f
fix i18ncube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3674
diff
changeset
|
240 |
objid = '%s_%s' % (reg, obj.__regid__) |
0 | 241 |
if objid in done: |
1470
fbdf66a08fbb
don't add to cube i18n catalog msg id for components redefined from cw or from a depending cube
sylvain.thenault@logilab.fr
parents:
1451
diff
changeset
|
242 |
break |
3677
acdba524bb8f
fix i18ncube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3674
diff
changeset
|
243 |
try: # XXX < 3.6 bw compat |
acdba524bb8f
fix i18ncube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3674
diff
changeset
|
244 |
pdefs = obj.property_defs |
acdba524bb8f
fix i18ncube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3674
diff
changeset
|
245 |
except AttributeError: |
acdba524bb8f
fix i18ncube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3674
diff
changeset
|
246 |
pdefs = getattr(obj, 'cw_property_defs', {}) |
acdba524bb8f
fix i18ncube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3674
diff
changeset
|
247 |
if pdefs: |
1470
fbdf66a08fbb
don't add to cube i18n catalog msg id for components redefined from cw or from a depending cube
sylvain.thenault@logilab.fr
parents:
1451
diff
changeset
|
248 |
yield objid |
0 | 249 |
done.add(objid) |
1470
fbdf66a08fbb
don't add to cube i18n catalog msg id for components redefined from cw or from a depending cube
sylvain.thenault@logilab.fr
parents:
1451
diff
changeset
|
250 |
break |
374
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
251 |
|
1451 | 252 |
|
0 | 253 |
DEFAULT_POT_HEAD = r'''msgid "" |
254 |
msgstr "" |
|
255 |
"Project-Id-Version: cubicweb %s\n" |
|
256 |
"PO-Revision-Date: 2008-03-28 18:14+0100\n" |
|
257 |
"Last-Translator: Logilab Team <contact@logilab.fr>\n" |
|
258 |
"Language-Team: fr <contact@logilab.fr>\n" |
|
259 |
"MIME-Version: 1.0\n" |
|
260 |
"Content-Type: text/plain; charset=UTF-8\n" |
|
261 |
"Content-Transfer-Encoding: 8bit\n" |
|
262 |
"Generated-By: cubicweb-devtools\n" |
|
263 |
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
|
264 |
||
265 |
''' % cubicwebversion |
|
266 |
||
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
267 |
def cw_languages(): |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
268 |
for fname in listdir(osp.join(WebConfiguration.i18n_lib_dir())): |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
269 |
if fname.endswith('.po'): |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
270 |
yield osp.splitext(fname)[0] |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
271 |
|
0 | 272 |
|
273 |
class UpdateCubicWebCatalogCommand(Command): |
|
274 |
"""Update i18n catalogs for cubicweb library. |
|
1451 | 275 |
|
0 | 276 |
It will regenerate cubicweb/i18n/xx.po files. You'll have then to edit those |
277 |
files to add translations of newly added messages. |
|
278 |
""" |
|
1898
39b37f90a8a4
[cw-ctl] rename i18n commands (see #342889)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1850
diff
changeset
|
279 |
name = 'i18ncubicweb' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
280 |
min_args = max_args = 0 |
0 | 281 |
|
282 |
def run(self, args): |
|
283 |
"""run the command with its specific arguments""" |
|
284 |
import shutil |
|
2446
440cb4ea7e5c
[refactor] #342855: replace uses of (deprecated) mktemp
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
285 |
import tempfile |
0 | 286 |
import yams |
287 |
from logilab.common.fileutils import ensure_fs_mode |
|
58
c7c22b210372
only try to internationalize our own js files
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
57
diff
changeset
|
288 |
from logilab.common.shellutils import globfind, find, rm |
4718
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
289 |
from logilab.common.modutils import get_module_files |
4021
280c910c8710
move i18n / migration modules from cw.common to cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3998
diff
changeset
|
290 |
from cubicweb.i18n import extract_from_tal, execute |
2692
bffb0e64736c
[i18ncubicweb] fix stupid NameError with mkdtemp
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2657
diff
changeset
|
291 |
tempdir = tempfile.mkdtemp() |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
292 |
cwi18ndir = WebConfiguration.i18n_lib_dir() |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
293 |
print '-> extract schema messages.' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
294 |
schemapot = osp.join(tempdir, 'schema.pot') |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
295 |
potfiles = [schemapot] |
0 | 296 |
potfiles.append(schemapot) |
297 |
# explicit close necessary else the file may not be yet flushed when |
|
298 |
# we'll using it below |
|
299 |
schemapotstream = file(schemapot, 'w') |
|
300 |
generate_schema_pot(schemapotstream.write, cubedir=None) |
|
301 |
schemapotstream.close() |
|
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
302 |
print '-> extract TAL messages.' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
303 |
tali18nfile = osp.join(tempdir, 'tali18n.py') |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
304 |
extract_from_tal(find(osp.join(BASEDIR, 'web'), ('.py', '.pt')), |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
305 |
tali18nfile) |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
306 |
print '-> generate .pot files.' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
307 |
pyfiles = get_module_files(BASEDIR) |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
308 |
pyfiles += globfind(osp.join(BASEDIR, 'misc', 'migration'), '*.py') |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
309 |
schemafiles = globfind(osp.join(BASEDIR, 'schemas'), '*.py') |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
310 |
jsfiles = globfind(osp.join(BASEDIR, 'web'), 'cub*.js') |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
311 |
for id, files, lang in [('pycubicweb', pyfiles, None), |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
312 |
('schemadescr', schemafiles, None), |
0 | 313 |
('yams', get_module_files(yams.__path__[0]), None), |
314 |
('tal', [tali18nfile], None), |
|
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
315 |
('js', jsfiles, 'java'), |
0 | 316 |
]: |
60
dc90556488d8
oops, bad changeset review, revert debug changes
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
58
diff
changeset
|
317 |
cmd = 'xgettext --no-location --omit-header -k_ -o %s %s' |
0 | 318 |
if lang is not None: |
319 |
cmd += ' -L %s' % lang |
|
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
320 |
potfile = osp.join(tempdir, '%s.pot' % id) |
3117
32686ae66c75
mostly adapt the i18n subsystem to limitation wrt redirection handinling in windows, using the -o argument of the utilities
Aurélien Campéas
parents:
2692
diff
changeset
|
321 |
execute(cmd % (potfile, ' '.join('"%s"' % f for f in files))) |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
322 |
if osp.exists(potfile): |
1502 | 323 |
potfiles.append(potfile) |
324 |
else: |
|
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
325 |
print '-> WARNING: %s file was not generated' % potfile |
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
326 |
print '-> merging %i .pot files' % len(potfiles) |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
327 |
cubicwebpot = osp.join(tempdir, 'cubicweb.pot') |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
328 |
execute('msgcat -o %s %s' |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
329 |
% (cubicwebpot, ' '.join('"%s"' % f for f in potfiles))) |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
330 |
print '-> merging main pot file with existing translations.' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
331 |
chdir(cwi18ndir) |
0 | 332 |
toedit = [] |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
333 |
for lang in cw_languages(): |
0 | 334 |
target = '%s.po' % lang |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
335 |
execute('msgmerge -N --sort-output -o "%snew" "%s" "%s"' |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
336 |
% (target, target, cubicwebpot)) |
0 | 337 |
ensure_fs_mode(target) |
338 |
shutil.move('%snew' % target, target) |
|
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
339 |
toedit.append(osp.abspath(target)) |
0 | 340 |
# cleanup |
60
dc90556488d8
oops, bad changeset review, revert debug changes
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
58
diff
changeset
|
341 |
rm(tempdir) |
0 | 342 |
# instructions pour la suite |
2396
8bfb99d7bbcc
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2395
diff
changeset
|
343 |
print '-> regenerated CubicWeb\'s .po catalogs.' |
8bfb99d7bbcc
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2395
diff
changeset
|
344 |
print '\nYou can now edit the following files:' |
0 | 345 |
print '* ' + '\n* '.join(toedit) |
2396
8bfb99d7bbcc
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2395
diff
changeset
|
346 |
print 'when you are done, run "cubicweb-ctl i18ncube yourcube".' |
0 | 347 |
|
348 |
||
6444
cc091175d3da
[c-c i18ncube] proper command class name
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6443
diff
changeset
|
349 |
class UpdateCubeCatalogCommand(Command): |
0 | 350 |
"""Update i18n catalogs for cubes. If no cube is specified, update |
351 |
catalogs of all registered cubes. |
|
352 |
""" |
|
1898
39b37f90a8a4
[cw-ctl] rename i18n commands (see #342889)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1850
diff
changeset
|
353 |
name = 'i18ncube' |
0 | 354 |
arguments = '[<cube>...]' |
1451 | 355 |
|
0 | 356 |
def run(self, args): |
357 |
"""run the command with its specific arguments""" |
|
358 |
if args: |
|
4479
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
359 |
cubes = [DevConfiguration.cube_dir(cube) for cube in args] |
0 | 360 |
else: |
4479
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
361 |
cubes = [DevConfiguration.cube_dir(cube) |
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
362 |
for cube in DevConfiguration.available_cubes()] |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
363 |
cubes = [cubepath for cubepath in cubes |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
364 |
if osp.exists(osp.join(cubepath, 'i18n'))] |
0 | 365 |
update_cubes_catalogs(cubes) |
366 |
||
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
367 |
|
0 | 368 |
def update_cubes_catalogs(cubes): |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
369 |
for cubedir in cubes: |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
370 |
if not osp.isdir(cubedir): |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
371 |
print '-> ignoring %s that is not a directory.' % cubedir |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
372 |
continue |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
373 |
try: |
5537
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
374 |
toedit = update_cube_catalogs(cubedir) |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
375 |
except Exception: |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
376 |
import traceback |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
377 |
traceback.print_exc() |
2527
e60db6312aa0
per cube message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
378 |
print '-> error while updating catalogs for cube', cubedir |
e60db6312aa0
per cube message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
379 |
else: |
e60db6312aa0
per cube message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
380 |
# instructions pour la suite |
5537
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
381 |
if toedit: |
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
382 |
print '-> regenerated .po catalogs for cube %s.' % cubedir |
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
383 |
print '\nYou can now edit the following files:' |
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
384 |
print '* ' + '\n* '.join(toedit) |
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
385 |
print ('When you are done, run "cubicweb-ctl i18ninstance ' |
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
386 |
'<yourinstance>" to see changes in your instances.') |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
387 |
|
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
388 |
def update_cube_catalogs(cubedir): |
0 | 389 |
import shutil |
2446
440cb4ea7e5c
[refactor] #342855: replace uses of (deprecated) mktemp
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
390 |
import tempfile |
0 | 391 |
from logilab.common.fileutils import ensure_fs_mode |
392 |
from logilab.common.shellutils import find, rm |
|
4021
280c910c8710
move i18n / migration modules from cw.common to cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3998
diff
changeset
|
393 |
from cubicweb.i18n import extract_from_tal, execute |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
394 |
cube = osp.basename(osp.normpath(cubedir)) |
2446
440cb4ea7e5c
[refactor] #342855: replace uses of (deprecated) mktemp
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
395 |
tempdir = tempfile.mkdtemp() |
2396
8bfb99d7bbcc
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2395
diff
changeset
|
396 |
print underline_title('Updating i18n catalogs for cube %s' % cube) |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
397 |
chdir(cubedir) |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
398 |
if osp.exists(osp.join('i18n', 'entities.pot')): |
2551
91f579b7a1e1
[F bw compat] warn if entities.pot exists but consider it anyway
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2534
diff
changeset
|
399 |
warn('entities.pot is deprecated, rename file to static-messages.pot (%s)' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
400 |
% osp.join('i18n', 'entities.pot'), DeprecationWarning) |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
401 |
potfiles = [osp.join('i18n', 'entities.pot')] |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
402 |
elif osp.exists(osp.join('i18n', 'static-messages.pot')): |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
403 |
potfiles = [osp.join('i18n', 'static-messages.pot')] |
2551
91f579b7a1e1
[F bw compat] warn if entities.pot exists but consider it anyway
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2534
diff
changeset
|
404 |
else: |
91f579b7a1e1
[F bw compat] warn if entities.pot exists but consider it anyway
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2534
diff
changeset
|
405 |
potfiles = [] |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
406 |
print '-> extract schema messages' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
407 |
schemapot = osp.join(tempdir, 'schema.pot') |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
408 |
potfiles.append(schemapot) |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
409 |
# explicit close necessary else the file may not be yet flushed when |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
410 |
# we'll using it below |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
411 |
schemapotstream = file(schemapot, 'w') |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
412 |
generate_schema_pot(schemapotstream.write, cubedir) |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
413 |
schemapotstream.close() |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
414 |
print '-> extract TAL messages' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
415 |
tali18nfile = osp.join(tempdir, 'tali18n.py') |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
416 |
ptfiles = find('.', ('.py', '.pt'), blacklist=STD_BLACKLIST+('test',)) |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
417 |
extract_from_tal(ptfiles, tali18nfile) |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
418 |
print '-> extract Javascript messages' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
419 |
jsfiles = [jsfile for jsfile in find('.', '.js') |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
420 |
if osp.basename(jsfile).startswith('cub')] |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
421 |
if jsfiles: |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
422 |
tmppotfile = osp.join(tempdir, 'js.pot') |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
423 |
execute('xgettext --no-location --omit-header -k_ -L java ' |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
424 |
'--from-code=utf-8 -o %s %s' % (tmppotfile, ' '.join(jsfiles))) |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
425 |
# no pot file created if there are no string to translate |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
426 |
if osp.exists(tmppotfile): |
0 | 427 |
potfiles.append(tmppotfile) |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
428 |
print '-> create cube-specific catalog' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
429 |
tmppotfile = osp.join(tempdir, 'generated.pot') |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
430 |
cubefiles = find('.', '.py', blacklist=STD_BLACKLIST+('test',)) |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
431 |
cubefiles.append(tali18nfile) |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
432 |
execute('xgettext --no-location --omit-header -k_ -o %s %s' |
3118 | 433 |
% (tmppotfile, ' '.join('"%s"' % f for f in cubefiles))) |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
434 |
if osp.exists(tmppotfile): # doesn't exists of no translation string found |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
435 |
potfiles.append(tmppotfile) |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
436 |
potfile = osp.join(tempdir, 'cube.pot') |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
437 |
print '-> merging %i .pot files:' % len(potfiles) |
3117
32686ae66c75
mostly adapt the i18n subsystem to limitation wrt redirection handinling in windows, using the -o argument of the utilities
Aurélien Campéas
parents:
2692
diff
changeset
|
438 |
execute('msgcat -o %s %s' % (potfile, |
32686ae66c75
mostly adapt the i18n subsystem to limitation wrt redirection handinling in windows, using the -o argument of the utilities
Aurélien Campéas
parents:
2692
diff
changeset
|
439 |
' '.join('"%s"' % f for f in potfiles))) |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
440 |
if not osp.exists(potfile): |
5537
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
441 |
print 'no message catalog for cube', cube, 'nothing to translate' |
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
442 |
# cleanup |
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
443 |
rm(tempdir) |
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
444 |
return () |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
445 |
print '-> merging main pot file with existing translations:' |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
446 |
chdir('i18n') |
5537
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
447 |
toedit = [] |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
448 |
for lang in cw_languages(): |
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2092
diff
changeset
|
449 |
print '-> language', lang |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
450 |
cubepo = '%s.po' % lang |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
451 |
if not osp.exists(cubepo): |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
452 |
shutil.copy(potfile, cubepo) |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
453 |
else: |
3118 | 454 |
execute('msgmerge -N -s -o %snew %s %s' % (cubepo, cubepo, potfile)) |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
455 |
ensure_fs_mode(cubepo) |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
456 |
shutil.move('%snew' % cubepo, cubepo) |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
457 |
toedit.append(osp.abspath(cubepo)) |
1770
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
458 |
# cleanup |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
459 |
rm(tempdir) |
8bd788149f85
refactor and don't crash on error while generating a cube's catalogs
sylvain.thenault@logilab.fr
parents:
1769
diff
changeset
|
460 |
return toedit |
0 | 461 |
|
462 |
||
4439
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
463 |
# XXX totally broken, fix it |
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
464 |
# class LiveServerCommand(Command): |
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
465 |
# """Run a server from within a cube directory. |
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
466 |
# """ |
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
467 |
# name = 'live-server' |
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
468 |
# arguments = '' |
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
469 |
# options = () |
1451 | 470 |
|
4439
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
471 |
# def run(self, args): |
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
472 |
# """run the command with its specific arguments""" |
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
473 |
# from cubicweb.devtools.livetest import runserver |
5ab3f63b06ad
live-server doesn't work, don't make think it does
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4434
diff
changeset
|
474 |
# runserver() |
0 | 475 |
|
476 |
||
132
561671b87c22
rename NewTemplateCommand class into NewCubeCommand
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
61
diff
changeset
|
477 |
class NewCubeCommand(Command): |
0 | 478 |
"""Create a new cube. |
479 |
||
480 |
<cubename> |
|
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
481 |
the name of the new cube. It should be a valid python module name. |
0 | 482 |
""" |
483 |
name = 'newcube' |
|
484 |
arguments = '<cubename>' |
|
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
485 |
min_args = max_args = 1 |
133
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
486 |
options = ( |
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
487 |
("layout", |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
488 |
{'short': 'L', 'type' : 'choice', 'metavar': '<cube layout>', |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
489 |
'default': 'simple', 'choices': ('simple', 'full'), |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
490 |
'help': 'cube layout. You\'ll get a minimal cube with the "simple" \ |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
491 |
layout, and a full featured cube with "full" layout.', |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
492 |
} |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
493 |
), |
1106
de873146183a
fix newcube command to deal with cubes path
sylvain.thenault@logilab.fr
parents:
1105
diff
changeset
|
494 |
("directory", |
de873146183a
fix newcube command to deal with cubes path
sylvain.thenault@logilab.fr
parents:
1105
diff
changeset
|
495 |
{'short': 'd', 'type' : 'string', 'metavar': '<cubes directory>', |
de873146183a
fix newcube command to deal with cubes path
sylvain.thenault@logilab.fr
parents:
1105
diff
changeset
|
496 |
'help': 'directory where the new cube should be created', |
de873146183a
fix newcube command to deal with cubes path
sylvain.thenault@logilab.fr
parents:
1105
diff
changeset
|
497 |
} |
de873146183a
fix newcube command to deal with cubes path
sylvain.thenault@logilab.fr
parents:
1105
diff
changeset
|
498 |
), |
133
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
499 |
("verbose", |
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
500 |
{'short': 'v', 'type' : 'yn', 'metavar': '<verbose>', |
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
501 |
'default': 'n', |
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
502 |
'help': 'verbose mode: will ask all possible configuration questions', |
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
503 |
} |
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
504 |
), |
365
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
505 |
("author", |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
506 |
{'short': 'a', 'type' : 'string', 'metavar': '<author>', |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
507 |
'default': 'LOGILAB S.A. (Paris, FRANCE)', |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
508 |
'help': 'cube author', |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
509 |
} |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
510 |
), |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
511 |
("author-email", |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
512 |
{'short': 'e', 'type' : 'string', 'metavar': '<email>', |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
513 |
'default': 'contact@logilab.fr', |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
514 |
'help': 'cube author\'s email', |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
515 |
} |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
516 |
), |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
517 |
("author-web-site", |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
518 |
{'short': 'w', 'type' : 'string', 'metavar': '<web site>', |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
519 |
'default': 'http://www.logilab.fr', |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
520 |
'help': 'cube author\'s web site', |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
521 |
} |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
522 |
), |
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
523 |
("license", |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
524 |
{'short': 'l', 'type' : 'choice', 'metavar': '<license>', |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
525 |
'default': 'LGPL', 'choices': ('GPL', 'LGPL', ''), |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
526 |
'help': 'cube license', |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
527 |
} |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
528 |
), |
133
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
529 |
) |
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
530 |
|
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
531 |
LICENSES = { |
5423
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
532 |
'LGPL': '''\ |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
533 |
# This program is free software: you can redistribute it and/or modify it under |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
534 |
# the terms of the GNU Lesser General Public License as published by the Free |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
535 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
536 |
# any later version. |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
537 |
# |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
538 |
# This program is distributed in the hope that it will be useful, but WITHOUT |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
539 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
540 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
541 |
# details. |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
542 |
# |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
543 |
# You should have received a copy of the GNU Lesser General Public License along |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
544 |
# with this program. If not, see <http://www.gnu.org/licenses/>. |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
545 |
''', |
5537
2889091bd1bf
[i18ncube] do not crash if cube has nothing to translate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
546 |
|
5423
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
547 |
'GPL': '''\ |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
548 |
# This program is free software: you can redistribute it and/or modify it under |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
549 |
# the terms of the GNU General Public License as published by the Free Software |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
550 |
# Foundation, either version 2.1 of the License, or (at your option) any later |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
551 |
# version. |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
552 |
# |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
553 |
# This program is distributed in the hope that it will be useful, but WITHOUT |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
554 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
555 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
556 |
# |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
557 |
# You should have received a copy of the GNU General Public License along with |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
558 |
# this program. If not, see <http://www.gnu.org/licenses/>. |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
559 |
''', |
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
560 |
'': '# INSERT LICENSE HERE' |
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
561 |
} |
1451 | 562 |
|
0 | 563 |
def run(self, args): |
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
564 |
import re |
4718
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
565 |
from logilab.common.shellutils import ASK |
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
566 |
cubename = args[0] |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
567 |
if not re.match('[_A-Za-z][_A-Za-z0-9]*$', cubename): |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
568 |
raise BadCommandUsage( |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
569 |
'cube name must be a valid python module name') |
133
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
570 |
verbose = self.get('verbose') |
1106
de873146183a
fix newcube command to deal with cubes path
sylvain.thenault@logilab.fr
parents:
1105
diff
changeset
|
571 |
cubesdir = self.get('directory') |
1116
163e6a65d488
fix dumb name error, should call cubes_search_path, not cubes_path
sylvain.thenault@logilab.fr
parents:
1106
diff
changeset
|
572 |
if not cubesdir: |
163e6a65d488
fix dumb name error, should call cubes_search_path, not cubes_path
sylvain.thenault@logilab.fr
parents:
1106
diff
changeset
|
573 |
cubespath = ServerConfiguration.cubes_search_path() |
1106
de873146183a
fix newcube command to deal with cubes path
sylvain.thenault@logilab.fr
parents:
1105
diff
changeset
|
574 |
if len(cubespath) > 1: |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
575 |
raise BadCommandUsage( |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
576 |
"can't guess directory where to put the new cube." |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
577 |
" Please specify it using the --directory option") |
1106
de873146183a
fix newcube command to deal with cubes path
sylvain.thenault@logilab.fr
parents:
1105
diff
changeset
|
578 |
cubesdir = cubespath[0] |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
579 |
if not osp.isdir(cubesdir): |
2615
1ea41b7c0836
F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2551
diff
changeset
|
580 |
print "-> creating cubes directory", cubesdir |
0 | 581 |
try: |
1106
de873146183a
fix newcube command to deal with cubes path
sylvain.thenault@logilab.fr
parents:
1105
diff
changeset
|
582 |
mkdir(cubesdir) |
0 | 583 |
except OSError, err: |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
584 |
self.fail("failed to create directory %r\n(%s)" |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
585 |
% (cubesdir, err)) |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
586 |
cubedir = osp.join(cubesdir, cubename) |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
587 |
if osp.exists(cubedir): |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
588 |
self.fail("%s already exists !" % cubedir) |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
589 |
skeldir = osp.join(BASEDIR, 'skeleton') |
5297
cc747dcef851
[c-c newcube] finish #676915: cubicweb-ctl newcube must be aware of python modules and debian package convention (python part already implemented)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
590 |
default_name = 'cubicweb-%s' % cubename.lower().replace('_', '-') |
133
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
591 |
if verbose: |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
592 |
distname = raw_input('Debian name for your cube ? [%s]): ' |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
593 |
% default_name).strip() |
133
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
594 |
if not distname: |
2615
1ea41b7c0836
F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2551
diff
changeset
|
595 |
distname = default_name |
133
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
596 |
elif not distname.startswith('cubicweb-'): |
2615
1ea41b7c0836
F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2551
diff
changeset
|
597 |
if ASK.confirm('Do you mean cubicweb-%s ?' % distname): |
133
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
598 |
distname = 'cubicweb-' + distname |
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
599 |
else: |
2615
1ea41b7c0836
F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2551
diff
changeset
|
600 |
distname = default_name |
5297
cc747dcef851
[c-c newcube] finish #676915: cubicweb-ctl newcube must be aware of python modules and debian package convention (python part already implemented)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
601 |
if not re.match('[a-z][-a-z0-9]*$', distname): |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
602 |
raise BadCommandUsage( |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
603 |
'cube distname should be a valid debian package name') |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
604 |
longdesc = shortdesc = raw_input( |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
605 |
'Enter a short description for your cube: ') |
133
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
606 |
if verbose: |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
607 |
longdesc = raw_input( |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
608 |
'Enter a long description (leave empty to reuse the short one): ') |
5347
8ebed973819b
merge stable, fixing dependencies generation on c-c newcube on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
609 |
dependencies = {'cubicweb': '>= %s' % cubicwebversion} |
133
6ad5e7eb06ff
provide a --verbose option to the newcube command and only ask for a short description by default
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
132
diff
changeset
|
610 |
if verbose: |
5347
8ebed973819b
merge stable, fixing dependencies generation on c-c newcube on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
611 |
dependencies.update(self._ask_for_dependencies()) |
0 | 612 |
context = {'cubename' : cubename, |
613 |
'distname' : distname, |
|
614 |
'shortdesc' : shortdesc, |
|
615 |
'longdesc' : longdesc or shortdesc, |
|
5347
8ebed973819b
merge stable, fixing dependencies generation on c-c newcube on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
616 |
'dependencies' : dependencies, |
0 | 617 |
'version' : cubicwebversion, |
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
396
diff
changeset
|
618 |
'year' : str(datetime.now().year), |
365
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
619 |
'author': self['author'], |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
620 |
'author-email': self['author-email'], |
5d8336b70aa7
make author information configurable
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
264
diff
changeset
|
621 |
'author-web-site': self['author-web-site'], |
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
622 |
'license': self['license'], |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
623 |
'long-license': self.LICENSES[self['license']], |
0 | 624 |
} |
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
625 |
exclude = SKEL_EXCLUDE |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
626 |
if self['layout'] == 'simple': |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
627 |
exclude += ('sobjects.py*', 'precreate.py*', 'realdb_test*', |
5466
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5442
diff
changeset
|
628 |
'cubes.*', 'uiprops.py*') |
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4722
diff
changeset
|
629 |
copy_skeleton(skeldir, cubedir, context, exclude=exclude) |
0 | 630 |
|
5344
ed4cd1ca96d6
[skeleton/dependencies] fix typo & new cube generation from template
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
4722
diff
changeset
|
631 |
def _ask_for_dependencies(self): |
4718
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
632 |
from logilab.common.shellutils import ASK |
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
633 |
from logilab.common.textutils import splitstrip |
5347
8ebed973819b
merge stable, fixing dependencies generation on c-c newcube on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
634 |
depcubes = [] |
8ebed973819b
merge stable, fixing dependencies generation on c-c newcube on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
635 |
for cube in ServerConfiguration.available_cubes(): |
8ebed973819b
merge stable, fixing dependencies generation on c-c newcube on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
636 |
answer = ASK.ask("Depends on cube %s? " % cube, |
2615
1ea41b7c0836
F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2551
diff
changeset
|
637 |
('N','y','skip','type'), 'N') |
1ea41b7c0836
F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2551
diff
changeset
|
638 |
if answer == 'y': |
5347
8ebed973819b
merge stable, fixing dependencies generation on c-c newcube on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
639 |
depcubes.append(cube) |
2615
1ea41b7c0836
F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2551
diff
changeset
|
640 |
if answer == 'type': |
5347
8ebed973819b
merge stable, fixing dependencies generation on c-c newcube on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
641 |
depcubes = splitstrip(raw_input('type dependencies: ')) |
0 | 642 |
break |
2615
1ea41b7c0836
F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2551
diff
changeset
|
643 |
elif answer == 'skip': |
0 | 644 |
break |
5347
8ebed973819b
merge stable, fixing dependencies generation on c-c newcube on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
645 |
return dict(('cubicweb-' + cube, ServerConfiguration.cube_version(cube)) |
8ebed973819b
merge stable, fixing dependencies generation on c-c newcube on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
646 |
for cube in depcubes) |
1451 | 647 |
|
374
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
648 |
|
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
649 |
class ExamineLogCommand(Command): |
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
650 |
"""Examine a rql log file. |
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
651 |
|
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
652 |
will print out the following table |
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
653 |
|
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
654 |
total execution time || number of occurences || rql query |
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
655 |
|
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
656 |
sorted by descending total execution time |
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
657 |
|
4708
2bd3d03721f3
#687194: cubicweb-ctl exlog : fix help message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4479
diff
changeset
|
658 |
chances are the lines at the top are the ones that will bring the higher |
2bd3d03721f3
#687194: cubicweb-ctl exlog : fix help message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4479
diff
changeset
|
659 |
benefit after optimisation. Start there. |
374
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
660 |
""" |
5375
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
661 |
arguments = 'rql.log' |
374
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
662 |
name = 'exlog' |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
663 |
options = () |
1451 | 664 |
|
374
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
665 |
def run(self, args): |
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
666 |
import re |
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
667 |
requests = {} |
5375
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
668 |
for filepath in args: |
1188
6937dfb242fb
[devtools] ExamineLog command does not fail on strange input and outputs to csv
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1116
diff
changeset
|
669 |
try: |
5375
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
670 |
stream = file(filepath) |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
671 |
except OSError, ex: |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
672 |
raise BadCommandUsage("can't open rql log file %s: %s" |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
673 |
% (filepath, ex)) |
5755
ca9e1c9123d7
[c-c exlog] fix code and documentation
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5608
diff
changeset
|
674 |
for lineno, line in enumerate(stream): |
5375
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
675 |
if not ' WHERE ' in line: |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
676 |
continue |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
677 |
try: |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
678 |
rql, time = line.split('--') |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
679 |
rql = re.sub("(\'\w+': \d*)", '', rql) |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
680 |
if '{' in rql: |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
681 |
rql = rql[:rql.index('{')] |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
682 |
req = requests.setdefault(rql, []) |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
683 |
time.strip() |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
684 |
chunks = time.split() |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
685 |
clocktime = float(chunks[0][1:]) |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
686 |
cputime = float(chunks[-3]) |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
687 |
req.append( (clocktime, cputime) ) |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
688 |
except Exception, exc: |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
689 |
sys.stderr.write('Line %s: %s (%s)\n' % (lineno, exc, line)) |
374
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
690 |
stat = [] |
5375
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
691 |
for rql, times in requests.iteritems(): |
2092
f5102472243d
[exlog] print clocktime in addition to cputime
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
692 |
stat.append( (sum(time[0] for time in times), |
f5102472243d
[exlog] print clocktime in addition to cputime
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
693 |
sum(time[1] for time in times), |
f5102472243d
[exlog] print clocktime in addition to cputime
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
694 |
len(times), rql) ) |
374
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
695 |
stat.sort() |
89225b187eb8
turn exlog into a cw-ctl command
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
373
diff
changeset
|
696 |
stat.reverse() |
5375
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
697 |
total_time = sum(clocktime for clocktime, cputime, occ, rql in stat) * 0.01 |
2092
f5102472243d
[exlog] print clocktime in addition to cputime
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
698 |
print 'Percentage;Cumulative Time (clock);Cumulative Time (CPU);Occurences;Query' |
f5102472243d
[exlog] print clocktime in addition to cputime
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
699 |
for clocktime, cputime, occ, rql in stat: |
5375
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
700 |
print '%.2f;%.2f;%.2f;%s;%s' % (clocktime/total_time, clocktime, |
962e13ab0930
[c-c exlog] #687204: cubicweb-ctl exlog: use a proper file and not stdin for input
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5344
diff
changeset
|
701 |
cputime, occ, rql) |
1451 | 702 |
|
4479
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
703 |
|
4428
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
704 |
class GenerateSchema(Command): |
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
705 |
"""Generate schema image for the given cube""" |
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
706 |
name = "schema" |
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
707 |
arguments = '<cube>' |
6138
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
708 |
min_args = max_args = 1 |
6356
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
709 |
options = [ |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
710 |
('output-file', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
711 |
{'type':'file', 'default': None, |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
712 |
'metavar': '<file>', 'short':'o', 'help':'output image file', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
713 |
'input':False, |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
714 |
}), |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
715 |
('viewer', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
716 |
{'type': 'string', 'default':None, |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
717 |
'short': "d", 'metavar':'<cmd>', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
718 |
'help':'command use to view the generated file (empty for none)', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
719 |
}), |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
720 |
('show-meta', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
721 |
{'action': 'store_true', 'default':False, |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
722 |
'short': "m", 'metavar': "<yN>", |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
723 |
'help':'include meta and internal entities in schema', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
724 |
}), |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
725 |
('show-workflow', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
726 |
{'action': 'store_true', 'default':False, |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
727 |
'short': "w", 'metavar': "<yN>", |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
728 |
'help':'include workflow entities in schema', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
729 |
}), |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
730 |
('show-cw-user', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
731 |
{'action': 'store_true', 'default':False, |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
732 |
'metavar': "<yN>", |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
733 |
'help':'include cubicweb user entities in schema', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
734 |
}), |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
735 |
('exclude-type', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
736 |
{'type':'string', 'default':'', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
737 |
'short': "x", 'metavar': "<types>", |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
738 |
'help':'coma separated list of entity types to remove from view', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
739 |
}), |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
740 |
('include-type', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
741 |
{'type':'string', 'default':'', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
742 |
'short': "i", 'metavar': "<types>", |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
743 |
'help':'coma separated list of entity types to include in view', |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
744 |
}), |
e89f71a41e20
[c-c i18n] namespace/line wrap cleanup + dynamically compute available language + make it works in installed mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6138
diff
changeset
|
745 |
] |
4428
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
746 |
|
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
747 |
def run(self, args): |
4718
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
748 |
from subprocess import Popen |
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
749 |
from tempfile import NamedTemporaryFile |
4428
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
750 |
from logilab.common.textutils import splitstrip |
4718
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
751 |
from yams import schema2dot, BASE_TYPES |
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
752 |
from cubicweb.schema import (META_RTYPES, SCHEMA_TYPES, SYSTEM_RTYPES, |
3dc3ad02d091
avoid module import in c-c plugins module, and remind it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4708
diff
changeset
|
753 |
WORKFLOW_TYPES, INTERNAL_TYPES) |
6138
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
754 |
cubes = splitstrip(args[0]) |
4479
f25e61a93c42
replace DevCubeConfiguration/DevDepsConfiguration by a single DevConfiguration, fixing recently introduced by w/ i18ncube command on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
755 |
dev_conf = DevConfiguration(*cubes) |
4428
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
756 |
schema = dev_conf.load_schema() |
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
757 |
out, viewer = self['output-file'], self['viewer'] |
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
758 |
if out is None: |
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
759 |
tmp_file = NamedTemporaryFile(suffix=".svg") |
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
760 |
out = tmp_file.name |
4434
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4428
diff
changeset
|
761 |
skiptypes = BASE_TYPES | SCHEMA_TYPES |
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4428
diff
changeset
|
762 |
if not self['show-meta']: |
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4428
diff
changeset
|
763 |
skiptypes |= META_RTYPES | SYSTEM_RTYPES | INTERNAL_TYPES |
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4428
diff
changeset
|
764 |
if not self['show-workflow']: |
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4428
diff
changeset
|
765 |
skiptypes |= WORKFLOW_TYPES |
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4428
diff
changeset
|
766 |
if not self['show-cw-user']: |
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4428
diff
changeset
|
767 |
skiptypes |= set(('CWUser', 'CWGroup', 'EmailAddress')) |
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4428
diff
changeset
|
768 |
skiptypes |= set(self['exclude-type'].split(',')) |
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4428
diff
changeset
|
769 |
skiptypes -= set(self['include-type'].split(',')) |
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4428
diff
changeset
|
770 |
schema2dot.schema2dot(schema, out, skiptypes=skiptypes) |
4428
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
771 |
if viewer: |
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
772 |
p = Popen((viewer, out)) |
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
773 |
p.wait() |
03614b377ecd
Add a ``schema`` command to cmd ctrl to generate schema image.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4400
diff
changeset
|
774 |
|
5775
34195230dc2a
[packaging] more cleanups, handle javascript test files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5762
diff
changeset
|
775 |
|
34195230dc2a
[packaging] more cleanups, handle javascript test files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5762
diff
changeset
|
776 |
class GenerateQUnitHTML(Command): |
34195230dc2a
[packaging] more cleanups, handle javascript test files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5762
diff
changeset
|
777 |
"""Generate a QUnit html file to see test in your browser""" |
34195230dc2a
[packaging] more cleanups, handle javascript test files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5762
diff
changeset
|
778 |
name = "qunit-html" |
34195230dc2a
[packaging] more cleanups, handle javascript test files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5762
diff
changeset
|
779 |
arguments = '<test file> [<dependancy js file>...]' |
34195230dc2a
[packaging] more cleanups, handle javascript test files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5762
diff
changeset
|
780 |
|
34195230dc2a
[packaging] more cleanups, handle javascript test files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5762
diff
changeset
|
781 |
def run(self, args): |
34195230dc2a
[packaging] more cleanups, handle javascript test files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5762
diff
changeset
|
782 |
from cubicweb.devtools.qunit import make_qunit_html |
34195230dc2a
[packaging] more cleanups, handle javascript test files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5762
diff
changeset
|
783 |
print make_qunit_html(args[0], args[1:]) |
34195230dc2a
[packaging] more cleanups, handle javascript test files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5762
diff
changeset
|
784 |
|
6138
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
785 |
for cmdcls in (UpdateCubicWebCatalogCommand, |
6444
cc091175d3da
[c-c i18ncube] proper command class name
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6443
diff
changeset
|
786 |
UpdateCubeCatalogCommand, |
6138
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
787 |
#LiveServerCommand, |
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
788 |
NewCubeCommand, |
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
789 |
ExamineLogCommand, |
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
790 |
GenerateSchema, |
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
791 |
GenerateQUnitHTML, |
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
792 |
): |
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5775
diff
changeset
|
793 |
CWCTL.register(cmdcls) |