'Returns and logs the number of all items in the given directory.
The argument ``pattern`` has the same semantics as with `List Directory`
keyword. The count is returned as an integer, so it must be checked e.g.
with the built-in keyword `Should Be Equal As Integers`.'

def count_items_in_directory(self, path, pattern=None):

    count = len(self._list_dir(path, pattern))
    self._info(('%s    item%s.' % (count, plural_or_not(count))))
    return count
