Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Add Split Packages and output file format options #104

Merged
merged 45 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c5364fd
added new function, split packages
Ravf95 Jun 1, 2020
6a56e15
Merge branch '81-split_files' of https://github.com/Ravf95/toucan int…
Ravf95 Jun 1, 2020
c85a733
added pretty json and encoding to optional arguments
Ravf95 Jun 2, 2020
20c8465
changes for formatted imports
Ravf95 Jun 2, 2020
4279f71
updates and fixes
Ravf95 Jun 5, 2020
1441bdc
applied suggested changes
Ravf95 Jun 11, 2020
aa45592
Merge pull request #99 from Ravf95/81-split_files
aguilerapy Jul 1, 2020
c5b1538
Add new icon for split-packages
aguilerapy Jul 2, 2020
e4f6657
Update index.html
aguilerapy Jul 2, 2020
7dd50fa
Update descriptions for split-packages
aguilerapy Jul 2, 2020
2720ebf
Update name method for split-packages
aguilerapy Jul 2, 2020
de03eb8
Reorder paths
aguilerapy Jul 2, 2020
3ed9e80
Update check split size
aguilerapy Jul 3, 2020
aa75a10
Update translations
aguilerapy Jul 3, 2020
8e93be7
Fix warning
aguilerapy Jul 3, 2020
5221c84
Merge branch 'master' into 81-split_files
aguilerapy Jul 6, 2020
e766b6d
Fix merge conflicts and update translations
aguilerapy Jul 6, 2020
20465c8
Merge branch 'master' into 81-split_files
aguilerapy Jul 16, 2020
9c36ba3
Update default/templates/default/split-packages.html
aguilerapy Jul 16, 2020
5ad9f0a
Update to validate_split_size
aguilerapy Jul 16, 2020
3db92b5
Update templates
aguilerapy Jul 16, 2020
0470613
Update translations
aguilerapy Jul 16, 2020
23eaee6
Merge remote-tracking branch 'origin/81-split_files' into 81-split_files
aguilerapy Jul 16, 2020
8a3054a
Update validate_optional_args
aguilerapy Jul 21, 2020
47dd3c0
Update comment
aguilerapy Jul 21, 2020
fc558cc
Update args snippet
aguilerapy Jul 21, 2020
6ff61bc
Update translations
aguilerapy Jul 21, 2020
7ea5d22
Update decorators
aguilerapy Jul 21, 2020
7819ad2
Update templates and create js files
aguilerapy Jul 23, 2020
0406942
Fix template
aguilerapy Jul 23, 2020
d955cbc
Update translations
aguilerapy Jul 24, 2020
d95e156
Fix warning
aguilerapy Jul 24, 2020
eed2435
Update default/static/js/uploader.js
aguilerapy Jul 27, 2020
b132f35
Remove trigger
aguilerapy Jul 27, 2020
1638a8e
Add options for to-json
aguilerapy Aug 7, 2020
ac6ff1b
Update tests
aguilerapy Aug 7, 2020
23f9911
Merge branch 'master' into 81-split_files
aguilerapy Aug 12, 2020
6ad4dc1
Fix merge conflicts
aguilerapy Aug 12, 2020
0962f94
Fix merge conflicts and minor changes
aguilerapy Aug 13, 2020
71ddca5
Update changes
aguilerapy Sep 4, 2020
adef9a6
Apply suggestions from code review
aguilerapy Sep 4, 2020
d9ba4bf
Merge branch 'master' into 81-split_files
aguilerapy Sep 4, 2020
e65a31b
Merge branch '81-split_files' of github.com:open-contracting/toucan i…
aguilerapy Sep 4, 2020
019b420
Merge branch 'master' into 81-split_files
aguilerapy Sep 8, 2020
5c9de63
Fix merge conflicts
aguilerapy Sep 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ __pycache__
*.mo
.coverage
/media
.DS_Store
130 changes: 86 additions & 44 deletions assets/selection.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
{}
],
"properties": {
"order": 18,
"order": 41,
"id": 9,
"name": "convert-to-json",
"prevSize": 32,
"code": 59657
},
"setIdx": 1,
"setId": 3,
"setIdx": 0,
"setId": 1,
"iconIdx": 0
},
{
Expand All @@ -54,7 +54,7 @@
"M420.253 321.676c-14.246 0-25.952-11.677-25.952-25.958v-147.068h-216.259c-14.374 0-25.952 11.576-25.952 25.963v501.736c0 14.381 11.576 25.981 25.952 25.981h363.338c14.397 0 25.958-11.599 25.958-25.981v-354.672h-147.087zM364.596 569.116v-42.8h-108.685v-28.639h108.692v-42.8l98.912 57.122-98.919 57.116z",
"M805.871 494.697c-14.258 0-25.952-11.669-25.952-25.952v-147.068h-185.522v354.672c0 29.245-23.783 53.040-53.017 53.040h-3.685v119.982c0 14.381 11.584 25.981 25.963 25.981h363.333c14.392 0 25.963-11.599 25.963-25.981v-354.672h-147.087zM849.132 699.342h-108.697v42.793l-98.9-57.116 98.9-57.105v42.793h108.697v28.632z"
],
"width": 1105,
"width": 1056,
"attrs": [
{},
{},
Expand All @@ -64,7 +64,7 @@
"isMulticolor": false,
"isMulticolor2": false,
"tags": [
"Release package"
"Combine packages"
],
"grid": 16
},
Expand All @@ -75,14 +75,14 @@
{}
],
"properties": {
"order": 2,
"order": 40,
"id": 0,
"name": "combine-package",
"name": "combine-packages",
"prevSize": 32,
"code": 59656
},
"setIdx": 1,
"setId": 3,
"setIdx": 0,
"setId": 1,
"iconIdx": 1
},
{
Expand Down Expand Up @@ -110,15 +110,15 @@
{}
],
"properties": {
"order": 13,
"order": 39,
"id": 2,
"name": "convert-to-spreadsheet",
"prevSize": 32,
"code": 59649
},
"setIdx": 1,
"setId": 3,
"iconIdx": 3
"setIdx": 0,
"setId": 1,
"iconIdx": 2
},
{
"icon": {
Expand All @@ -143,7 +143,7 @@
"tags": [
"Compiled releases"
],
"grid": 0
"grid": 16
},
"attrs": [
{},
Expand All @@ -154,15 +154,15 @@
{}
],
"properties": {
"order": 3,
"order": 38,
"id": 1,
"name": "compile-releases",
"prevSize": 32,
"code": 59648
},
"setIdx": 1,
"setId": 3,
"iconIdx": 2
"setIdx": 0,
"setId": 1,
"iconIdx": 3
},
{
"icon": {
Expand All @@ -182,22 +182,22 @@
"tags": [
"Data review tool"
],
"grid": 0
"grid": 16
},
"attrs": [
{},
{},
{}
],
"properties": {
"order": 11,
"order": 37,
"id": 3,
"name": "data-review",
"prevSize": 32,
"code": 59650
},
"setIdx": 1,
"setId": 3,
"setIdx": 0,
"setId": 1,
"iconIdx": 4
},
{
Expand All @@ -214,20 +214,20 @@
"tags": [
"Generate spreadsheet"
],
"grid": 0
"grid": 16
},
"attrs": [
{}
],
"properties": {
"order": 5,
"order": 36,
"id": 4,
"name": "schema-spreadsheet",
"prevSize": 32,
"code": 59651
},
"setIdx": 1,
"setId": 3,
"setIdx": 0,
"setId": 1,
"iconIdx": 5
},
{
Expand All @@ -250,7 +250,7 @@
"tags": [
"OCDS extension creator"
],
"grid": 0
"grid": 16
},
"attrs": [
{},
Expand All @@ -259,14 +259,14 @@
{}
],
"properties": {
"order": 7,
"order": 35,
"id": 5,
"name": "extension-creator",
"prevSize": 32,
"code": 59652
},
"setIdx": 1,
"setId": 3,
"setIdx": 0,
"setId": 1,
"iconIdx": 6
},
{
Expand Down Expand Up @@ -294,7 +294,7 @@
"tags": [
"Record packages"
],
"grid": 0
"grid": 16
},
"attrs": [
{},
Expand All @@ -306,14 +306,14 @@
{}
],
"properties": {
"order": 8,
"order": 34,
"id": 6,
"name": "package-records",
"prevSize": 32,
"code": 59653
},
"setIdx": 1,
"setId": 3,
"setIdx": 0,
"setId": 1,
"iconIdx": 7
},
{
Expand All @@ -335,7 +335,7 @@
"tags": [
"Release packages"
],
"grid": 0
"grid": 16
},
"attrs": [
{},
Expand All @@ -344,14 +344,14 @@
{}
],
"properties": {
"order": 12,
"order": 33,
"id": 7,
"name": "package-releases",
"prevSize": 32,
"code": 59654
},
"setIdx": 1,
"setId": 3,
"setIdx": 0,
"setId": 1,
"iconIdx": 8
},
{
Expand All @@ -369,22 +369,60 @@
"tags": [
"Upgrade"
],
"grid": 0
"grid": 16
},
"attrs": [
{},
{}
],
"properties": {
"order": 10,
"order": 42,
"id": 8,
"name": "upgrade",
"prevSize": 32,
"code": 59655
},
"setIdx": 1,
"setId": 3,
"setIdx": 0,
"setId": 1,
"iconIdx": 9
},
{
"icon": {
"paths": [
"M155.316 148.832c-9.982 0.535-15.061 2.139-19.785 6.506-3.119 2.941-6.328 8.288-7.664 12.744-0.802 2.852-1.069 63.276-1.069 257.114 0 268.7-0.178 256.579 3.832 264.244 1.961 3.743 6.684 7.754 12.12 10.516l4.902 2.317h375.645l4.991-2.317c9.179-4.367 13.725-10.427 15.507-20.943 1.515-8.912 1.426-356.306-0.089-356.84-0.624-0.267-35.025-0.535-76.466-0.624-71.029-0.267-75.575-0.356-79.942-1.961-6.506-2.317-10.516-5.971-13.636-12.477l-2.674-5.704v-75.129c0-41.441-0.356-75.753-0.802-76.466-0.713-1.069-16.487-1.248-103.202-1.337-56.235-0.089-106.5 0.089-111.669 0.356zM337.033 471.628c0.089 10.873 0.356 19.963 0.624 20.23s24.865 0.713 54.542 0.98l54.096 0.446 0.267 12.833c0.178 8.199-0.089 13.19-0.713 13.903-0.802 0.98-11.407 1.248-54.096 1.248-31.638 0-53.473 0.356-54.007 0.891-0.446 0.446-0.713 9.090-0.713 19.963 0.089 12.388-0.178 19.428-0.713 19.785-0.535 0.267-3.654-1.069-6.951-2.941-3.387-1.961-7.486-4.367-9.179-5.347-11.675-6.595-14.705-8.377-16.755-9.803-1.337-0.98-3.565-2.317-5.080-3.030-2.941-1.426-9.179-4.991-15.774-8.823-2.406-1.426-4.456-2.585-4.634-2.585s-2.406-1.426-4.991-3.119c-2.585-1.693-4.991-3.119-5.347-3.119-0.446 0-5.169-2.585-10.427-5.615-5.347-3.119-10.695-5.971-11.853-6.238-2.585-0.713-6.862-3.832-6.149-4.545 0.267-0.267 8.021-4.813 17.379-10.16 9.269-5.347 20.765-11.942 25.578-14.794 4.813-2.763 11.407-6.506 14.705-8.199 3.297-1.782 6.595-3.654 7.308-4.189 1.693-1.337 4.991-3.208 9.090-5.258 1.872-0.891 7.308-4.010 12.031-6.951s9.358-5.347 10.16-5.347c1.426 0 1.604 1.693 1.604 19.785z",
"M407.439 148.654c-0.713 0.267-1.515 0.891-1.872 1.426-0.98 1.337-0.891 134.394 0.089 135.82 0.624 0.98 11.229 1.248 58.998 1.159 78.248 0 77.713 0 79.139-0.891 1.069-0.713 1.069-1.872 0.178-7.664-0.624-3.743-1.961-8.377-3.030-10.338-1.515-2.852-102.4-104.717-112.471-113.54-1.426-1.337-4.010-2.941-5.615-3.654-3.297-1.426-13.368-2.941-15.418-2.317z",
"M658.225 321.548l-86.715 0.178v15.418c0 8.377-0.089 90.28-0.267 181.985l-0.178 166.656-2.406 6.684c-1.337 3.654-3.208 7.664-4.1 8.912s-2.317 3.387-3.119 4.902c-1.159 2.317-3.297 4.634-9.358 10.338-7.13 6.595-18.715 11.318-30.39 12.299l-6.773 0.535v126.552l2.228 4.456c3.030 6.149 7.843 10.605 13.903 12.833l5.169 1.961h186.085c132.523 0 187.065-0.267 189.739-0.98 9.803-2.674 16.398-9.536 18.715-19.607 0.891-3.476 1.159-357.91 0.356-359.247-0.356-0.446-30.925-0.802-77.624-0.802-75.396 0-77.179 0-80.565-1.782-4.634-2.406-9.536-6.773-11.407-10.16-3.743-6.951-3.743-6.862-3.743-85.021 0-59.265-0.267-75.129-1.069-75.485-2.585-0.802-16.042-0.891-98.479-0.624zM729.255 632.313c3.030 1.693 5.793 3.119 6.060 3.119s1.159 0.535 1.872 1.248c0.802 0.624 4.813 2.941 9.001 4.991 4.189 2.139 8.199 4.367 8.912 4.991s3.565 2.317 6.238 3.743c2.674 1.426 9.892 5.526 16.042 9.090 6.149 3.476 13.368 7.664 16.042 9.179 2.674 1.426 5.347 2.941 5.793 3.297 0.802 0.624 3.654 2.228 13.636 7.664 6.328 3.565 7.13 4.545 5.080 6.060-0.98 0.713-2.763 1.872-4.010 2.495s-3.743 2.050-5.615 3.208c-4.545 2.763-8.199 4.813-17.379 9.714-4.278 2.228-7.932 4.367-8.199 4.723-0.267 0.267-2.228 1.604-4.456 2.763-2.228 1.248-5.615 3.208-7.575 4.367s-5.526 3.119-8.021 4.456c-2.406 1.248-6.060 3.387-8.021 4.634-1.961 1.159-5.347 3.208-7.575 4.456s-6.595 3.743-9.803 5.615c-11.497 6.595-13.279 7.575-14.17 7.575-0.713 0-0.98-6.506-0.98-19.963 0-17.379-0.178-20.052-1.426-20.498-0.802-0.267-25.221-0.535-54.275-0.535-47.323 0-52.849-0.178-53.383-1.426-0.267-0.802-0.535-6.951-0.535-13.725 0-10.962 0.178-12.477 1.604-13.279 0.891-0.446 22.815-0.802 54.007-0.891 28.875 0 52.849-0.356 53.205-0.713 0.446-0.446 0.802-9.269 0.802-19.607 0.089-16.309 0.356-19.874 1.426-19.874 0.089 0 2.674 1.426 5.704 3.119z",
"M793.065 322.44c-0.267 0.446-0.535 31.46-0.624 68.891 0 55.166 0.178 68.088 1.159 68.623 1.337 0.891 134.394 1.069 136.533 0.267 1.069-0.446 1.426-1.872 1.426-6.238 0-10.784-1.248-12.388-33.42-44.293-75.842-75.396-84.754-84.13-88.23-85.734-4.010-1.872-15.953-2.941-16.844-1.515z"
],
"attrs": [
{},
{},
{},
{}
],
"tags": [
"Split packages"
],
"grid": 20,
"isMulticolor": false,
"isMulticolor2": false
},
"attrs": [
{},
{},
{},
{}
],
"properties": {
"order": 44,
"id": 10,
"name": "split-packages",
"prevSize": 32,
"code": 59664
},
"setIdx": 0,
"setId": 1,
"iconIdx": 10
}
],
"height": 1024,
Expand Down Expand Up @@ -422,10 +460,14 @@
"color": 0,
"bgColor": 16777215,
"name": "icomoon",
"classSelector": ".icon"
"classSelector": ".icon",
"autoHost": false
},
"historySize": 50,
"gridSize": 16,
"showGrid": true
"showGrid": false,
"quickUsageToken": {
"UntitledProject": "OGE5ZGY4YzQwNGYyZDAyMDEzN2E0ZWUxMDFjN2RiMTUjMSMxNTkzNjQ3MTEzIyMj"
}
}
}
14 changes: 10 additions & 4 deletions default/data_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def size(self):
"""
return os.path.getsize(self.path)

def json(self, **kwargs):
def json(self, codec='utf-8', **kwargs):
"""
Returns the file's parsed JSON contents.
"""
with open(self.path, encoding='utf-8') as f:
with open(self.path, encoding=codec) as f:
return json.load(f, **kwargs)

def write(self, file):
Expand All @@ -84,19 +84,25 @@ def write(self, file):
for chunk in file.chunks():
f.write(chunk)

def write_json_to_zip(self, files):
def write_json_to_zip(self, files, pretty_json=None, codec=None):
"""
Writes JSON data to a ZIP file.

:param files: a dict in which keys are file names and values are file contents, or a generator that yields
tuples of file names and file contents.
"""
self._makedirs()
kwargs = {}

if pretty_json:
kwargs['indent'] = 2

if isinstance(files, dict):
files = files.items()

with ZipFile(self.path, 'w', compression=ZIP_DEFLATED) as zipfile:
for name, content in files:
zipfile.writestr(name, json_dumps(content) + '\n')
zipfile.writestr(name, (json_dumps(content, **kwargs) + '\n').encode(codec))

@property
def _name(self):
Expand Down
Loading