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
30927737
Commit
30927737
authored
Mar 12, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move checksum calculation to Unit class
parent
00e58d18
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
trans/formats.py
trans/formats.py
+12
-0
trans/models/unit.py
trans/models/unit.py
+2
-3
No files found.
trans/formats.py
View file @
30927737
...
...
@@ -27,6 +27,7 @@ from translate.storage import factory
from
trans.util
import
get_source
,
get_string
from
translate.misc
import
quote
import
re
import
hashlib
import
importlib
import
__builtin__
...
...
@@ -145,6 +146,17 @@ class FileUnit(object):
return
self
.
mainunit
.
getid
()
return
context
def
get_checksum
(
self
):
'''
Returns checksum of source string, used for quick lookup.
We use MD5 as it is faster than SHA1.
'''
md5
=
hashlib
.
md5
()
md5
.
update
(
self
.
get_source
().
encode
(
'utf-8'
))
md5
.
update
(
self
.
get_context
().
encode
(
'utf-8'
))
return
md5
.
hexdigest
()
def
is_translated
(
self
):
'''
Checks whether unit is translated.
...
...
trans/models/unit.py
View file @
30927737
...
...
@@ -48,11 +48,10 @@ class UnitManager(models.Manager):
'''
Process translation toolkit unit and stores/updates database entry.
'''
# Get basic unit data
src
=
unit
.
get_source
()
ctx
=
unit
.
get_context
()
# TODO: move to unit
checksum
=
msg_checksum
(
src
,
ctx
)
checksum
=
unit
.
get_checksum
()
# Try getting existing unit
dbunit
=
None
...
...
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