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
fdf98661
Commit
fdf98661
authored
Nov 08, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify command line processing
parent
d8c55c00
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
46 additions
and
59 deletions
+46
-59
weblate/trans/management/commands/__init__.py
weblate/trans/management/commands/__init__.py
+32
-45
weblate/trans/management/commands/checkgit.py
weblate/trans/management/commands/checkgit.py
+2
-2
weblate/trans/management/commands/commitgit.py
weblate/trans/management/commands/commitgit.py
+2
-2
weblate/trans/management/commands/loadpo.py
weblate/trans/management/commands/loadpo.py
+3
-3
weblate/trans/management/commands/rebuild_index.py
weblate/trans/management/commands/rebuild_index.py
+3
-3
weblate/trans/management/commands/updatechecks.py
weblate/trans/management/commands/updatechecks.py
+2
-2
weblate/trans/management/commands/updategit.py
weblate/trans/management/commands/updategit.py
+2
-2
No files found.
weblate/trans/management/commands/__init__.py
View file @
fdf98661
...
@@ -22,9 +22,9 @@ from django.core.management.base import BaseCommand
...
@@ -22,9 +22,9 @@ from django.core.management.base import BaseCommand
from
optparse
import
make_option
from
optparse
import
make_option
from
weblate.trans.models
import
Unit
,
SubProject
from
weblate.trans.models
import
Unit
,
SubProject
class
Unit
Command
(
BaseCommand
):
class
Weblate
Command
(
BaseCommand
):
'''
'''
Command which accepts project/subproject/--all params to process
units
.
Command which accepts project/subproject/--all params to process.
'''
'''
args
=
'<project/subproject>'
args
=
'<project/subproject>'
option_list
=
BaseCommand
.
option_list
+
(
option_list
=
BaseCommand
.
option_list
+
(
...
@@ -32,62 +32,49 @@ class UnitCommand(BaseCommand):
...
@@ -32,62 +32,49 @@ class UnitCommand(BaseCommand):
action
=
'store_true'
,
action
=
'store_true'
,
dest
=
'all'
,
dest
=
'all'
,
default
=
False
,
default
=
False
,
help
=
'
work on all
projects'
),
help
=
'
process all sub
projects'
),
)
)
def
get_units
(
self
,
*
args
,
**
options
):
def
get_units
(
self
,
*
args
,
**
options
):
'''
'''
Returns list of units matching parameters.
Returns list of units matching parameters.
'''
'''
if
options
[
'all'
]:
subprojects
=
self
.
get_subprojects
(
*
args
,
**
options
)
base
=
Unit
.
objects
.
all
()
return
Unit
.
objects
.
filter
(
translation__subproject__in
=
subprojects
)
else
:
base
=
Unit
.
objects
.
none
()
for
arg
in
args
:
parts
=
arg
.
split
(
'/'
)
if
len
(
parts
)
==
2
:
prj
,
subprj
=
parts
base
|=
Unit
.
objects
.
filter
(
translation__subproject__slug
=
subprj
,
translation__subproject__project__slug
=
prj
)
else
:
prj
=
parts
[
0
]
base
|=
Unit
.
objects
.
filter
(
translation__subproject__project__slug
=
prj
)
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
):
def
get_subprojects
(
self
,
*
args
,
**
options
):
'''
'''
Returns list of units matching parameters.
Returns list of units matching parameters.
'''
'''
if
options
[
'all'
]:
if
options
[
'all'
]:
base
=
SubProject
.
objects
.
all
()
# all subprojects
result
=
SubProject
.
objects
.
all
()
elif
len
(
args
)
==
0
:
# no argumets to filter projects
print
'WARNING: nothing to process, please use either --all or <project/subproject>'
result
=
SubProject
.
objects
.
none
()
else
:
else
:
base
=
SubProject
.
objects
.
none
()
# start with none and add found
result
=
SubProject
.
objects
.
none
()
# process arguments
for
arg
in
args
:
for
arg
in
args
:
# do we have also subproject?
parts
=
arg
.
split
(
'/'
)
parts
=
arg
.
split
(
'/'
)
# filter by project
found
=
SubProject
.
objects
.
filter
(
project__slug
=
parts
[
0
])
# filter by subproject if available
if
len
(
parts
)
==
2
:
if
len
(
parts
)
==
2
:
prj
,
subprj
=
parts
found
=
found
.
filter
(
project__slug
=
parts
[
1
])
base
|=
SubProject
.
objects
.
filter
(
slug
=
subprj
,
project__slug
=
prj
)
else
:
# warn on no match
prj
=
parts
[
0
]
if
found
.
count
()
==
0
:
base
|=
SubProject
.
objects
.
filter
(
project__slug
=
prj
)
print
'WARNING: "%s" did not match any subproject'
%
arg
if
len
(
args
)
==
0
or
base
.
count
()
==
0
:
print
'Nothing to process, please use either --all or <project/subproject>'
# merge results
return
base
result
|=
found
return
result
weblate/trans/management/commands/checkgit.py
View file @
fdf98661
...
@@ -18,9 +18,9 @@
...
@@ -18,9 +18,9 @@
# 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
weblate.trans.management.commands
import
SubProject
Command
from
weblate.trans.management.commands
import
Weblate
Command
class
Command
(
SubProject
Command
):
class
Command
(
Weblate
Command
):
help
=
'checks status of git repo'
help
=
'checks status of git repo'
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
...
...
weblate/trans/management/commands/commitgit.py
View file @
fdf98661
...
@@ -18,9 +18,9 @@
...
@@ -18,9 +18,9 @@
# 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
weblate.trans.management.commands
import
SubProject
Command
from
weblate.trans.management.commands
import
Weblate
Command
class
Command
(
SubProject
Command
):
class
Command
(
Weblate
Command
):
help
=
'forces commiting changes to git repo'
help
=
'forces commiting changes to git repo'
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
...
...
weblate/trans/management/commands/loadpo.py
View file @
fdf98661
...
@@ -18,12 +18,12 @@
...
@@ -18,12 +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
weblate.trans.management.commands
import
SubProject
Command
from
weblate.trans.management.commands
import
Weblate
Command
from
optparse
import
make_option
from
optparse
import
make_option
class
Command
(
SubProject
Command
):
class
Command
(
Weblate
Command
):
help
=
'(re)loads translations from disk'
help
=
'(re)loads translations from disk'
option_list
=
SubProject
Command
.
option_list
+
(
option_list
=
Weblate
Command
.
option_list
+
(
make_option
(
'--force'
,
make_option
(
'--force'
,
action
=
'store_true'
,
action
=
'store_true'
,
dest
=
'force'
,
dest
=
'force'
,
...
...
weblate/trans/management/commands/rebuild_index.py
View file @
fdf98661
...
@@ -18,15 +18,15 @@
...
@@ -18,15 +18,15 @@
# 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
weblate.trans.management.commands
import
Unit
Command
from
weblate.trans.management.commands
import
Weblate
Command
from
weblate.trans.models
import
Unit
from
weblate.trans.models
import
Unit
from
weblate.lang.models
import
Language
from
weblate.lang.models
import
Language
from
weblate.trans.search
import
FULLTEXT_INDEX
,
create_source_index
,
create_target_index
from
weblate.trans.search
import
FULLTEXT_INDEX
,
create_source_index
,
create_target_index
from
optparse
import
make_option
from
optparse
import
make_option
class
Command
(
Unit
Command
):
class
Command
(
Weblate
Command
):
help
=
'rebuilds index for fulltext search'
help
=
'rebuilds index for fulltext search'
option_list
=
Unit
Command
.
option_list
+
(
option_list
=
Weblate
Command
.
option_list
+
(
make_option
(
'--clean'
,
make_option
(
'--clean'
,
action
=
'store_true'
,
action
=
'store_true'
,
dest
=
'clean'
,
dest
=
'clean'
,
...
...
weblate/trans/management/commands/updatechecks.py
View file @
fdf98661
...
@@ -18,9 +18,9 @@
...
@@ -18,9 +18,9 @@
# 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
weblate.trans.management.commands
import
Unit
Command
from
weblate.trans.management.commands
import
Weblate
Command
class
Command
(
Unit
Command
):
class
Command
(
Weblate
Command
):
help
=
'updates checks for units'
help
=
'updates checks for units'
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
...
...
weblate/trans/management/commands/updategit.py
View file @
fdf98661
...
@@ -18,9 +18,9 @@
...
@@ -18,9 +18,9 @@
# 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
weblate.trans.management.commands
import
SubProject
Command
from
weblate.trans.management.commands
import
Weblate
Command
class
Command
(
SubProject
Command
):
class
Command
(
Weblate
Command
):
help
=
'updates git repos'
help
=
'updates git repos'
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
...
...
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