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
9f9b0abd
Commit
9f9b0abd
authored
Apr 19, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid using deprecated interface for positional args in commands
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
6270b71f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
19 deletions
+27
-19
weblate/accounts/management/commands/dumpuserdata.py
weblate/accounts/management/commands/dumpuserdata.py
+9
-6
weblate/accounts/management/commands/importuserdata.py
weblate/accounts/management/commands/importuserdata.py
+10
-7
weblate/accounts/management/commands/importusers.py
weblate/accounts/management/commands/importusers.py
+1
-1
weblate/lang/management/commands/checklang.py
weblate/lang/management/commands/checklang.py
+7
-5
No files found.
weblate/accounts/management/commands/dumpuserdata.py
View file @
9f9b0abd
...
...
@@ -20,23 +20,26 @@
import
json
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.base
import
BaseCommand
from
weblate.accounts.models
import
Profile
class
Command
(
BaseCommand
):
help
=
'dumps user data to JSON file'
args
=
'<json-file>'
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'json-file'
,
type
=
argparse
.
FileType
(
'w'
),
help
=
'File where to export'
,
)
def
handle
(
self
,
*
args
,
**
options
):
'''
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 create!'
)
data
=
[]
fields
=
(
'language'
,
...
...
@@ -72,4 +75,4 @@ class Command(BaseCommand):
data
.
append
(
item
)
json
.
dump
(
data
,
op
en
(
args
[
0
],
'w'
)
,
indent
=
2
)
json
.
dump
(
data
,
op
tions
[
'json-file'
]
,
indent
=
2
)
weblate/accounts/management/commands/importuserdata.py
View file @
9f9b0abd
...
...
@@ -20,7 +20,7 @@
import
json
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
from
weblate.accounts.models
import
Profile
...
...
@@ -30,7 +30,13 @@ from weblate.trans.models import Project
class
Command
(
BaseCommand
):
help
=
'imports userdata from JSON dump of database'
args
=
'<json-file>'
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'json-file'
,
type
=
argparse
.
FileType
(
'r'
),
help
=
'File to import'
,
)
def
import_subscriptions
(
self
,
profile
,
userprofile
):
"""
...
...
@@ -63,15 +69,12 @@ class Command(BaseCommand):
Language
.
objects
.
get
(
code
=
lang
)
)
def
handle
(
self
,
*
args
,
*
*
options
):
def
handle
(
self
,
**
options
):
'''
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!'
)
userdata
=
json
.
load
(
open
(
args
[
0
]))
userdata
=
json
.
load
(
options
[
'json-file'
])
for
userprofile
in
userdata
:
try
:
...
...
weblate/accounts/management/commands/importusers.py
View file @
9f9b0abd
...
...
@@ -38,7 +38,7 @@ class Command(BaseCommand):
)
parser
.
add_argument
(
'json-file'
,
type
=
argparse
.
FileType
(
'r
b
'
),
type
=
argparse
.
FileType
(
'r'
),
help
=
'File to import'
,
)
...
...
weblate/lang/management/commands/checklang.py
View file @
9f9b0abd
...
...
@@ -24,16 +24,18 @@ from weblate.lang.models import Language
class
Command
(
BaseCommand
):
help
=
'Checks language definitions against rst/csv file'
args
=
'<test-file>'
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'test-file'
,
help
=
'File to test'
,
)
def
handle
(
self
,
*
args
,
**
options
):
'''
Creates default set of languages, optionally updating them
to match current shipped definitions.
'''
if
len
(
args
)
!=
1
:
raise
CommandError
(
'Use: checklang file'
)
errors
=
Language
.
objects
.
check_definitions
(
args
[
0
])
errors
=
Language
.
objects
.
check_definitions
(
options
[
'test-file'
])
for
error
in
errors
:
self
.
stderr
.
write
(
error
)
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