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
fce20aca
Commit
fce20aca
authored
Mar 03, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move options processing and validation to separate method
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
954a0e0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
23 deletions
+27
-23
weblate/trans/management/commands/import_project.py
weblate/trans/management/commands/import_project.py
+27
-23
No files found.
weblate/trans/management/commands/import_project.py
View file @
fce20aca
...
...
@@ -217,23 +217,8 @@ class Command(BaseCommand):
'Failed to find suitable name for {0}'
.
format
(
name
)
)
def
handle
(
self
,
*
args
,
**
options
):
'''
Automatic import of project.
'''
# Check params
if
len
(
args
)
!=
4
:
raise
CommandError
(
'Invalid number of parameters!'
)
if
options
[
'file_format'
]
not
in
FILE_FORMATS
:
raise
CommandError
(
'Invalid file format: %s'
%
options
[
'file_format'
]
)
# Read params
repo
=
args
[
1
]
branch
=
args
[
2
]
def
parse_options
(
self
,
args
,
options
):
"""Parses parameters"""
self
.
filemask
=
args
[
3
]
self
.
vcs
=
options
[
'vcs'
]
self
.
file_format
=
options
[
'file_format'
]
...
...
@@ -260,13 +245,10 @@ class Command(BaseCommand):
'Component regullar expression lacks named group "name"'
)
# Try to get project
try
:
project
=
Project
.
objects
.
get
(
slug
=
args
[
0
])
except
Project
.
DoesNotExist
:
# Is file format supported?
if
self
.
file_format
not
in
FILE_FORMATS
:
raise
CommandError
(
'Project %s does not exist, you need to create it first!'
%
args
[
0
]
'Invalid file format: %s'
%
options
[
'file_format'
]
)
# Do we have correct mask?
...
...
@@ -276,6 +258,28 @@ class Command(BaseCommand):
'for subproject part of the match!'
)
def
handle
(
self
,
*
args
,
**
options
):
'''
Automatic import of project.
'''
# Check params count
if
len
(
args
)
!=
4
:
raise
CommandError
(
'Invalid number of parameters!'
)
# Read params
repo
=
args
[
1
]
branch
=
args
[
2
]
self
.
parse_options
(
args
,
options
)
# Try to get project
try
:
project
=
Project
.
objects
.
get
(
slug
=
args
[
0
])
except
Project
.
DoesNotExist
:
raise
CommandError
(
'Project %s does not exist, you need to create it first!'
%
args
[
0
]
)
if
is_repo_link
(
repo
):
sharedrepo
=
repo
try
:
...
...
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