Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pipeline
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-pipeline
Commits
2c6d0634
Commit
2c6d0634
authored
Nov 14, 2008
by
Sander Smits
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved md5 versioning to hash/__init__.py
added sha1 versioning to hash versioning
parent
efd2e5d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
21 deletions
+30
-21
compress/versioning/hash/__init__.py
+30
-21
No files found.
compress/versioning/
md5
/__init__.py
→
compress/versioning/
hash
/__init__.py
View file @
2c6d0634
import
cStringIO
import
md5
from
hashlib
import
md5
,
sha1
import
os
from
compress.conf
import
settings
from
compress.utils
import
concat
,
get_output_filename
from
compress.versioning.base
import
VersioningBase
def
get_md5
(
f
,
CHUNK
=
2
**
16
):
m
=
md5
.
new
()
while
1
:
chunk
=
f
.
read
(
CHUNK
)
if
not
chunk
:
break
m
.
update
(
chunk
)
return
m
.
hexdigest
()
class
MD5Versioning
(
VersioningBase
):
class
HashVersioningBase
(
VersioningBase
):
def
__init__
(
self
,
hash_method
):
self
.
hash_method
=
hash_method
def
get_version
(
self
,
source_files
):
buf
=
concat
(
source_files
)
s
=
cStringIO
.
StringIO
(
buf
)
version
=
get_md5
(
s
)
s
.
close
()
return
version
def
needs_update
(
self
,
output_file
,
source_files
,
version
):
output_file_name
=
get_output_filename
(
output_file
,
version
)
ph
=
settings
.
COMPRESS_VERSION_PLACEHOLDER
...
...
@@ -35,4 +20,28 @@ class MD5Versioning(VersioningBase):
return
(
version
!=
old_version
),
version
except
ValueError
:
# no placeholder found, do not update, manual update if needed
return
False
,
version
\ No newline at end of file
return
False
,
version
def
get_version
(
self
,
source_files
):
buf
=
concat
(
source_files
)
s
=
cStringIO
.
StringIO
(
buf
)
version
=
self
.
get_hash
(
s
)
s
.
close
()
return
version
def
get_hash
(
self
,
f
,
CHUNK
=
2
**
16
):
m
=
self
.
hash_method
()
while
1
:
chunk
=
f
.
read
(
CHUNK
)
if
not
chunk
:
break
m
.
update
(
chunk
)
return
m
.
hexdigest
()
class
MD5Versioning
(
HashVersioningBase
):
def
__init__
(
self
):
super
(
MD5Versioning
,
self
)
.
__init__
(
md5
)
class
SHA1Versioning
(
HashVersioningBase
):
def
__init__
(
self
):
super
(
SHA1Versioning
,
self
)
.
__init__
(
sha1
)
\ No newline at end of file
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