"""Constants related to sales data files content.""" from collections import namedtuple SALES_DATA_HEADERS_PHONOFILE = { 'pMonth', 'pYear', 'label', 'upc', 'releaseDate', 'releaseTitle', 'releaseArtist', 'isrc', 'trkUID', 'trkTitle', 'trkArtist', 'PlayingTimeMinutes', 'PlayingTimeSeconds', 'Songwriters', 'Publishers', 'transactionType', 'store', 'unitsSold', 'grossRevenue', 'netRevenue', 'distFee', 'mechRate', 'copyrightWithholding', 'adminFee', 'PublicDomain', 'UsageTypeID'} SALES_DATA_HEADERS_FINETUNES = { 'Sales Period Month', 'Sales Period Year', 'Label Name', 'UPC', 'Album/Release Date', 'Album/Release Name', 'Album/Release Artist', 'ISRC Code', 'Internal Unique Track ID (if applicable)', 'Track Name', 'Track Artist', 'Total Playing Time - Minutes', 'Total Playing Time - Seconds', 'Songwriter(s)/Composer(s)', 'Publisher(s)', 'Transaction Type /Configuration Code', 'Store', 'Units Sold', 'Gross Revenue (From Source)', 'Net Revenue (Amount Paid to Label)', 'Label\'s Distribution Fee', 'Mechanical Royalty Rate', 'Total Mechanical Royalties Deducted from Label’s Receipts (if applicable)' } PHONOFILE = 'phonofile' FINETUNES = 'finetunes' COMPANY_TO_HEADERS_MAPPING = { PHONOFILE: SALES_DATA_HEADERS_PHONOFILE, FINETUNES: SALES_DATA_HEADERS_FINETUNES} VendorsFieldNames = namedtuple('vendors_field_names', (PHONOFILE, FINETUNES)) SALES_DATA_HEADERS_MAPPING = { 'label': VendorsFieldNames('label', 'Label Name'), 'upc': VendorsFieldNames('upc', 'UPC'), 'period_year': VendorsFieldNames('pYear', 'Sales Period Year'), 'period_month': VendorsFieldNames('pMonth', 'Sales Period Month'), 'release_date': VendorsFieldNames('releaseDate', 'Album/Release Date'), 'release_title': VendorsFieldNames( 'releaseTitle', 'Album/Release Name'), 'release_artist': VendorsFieldNames( 'releaseArtist', 'Album/Release Artist'), 'isrc': VendorsFieldNames('isrc', 'ISRC Code'), 'original_track_id': VendorsFieldNames( 'trkUID', 'Internal Unique Track ID (if applicable)'), 'track_name': VendorsFieldNames('trkTitle', 'Track Name'), 'track_artist': VendorsFieldNames('trkArtist', 'Track Artist'), 'length_minute': VendorsFieldNames( 'PlayingTimeMinutes', 'Total Playing Time - Minutes'), 'length_seconds': VendorsFieldNames( 'PlayingTimeSeconds', 'Total Playing Time - Seconds'), 'writer': VendorsFieldNames('Songwriters', 'Songwriter(s)/Composer(s)'), 'original_publishers': VendorsFieldNames('Publishers', 'Publisher(s)'), 'transaction_type': VendorsFieldNames( 'transactionType', 'Transaction Type /Configuration Code'), 'store': VendorsFieldNames('store', 'Store'), 'qty': VendorsFieldNames('unitsSold', 'Units Sold'), 'gross_revenue': VendorsFieldNames( 'grossRevenue', 'Gross Revenue (From Source)'), 'net_revenue': VendorsFieldNames( 'netRevenue', 'Net Revenue (Amount Paid to Label)'), 'dist_fee': VendorsFieldNames('distFee', 'Label\'s Distribution Fee'), 'royalty_rate': VendorsFieldNames('mechRate', 'Mechanical Royalty Rate'), 'royalty': VendorsFieldNames( 'copyrightWithholding', ( 'Total Mechanical Royalties Deducted' ' from Label’s Receipts (if applicable)')), 'admin_fee': VendorsFieldNames('adminFee', None), 'public_domain': VendorsFieldNames('PublicDomain', None), 'usage_type': VendorsFieldNames('UsageTypeID', None)} MANDATORY_FIELDS = { 'store', 'qty', 'original_track_id', 'period_year', 'period_month', 'length_minute', 'length_seconds', 'track_name', 'track_artist'} SEPARATOR_PIPE = '||' SEPARATOR_SLASH = ' / ' ROWS_TO_PROCESS_PER_ITERATION = 200000 ENCODING_WINDOWS_1252 = 'windows-1252' ENCODING_ISO_8859_1 = 'iso-8859-1' ENCODING_UTF_8 = 'utf-8' ENCODINGS_TO_TRY = [ENCODING_UTF_8, ENCODING_WINDOWS_1252, ENCODING_ISO_8859_1] HEADERS_DEFAULT_ENCODING = ENCODING_WINDOWS_1252