def run(self, doc):
        for elem in doc.getiterator():
            if elem.tag in AutoTextDirectionTreeprocessor.BLOCK_LVL_ELS:
                # be sure to set the text properly to handle
                # http://dev.w3.org/html5/spec-preview/global-attributes.html#the-dir-attribute
                # if there are both ltr and rtl charas, force to ltr
                #print(elem.tag)
                if elem.text is not None:
                    #for child in elem.itertext():
                    #    print(child)
                    elem.set('dir', self._check_true_dir(elem.text))
                    #print("---", elem.tag, list(elem.iter()))
                else:
                    elem.set('dir', 'auto')
                #print("---")

    # http://stackoverflow.com/questions/17684990/python-testing-for-utf-8-character-in-string
dataset/ETHPy150Open ShadowKyogre/mikidown/mikidown/mdx_autodir.py/AutoTextDirectionTreeprocessor.run/original