582 Private method to scan the source text of a Python module and retrieve |
582 Private method to scan the source text of a Python module and retrieve |
583 the relevant information. |
583 the relevant information. |
584 |
584 |
585 @param src the source text to be scanned |
585 @param src the source text to be scanned |
586 @type str |
586 @type str |
587 """ # __IGNORE_WARNING_D234__ |
587 """ # __IGNORE_WARNING_D-234__ |
588 |
588 |
589 def calculateEndline(lineno, lines, indent): |
589 def calculateEndline(lineno, lines, indent): |
590 """ |
590 """ |
591 Function to calculate the end line of a class or method/function. |
591 Function to calculate the end line of a class or method/function. |
592 |
592 |
1741 |
1741 |
1742 if extension == ".ptl": |
1742 if extension == ".ptl": |
1743 moduleType = PTL_SOURCE |
1743 moduleType = PTL_SOURCE |
1744 elif extension == ".rb": |
1744 elif extension == ".rb": |
1745 moduleType = RB_SOURCE |
1745 moduleType = RB_SOURCE |
1746 elif extension in _extensions: # noqa: Y106 |
1746 elif extension in _extensions: # noqa: Y-106 |
1747 moduleType = PY_SOURCE |
1747 moduleType = PY_SOURCE |
1748 else: |
1748 else: |
1749 raise ImportError |
1749 raise ImportError |
1750 |
1750 |
1751 file = modname |
1751 file = modname |
1833 if os.path.exists(os.path.join(p, name)): |
1833 if os.path.exists(os.path.join(p, name)): |
1834 pathname = os.path.join(p, name) |
1834 pathname = os.path.join(p, name) |
1835 if ext == ".ptl": |
1835 if ext == ".ptl": |
1836 # Quixote page template |
1836 # Quixote page template |
1837 return ( |
1837 return ( |
1838 open(pathname), # noqa: Y115 |
1838 open(pathname), # noqa: Y-115 |
1839 pathname, |
1839 pathname, |
1840 (".ptl", "r", PTL_SOURCE), |
1840 (".ptl", "r", PTL_SOURCE), |
1841 ) |
1841 ) |
1842 elif ext == ".rb": |
1842 elif ext == ".rb": |
1843 # Ruby source file |
1843 # Ruby source file |
1844 return ( |
1844 return ( |
1845 open(pathname), # noqa: Y115 |
1845 open(pathname), # noqa: Y-115 |
1846 pathname, |
1846 pathname, |
1847 (".rb", "r", RB_SOURCE), |
1847 (".rb", "r", RB_SOURCE), |
1848 ) |
1848 ) |
1849 else: |
1849 else: |
1850 return ( |
1850 return ( |
1851 open(pathname), # noqa: Y115 |
1851 open(pathname), # noqa: Y-115 |
1852 pathname, |
1852 pathname, |
1853 (ext, "r", PY_SOURCE), |
1853 (ext, "r", PY_SOURCE), |
1854 ) |
1854 ) |
1855 raise ImportError |
1855 raise ImportError |
1856 |
1856 |
1861 spec = importlib.machinery.PathFinder.find_spec(name, path) |
1861 spec = importlib.machinery.PathFinder.find_spec(name, path) |
1862 if spec is None: |
1862 if spec is None: |
1863 raise ImportError |
1863 raise ImportError |
1864 if isinstance(spec.loader, importlib.machinery.SourceFileLoader): |
1864 if isinstance(spec.loader, importlib.machinery.SourceFileLoader): |
1865 ext = os.path.splitext(spec.origin)[-1] |
1865 ext = os.path.splitext(spec.origin)[-1] |
1866 return (open(spec.origin), spec.origin, (ext, "r", PY_SOURCE)) # noqa: Y115 |
1866 return (open(spec.origin), spec.origin, (ext, "r", PY_SOURCE)) # noqa: Y-115 |
1867 |
1867 |
1868 raise ImportError |
1868 raise ImportError |
1869 |
1869 |
1870 |
1870 |
1871 def resetParsedModules(): |
1871 def resetParsedModules(): |