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
3d890e8c
Commit
3d890e8c
authored
Mar 12, 2013
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
52218c2d
ff489030
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
54 deletions
+67
-54
trans/models/subproject.py
trans/models/subproject.py
+67
-54
No files found.
trans/models/subproject.py
View file @
3d890e8c
...
@@ -735,6 +735,32 @@ class SubProject(models.Model):
...
@@ -735,6 +735,32 @@ class SubProject(models.Model):
self
.
update_remote_branch
()
self
.
update_remote_branch
()
self
.
update_branch
()
self
.
update_branch
()
def
clean_repo_link
(
self
):
'''
Validates repository link.
'''
if
self
.
push
!=
''
:
raise
ValidationError
(
_
(
'Push URL is not used when repository is linked!'
)
)
validate_repo
(
self
.
repo
)
def
clean_template
(
self
):
'''
Validates whether template can be loaded.
'''
try
:
self
.
load_template_store
()
except
ValueError
:
raise
ValidationError
(
_
(
'Format of translation template could not be recognized.'
)
)
except
Exception
as
e
:
raise
ValidationError
(
_
(
'Failed to parse translation template.'
)
)
def
clean
(
self
):
def
clean
(
self
):
'''
'''
Validator fetches repository and tries to find translation files.
Validator fetches repository and tries to find translation files.
...
@@ -748,62 +774,49 @@ class SubProject(models.Model):
...
@@ -748,62 +774,49 @@ class SubProject(models.Model):
self
.
sync_git_repo
(
True
)
self
.
sync_git_repo
(
True
)
# Push repo is not used with link
# Push repo is not used with link
if
self
.
is_repo_link
()
and
self
.
push
!=
''
:
if
self
.
is_repo_link
():
raise
ValidationError
(
self
.
clean_repo_link
()
_
(
'Push URL is not used when repository is linked!'
)
)
matches
=
self
.
get_mask_matches
()
if
len
(
matches
)
==
0
:
try
:
raise
ValidationError
(
_
(
'The mask did not match any files!'
))
matches
=
self
.
get_mask_matches
()
langs
=
set
()
if
len
(
matches
)
==
0
:
for
match
in
matches
:
raise
ValidationError
(
_
(
'The mask did not match any files!'
))
code
=
self
.
get_lang_code
(
match
)
langs
=
{}
if
code
in
langs
:
for
match
in
matches
:
raise
ValidationError
(
_
(
code
=
self
.
get_lang_code
(
match
)
'There are more files for single language, please '
if
code
in
langs
:
'adjust the mask and use subprojects for translating '
raise
ValidationError
(
_
(
'different resources.'
'There are more files for single language, please '
'adjust the mask and use subprojects for translating '
'different resources.'
))
langs
[
code
]
=
match
# Try parsing files
notrecognized
=
[]
errors
=
[]
for
match
in
matches
:
try
:
self
.
file_format_cls
.
load
(
os
.
path
.
join
(
self
.
get_path
(),
match
),
)
except
ValueError
:
notrecognized
.
append
(
match
)
except
Exception
as
e
:
errors
.
append
(
'%s: %s'
%
(
match
,
str
(
e
)))
if
len
(
notrecognized
)
>
0
:
raise
ValidationError
(
'%s
\
n
%s'
%
(
(
_
(
'Format of %d matched files could not be recognized.'
)
%
len
(
notrecognized
)),
'
\
n
'
.
join
(
notrecognized
)
))
if
len
(
errors
)
>
0
:
raise
ValidationError
(
'%s
\
n
%s'
%
(
(
_
(
'Failed to parse %d matched files!'
)
%
len
(
errors
)),
'
\
n
'
.
join
(
errors
)
))
))
langs
.
add
(
code
)
# Validate template
# Try parsing files
if
self
.
has_template
():
notrecognized
=
[]
try
:
errors
=
[]
self
.
load_template_store
()
for
match
in
matches
:
except
ValueError
:
try
:
raise
ValidationError
(
_
(
'Format of translation template could not be recognized.'
))
self
.
file_format_cls
.
load
(
except
Exception
as
e
:
os
.
path
.
join
(
self
.
get_path
(),
match
),
raise
ValidationError
(
)
_
(
'Failed to parse translation template.'
)
except
ValueError
:
)
notrecognized
.
append
(
match
)
except
SubProject
.
DoesNotExist
:
except
Exception
as
e
:
# Happens with invalid link
errors
.
append
(
'%s: %s'
%
(
match
,
str
(
e
)))
pass
if
len
(
notrecognized
)
>
0
:
raise
ValidationError
(
'%s
\
n
%s'
%
(
(
_
(
'Format of %d matched files could not be recognized.'
)
%
len
(
notrecognized
)),
'
\
n
'
.
join
(
notrecognized
)
))
if
len
(
errors
)
>
0
:
raise
ValidationError
(
'%s
\
n
%s'
%
(
(
_
(
'Failed to parse %d matched files!'
)
%
len
(
errors
)),
'
\
n
'
.
join
(
errors
)
))
# Validate template
if
self
.
has_template
():
self
.
clean_template
()
def
get_template_filename
(
self
):
def
get_template_filename
(
self
):
'''
'''
...
...
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