def make_photograph_template(self, item): """ Create the Photograph template for a single NM entry. :param item: the metadata for the media file in question :return: str """ template_name = 'Photograph' template_data = OrderedDict() template_data['photographer'] = item.get_creator() template_data['title'] = item.get_title() template_data['description'] = item.get_description() template_data['other_fields_2'] = item.get_original_description() template_data['depicted people'] = item.get_depicted_object( typ='person') template_data['depicted place'] = item.get_depicted_place() template_data['date'] = item.get_creation_date() template_data['exhibition_history'] = item.get_exhibitions() template_data['institution'] = item.get_institution() template_data['accession number'] = item.get_id_link() template_data['source'] = item.get_source() template_data['permission'] = item.get_license_text() template_data['other_versions'] = item.get_other_versions() txt = helpers.output_block_template(template_name, template_data, 0) txt += self.get_object_location(item) return txt
def make_artwork_info(self, item): """ Create the Artwork template for a single NM entry. :param item: the metadata for the media file in question :return: str """ template_name = 'Artwork' template_data = OrderedDict() template_data['artist'] = item.get_creator() template_data['title'] = item.get_title() template_data['date'] = item.get_creation_date() template_data['description'] = item.get_description(with_depicted=True) template_data['other_fields_2'] = item.get_original_description() template_data['medium'] = item.get_materials() template_data['dimensions'] = '' template_data['institution'] = item.get_institution() template_data['exhibition_history'] = item.get_exhibitions() template_data['location'] = '' template_data['references'] = '' template_data['object history'] = '' template_data['credit line'] = '' template_data['inscriptions'] = item.get_inscriptions() template_data['notes'] = '' template_data['accession number'] = item.get_id_link() template_data['source'] = item.get_source() template_data['permission'] = item.get_license_text() template_data['other_versions'] = item.get_other_versions() txt = helpers.output_block_template(template_name, template_data, 0) txt += self.get_object_location(item) return txt
def make_artwork_info(self, item): """ Create the Artwork template for a single SMVK entry. :param item: the metadata for the media file in question :return: str """ template_name = 'Artwork' template_data = OrderedDict() template_data['artist'] = item.get_creator_name() template_data['title'] = '' template_data['date'] = item.date_text template_data['other_fields_1'] = item.get_original_description( wrap=True) template_data['description'] = item.get_description(with_depicted=True) template_data['medium'] = '' template_data['dimensions'] = '' template_data['institution'] = ( '{{Institution:Statens museer för världskultur}}') template_data['department'] = item.get_museum_link() template_data['location'] = '' template_data['references'] = item.get_references() template_data['object history'] = '' template_data['credit line'] = '' template_data['notes'] = item.get_notes() template_data['accession number'] = item.get_id_link() template_data['source'] = item.get_source() template_data['permission'] = item.license_text template_data['other_versions'] = '' return helpers.output_block_template(template_name, template_data, 0)
def make_photograph_template(self, item): """ Create the Photograph template for a single SMVK entry. :param item: the metadata for the media file in question :return: str """ template_name = 'Photograph' template_data = OrderedDict() template_data['photographer'] = item.get_creator_name() template_data['title'] = '' template_data['description'] = item.get_description() template_data['original description info'] = ( '{{SMVK description/i18n}}') template_data['original description'] = item.get_original_description() template_data['depicted people'] = item.get_depicted_person() template_data['depicted place'] = item.get_depicted_place() template_data['date'] = item.date_text template_data['institution'] = ( '{{Institution:Statens museer för världskultur}}') template_data['department'] = item.get_museum_link() template_data['references'] = item.get_references() template_data['notes'] = item.get_notes() template_data['accession number'] = item.get_id_link() template_data['source'] = item.get_source() template_data['permission'] = item.license_text template_data['other_versions'] = '' return helpers.output_block_template(template_name, template_data, 0)
def make_info_template(self, item): """ Create the description template for a single KMB entry. :param item: the metadata for the media file in question :return: str """ template_name = 'Kulturmiljöbild-image' template_data = OrderedDict() template_data['short title'] = item.namn template_data['original description'] = item.get_original_description() template_data['wiki description'] = item.get_wiki_description() template_data['photographer'] = item.get_photographer() template_data['depicted place'] = item.get_depicted_place() template_data['date'] = item.date template_data['permission'] = item.license_text template_data['ID'] = item.ID template_data['bildbeteckning'] = item.bildbeteckning template_data['source'] = item.get_source() template_data['notes'] = '' template_data['other versions'] = item.get_other_versions() txt = helpers.output_block_template(template_name, template_data, 0) # append object location if appropriate if item.latitude and item.longitude: txt += '\n{{Object location dec|%s|%s}}' % ( item.latitude, item.longitude) return txt
def test_output_block_template_auto_padding(self): expected = "{{TemplateName\n" \ "| param1 = text1\n" \ "| param10 = text10\n" \ "| param100 = text100\n" \ "}}" self.assertEqual(output_block_template(self.name, self.data, None), expected)
def test_output_block_template_ommit_entry(self): self.data['special'] = None expected = "{{TemplateName\n" \ "| param1 = text1\n" \ "| param10 = text10\n" \ "| param100 = text100\n" \ "}}" self.assertEqual(output_block_template(self.name, self.data, None), expected)
def make_info_template(self, item): template_name = 'Musikverket-image' template_data = OrderedDict() template_data['title'] = item.image_title.replace("_", " ") template_data['depicted people'] = item.generate_depicted_people() template_data['date'] = item.generate_date() template_data['notes'] = self.generate_note() template_data['department'] = item.generate_collection() template_data['permission'] = item.generate_license() template_data['ID'] = item.id_no template_data['source'] = item.generate_source() return helpers.output_block_template(template_name, template_data, 0)
def make_info_template(self, item): template_name = 'Musikverket-image' template_data = OrderedDict() template_data['title'] = item.image_title template_data['description'] = item.generate_descriptions() template_data['dimensions'] = item.generate_dimensions() template_data['date'] = item.generate_date() template_data['department'] = item.generate_collection() template_data['permission'] = item.generate_license() template_data['ID'] = item.id_no template_data['source'] = item.generate_source() template_data['other versions'] = item.get_other_versions() return helpers.output_block_template(template_name, template_data, 0)
def make_info_template(self, item): template_name = 'Photograph' template_data = OrderedDict() template_data['title'] = item.generate_title() template_data['description'] = item.generate_description() template_data['photographer'] = "{{Creator:Sigurd Curman}}" template_data['department'] = ("Sigurd Curmans arkiv / " "Tekniska museet (SC-K1-1)") # template_data['date'] = item.generate_date() template_data['permission'] = item.generate_license() template_data['ID'] = item.generate_id() template_data['source'] = item.generate_source() return helpers.output_block_template(template_name, template_data, 0)
def make_list_row(self, data, template=None, delimiter='/'): """ Create the list template for a single mapping entry. @param data: the mapping data for a single entry @param template: the row template to use @param delimiter: delimiter to use for lists @return: str """ template_data = OrderedDict() template = template or self.row_template for data_key, template_key in self.parameters.items(): data_val = data.get(data_key) if isinstance(data_val, (set, list)): data_val = delimiter.join(data_val) elif data_val is None: data_val = '' template_data[template_key] = data_val return helpers.output_block_template(template, template_data, 0)
def test_output_block_template_unordered_dict(self): data = {'param1': 'text1'} expected = "{{TemplateName\n" \ "| param1 = text1\n" \ "}}" self.assertEqual(output_block_template(self.name, data, 0), expected)
def test_output_block_template_empty(self): expected = "{{\n}}" self.assertEqual(output_block_template('', {}, 0), expected)