Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
19913bb2
Commit
19913bb2
authored
Jul 02, 2013
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
c4a58a1e
486582ec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
5 deletions
+77
-5
docs/management.rst
docs/management.rst
+6
-0
trans/management/commands/import_project.py
trans/management/commands/import_project.py
+29
-4
trans/models/unit.py
trans/models/unit.py
+1
-1
trans/tests/commands.py
trans/tests/commands.py
+41
-0
No files found.
docs/management.rst
View file @
19913bb2
...
...
@@ -87,6 +87,12 @@ To customise the subproject's name, use the `--name-template` option.
Its parameter is a python formatting string, which will expect the
match from `<filemask>`.
By format string passed by the `--base-file-template` option you can customize
base file for monolingual translations.
You can also specify file format to use (see :ref:`formats`) by the
`--file-format` parameter. The default is autodetection.
For example:
.. code-block:: bash
...
...
trans/management/commands/import_project.py
View file @
19913bb2
...
...
@@ -45,8 +45,27 @@ class Command(BaseCommand):
help
=
'Python formatting string, transforming the filemask '
'match to a project name'
),
make_option
(
'--base-file-template'
,
default
=
'%s'
,
help
=
'Python formatting string, transforming the filemask '
'match to a monolingual base file name'
),
make_option
(
'--file-format'
,
default
=
'auto'
,
help
=
'File format type, defaults to autodetection'
,
),
)
def
format_string
(
self
,
template
,
match
):
'''
Formats template string with match.
'''
if
'%s'
in
template
:
return
template
%
match
return
template
def
get_name
(
self
,
maskre
,
path
):
matches
=
maskre
.
match
(
path
)
return
matches
.
group
(
1
)
...
...
@@ -148,12 +167,13 @@ class Command(BaseCommand):
)
else
:
matches
,
sharedrepo
=
self
.
import_initial
(
project
,
repo
,
branch
,
filemask
,
options
[
'name_template'
]
project
,
repo
,
branch
,
filemask
,
options
[
'name_template'
],
options
[
'file_format'
],
options
[
'base_file_template'
]
)
# Create remaining subprojects sharing git repository
for
match
in
matches
:
name
=
options
[
'name_template'
]
%
match
name
=
self
.
format_string
(
options
[
'name_template'
],
match
)
slug
=
slugify
(
name
)
subprojects
=
SubProject
.
objects
.
filter
(
Q
(
name
=
name
)
|
Q
(
slug
=
slug
),
...
...
@@ -173,10 +193,13 @@ class Command(BaseCommand):
project
=
project
,
repo
=
sharedrepo
,
branch
=
branch
,
file_format
=
options
[
'file_format'
],
template
=
self
.
format_string
(
options
[
'base_file_template'
],
match
),
filemask
=
filemask
.
replace
(
'**'
,
match
)
)
def
import_initial
(
self
,
project
,
repo
,
branch
,
filemask
,
name_template
):
def
import_initial
(
self
,
project
,
repo
,
branch
,
filemask
,
name_template
,
file_format
,
base_file_template
):
'''
Import the first repository of a project
'''
...
...
@@ -186,7 +209,7 @@ class Command(BaseCommand):
# Create first subproject (this one will get full git repo)
match
=
matches
.
pop
()
name
=
name_template
%
match
name
=
self
.
format_string
(
name_template
,
match
)
slug
=
slugify
(
name
)
if
SubProject
.
objects
.
filter
(
project
=
project
,
slug
=
slug
).
exists
():
...
...
@@ -212,6 +235,8 @@ class Command(BaseCommand):
project
=
project
,
repo
=
repo
,
branch
=
branch
,
file_format
=
file_format
,
template
=
self
.
format_string
(
base_file_template
,
match
),
filemask
=
filemask
.
replace
(
'**'
,
match
)
)
...
...
trans/models/unit.py
View file @
19913bb2
...
...
@@ -953,7 +953,7 @@ class Unit(models.Model):
for
unit
in
Unit
.
objects
.
same
(
self
).
exclude
(
id
=
self
.
id
):
unit
.
update_has_failing_check
(
was_change
)
def
update_has_failing_check
(
self
):
def
update_has_failing_check
(
self
,
was_change
):
'''
Updates flag counting failing checks.
'''
...
...
trans/tests/commands.py
View file @
19913bb2
...
...
@@ -48,6 +48,47 @@ class ImportProjectTest(RepoTestCase):
# We should have loaded three subprojects
self
.
assertEqual
(
project
.
subproject_set
.
count
(),
4
)
def
test_import_po
(
self
):
project
=
self
.
create_project
()
call_command
(
'import_project'
,
'test'
,
self
.
repo_path
,
'master'
,
'**/*.po'
,
file_format
=
'po'
)
# We should have loaded three subprojects
self
.
assertEqual
(
project
.
subproject_set
.
count
(),
4
)
def
test_import_aresource
(
self
):
project
=
self
.
create_project
()
call_command
(
'import_project'
,
'test'
,
self
.
repo_path
,
'master'
,
'**/values-*/strings.xml'
,
file_format
=
'aresource'
,
base_file_template
=
'android/values/strings.xml'
,
)
# We should have loaded one subproject
self
.
assertEqual
(
project
.
subproject_set
.
count
(),
1
)
def
test_import_aresource_format
(
self
):
project
=
self
.
create_project
()
call_command
(
'import_project'
,
'test'
,
self
.
repo_path
,
'master'
,
'**/values-*/strings.xml'
,
file_format
=
'aresource'
,
base_file_template
=
'%s/values/strings.xml'
,
)
# We should have loaded one subproject
self
.
assertEqual
(
project
.
subproject_set
.
count
(),
1
)
def
test_re_import
(
self
):
project
=
self
.
create_project
()
call_command
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment