Skip to content

Commit f3b6ba8

Browse files
authored
Merge pull request #174 from weso/develop
Develop
2 parents c21b8a2 + 16fc94b commit f3b6ba8

50 files changed

Lines changed: 3928 additions & 176 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.scripts/deploy_docs.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

.scripts/run_tests.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

.travis.yml

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,43 @@
1+
# Travis CI Configuration file
2+
# @link https://travis-ci.org/
3+
4+
# Using Python for the project
15
language: python
26
python:
3-
- "2.6"
4-
- "2.7"
5-
- "3.2"
6-
- "3.3"
77
- "3.4"
8-
- "pypy"
9-
- "pypy3"
8+
- "3.5"
9+
# Python 3.6 is set to test and deploy the docs in the configuration matrix
10+
#- "3.6"
11+
# PyPy currently is not working with the required dependencies
12+
#- "pypy"
13+
#- "pypy3"
14+
env:
15+
- TEST_DOCS=true
1016
matrix:
11-
exclude:
12-
- python: "2.7"
1317
include:
14-
- python: "2.7"
15-
env:
16-
- COVERAGE=true
17-
- DOCS=true
18-
- DEPLOY_DOCS=true
19-
- python: "3.4"
20-
env: DOCS=true
18+
# Tests and deploys docs, also runs coverage report
19+
- python: "3.6"
20+
env: TEST_DOCS=true DEPLOY_DOCS=true
2121

2222
before_install:
23-
- chmod +x ./.scripts/run_tests.sh
24-
- chmod +x ./.scripts/deploy_docs.sh
23+
# Gets scripts
24+
- git clone -b v0.4.1 --single-branch https://github.com/Bernardo-MG/ci-shell-scripts.git ~/.scripts
25+
# Sets scripts as executable
26+
- chmod -R +x ~/.scripts/*
27+
# Prepares CI environment
28+
- source ~/.scripts/travis/load-travis-environment.sh
2529
install:
30+
# tox is required for the tests
2631
- pip install tox
32+
# sphinx is required for the docs
33+
- pip install sphinx
34+
# Dependencies
35+
- pip install --upgrade -r requirements.txt
2736
script:
28-
- ./.scripts/run_tests.sh
29-
- if [ ! -z "$DOCS" ]; then tox -e docs; fi
30-
- if [ ! -z "$DEPLOY_DOCS" ]; then ./.scripts/deploy_docs.sh; fi
31-
- if [ ! -z "$COVERAGE" ]; then tox -e coverage; fi
37+
# Tests are run
38+
- ~/.scripts/python/run_tests.sh true $PYTHON_VERSION_TEST
39+
# Documentation tests are run
40+
- ~/.scripts/python/run_tests.sh $DO_TEST_DOCS docs
41+
after_success:
42+
# Documentation deployment
43+
- ~/.scripts/rtd/deploy.sh $DO_DEPLOY_DOCS cwr

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
The MIT License (MIT)
22

33
Copyright (c) 2014 WESO
4+
Copyright (c) 2016 United Media Agency
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ include .coveragerc
1111
recursive-exclude tests *.pyc
1212
recursive-exclude tests *.pyo
1313

14+
recursive-include tests *.V21
15+
recursive-include tests *.cwr
16+
1417
# Data files
1518
include data_cwr/*.py
1619
include data_cwr/*.csv

Makefile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ DISTDIR = dist
1616

1717
# Sets the .egg file path.
1818
# The file will be located at the project's root.
19-
EGGDIR = CWR_API.egg-info
19+
EGGDIR = dice-notation.egg-info
2020

2121
# Sets the tox folder path.
2222
# It will be the '.tox' folder.
@@ -25,14 +25,14 @@ TOXDIR = .tox
2525
# Sets the docs output folder path.
2626
# It will be in the 'docs' folder.
2727
DOCBUILDDIR = docs\\build
28-
28+
2929
# User-friendly check for sphinx-build
3030
ifeq ($(shell which $(PYTHON) >/dev/null 2>&1; echo $$?), 1)
3131
$(error The '$(PYTHON)' command was not found. Make sure you have a version of the python interpreter installed, then add the directory where it was installed to the PATH.)
3232
endif
33-
34-
.PHONY: help clean
35-
33+
34+
.PHONY: help clean
35+
3636
# Help option
3737
# Shows the allowed commands to be received as parameters
3838
help:
@@ -66,24 +66,24 @@ install:
6666
# Install the project requirements
6767
requirements:
6868
pip install --upgrade -r requirements.txt
69-
69+
7070
# Pypi registration.
7171
register:
7272
$(PYTHON) setup.py register -r pypi
73-
73+
7474
# Pypitest registration.
7575
register-test:
7676
$(PYTHON) setup.py register -r testpypi
77-
77+
7878
# Pypi deployment.
7979
deploy:
8080
$(PYTHON) setup.py sdist
8181
twine upload dist/*
82-
82+
8383
# Pypitest deployment.
8484
deploy-test:
8585
$(PYTHON) setup.py sdist upload -r testpypi
8686

8787
# Tests suite.
8888
test:
89-
tox
89+
tox

README.rst

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
CWR Data Model API
22
==================
33

4-
.. image:: https://badge.fury.io/py/cwr-api.svg
5-
:target: https://pypi.python.org/pypi/cwr-api
6-
:alt: CWR-API Pypi package page
7-
8-
.. image:: https://readthedocs.org/projects/cwr-dataapi/badge/?version=latest
9-
:target: http://cwr-dataapi.readthedocs.org/en/latest/
10-
:alt: CWR-API latest documentation Status
11-
12-
.. image:: https://badges.gitter.im/Join%20Chat.svg
13-
:target: https://gitter.im/weso/CWR-DataApi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
14-
:alt: Join the chat at https://gitter.im/weso/CWR-DataApi
15-
164
This projects offers a domain model for the CISAC CWR standard v2.1 to be
175
used on Python applications, along a series of parsing which allow
186
transformations between the model and various data structures.
@@ -25,6 +13,18 @@ works data.
2513
While the CWR standard has been created by `CISAC`_ this library has been
2614
developed by `WESO`_ independently, with help from `BMAT`_.
2715

16+
.. image:: https://badge.fury.io/py/cwr-api.svg
17+
:target: https://pypi.python.org/pypi/cwr-api
18+
:alt: CWR-API Pypi package page
19+
20+
.. image:: https://readthedocs.org/projects/cwr-dataapi/badge/?version=latest
21+
:target: http://cwr-dataapi.readthedocs.org/en/latest/
22+
:alt: CWR-API latest documentation Status
23+
24+
.. image:: https://badges.gitter.im/Join%20Chat.svg
25+
:target: https://gitter.im/weso/CWR-DataApi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
26+
:alt: Join the chat at https://gitter.im/weso/CWR-DataApi
27+
2828
Features
2929
--------
3030

@@ -40,24 +40,20 @@ Check the `latest docs`_ for the most current version of the documentation.
4040
They are generated with the help of `Sphinx`_. The source files for this are
4141
stored in the docs folder.
4242

43-
Building the code
44-
-----------------
43+
Usage
44+
-----
4545

46-
The application has been coded in Python, without using any particular
47-
framework.
46+
The application has been coded in Python. Dependencies are taken care with the
47+
use of pip, and an included makefile helps building the project.
4848

4949
Prerequisites
5050
~~~~~~~~~~~~~
5151

5252
The project has been tested in the following versions of the interpreter:
5353

54-
- Python 2.6
55-
- Python 2.7
56-
- Python 3.2
57-
- Python 3.3
5854
- Python 3.4
59-
- Pypy
60-
- Pypy 3
55+
- Python 3.5
56+
- Python 3.6
6157

6258
All other dependencies are indicated on the requirements.txt file.
6359
The included makefile can install them with the command:
@@ -81,6 +77,43 @@ Additionally, the project is offered as a `Pypi package`_, and can be installed
8177

8278
``$ pip install cwr-api``
8379

80+
Making use of the parser
81+
~~~~~~~~~~~~~~~~~~~~~~~~
82+
83+
Once the project is installed it can be used in a similar way to this (using Python 2.7)::
84+
85+
import codecs
86+
import os
87+
88+
from cwr.parser.decoder.file import default_file_decoder
89+
from cwr.parser.encoder.cwrjson import JSONEncoder
90+
91+
if __name__ == '__main__':
92+
print('File to JSON test')
93+
path = raw_input(
94+
'Please enter the full path to a CWR file (e.g. c:/documents/file.cwr): ')
95+
output = raw_input(
96+
'Please enter the full path to the file where the results will be stored: ')
97+
print('\n')
98+
print('Reading file %s' % path)
99+
print('Storing output on %s' % output)
100+
print('\n')
101+
102+
decoder = default_file_decoder()
103+
104+
data = {}
105+
data['filename'] = os.path.basename(path)
106+
data['contents'] = codecs.open(path, 'r', 'latin-1').read()
107+
108+
data = decoder.decode(data)
109+
110+
encoder = JSONEncoder()
111+
result = encoder.encode(data)
112+
113+
output = codecs.open(output, 'w', 'latin-1')
114+
115+
output.write(result)
116+
84117
Collaborate
85118
-----------
86119

config_cwr/accessor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def __init__(self):
7777
self._group_configs = {}
7878
self._record_configs = {}
7979
self._transaction_configs = {}
80+
self._acknowledge_configs = {}
8081

8182
def _load_cwr_defaults(self):
8283
"""
@@ -152,3 +153,14 @@ def default_version(self):
152153
:return: the current version of the CWR standard
153154
"""
154155
return self._load_cwr_defaults()['default_version']
156+
157+
def load_acknowledge_config(self, file_id):
158+
"""
159+
Loads the CWR acknowledge config
160+
:return: the values matrix
161+
"""
162+
if self._cwr_defaults is None:
163+
self._cwr_defaults = self._reader.read_yaml_file(
164+
'acknowledge_config_%s.yml' % file_id)
165+
166+
return self._cwr_defaults
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
sender_name: 'UMA EXAMPLE'
3+
sender_id: 999
4+
sender_type: 'SO'
5+
version: 2.1
6+
tis:
7+
world: 2136
8+
uzbekistan: 860
9+
ukraine: 804
10+
turkmenistan: 795
11+
tajikistan: 762
12+
russia: 643
13+
moldova: 498
14+
kazakhstan: 417
15+
kazahstan: 398
16+
georgia: 268
17+
belarus: 112
18+
armenia: 51
19+
azerbaijan: 32
20+
21+
22+

config_cwr/field_config_common.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ first_album_label:
185185
name: First Album Label
186186

187187
first_album_title:
188-
type: alphanum
188+
type: alphanum_ext
189189
size: 60
190190
name: First Album Title
191191

@@ -297,7 +297,7 @@ library:
297297
name: Library
298298

299299
message_text:
300-
type: alphanum
300+
type: alphanum_end
301301
size: 150
302302
name: Message Text
303303

@@ -368,7 +368,7 @@ performance_dialect:
368368
name: Dialect
369369

370370
performing_artist_first_name:
371-
type: alphanum
371+
type: alphanum_end
372372
size: 30
373373
name: Performing Artist First Name
374374

@@ -395,7 +395,7 @@ performing_artist_ipi_name_n:
395395
name: IPI Name Number
396396

397397
performing_artist_last_name:
398-
type: alphanum
398+
type: alphanum_end
399399
size: 45
400400
name: Performing Artist Last Name
401401

@@ -559,7 +559,7 @@ shares_change:
559559
name: Shares Change
560560

561561
society_assigned_agreement_n:
562-
type: alphanum
562+
type: alphanum_end
563563
size: 14
564564
name: Society Given Agreement Number
565565

@@ -594,7 +594,7 @@ submitter_creation_n:
594594
name: Submitter Creation Number
595595

596596
submitter_work_n:
597-
type: alphanum
597+
type: alphanum_end
598598
size: 14
599599
name: Submitter Work Number
600600

0 commit comments

Comments
 (0)