-
Notifications
You must be signed in to change notification settings - Fork 90
Attachments and configurable blobs #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
5918b2c
move dj.config into settings.py
dimitri-yatsenko bc85f21
Merge branch 'dev' into attachments
dimitri-yatsenko 92553b0
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko c127693
Merge branch 'dev' into attachments
dimitri-yatsenko 1b188da
Merge branch 'dev' into attachments
dimitri-yatsenko 13573c5
Merge branch 'dev' into attachments
dimitri-yatsenko f3dd5b3
add properties for heading attributes for supporting configurable blo…
dimitri-yatsenko 046291a
rename property is_supported to unsupported for heading attributes
dimitri-yatsenko 1f5fe9d
load configurable fields
dimitri-yatsenko 3350516
implement declaration of configurable attributes: blob- and attach.
dimitri-yatsenko acc07fb
prepare for saving attachments
dimitri-yatsenko c11bbbf
add attach.py for saving and loading attachments
dimitri-yatsenko 390b0b7
implement inserting attachments
dimitri-yatsenko 2c04d74
implement fetch of attachments and configurable blobs
dimitri-yatsenko 43e9c76
fix issue #467
dimitri-yatsenko 51336ff
further cleanup of __init__.py
dimitri-yatsenko cee588e
Use DEFAULT instead of NULL when the insert value is None.
dimitri-yatsenko c04f974
slight refactor of Table.insert
dimitri-yatsenko 9de4782
fix for error introduced in previous commit
dimitri-yatsenko 0c35af1
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko 1588303
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko f265674
implement external file folding
dimitri-yatsenko bcebce5
Merge branch 'master' into attachments
dimitri-yatsenko 50f17ce
remote the `keys` property from `fetch` (a warning was displayed in s…
dimitri-yatsenko f141aa7
add `dj.get_schema_names()`
dimitri-yatsenko 6310c7d
stylistic improvements
dimitri-yatsenko 7cb1d3f
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko aa72832
Merge branch 'master' into attachments
dimitri-yatsenko 4818bbb
Merge branch 'master' into attachments
dimitri-yatsenko 3aa936e
complete implementation of attachments and configurable blobs with pa…
dimitri-yatsenko bdf8195
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko 173bf1d
add test for configurable blobs
dimitri-yatsenko 61c2ce7
drop support of Python 3.4
dimitri-yatsenko aa6a2ce
add test for attachment methods
dimitri-yatsenko f49cf22
fix test_attach
dimitri-yatsenko eea3e20
fix 3.4 compatibility
dimitri-yatsenko 7ee6134
Python 3.4 compatibility
dimitri-yatsenko 6701abb
fix Python 3.4 compatibility
dimitri-yatsenko 346f47f
fix Python 3.4 compatibility
dimitri-yatsenko b2087aa
fix Python 3.4 compatibility
dimitri-yatsenko 332cfd6
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko 0c491e2
improve error message
dimitri-yatsenko 7e51e4f
improve error message
dimitri-yatsenko 0434fc8
Merge branch 'attachments' of https://github.com/dimitri-yatsenko/dat…
dimitri-yatsenko 484e926
bugfix in S3 store
dimitri-yatsenko 1a83fe6
bugfix in S3 store
dimitri-yatsenko 4c8b6eb
Merge branch 'attachments' of https://github.com/dimitri-yatsenko/dat…
dimitri-yatsenko bf66d64
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko 8f4e8f9
Merge branch 'master' into attachments
dimitri-yatsenko 0826d94
implement external storage cleanup with subfolding
dimitri-yatsenko fb14029
fix error message and release date
dimitri-yatsenko 90cf697
improve warning messages
dimitri-yatsenko afeadb1
change version to 0.12.dev
dimitri-yatsenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| """ | ||
| functionality for attaching files | ||
| """ | ||
| from os import path | ||
| from itertools import count, chain | ||
|
|
||
|
|
||
| def load(local_path): | ||
| """ make an attachment from a local file """ | ||
| with open(local_path, mode='rb') as f: # b is important -> binary | ||
| contents = f.read() | ||
| return str.encode(path.basename(local_path)) + b'\0' + contents | ||
|
|
||
|
|
||
| def save(buffer, save_path='.'): | ||
| """ save attachment from memory buffer into the save_path """ | ||
| p = buffer.find(b'\0') | ||
| file_path = path.abspath(path.join(save_path, buffer[:p].decode())) | ||
|
|
||
| if path.isfile(file_path): | ||
| # generate a new filename | ||
| file, ext = path.splitext(file_path) | ||
| file_path = next(f for f in ('%s_%04x%s' % (file, n, ext) for n in count()) | ||
| if not path.isfile(f)) | ||
|
|
||
| with open(file_path, mode='wb') as f: | ||
| f.write(buffer[p+1:]) | ||
| return file_path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are now three libraries mentioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed