def count_tables(filename_or_fobj, encoding="<STR_LIT:utf-8>", table_tag="<STR_LIT>"):
source = Source.from_file(<EOL>filename_or_fobj, plugin_name="<STR_LIT:html>", mode="<STR_LIT:rb>", encoding=encoding<EOL>)<EOL>html = source.fobj.read().decode(source.encoding)<EOL>html_tree = document_fromstring(html)<EOL>tables = html_tree.xpath("<STR_LIT>".format(table_tag))<EOL>result = len(tables)<EOL>if source.should_close:<EOL><INDENT>source.fobj.close()<EOL><DEDENT>return result<EOL>
Read a file passed by arg and return your table HTML tag count.