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
0c055d7a
Commit
0c055d7a
authored
Nov 08, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unifiy params handling for subproject based commands
parent
95227ec0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
73 deletions
+49
-73
weblate/trans/management/commands/__init__.py
weblate/trans/management/commands/__init__.py
+35
-2
weblate/trans/management/commands/checkgit.py
weblate/trans/management/commands/checkgit.py
+3
-20
weblate/trans/management/commands/commitgit.py
weblate/trans/management/commands/commitgit.py
+3
-18
weblate/trans/management/commands/loadpo.py
weblate/trans/management/commands/loadpo.py
+4
-8
weblate/trans/management/commands/updategit.py
weblate/trans/management/commands/updategit.py
+4
-25
No files found.
weblate/trans/management/commands/__init__.py
View file @
0c055d7a
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
from
django.core.management.base
import
BaseCommand
from
django.core.management.base
import
BaseCommand
from
optparse
import
make_option
from
optparse
import
make_option
from
weblate.trans.models
import
Unit
from
weblate.trans.models
import
Unit
,
SubProject
class
UnitCommand
(
BaseCommand
):
class
UnitCommand
(
BaseCommand
):
'''
'''
...
@@ -54,7 +54,40 @@ class UnitCommand(BaseCommand):
...
@@ -54,7 +54,40 @@ class UnitCommand(BaseCommand):
else
:
else
:
prj
=
parts
[
0
]
prj
=
parts
[
0
]
base
|=
Unit
.
objects
.
filter
(
translation__subproject__project__slug
=
prj
)
base
|=
Unit
.
objects
.
filter
(
translation__subproject__project__slug
=
prj
)
else
:
if
len
(
args
)
==
0
or
base
.
count
()
==
0
:
print
'Nothing to process, please use either --all or <project/subproject>'
return
base
class
SubProjectCommand
(
BaseCommand
):
'''
Command which accepts project/subproject/--all params to process subprojects.
'''
args
=
'<project/subproject>'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--all'
,
action
=
'store_true'
,
dest
=
'all'
,
default
=
False
,
help
=
'work on all projects'
),
)
def
get_subprojects
(
self
,
*
args
,
**
options
):
'''
Returns list of units matching parameters.
'''
if
options
[
'all'
]:
base
=
SubProject
.
objects
.
all
()
else
:
base
=
SubProject
.
objects
.
none
()
for
arg
in
args
:
parts
=
arg
.
split
(
'/'
)
if
len
(
parts
)
==
2
:
prj
,
subprj
=
parts
base
|=
SubProject
.
objects
.
filter
(
slug
=
subprj
,
project__slug
=
prj
)
else
:
prj
=
parts
[
0
]
base
|=
SubProject
.
objects
.
filter
(
project__slug
=
prj
)
if
len
(
args
)
==
0
or
base
.
count
()
==
0
:
print
'Nothing to process, please use either --all or <project/subproject>'
print
'Nothing to process, please use either --all or <project/subproject>'
return
base
return
base
weblate/trans/management/commands/checkgit.py
View file @
0c055d7a
...
@@ -18,33 +18,16 @@
...
@@ -18,33 +18,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
from
django.core.management.base
import
BaseCommand
from
weblate.trans.management.commands
import
SubProjectCommand
from
weblate.trans.models
import
SubProject
from
optparse
import
make_option
class
Command
(
Base
Command
):
class
Command
(
SubProject
Command
):
help
=
'checks status of git repo'
help
=
'checks status of git repo'
args
=
'<project/subproject>'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--all'
,
action
=
'store_true'
,
dest
=
'all'
,
default
=
False
,
help
=
'Check all projects'
),
)
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
'''
'''
Shows status of git repository in given projects.
Shows status of git repository in given projects.
'''
'''
if
options
[
'all'
]:
for
s
in
self
.
get_subprojects
(
*
args
,
**
options
):
for
s
in
SubProject
.
objects
.
all
():
r
=
s
.
get_repo
()
print
'%s:'
%
s
print
r
.
git
.
status
()
for
arg
in
args
:
prj
,
subprj
=
arg
.
split
(
'/'
)
s
=
SubProject
.
objects
.
get
(
slug
=
subprj
,
project__slug
=
prj
)
r
=
s
.
get_repo
()
r
=
s
.
get_repo
()
print
'%s:'
%
s
print
'%s:'
%
s
print
r
.
git
.
status
()
print
r
.
git
.
status
()
...
...
weblate/trans/management/commands/commitgit.py
View file @
0c055d7a
...
@@ -18,31 +18,16 @@
...
@@ -18,31 +18,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
from
django.core.management.base
import
BaseCommand
from
weblate.trans.management.commands
import
SubProjectCommand
from
weblate.trans.models
import
SubProject
from
optparse
import
make_option
class
Command
(
Base
Command
):
class
Command
(
SubProject
Command
):
help
=
'forces commiting changes to git repo'
help
=
'forces commiting changes to git repo'
args
=
'<project/subproject>'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--all'
,
action
=
'store_true'
,
dest
=
'all'
,
default
=
False
,
help
=
'Check all projects'
),
)
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
'''
'''
Commits pending translations in given projects.
Commits pending translations in given projects.
'''
'''
if
options
[
'all'
]:
for
s
in
self
.
get_subprojects
(
*
args
,
**
options
):
for
s
in
SubProject
.
objects
.
all
():
s
.
commit_pending
()
for
arg
in
args
:
prj
,
subprj
=
arg
.
split
(
'/'
)
s
=
SubProject
.
objects
.
get
(
slug
=
subprj
,
project__slug
=
prj
)
s
.
commit_pending
()
s
.
commit_pending
()
...
...
weblate/trans/management/commands/loadpo.py
View file @
0c055d7a
...
@@ -18,14 +18,12 @@
...
@@ -18,14 +18,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
from
django.core.management.base
import
BaseCommand
from
weblate.trans.management.commands
import
SubProjectCommand
from
weblate.trans.models
import
SubProject
from
optparse
import
make_option
from
optparse
import
make_option
class
Command
(
Base
Command
):
class
Command
(
SubProject
Command
):
help
=
'(re)loads translations from disk'
help
=
'(re)loads translations from disk'
args
=
'<project/subproject>'
option_list
=
SubProjectCommand
.
option_list
+
(
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--force'
,
make_option
(
'--force'
,
action
=
'store_true'
,
action
=
'store_true'
,
dest
=
'force'
,
dest
=
'force'
,
...
@@ -45,7 +43,5 @@ class Command(BaseCommand):
...
@@ -45,7 +43,5 @@ class Command(BaseCommand):
langs
=
None
langs
=
None
if
options
[
'lang'
]
is
not
None
:
if
options
[
'lang'
]
is
not
None
:
langs
=
options
[
'lang'
].
split
(
','
)
langs
=
options
[
'lang'
].
split
(
','
)
for
arg
in
args
:
for
s
in
self
.
get_subprojects
(
*
args
,
**
options
):
prj
,
subprj
=
arg
.
split
(
'/'
)
s
=
SubProject
.
objects
.
get
(
slug
=
subprj
,
project__slug
=
prj
)
s
.
create_translations
(
options
[
'force'
],
langs
)
s
.
create_translations
(
options
[
'force'
],
langs
)
weblate/trans/management/commands/updategit.py
View file @
0c055d7a
...
@@ -18,32 +18,11 @@
...
@@ -18,32 +18,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
from
django.core.management.base
import
BaseCommand
from
weblate.trans.management.commands
import
SubProjectCommand
from
weblate.trans.models
import
SubProject
,
Project
from
optparse
import
make_option
class
Command
(
Base
Command
):
class
Command
(
SubProject
Command
):
help
=
'updates git repos'
help
=
'updates git repos'
args
=
'<project/subproject>'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--all'
,
action
=
'store_true'
,
dest
=
'all'
,
default
=
False
,
help
=
'Update all projects'
),
)
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
if
options
[
'all'
]:
for
s
in
self
.
get_subprojects
(
*
args
,
**
options
):
for
s
in
SubProject
.
objects
.
all
():
s
.
do_update
()
s
.
do_update
()
for
arg
in
args
:
parts
=
arg
.
split
(
'/'
)
if
len
(
parts
)
==
2
:
prj
,
subprj
=
parts
s
=
SubProject
.
objects
.
get
(
slug
=
subprj
,
project__slug
=
prj
)
s
.
do_update
()
else
:
p
=
Project
.
objects
.
get
(
slug
=
parts
[
0
])
p
.
do_update
()
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