def test_query_return_splitted_list(_mdfind): result = mdfind.count("kind:image", onlyin="~") assert result == int(COUNT_STDOUT)
def test_count_calls_mdfind_correct(_mdfind): mdfind.count("kind:image", onlyin="~") assert _mdfind.call_args == call("-count", "kind:image", "-onlyin", "~") mdfind.count("kind:image") assert _mdfind.call_args == call("-count", "kind:image")
def count(tag: AnyTag, *, onlyin: Optional[str] = None) -> int: """Output the total number of files by `tag`.""" tag = _create_tag(tag) return mdfind.count(query=_MDFIND_TAGS_QUERY.format(tag.name), onlyin=onlyin)
#!/usr/bin/env python import mdfind query = 'kMDItemContentType==public.mp3' count = mdfind.count(query=query) print(count)
#!/usr/bin/env python import mdfind import tests_os.mac name = "Downloads" count = mdfind.count(name=name) print(count)