Music Metedata - Territory-related tools
Project description
Music Metadata - Territories
A simple library for dealing with territory hierarchies used in music metadata, currently primarily focused on CISAC TIS.
Conversion between TIS and DDEX territories will follow in the next release.
Code
It has only two classes:
Territory
- the territory, e.g. World, Europe, CroatiaTerritoryList
- this class makes including and excluding territories simpler, it also splits territories down when needed
World excluding USA results in a minimal list of included territories:
from music_metadata.territories.territory import Territory
from music_metadata.territories.territory_list import TerritoryList
world = Territory.get('2136')
usa = Territory.get('US')
l = TerritoryList()
l.include(world)
l.exclude(usa)
for t in sorted(l, key=lambda x: x.name):
print(f'{t.tis_n:0>4}', t.name)
Result:
2100 AFRICA
2106 ASIA
0124 CANADA
2113 CENTRAL AMERICA
2120 EUROPE
0484 MEXICO
2130 OCEANIA
2132 SOUTH AMERICA
2134 WEST INDIES
It is simple to list all the countries as well:
for t in sorted(l.countries, key=lambda x: x.name):
print(f'{t.tis_a:0>4}', t.name)
Result:
AF AFGHANISTAN
AL ALBANIA
DZ ALGERIA
AD ANDORRA
AO ANGOLA
AG ANTIGUA AND BARBUDA
AR ARGENTINA
AM ARMENIA
AU AUSTRALIA
AT AUSTRIA
...
One can check if a country is finally included in the list:
usa in l
False
You may test it online, no coding skills required: https://music-metadata.herokuapp.com/territories/
The code for it is here: https://github.com/musicmetadata/web-wrapper
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for music_metadata_territories-19.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c03dd752978de339e26d594cdbb048dcedc796c79b8d89aa0e5ba8010490283 |
|
MD5 | b19f12f1803d0052409446af2c4f5e20 |
|
BLAKE2b-256 | 137649fbf4ffc6ae3c596d48b4b4e03acaf844e99cf03fa7b5fa604e01f622d0 |
Close
Hashes for music_metadata_territories-19-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b2ffa8f9090e0efc9e3dd22b6c8141bed99b3741e5d420e6ea895a3a1ece57a |
|
MD5 | b86a56b28ad6d516cecab22d929dc10f |
|
BLAKE2b-256 | d74ac40202fc0b1d4af332e2354b2aa7de147adaac411ad7a9a9878e0e8c6a27 |