def test_name_set_no_changes(self): """ Tests that the field name does not change for creating a new one """ field1 = basic.date(name='field1') field2 = basic.date(name='field2') self.assertEqual('field1', field1.name) self.assertEqual('field2', field2.name)
def test_name_default(self): """ Tests that the default field name is correct for optional fields. """ field = basic.date() self.assertEqual('Date Field', field.name)
def date_time(name=None): """ Creates the grammar for a date and time field, which is a combination of the Date (D) and Time or Duration field (T). This field requires first a Date, and then a Time, without any space in between. :param name: name for the field :return: grammar for a Date and Time field """ if name is None: name = 'Date and Time Field' date = basic.date('Date') time = basic.time('Time') date = date.setResultsName('date') time = time.setResultsName('time') field = pp.Group(date + time) field.setParseAction(lambda d: _combine_date_time(d[0])) field.setName(name) return field.setResultsName('date_time')
def test_name_default_compulsory(self): """ Tests that the default field name is correct for optional fields, for compulsory fields. """ field = basic.date(compulsory=True) self.assertEqual('Date Field', field.name)
def test_name_set(self): """ Tests that the given field name is set correctly for optional fields. """ name = "Field Name" field = basic.date(name=name) self.assertEqual(name, field.name)
def setUp(self): self.date = basic.date()
from cwr.grammar.field import basic """ CWR Acknowledgement record fields grammar. """ __author__ = 'Bernardo Martínez Garrido' __license__ = 'MIT' __status__ = 'Development' # Acquires data sources _config = CWRConfiguration() # Creation Date creation_date = basic.date(compulsory=True) creation_date = creation_date.setName('Creation Date').setResultsName('creation_date') # Creation Time creation_time = basic.time(compulsory=True) creation_time = creation_time.setName('Creation Time').setResultsName('creation_time') # Original Group ID original_group_id = group.group_id original_group_id = original_group_id.setName('Original Group ID') # Original Transaction Sequence # original_transaction_sequence_n = basic.numeric(_config.field_size('acknowledgement', 'transaction_n'), compulsory=True) original_transaction_sequence_n = original_transaction_sequence_n.setName( 'Original Transaction Sequence #').setResultsName( 'original_transaction_sequence_n')
def get_field(self, name=None, columns=None, values=None): return basic.date(name)
def setUp(self): self.date = basic.date(compulsory=True)
_config = CWRConfiguration() # Work Title work_title = basic.alphanum(_config.field_size('work', 'work_title'), compulsory=True) work_title = work_title.setName('Work Title').setResultsName('title') # Submitter Work Number submitter_work_n = basic.alphanum(_config.field_size('work', 'work_id'), compulsory=True) submitter_work_n = submitter_work_n.setName('Submitter Work Number').setResultsName('submitter_work_n') # ISWC iswc = special.iswc() iswc = iswc.setResultsName('iswc') # Copyright Date copyright_date = basic.date() copyright_date = copyright_date.setName('Copyright Date').setResultsName('copyright_date') # Copyright Number copyright_number = basic.alphanum(_config.field_size('work', 'copyright_number')) copyright_number = copyright_number.setName('Copyright Number').setResultsName('copyright_number') # Duration duration = basic.time() duration = duration.setName('Duration').setResultsName('duration') # Recorded Indicator recorded = basic.flag(compulsory=True) recorded = recorded.setName('Recorded Indicator').setResultsName('recorded_indicator') # Contact Name
""" # Sender ID sender_id = basic.numeric(_config.field_size('transmission_header', 'sender_id'), compulsory=True) sender_id = sender_id.setName('Sender ID').setResultsName('sender_id') # Sender Name sender_name = basic.alphanum(_config.field_size('transmission_header', 'sender_name'), compulsory=True) sender_name = sender_name.setName('Sender Name').setResultsName('sender_name') # EDI Version edi_version = pp.Literal(_config.field_value('transmission_header', 'edi_version')) edi_version = edi_version.setName('EDI Version').setResultsName('edi_version') # Creation Date creation_date = basic.date(compulsory=True) creation_date = creation_date.setName('Creation Date').setResultsName('creation_date') # Creation Time creation_time = basic.time() creation_time = creation_time.setName('Creation Time').setResultsName('creation_time') # Transmission Date transmission_date = basic.date(compulsory=True) transmission_date = transmission_date.setName('Transmission Date').setResultsName('transmission_date') # Character Set character_set = table.char_code(_config.field_size('transmission_header', 'character_set')) character_set = character_set.setName('Character Set').setResultsName('character_set') """
# Performing Artist Last Name performing_artist_last_name = basic.alphanum(_config.field_size('performing_artist', 'performer_last_name')) performing_artist_last_name = performing_artist_last_name.setName('Performing Artist Last Name').setResultsName( 'performing_artist_last_name') # Performing Artist First Name performing_artist_first_name = basic.alphanum(_config.field_size('performing_artist', 'performer_first_name')) performing_artist_first_name = performing_artist_first_name.setName('Performing Artist First Name').setResultsName( 'performing_artist_first_name') """ REC fields. """ # First Release Date first_release = basic.date() first_release = first_release.setName('First Release Date').setResultsName('first_release_date') # First Release Duration first_release_duration = basic.time() first_release_duration = first_release_duration.setName('First Release Duration').setResultsName( 'first_release_duration') # First Album Title first_title = basic.alphanum(_config.field_size('recording_detail', 'first_album_title')) first_title = first_title.setName('First Album Title').setResultsName('first_album_title') # First Album Label first_label = basic.alphanum(_config.field_size('recording_detail', 'first_album_label')) first_label = first_label.setName('First Album Label').setResultsName('first_album_label')