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
e4219b6e
Commit
e4219b6e
authored
Mar 20, 2013
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
3f5b29de
44b1d129
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
32 deletions
+28
-32
trans/checks/__init__.py
trans/checks/__init__.py
+2
-16
trans/machine/__init__.py
trans/machine/__init__.py
+2
-16
trans/util.py
trans/util.py
+24
-0
No files found.
trans/checks/__init__.py
View file @
e4219b6e
...
...
@@ -19,24 +19,10 @@
#
from
weblate
import
appsettings
from
django.core.exceptions
import
ImproperlyConfigured
from
trans.util
import
load_class
# Initialize checks list
CHECKS
=
{}
for
path
in
appsettings
.
CHECK_LIST
:
module
,
attr
=
path
.
rsplit
(
'.'
,
1
)
try
:
mod
=
__import__
(
module
,
{},
{},
[
attr
])
except
ImportError
as
e
:
raise
ImproperlyConfigured
(
'Error importing translation check module %s: "%s"'
%
(
module
,
e
)
)
try
:
cls
=
getattr
(
mod
,
attr
)
except
AttributeError
:
raise
ImproperlyConfigured
(
'Module "%s" does not define a "%s" callable check'
%
(
module
,
attr
)
)
cls
=
load_class
(
path
)
CHECKS
[
cls
.
check_id
]
=
cls
()
trans/machine/__init__.py
View file @
e4219b6e
...
...
@@ -19,24 +19,10 @@
#
from
weblate
import
appsettings
from
django.core.exceptions
import
ImproperlyConfigured
from
trans.util
import
load_class
# Initialize checks list
SERVICES
=
{}
for
path
in
appsettings
.
MACHINE_TRANSLATION_SERVICES
:
module
,
attr
=
path
.
rsplit
(
'.'
,
1
)
try
:
mod
=
__import__
(
module
,
{},
{},
[
attr
])
except
ImportError
as
e
:
raise
ImproperlyConfigured
(
'Error importing machine translation module %s: "%s"'
%
(
module
,
e
)
)
try
:
cls
=
getattr
(
mod
,
attr
)
except
AttributeError
:
raise
ImproperlyConfigured
(
'Module "%s" does not define a "%s" class'
%
(
module
,
attr
)
)
cls
=
load_class
(
path
)
SERVICES
[
cls
.
mtid
]
=
cls
()
trans/util.py
View file @
e4219b6e
...
...
@@ -19,11 +19,13 @@
#
import
hashlib
from
django.core.exceptions
import
ImproperlyConfigured
from
django.contrib.sites.models
import
Site
from
django.utils.translation
import
ugettext
as
_
from
django.utils.html
import
escape
from
django.utils.safestring
import
mark_safe
from
django.conf
import
settings
from
importlib
import
import_module
import
urllib
import
time
import
random
...
...
@@ -174,3 +176,25 @@ def sleep_while_git_locked():
Random sleep to perform when git repository is locked.
'''
time
.
sleep
(
random
.
random
()
*
2
)
def
load_class
(
name
):
'''
Imports module and creates class given by name in string.
'''
module
,
attr
=
name
.
rsplit
(
'.'
,
1
)
try
:
mod
=
import_module
(
module
)
except
ImportError
as
e
:
raise
ImproperlyConfigured
(
'Error importing module %s: "%s"'
%
(
module
,
e
)
)
try
:
cls
=
getattr
(
mod
,
attr
)
except
AttributeError
:
raise
ImproperlyConfigured
(
'Module "%s" does not define a "%s" class'
%
(
module
,
attr
)
)
return
cls
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