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
fa41f13e
Commit
fa41f13e
authored
Apr 19, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid using deprecated optparse
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
5314c581
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
216 additions
and
200 deletions
+216
-200
weblate/accounts/management/commands/changesite.py
weblate/accounts/management/commands/changesite.py
+9
-11
weblate/accounts/management/commands/createadmin.py
weblate/accounts/management/commands/createadmin.py
+4
-5
weblate/accounts/management/commands/importusers.py
weblate/accounts/management/commands/importusers.py
+10
-8
weblate/accounts/management/commands/setupgroups.py
weblate/accounts/management/commands/setupgroups.py
+6
-8
weblate/lang/management/commands/setuplang.py
weblate/lang/management/commands/setuplang.py
+3
-6
weblate/settings_test.py
weblate/settings_test.py
+2
-1
weblate/trans/management/commands/__init__.py
weblate/trans/management/commands/__init__.py
+44
-31
weblate/trans/management/commands/add_suggestions.py
weblate/trans/management/commands/add_suggestions.py
+16
-16
weblate/trans/management/commands/auto_translate.py
weblate/trans/management/commands/auto_translate.py
+12
-17
weblate/trans/management/commands/benchmark.py
weblate/trans/management/commands/benchmark.py
+23
-15
weblate/trans/management/commands/commit_pending.py
weblate/trans/management/commands/commit_pending.py
+7
-8
weblate/trans/management/commands/import_project.py
weblate/trans/management/commands/import_project.py
+46
-35
weblate/trans/management/commands/list_ignored_checks.py
weblate/trans/management/commands/list_ignored_checks.py
+8
-9
weblate/trans/management/commands/loadpo.py
weblate/trans/management/commands/loadpo.py
+6
-7
weblate/trans/management/commands/pushgit.py
weblate/trans/management/commands/pushgit.py
+6
-7
weblate/trans/management/commands/rebuild_index.py
weblate/trans/management/commands/rebuild_index.py
+8
-9
weblate/trans/management/commands/update_index.py
weblate/trans/management/commands/update_index.py
+6
-7
No files found.
weblate/accounts/management/commands/changesite.py
View file @
fa41f13e
...
...
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.contrib.sites.models
import
Site
...
...
@@ -26,29 +25,28 @@ from django.contrib.sites.models import Site
class
Command
(
BaseCommand
):
help
=
'changes default site name'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--set-name'
,
type
=
'str'
,
dest
=
'set_name'
,
default
=
None
,
help
=
'site name to set'
)
,
make_option
(
)
parser
.
add_argument
(
'--site-id'
,
type
=
'int'
,
type
=
int
,
dest
=
'site_id'
,
default
=
1
,
help
=
'site ID to manipulate (1 by default)'
)
,
make_option
(
)
parser
.
add_argument
(
'--get-name'
,
action
=
'store_true'
,
dest
=
'get_name'
,
default
=
False
,
help
=
'just display the site name'
),
)
)
def
handle
(
self
,
*
args
,
**
options
):
if
options
[
'set_name'
]:
...
...
weblate/accounts/management/commands/createadmin.py
View file @
fa41f13e
...
...
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
import
random
import
string
...
...
@@ -28,14 +27,14 @@ from django.contrib.auth.models import User
class
Command
(
BaseCommand
):
help
=
'setups admin user with random password'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--password'
,
dest
=
'password'
,
default
=
None
,
help
=
'Password to set, random is generated if not specified'
),
)
)
@
staticmethod
def
make_password
(
length
):
...
...
weblate/accounts/management/commands/importusers.py
View file @
fa41f13e
...
...
@@ -20,7 +20,7 @@
from
__future__
import
unicode_literals
from
optparse
import
make_option
import
argparse
import
json
from
django.core.management.base
import
BaseCommand
,
CommandError
...
...
@@ -29,13 +29,17 @@ from django.contrib.auth.models import User
class
Command
(
BaseCommand
):
help
=
'imports users from JSON dump of database'
args
=
'<json-file>'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--check'
,
action
=
'store_true'
,
help
=
'Only check import, do not actually create users'
),
)
parser
.
add_argument
(
'json-file'
,
type
=
argparse
.
FileType
(
'rb'
),
help
=
'File to import'
,
)
def
handle
(
self
,
*
args
,
**
options
):
...
...
@@ -43,10 +47,8 @@ class Command(BaseCommand):
Creates default set of groups and optionally updates them and moves
users around to default group.
'''
if
len
(
args
)
!=
1
:
raise
CommandError
(
'Please specify JSON file to import!'
)
data
=
json
.
load
(
op
en
(
args
[
0
])
)
data
=
json
.
load
(
op
tions
[
'json-file'
]
)
for
line
in
data
:
if
'fields'
in
line
:
...
...
weblate/accounts/management/commands/setupgroups.py
View file @
fa41f13e
...
...
@@ -18,8 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
from
django.core.management.base
import
BaseCommand
from
weblate.accounts.models
import
create_groups
,
move_users
...
...
@@ -27,22 +25,22 @@ from weblate.accounts.models import create_groups, move_users
class
Command
(
BaseCommand
):
help
=
'setups default user groups'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--move'
,
action
=
'store_true'
,
dest
=
'move'
,
default
=
False
,
help
=
'Move all users to Users group'
)
,
make_option
(
)
parser
.
add_argument
(
'--no-privs-update'
,
action
=
'store_false'
,
dest
=
'update'
,
default
=
True
,
help
=
'Prevents updates of privileges of existing groups'
),
)
)
def
handle
(
self
,
*
args
,
**
options
):
'''
...
...
weblate/lang/management/commands/setuplang.py
View file @
fa41f13e
...
...
@@ -18,8 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
from
django.core.management.base
import
BaseCommand
from
weblate.lang.models
import
Language
...
...
@@ -28,15 +26,14 @@ from weblate.lang.models import Language
class
Command
(
BaseCommand
):
help
=
'Populates language definitions'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--no-update'
,
action
=
'store_false'
,
dest
=
'update'
,
default
=
True
,
help
=
'Prevents updates to existing language definitions'
),
)
)
def
handle
(
self
,
*
args
,
**
options
):
'''
...
...
weblate/settings_test.py
View file @
fa41f13e
...
...
@@ -22,10 +22,11 @@
# Django settings for running testsuite
#
from
weblate.settings_example
import
*
import
warnings
import
os
from
weblate.settings_example
import
*
if
'CI_DATABASE'
in
os
.
environ
:
if
os
.
environ
[
'CI_DATABASE'
]
==
'mysql'
:
DATABASES
[
'default'
][
'ENGINE'
]
=
'django.db.backends.mysql'
...
...
weblate/trans/management/commands/__init__.py
View file @
fa41f13e
...
...
@@ -21,8 +21,6 @@
Helper classes for management commands.
'''
from
optparse
import
make_option
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.db
import
transaction
...
...
@@ -33,32 +31,35 @@ class WeblateCommand(BaseCommand):
'''
Command which accepts project/component/--all params to process.
'''
args
=
'<project/component>'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--all'
,
action
=
'store_true'
,
dest
=
'all'
,
default
=
False
,
help
=
'process all components'
),
)
)
parser
.
add_argument
(
'component'
,
nargs
=
'*'
,
help
=
'Slug <project/component> of component to process'
)
def
get_units
(
self
,
*
args
,
*
*
options
):
def
get_units
(
self
,
**
options
):
'''
Returns list of units matching parameters.
'''
if
options
[
'all'
]:
return
Unit
.
objects
.
all
()
return
Unit
.
objects
.
filter
(
translation__subproject__in
=
self
.
get_subprojects
(
*
args
,
*
*
options
)
translation__subproject__in
=
self
.
get_subprojects
(
**
options
)
)
def
iterate_units
(
self
,
*
args
,
*
*
options
):
def
iterate_units
(
self
,
**
options
):
"""
Memory effective iteration over units.
"""
units
=
self
.
get_units
(
*
args
,
*
*
options
).
order_by
(
'pk'
)
units
=
self
.
get_units
(
**
options
).
order_by
(
'pk'
)
count
=
units
.
count
()
if
not
count
:
return
...
...
@@ -87,25 +88,25 @@ class WeblateCommand(BaseCommand):
yield
unit
self
.
stdout
.
write
(
'Operation completed'
)
def
get_translations
(
self
,
*
args
,
*
*
options
):
def
get_translations
(
self
,
**
options
):
'''
Returns list of translations matching parameters.
'''
return
Translation
.
objects
.
filter
(
subproject__in
=
self
.
get_subprojects
(
*
args
,
*
*
options
)
subproject__in
=
self
.
get_subprojects
(
**
options
)
)
def
get_subprojects
(
self
,
*
args
,
*
*
options
):
def
get_subprojects
(
self
,
**
options
):
'''
Returns list of components matching parameters.
'''
if
options
[
'all'
]:
# all components
result
=
SubProject
.
objects
.
all
()
elif
len
(
args
)
==
0
:
elif
len
(
options
[
'component'
]
)
==
0
:
# no argumets to filter projects
self
.
stderr
.
write
(
'Please specify either --all or <project/component>'
'Please specify either --all or
at least one
<project/component>'
)
raise
CommandError
(
'Nothing to process!'
)
else
:
...
...
@@ -113,7 +114,7 @@ class WeblateCommand(BaseCommand):
result
=
SubProject
.
objects
.
none
()
# process arguments
for
arg
in
args
:
for
arg
in
options
[
'component'
]
:
# do we have also component?
parts
=
arg
.
split
(
'/'
)
...
...
@@ -150,22 +151,21 @@ class WeblateLangCommand(WeblateCommand):
Command accepting additional language parameter to filter
list of languages to process.
'''
option_list
=
WeblateCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
WeblateLangCommand
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--lang'
,
action
=
'store'
,
type
=
'string'
,
dest
=
'lang'
,
default
=
None
,
help
=
'Limit only to given languages (comma separated list)'
),
)
)
def
get_units
(
self
,
*
args
,
*
*
options
):
def
get_units
(
self
,
**
options
):
'''
Returns list of units matching parameters.
'''
units
=
super
(
WeblateLangCommand
,
self
).
get_units
(
*
args
,
*
*
options
)
units
=
super
(
WeblateLangCommand
,
self
).
get_units
(
**
options
)
if
options
[
'lang'
]
is
not
None
:
units
=
units
.
filter
(
...
...
@@ -174,12 +174,12 @@ class WeblateLangCommand(WeblateCommand):
return
units
def
get_translations
(
self
,
*
args
,
*
*
options
):
def
get_translations
(
self
,
**
options
):
'''
Returns list of translations matching parameters.
'''
result
=
super
(
WeblateLangCommand
,
self
).
get_translations
(
*
args
,
*
*
options
**
options
)
if
options
[
'lang'
]
is
not
None
:
...
...
@@ -199,15 +199,28 @@ class WeblateLangCommand(WeblateCommand):
class
WeblateTranslationCommand
(
BaseCommand
):
"""Command with target of one translation."""
args
=
'<project> <component> <language>'
def
get_translation
(
self
,
args
):
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'project'
,
help
=
'Slug of project'
)
parser
.
add_argument
(
'component'
,
help
=
'Slug of component'
)
parser
.
add_argument
(
'language'
,
help
=
'Slug of language'
)
def
get_translation
(
self
,
**
options
):
"""Get translation object"""
try
:
return
Translation
.
objects
.
get
(
subproject__project__slug
=
args
[
0
],
subproject__slug
=
args
[
1
],
language__code
=
args
[
2
],
subproject__project__slug
=
options
[
'project'
],
subproject__slug
=
options
[
'component'
],
language__code
=
options
[
'language'
],
)
except
Translation
.
DoesNotExist
:
raise
CommandError
(
'No matching translation project found!'
)
...
...
weblate/trans/management/commands/add_suggestions.py
View file @
fa41f13e
...
...
@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
import
argparse
from
django.core.management.base
import
CommandError
from
django.contrib.auth.models
import
User
...
...
@@ -33,24 +33,25 @@ class Command(WeblateTranslationCommand):
Command for mass importing suggestions.
"""
help
=
'imports suggestions'
args
=
'<project> <component> <language> <file>'
option_list
=
WeblateTranslationCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
Command
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--author'
,
default
=
'noreply@weblate.org'
,
help
=
(
'Email address of author (has to be registered in Weblate)'
)
),
)
)
parser
.
add_argument
(
'file'
,
type
=
argparse
.
FileType
(
'rb'
),
help
=
'File to import'
,
)
def
handle
(
self
,
*
args
,
**
options
):
# Check params
if
len
(
args
)
!=
4
:
raise
CommandError
(
'Invalid number of parameters!'
)
# Get translation object
translation
=
self
.
get_translation
(
arg
s
)
translation
=
self
.
get_translation
(
**
option
s
)
# Get user
try
:
...
...
@@ -64,10 +65,9 @@ class Command(WeblateTranslationCommand):
# Process import
try
:
with
open
(
args
[
3
],
'rb'
)
as
handle
:
translation
.
merge_upload
(
request
,
handle
,
False
,
method
=
'suggest'
,
author
=
get_author_name
(
user
),
)
translation
.
merge_upload
(
request
,
options
[
'file'
],
False
,
method
=
'suggest'
,
author
=
get_author_name
(
user
),
)
except
IOError
:
raise
CommandError
(
'Failed to import translation file!'
)
weblate/trans/management/commands/auto_translate.py
View file @
fa41f13e
...
...
@@ -18,8 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
from
django.core.management.base
import
CommandError
from
django.contrib.auth.models
import
User
...
...
@@ -33,46 +31,43 @@ class Command(WeblateTranslationCommand):
Command for mass automatic translation.
"""
help
=
'performs automatic translation based on other components'
option_list
=
WeblateTranslationCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
Command
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--user'
,
default
=
'anonymous'
,
help
=
(
'User performing the change'
)
)
,
make_option
(
)
parser
.
add_argument
(
'--source'
,
default
=
''
,
help
=
(
'Source component <project/component>'
)
)
,
make_option
(
)
parser
.
add_argument
(
'--overwrite'
,
default
=
False
,
action
=
'store_true'
,
help
=
(
'Overwrite existing translations in target component'
)
)
,
make_option
(
)
parser
.
add_argument
(
'--inconsistent'
,
default
=
False
,
action
=
'store_true'
,
help
=
(
'Process only inconsistent translations'
)
),
)
)
def
handle
(
self
,
*
args
,
**
options
):
# Check params
if
len
(
args
)
!=
3
:
raise
CommandError
(
'Invalid number of parameters!'
)
# Get translation object
translation
=
self
.
get_translation
(
arg
s
)
translation
=
self
.
get_translation
(
**
option
s
)
# Get user
try
:
...
...
weblate/trans/management/commands/benchmark.py
View file @
fa41f13e
...
...
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
import
cProfile
import
pstats
...
...
@@ -32,28 +31,37 @@ class Command(BaseCommand):
Runs simple project import to perform benchmarks.
'''
help
=
'performs import benchmark'
args
=
'<project> <repo> <mask>'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
Command
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--profile-sort'
,
type
=
'str'
,
dest
=
'profile_sort'
,
default
=
'cumulative'
,
help
=
'sort order for profile stats'
,
)
,
make_option
(
)
parser
.
add_argument
(
'--profile-count'
,
type
=
'int'
,
type
=
int
,
dest
=
'profile_count'
,
default
=
20
,
help
=
'number of profile stats to show'
,
),
)
)
parser
.
add_argument
(
'project'
,
help
=
'Existing project slug for tests'
,
)
parser
.
add_argument
(
'repo'
,
help
=
'VCS repository URL'
,
)
parser
.
add_argument
(
'mask'
,
help
=
'File mask'
,
)
def
handle
(
self
,
*
args
,
**
options
):
if
len
(
args
)
<
3
:
raise
CommandError
(
'Missing arguments!'
)
project
=
Project
.
objects
.
get
(
slug
=
args
[
0
])
project
=
Project
.
objects
.
get
(
slug
=
options
[
'project'
])
# Delete any possible previous tests
SubProject
.
objects
.
filter
(
project
=
project
,
...
...
@@ -64,8 +72,8 @@ class Command(BaseCommand):
SubProject
.
objects
.
create
,
name
=
'Benchmark'
,
slug
=
'benchmark'
,
repo
=
args
[
1
],
filemask
=
args
[
2
],
repo
=
options
[
'repo'
],
filemask
=
options
[
'mask'
],
project
=
project
)
stats
=
pstats
.
Stats
(
profiler
)
...
...
weblate/trans/management/commands/commit_pending.py
View file @
fa41f13e
...
...
@@ -19,8 +19,6 @@
#
from
datetime
import
timedelta
from
optparse
import
make_option
from
django.utils
import
timezone
from
weblate.trans.management.commands
import
WeblateLangCommand
...
...
@@ -28,22 +26,23 @@ from weblate.trans.management.commands import WeblateLangCommand
class
Command
(
WeblateLangCommand
):
help
=
'commits pending changes older than given age'
option_list
=
WeblateLangCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
Command
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--age'
,
action
=
'store'
,
type
=
'int'
,
type
=
int
,
dest
=
'age'
,
default
=
24
,
help
=
'Age of changes to commit in hours (default is 24 hours)'
),
)
)
def
handle
(
self
,
*
args
,
**
options
):
age
=
timezone
.
now
()
-
timedelta
(
hours
=
options
[
'age'
])
for
translation
in
self
.
get_translations
(
*
args
,
*
*
options
):
for
translation
in
self
.
get_translations
(
**
options
):
if
not
translation
.
repo_needs_commit
():
continue
...
...
weblate/trans/management/commands/import_project.py
View file @
fa41f13e
...
...
@@ -19,7 +19,6 @@
#
from
glob
import
glob
from
optparse
import
make_option
import
tempfile
import
os
import
re
...
...
@@ -43,45 +42,46 @@ class Command(BaseCommand):
Command for mass importing of repositories into Weblate.
"""
help
=
'imports projects with more components'
args
=
'<project> <gitrepo> <branch> <filemask>'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
Command
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--name-template'
,
default
=
'%s'
,
help
=
(
'Python formatting string, transforming the filemask '
'match to a project name'
)
)
,
make_option
(
)
parser
.
add_argument
(
'--component-regexp'
,
default
=
None
,
help
=
(
'Regular expression to match component out of filename'
)
)
,
make_option
(
)
parser
.
add_argument
(
'--base-file-template'
,
default
=
''
,
help
=
(
'Python formatting string, transforming the filemask '
'match to a monolingual base file name'
)
)
,
make_option
(
)
parser
.
add_argument
(
'--file-format'
,
default
=
'auto'
,
help
=
'File format type, defaults to autodetection'
,
)
,
make_option
(
)
parser
.
add_argument
(
'--language-regex'
,
default
=
None
,
help
=
(
'Language filter regular expression to be used for created'
' components'
),
)
,
make_option
(
)
parser
.
add_argument
(
'--no-skip-duplicates'
,
action
=
'store_true'
,
default
=
False
,
...
...
@@ -90,31 +90,46 @@ class Command(BaseCommand):
'Avoid skipping duplicate component names/slugs. '
'Use this if importing project with long names '
)
)
,
make_option
(
)
parser
.
add_argument
(
'--license'
,
default
=
None
,
help
=
'License of imported components'
,
)
,
make_option
(
)
parser
.
add_argument
(
'--license-url'
,
default
=
None
,
help
=
'License URL of imported components'
,
)
,
make_option
(
)
parser
.
add_argument
(
'--vcs'
,
default
=
'git'
,
help
=
'Version control system to use'
,
)
,
make_option
(
)
parser
.
add_argument
(
'--main-component'
,
default
=
None
,
help
=
(
'Define which component will be used as main - including full'
' VCS repository'
)
),
)
)
parser
.
add_argument
(
'project'
,
help
=
'Existing project slug'
,
)
parser
.
add_argument
(
'repo'
,
help
=
'VCS repository URL'
,
)
parser
.
add_argument
(
'branch'
,
help
=
'VCS repository branch'
,
)
parser
.
add_argument
(
'filemask'
,
help
=
'File mask'
,
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Command
,
self
).
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -219,9 +234,9 @@ class Command(BaseCommand):
'Failed to find suitable name for {0}'
.
format
(
name
)
)
def
parse_options
(
self
,
args
,
options
):
def
parse_options
(
self
,
options
):
"""Parses parameters"""
self
.
filemask
=
args
[
3
]
self
.
filemask
=
options
[
'filemask'
]
self
.
vcs
=
options
[
'vcs'
]
self
.
file_format
=
options
[
'file_format'
]
self
.
language_regex
=
options
[
'language_regex'
]
...
...
@@ -264,22 +279,18 @@ class Command(BaseCommand):
'''
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
)
repo
=
options
[
'repo'
]
branch
=
options
[
'branch'
]
self
.
parse_options
(
options
)
# Try to get project
try
:
project
=
Project
.
objects
.
get
(
slug
=
args
[
0
])
project
=
Project
.
objects
.
get
(
slug
=
options
[
'project'
])
except
Project
.
DoesNotExist
:
raise
CommandError
(
'Project %s does not exist, you need to create it first!'
%
args
[
0
]
options
[
'project'
]
)
if
is_repo_link
(
repo
):
...
...
weblate/trans/management/commands/list_ignored_checks.py
View file @
fa41f13e
...
...
@@ -18,8 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
from
django.core.management.base
import
BaseCommand
from
weblate.trans.models
import
Check
,
get_related_units
...
...
@@ -27,22 +25,23 @@ from weblate.trans.models import Check, get_related_units
class
Command
(
BaseCommand
):
help
=
'lists top ignored checks'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
Command
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--count'
,
type
=
'int'
,
type
=
int
,
dest
=
'count'
,
default
=
100
,
help
=
'Number of top checks to list'
,
)
,
make_option
(
)
parser
.
add_argument
(
'--list-all'
,
action
=
'store_true'
,
dest
=
'list_all'
,
default
=
False
,
help
=
'List all checks (not only ignored)'
,
),
)
)
def
handle
(
self
,
*
args
,
**
options
):
results
=
{}
...
...
weblate/trans/management/commands/loadpo.py
View file @
fa41f13e
...
...
@@ -18,26 +18,25 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
from
weblate.trans.management.commands
import
WeblateLangCommand
class
Command
(
WeblateLangCommand
):
help
=
'(re)loads translations from disk'
option_list
=
WeblateLangCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
Command
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--force'
,
action
=
'store_true'
,
dest
=
'force'
,
default
=
False
,
help
=
'Force rereading files even when they should be up to date'
),
)
)
def
handle
(
self
,
*
args
,
**
options
):
langs
=
None
if
options
[
'lang'
]
is
not
None
:
langs
=
options
[
'lang'
].
split
(
','
)
for
subproject
in
self
.
get_subprojects
(
*
args
,
*
*
options
):
for
subproject
in
self
.
get_subprojects
(
**
options
):
subproject
.
create_translations
(
options
[
'force'
],
langs
)
weblate/trans/management/commands/pushgit.py
View file @
fa41f13e
...
...
@@ -18,23 +18,22 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
from
weblate.trans.management.commands
import
WeblateCommand
class
Command
(
WeblateCommand
):
help
=
'pushes all changes to upstream respository'
option_list
=
WeblateCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
Command
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--force-commit'
,
action
=
'store_true'
,
dest
=
'force_commit'
,
default
=
False
,
help
=
'Forces commiting pending changes'
),
)
)
def
handle
(
self
,
*
args
,
**
options
):
for
subproject
in
self
.
get_subprojects
(
*
args
,
*
*
options
):
for
subproject
in
self
.
get_subprojects
(
**
options
):
subproject
.
do_push
(
None
,
force_commit
=
options
[
'force_commit'
])
weblate/trans/management/commands/rebuild_index.py
View file @
fa41f13e
...
...
@@ -18,8 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
from
weblate.trans.management.commands
import
WeblateCommand
from
weblate.trans.search
import
(
get_source_index
,
get_target_index
,
...
...
@@ -31,22 +29,23 @@ from weblate.lang.models import Language
class
Command
(
WeblateCommand
):
help
=
'rebuilds index for fulltext search'
option_list
=
WeblateCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
Command
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--clean'
,
action
=
'store_true'
,
dest
=
'clean'
,
default
=
False
,
help
=
'removes also all words from database'
)
,
make_option
(
)
parser
.
add_argument
(
'--optimize'
,
action
=
'store_true'
,
dest
=
'optimize'
,
default
=
False
,
help
=
'optimize index without rebuilding it'
),
)
)
def
optimize_index
(
self
):
"""Optimizes index structures"""
...
...
@@ -72,7 +71,7 @@ class Command(WeblateCommand):
try
:
# Process all units
for
unit
in
self
.
iterate_units
(
*
args
,
*
*
options
):
for
unit
in
self
.
iterate_units
(
**
options
):
lang
=
unit
.
translation
.
language
.
code
# Lazy open writer
if
lang
not
in
target_writers
:
...
...
weblate/trans/management/commands/update_index.py
View file @
fa41f13e
...
...
@@ -18,8 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
optparse
import
make_option
from
django.core.management.base
import
BaseCommand
from
django.db
import
transaction
...
...
@@ -29,16 +27,17 @@ from weblate.trans.search import update_index, delete_search_unit
class
Command
(
BaseCommand
):
help
=
'updates index for fulltext search'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
def
add_arguments
(
self
,
parser
):
super
(
Command
,
self
).
add_arguments
(
parser
)
parser
.
add_argument
(
'--limit'
,
action
=
'store'
,
type
=
'int'
,
type
=
int
,
dest
=
'limit'
,
default
=
1000
,
help
=
'number of updates to process in one run'
),
)
)
def
handle
(
self
,
*
args
,
**
options
):
self
.
do_update
(
options
[
'limit'
])
...
...
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