def generate_filename(self, item): id_no = item.id_no title = item.image_title number = item.number provider = "SMV" filename = helpers.format_filename(title, provider, id_no + number) return filename
def generate_filename(self, item): """ Given an item (dict) generate an appropriate filename. The filename has the shape: descr - Collection - id and does not include filetype """ descr = item.generate_filename_descr() return helpers.format_filename(descr, item.samling, item.idno)
def generate_filename(self, item): """ Produce a descriptive filename for a single media file. This method is responsible for identifying the components which should be passed through helpers.format_filename(). @param item: the metadata for the media file in question @return: str """ descr = item.generate_filename_descr() return helpers.format_filename(descr, COLLECTION, item.obj_id)
def generate_filename(self, item): """ Given an item (dict) generate an appropriate filename. The filename has the shape: descr - Collection - id and does not include filetype :param item: the metadata for the media file in question :return: str """ return helpers.format_filename(item.get_title_description(), 'SMVK', item.photo_id)
def create_commons_filename(self, item): """ Transform original filename into Wikimedia commons style filename. See https://phabricator.wikimedia.org/T156612 for definition. Note: the returned filename does not include file extension e.g. '.tif' :param item: dictionary conatining metadata for one image :return: None (populates self.filename) """ fname_desc = "" fname_desc += re.sub(" Svenska Cypernexpeditionen\.?", "", item["Beskrivning"]) if not fname_desc.endswith("."): fname_desc += "." # Enrich with keywords keywords_to_append = [] if self.data["keyword_list"]: for keyword in self.data["keyword_list"]: if keyword not in item["Beskrivning"]: keywords_to_append.append(keyword) if keywords_to_append: fname_desc += " {}.".format(", ".join(keywords_to_append)) # Enrich with regional data if not item["Ort, foto"] in item["Beskrivning"]: fname_desc += " {},".format(item["Ort, foto"]) if not item["Region, foto"] in item["Beskrivning"]: fname_desc += " {},".format(item["Region, foto"]) if not item["Land, foto"] in item["Beskrivning"]: fname_desc += " {},".format(item["Land, foto"]) if fname_desc.endswith(","): fname_desc = "{}.".format(fname_desc.strip(",")) # Ensure first descriptive part is not empty if not fname_desc.strip(): fname_desc = "Svenska Cypernexpeditionen 1927–1931" fname_desc = fname_desc.replace("svenska cypernexpeditionen", "Svenska Cypernexpeditionen") self.filename = helpers.format_filename(fname_desc, "SMVK", item["Fotonummer"])
def generate_filename(self, item): """ Given an item (dict) generate an appropriate filename. The filename has the shape: descr - Collection - id and does not include filetype :param item: the metadata for the media file in question :return: str """ idno = item.glam_id title_desc = item.get_title_description() glam = self.glam_data.get("name") fname = helpers.format_filename(title_desc, glam, idno) if item.see_also: # sliders are numbered from 0, # but we want filenames to be numbered from 1 # note that get_other_versions must agree w/any changes here slider_plus_one = item.slider_order + 1 fname += "_({})".format(slider_plus_one) return fname
def get_other_versions(self): """ Create a gallery for other images of the same object. Sliders are numbered from 0, but we want filenames to start from 1. Note that generate_filename must agree w/any changes here """ txt = "" slider_plus_one = self.slider_order + 1 if self.see_also: txt = "<gallery>\n" total_imgs = len(self.see_also) + 1 for _ in range(1, total_imgs + 1): if _ != slider_plus_one: idno = self.glam_id title_desc = self.get_title_description() glam = self.glam_data.get("name") fname = helpers.format_filename(title_desc, glam, idno) fname += "_({})".format(_) txt += "File:{}.jpg\n".format(fname) txt += "</gallery>" return txt
def generate_filename(self, item): id_no = item.id_no title = item.image_title provider = "SMV" return helpers.format_filename(title, provider, id_no)