diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-10-02 06:51:13 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-10-02 06:51:13 +0200 |
commit | c5fc6c6030d7d9d1b2af3d5165bebed3decd741b (patch) | |
tree | dfacccc9ae0747e53e53e5388b2ecd0623e040c3 /raphodo/rpdfile.py | |
parent | 77dd64c0757c0191b276e65c24ee9874959790c8 (diff) |
New upstream version 0.9.4upstream/0.9.4
Diffstat (limited to 'raphodo/rpdfile.py')
-rw-r--r-- | raphodo/rpdfile.py | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/raphodo/rpdfile.py b/raphodo/rpdfile.py index 055018a..5ae22e8 100644 --- a/raphodo/rpdfile.py +++ b/raphodo/rpdfile.py @@ -265,7 +265,16 @@ class FileTypeCounter(Counter): ('1 photo', 'photo') >>> f.file_types_present_details() '1 Photo' - >>> f[FileType.video] += 3 + >>> f.file_types_present_details(singular_natural=True) + 'a photo' + >>> f[FileType.photo] = 0 + >>> f[FileType.video] = 1 + >>> f.file_types_present_details(singular_natural=True) + 'a video' + >>> f[FileType.photo] += 1 + >>> f.file_types_present_details(singular_natural=True) + 'a photo and a video' + >>> f[FileType.video] += 2 >>> f FileTypeCounter({<FileType.video: 2>: 3, <FileType.photo: 1>: 1}) >>> f.file_types_present_details() @@ -308,19 +317,35 @@ class FileTypeCounter(Counter): 'filetypes': file_types_present} return (file_count_summary, file_types_present) - def file_types_present_details(self, title_case=True) -> str: + def file_types_present_details(self, title_case=True, singular_natural=False) -> str: + """ + + :param title_case: + :param singular_natural: if True, instead of '1 photo', return 'A photo'. If True, + title_case parameter is treated as always False. + :return: + """ + p = self[FileType.photo] v = self[FileType.video] if v > 1: videos = _('%(no_videos)s Videos') % dict(no_videos=thousands(v)) elif v == 1: - videos = _('1 Video') + if singular_natural: + # translators: natural language expression signifying a single video + videos = _('a video') + else: + videos = _('1 Video') if p > 1: photos = _('%(no_photos)s Photos') % dict(no_photos=thousands(p)) elif p == 1: - photos = _('1 Photo') + if singular_natural: + # translators: natural language expression signifying a single photo + photos = _('a photo') + else: + photos = _('1 Photo') if (p > 0) and (v > 0): s = make_internationalized_list([photos, videos]) @@ -331,7 +356,7 @@ class FileTypeCounter(Counter): else: s = photos - if title_case: + if title_case or singular_natural: return s else: return s.lower() @@ -370,7 +395,7 @@ class RPDFile: problem: Optional[Problem]=None) -> None: """ - :param name: filename (without path) + :param name: filename, including the extension, without its path :param path: path of the file :param size: file size :param device_timestamp_type: the method with which the device |