Skip to content

Commit

Permalink
Merge pull request #174 from weso/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Bernardo-MG authored May 21, 2017
2 parents c21b8a2 + 16fc94b commit f3b6ba8
Show file tree
Hide file tree
Showing 50 changed files with 3,928 additions and 176 deletions.
13 changes: 0 additions & 13 deletions .scripts/deploy_docs.sh

This file was deleted.

8 changes: 0 additions & 8 deletions .scripts/run_tests.sh

This file was deleted.

54 changes: 33 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
# Travis CI Configuration file
# @link https://travis-ci.org/

# Using Python for the project
language: python
python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "pypy"
- "pypy3"
- "3.5"
# Python 3.6 is set to test and deploy the docs in the configuration matrix
#- "3.6"
# PyPy currently is not working with the required dependencies
#- "pypy"
#- "pypy3"
env:
- TEST_DOCS=true
matrix:
exclude:
- python: "2.7"
include:
- python: "2.7"
env:
- COVERAGE=true
- DOCS=true
- DEPLOY_DOCS=true
- python: "3.4"
env: DOCS=true
# Tests and deploys docs, also runs coverage report
- python: "3.6"
env: TEST_DOCS=true DEPLOY_DOCS=true

before_install:
- chmod +x ./.scripts/run_tests.sh
- chmod +x ./.scripts/deploy_docs.sh
# Gets scripts
- git clone -b v0.4.1 --single-branch https://github.com/Bernardo-MG/ci-shell-scripts.git ~/.scripts
# Sets scripts as executable
- chmod -R +x ~/.scripts/*
# Prepares CI environment
- source ~/.scripts/travis/load-travis-environment.sh
install:
# tox is required for the tests
- pip install tox
# sphinx is required for the docs
- pip install sphinx
# Dependencies
- pip install --upgrade -r requirements.txt
script:
- ./.scripts/run_tests.sh
- if [ ! -z "$DOCS" ]; then tox -e docs; fi
- if [ ! -z "$DEPLOY_DOCS" ]; then ./.scripts/deploy_docs.sh; fi
- if [ ! -z "$COVERAGE" ]; then tox -e coverage; fi
# Tests are run
- ~/.scripts/python/run_tests.sh true $PYTHON_VERSION_TEST
# Documentation tests are run
- ~/.scripts/python/run_tests.sh $DO_TEST_DOCS docs
after_success:
# Documentation deployment
- ~/.scripts/rtd/deploy.sh $DO_DEPLOY_DOCS cwr
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) 2014 WESO
Copyright (c) 2016 United Media Agency

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ include .coveragerc
recursive-exclude tests *.pyc
recursive-exclude tests *.pyo

recursive-include tests *.V21
recursive-include tests *.cwr

# Data files
include data_cwr/*.py
include data_cwr/*.csv
Expand Down
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DISTDIR = dist

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

# Sets the tox folder path.
# It will be the '.tox' folder.
Expand All @@ -25,14 +25,14 @@ TOXDIR = .tox
# Sets the docs output folder path.
# It will be in the 'docs' folder.
DOCBUILDDIR = docs\\build

# User-friendly check for sphinx-build
ifeq ($(shell which $(PYTHON) >/dev/null 2>&1; echo $$?), 1)
$(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.)
endif
.PHONY: help clean

.PHONY: help clean

# Help option
# Shows the allowed commands to be received as parameters
help:
Expand Down Expand Up @@ -66,24 +66,24 @@ install:
# Install the project requirements
requirements:
pip install --upgrade -r requirements.txt

# Pypi registration.
register:
$(PYTHON) setup.py register -r pypi

# Pypitest registration.
register-test:
$(PYTHON) setup.py register -r testpypi

# Pypi deployment.
deploy:
$(PYTHON) setup.py sdist
twine upload dist/*

# Pypitest deployment.
deploy-test:
$(PYTHON) setup.py sdist upload -r testpypi

# Tests suite.
test:
tox
tox
77 changes: 55 additions & 22 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
CWR Data Model API
==================

.. image:: https://badge.fury.io/py/cwr-api.svg
:target: https://pypi.python.org/pypi/cwr-api
:alt: CWR-API Pypi package page

.. image:: https://readthedocs.org/projects/cwr-dataapi/badge/?version=latest
:target: http://cwr-dataapi.readthedocs.org/en/latest/
:alt: CWR-API latest documentation Status

.. image:: https://badges.gitter.im/Join%20Chat.svg
:target: https://gitter.im/weso/CWR-DataApi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
:alt: Join the chat at https://gitter.im/weso/CWR-DataApi

This projects offers a domain model for the CISAC CWR standard v2.1 to be
used on Python applications, along a series of parsing which allow
transformations between the model and various data structures.
Expand All @@ -25,6 +13,18 @@ works data.
While the CWR standard has been created by `CISAC`_ this library has been
developed by `WESO`_ independently, with help from `BMAT`_.

.. image:: https://badge.fury.io/py/cwr-api.svg
:target: https://pypi.python.org/pypi/cwr-api
:alt: CWR-API Pypi package page

.. image:: https://readthedocs.org/projects/cwr-dataapi/badge/?version=latest
:target: http://cwr-dataapi.readthedocs.org/en/latest/
:alt: CWR-API latest documentation Status

.. image:: https://badges.gitter.im/Join%20Chat.svg
:target: https://gitter.im/weso/CWR-DataApi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
:alt: Join the chat at https://gitter.im/weso/CWR-DataApi

Features
--------

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

Building the code
-----------------
Usage
-----

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

Prerequisites
~~~~~~~~~~~~~

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

- Python 2.6
- Python 2.7
- Python 3.2
- Python 3.3
- Python 3.4
- Pypy
- Pypy 3
- Python 3.5
- Python 3.6

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

``$ pip install cwr-api``

Making use of the parser
~~~~~~~~~~~~~~~~~~~~~~~~

Once the project is installed it can be used in a similar way to this (using Python 2.7)::

import codecs
import os

from cwr.parser.decoder.file import default_file_decoder
from cwr.parser.encoder.cwrjson import JSONEncoder

if __name__ == '__main__':
print('File to JSON test')
path = raw_input(
'Please enter the full path to a CWR file (e.g. c:/documents/file.cwr): ')
output = raw_input(
'Please enter the full path to the file where the results will be stored: ')
print('\n')
print('Reading file %s' % path)
print('Storing output on %s' % output)
print('\n')

decoder = default_file_decoder()

data = {}
data['filename'] = os.path.basename(path)
data['contents'] = codecs.open(path, 'r', 'latin-1').read()

data = decoder.decode(data)

encoder = JSONEncoder()
result = encoder.encode(data)

output = codecs.open(output, 'w', 'latin-1')

output.write(result)

Collaborate
-----------

Expand Down
12 changes: 12 additions & 0 deletions config_cwr/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(self):
self._group_configs = {}
self._record_configs = {}
self._transaction_configs = {}
self._acknowledge_configs = {}

def _load_cwr_defaults(self):
"""
Expand Down Expand Up @@ -152,3 +153,14 @@ def default_version(self):
:return: the current version of the CWR standard
"""
return self._load_cwr_defaults()['default_version']

def load_acknowledge_config(self, file_id):
"""
Loads the CWR acknowledge config
:return: the values matrix
"""
if self._cwr_defaults is None:
self._cwr_defaults = self._reader.read_yaml_file(
'acknowledge_config_%s.yml' % file_id)

return self._cwr_defaults
22 changes: 22 additions & 0 deletions config_cwr/acknowledge_config_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

sender_name: 'UMA EXAMPLE'
sender_id: 999
sender_type: 'SO'
version: 2.1
tis:
world: 2136
uzbekistan: 860
ukraine: 804
turkmenistan: 795
tajikistan: 762
russia: 643
moldova: 498
kazakhstan: 417
kazahstan: 398
georgia: 268
belarus: 112
armenia: 51
azerbaijan: 32



12 changes: 6 additions & 6 deletions config_cwr/field_config_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ first_album_label:
name: First Album Label

first_album_title:
type: alphanum
type: alphanum_ext
size: 60
name: First Album Title

Expand Down Expand Up @@ -297,7 +297,7 @@ library:
name: Library

message_text:
type: alphanum
type: alphanum_end
size: 150
name: Message Text

Expand Down Expand Up @@ -368,7 +368,7 @@ performance_dialect:
name: Dialect

performing_artist_first_name:
type: alphanum
type: alphanum_end
size: 30
name: Performing Artist First Name

Expand All @@ -395,7 +395,7 @@ performing_artist_ipi_name_n:
name: IPI Name Number

performing_artist_last_name:
type: alphanum
type: alphanum_end
size: 45
name: Performing Artist Last Name

Expand Down Expand Up @@ -559,7 +559,7 @@ shares_change:
name: Shares Change

society_assigned_agreement_n:
type: alphanum
type: alphanum_end
size: 14
name: Society Given Agreement Number

Expand Down Expand Up @@ -594,7 +594,7 @@ submitter_creation_n:
name: Submitter Creation Number

submitter_work_n:
type: alphanum
type: alphanum_end
size: 14
name: Submitter Work Number

Expand Down
4 changes: 2 additions & 2 deletions config_cwr/field_config_table.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ media_type:

message_level:
type: lookup
size: 3
size: 1
name: Message Level
source: message_level

Expand All @@ -72,7 +72,7 @@ message_record_type:

message_type:
type: lookup
size: 3
size: 1
name: Message Type
source: message_type

Expand Down
Loading

0 comments on commit f3b6ba8

Please sign in to comment.