晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
| DIR:/opt/cloudlinux/venv/lib64/python3.11/site-packages/astroid/ |
| Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/astroid/__init__.py |
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt
"""Python Abstract Syntax Tree New Generation.
The aim of this module is to provide a common base representation of
python source code for projects such as pychecker, pyreverse,
pylint... Well, actually the development of this library is essentially
governed by pylint's needs.
It mimics the class defined in the python's _ast module with some
additional methods and attributes. New nodes instances are not fully
compatible with python's _ast.
Instance attributes are added by a
builder object, which can either generate extended ast (let's call
them astroid ;) by visiting an existent ast tree or by inspecting living
object. Methods are added by monkey patching ast classes.
Main modules are:
* nodes and scoped_nodes for more information about methods and
attributes added to different node classes
* the manager contains a high level object to get astroid trees from
source files and living objects. It maintains a cache of previously
constructed tree for quick access
* builder contains the class responsible to build astroid trees
"""
import functools
import tokenize
from importlib import import_module
# isort: off
# We have an isort: off on '__version__' because the packaging need to access
# the version before the dependencies are installed (in particular 'wrapt'
# that is imported in astroid.inference)
from astroid.__pkginfo__ import __version__, version
from astroid.nodes import node_classes, scoped_nodes
# isort: on
from astroid import inference, raw_building
from astroid.astroid_manager import MANAGER
from astroid.bases import BaseInstance, BoundMethod, Instance, UnboundMethod
from astroid.brain.helpers import register_module_extender
from astroid.builder import extract_node, parse
from astroid.const import BRAIN_MODULES_DIRECTORY, PY310_PLUS, Context, Del, Load, Store
from astroid.exceptions import (
AstroidBuildingError,
AstroidBuildingException,
AstroidError,
AstroidImportError,
AstroidIndexError,
AstroidSyntaxError,
AstroidTypeError,
AstroidValueError,
AttributeInferenceError,
BinaryOperationError,
DuplicateBasesError,
InconsistentMroError,
InferenceError,
InferenceOverwriteError,
MroError,
NameInferenceError,
NoDefault,
NotFoundError,
OperationError,
ParentMissingError,
ResolveError,
StatementMissing,
SuperArgumentTypeError,
SuperError,
TooManyLevelsError,
UnaryOperationError,
UnresolvableName,
UseInferenceDefault,
)
from astroid.inference_tip import _inference_tip_cached, inference_tip
from astroid.objects import ExceptionInstance
# isort: off
# It's impossible to import from astroid.nodes with a wildcard, because
# there is a cyclic import that prevent creating an __all__ in astroid/nodes
# and we need astroid/scoped_nodes and astroid/node_classes to work. So
# importing with a wildcard would clash with astroid/nodes/scoped_nodes
# and astroid/nodes/node_classes.
from astroid.nodes import ( # pylint: disable=redefined-builtin (Ellipsis)
CONST_CLS,
AnnAssign,
Arguments,
Assert,
Assign,
AssignAttr,
AssignName,
AsyncFor,
AsyncFunctionDef,
AsyncWith,
Attribute,
AugAssign,
Await,
BinOp,
BoolOp,
Break,
Call,
ClassDef,
Compare,
Comprehension,
ComprehensionScope,
Const,
Continue,
Decorators,
DelAttr,
Delete,
DelName,
Dict,
DictComp,
DictUnpack,
Ellipsis,
EmptyNode,
EvaluatedObject,
ExceptHandler,
Expr,
ExtSlice,
For,
FormattedValue,
FunctionDef,
GeneratorExp,
Global,
If,
IfExp,
Import,
ImportFrom,
Index,
JoinedStr,
Keyword,
Lambda,
List,
ListComp,
Match,
MatchAs,
MatchCase,
MatchClass,
MatchMapping,
MatchOr,
MatchSequence,
MatchSingleton,
MatchStar,
MatchValue,
Module,
Name,
NamedExpr,
NodeNG,
Nonlocal,
Pass,
Raise,
Return,
Set,
SetComp,
Slice,
Starred,
Subscript,
TryExcept,
TryFinally,
TryStar,
Tuple,
UnaryOp,
Unknown,
While,
With,
Yield,
YieldFrom,
are_exclusive,
builtin_lookup,
unpack_infer,
function_to_method,
)
# isort: on
from astroid.util import Uninferable
# Performance hack for tokenize. See https://bugs.python.org/issue43014
# Adapted from https://github.com/PyCQA/pycodestyle/pull/993
if (
not PY310_PLUS
and callable(getattr(tokenize, "_compile", None))
and getattr(tokenize._compile, "__wrapped__", None) is None # type: ignore[attr-defined]
):
tokenize._compile = functools.lru_cache()(tokenize._compile) # type: ignore[attr-defined]
# load brain plugins
for module in BRAIN_MODULES_DIRECTORY.iterdir():
if module.suffix == ".py":
import_module(f"astroid.brain.{module.stem}")
|