repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
textual
src/textual/widgets/_list_view.py
.py
from __future__ import annotations from typing import ClassVar, Iterable, Optional from typing_extensions import TypeGuard from textual._loop import loop_from_index from textual.await_complete import AwaitComplete from textual.await_remove import AwaitRemove from textual.binding import Binding, BindingType from text...
397
14,297
textual
src/textual/widgets/selection_list.py
.py
from textual.widgets._selection_list import ( MessageSelectionType, Selection, SelectionError, SelectionType, ) __all__ = ["MessageSelectionType", "Selection", "SelectionError", "SelectionType"]
9
212
textual
src/textual/widgets/input.py
.py
from textual.widgets._input import Selection __all__ = ["Selection"]
4
70
textual
src/textual/widgets/_content_switcher.py
.py
"""Provides a widget for switching between the display of its immediate children.""" from __future__ import annotations from typing import Optional from textual.await_complete import AwaitComplete from textual.containers import Container from textual.css.query import NoMatches from textual.events import Mount from t...
133
4,326
textual
src/textual/widgets/_static.py
.py
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from textual.app import RenderResult from textual.visual import Visual, VisualType, visualize from textual.widget import Widget class Static(Widget, inherit_bindings=False): """A widget to display simple static content, o...
96
3,220
textual
src/textual/widgets/_markdown_viewer.py
.py
from textual.widgets._markdown import MarkdownViewer __all__ = ["MarkdownViewer"]
4
83
textual
src/textual/widgets/_log.py
.py
from __future__ import annotations import re from typing import TYPE_CHECKING, Iterable, Optional, Sequence from rich.cells import cell_len from rich.highlighter import Highlighter, ReprHighlighter from rich.style import Style from rich.text import Text from textual import work from textual._line_split import line_s...
363
11,504
textual
src/textual/widgets/_tab.py
.py
from textual.widgets._tabs import Tab __all__ = ["Tab"]
4
57
textual
src/textual/widgets/option_list.py
.py
from textual.widgets._option_list import DuplicateID, Option, OptionDoesNotExist __all__ = ["DuplicateID", "Option", "OptionDoesNotExist"]
4
140
textual
src/textual/widgets/_rich_log.py
.py
"""Provides a scrollable text-logging widget.""" from __future__ import annotations from collections import deque from typing import TYPE_CHECKING, NamedTuple, Optional, cast from rich.console import RenderableType from rich.highlighter import Highlighter, ReprHighlighter from rich.measure import measure_renderables...
321
12,192
textual
src/textual/widgets/_collapsible.py
.py
from __future__ import annotations from textual import events from textual.app import ComposeResult from textual.binding import Binding from textual.containers import Container from textual.content import Content, ContentText from textual.css.query import NoMatches from textual.message import Message from textual.reac...
251
7,775
textual
src/textual/widgets/select.py
.py
from textual.widgets._select import ( NULL, EmptySelectError, InvalidSelectValueError, NoSelection, ) __all__ = ["EmptySelectError", "InvalidSelectValueError", "NoSelection", "NULL"]
9
200
textual
src/textual/widgets/_tree.py
.py
"""Provides a tree widget.""" from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING, ClassVar, Generic, Iterable, NewType, TypeVar, cast import rich.repr from rich.style import NULL_STYLE, Style from rich.text import Text, TextType from textual import events, on from ...
1,602
51,557
textual
src/textual/widgets/_data_table.py
.py
from __future__ import annotations import functools from dataclasses import dataclass from itertools import chain, zip_longest from operator import itemgetter from typing import ( Any, Callable, ClassVar, Generic, Iterable, NamedTuple, TypeVar, Union, ) import rich.repr from rich.conso...
2,865
108,987
textual
src/textual/widgets/_option_list.py
.py
from __future__ import annotations from dataclasses import dataclass, field from typing import TYPE_CHECKING, ClassVar, Iterable, Sequence, cast import rich.repr from rich.segment import Segment from textual import _widget_navigation, events from textual._loop import loop_last from textual.binding import Binding, Bi...
1,040
34,230
textual
src/textual/widgets/_progress_bar.py
.py
"""Implements a progress bar widget.""" from __future__ import annotations from typing import Optional, Type from rich.style import Style from textual._types import UnusedParameter from textual.app import ComposeResult, RenderResult from textual.clock import Clock from textual.color import Gradient from textual.eta...
386
13,150
textual
src/textual/widgets/_rule.py
.py
from __future__ import annotations from typing import Iterable from rich.console import Console, ConsoleOptions from rich.segment import Segment from rich.style import Style from typing_extensions import Literal from textual.app import RenderResult from textual.css._error_tools import friendly_list from textual.geom...
269
7,481
textual
src/textual/widgets/_header.py
.py
"""Provides a Textual application header widget.""" from __future__ import annotations from datetime import datetime from rich.text import Text from textual.app import ComposeResult, RenderResult from textual.content import Content from textual.dom import NoScreen from textual.events import Click, Mount from textua...
229
6,299
textual
src/textual/widgets/tree.py
.py
"""Make non-widget Tree support classes available.""" from textual.widgets._tree import ( AddNodeError, EventTreeDataType, NodeID, RemoveRootError, TreeDataType, TreeNode, UnknownNodeID, ) __all__ = [ "AddNodeError", "EventTreeDataType", "NodeID", "RemoveRootError", "Tr...
22
372
textual
src/textual/widgets/_button.py
.py
from __future__ import annotations from functools import partial from typing import TYPE_CHECKING, cast import rich.repr from rich.cells import cell_len from rich.console import ConsoleRenderable, RenderableType from typing_extensions import Literal, Self from textual import events if TYPE_CHECKING: from textua...
559
17,246
textual
src/textual/widgets/_placeholder.py
.py
"""Provides a Textual placeholder widget; useful when designing an app's layout.""" from __future__ import annotations from itertools import cycle from typing import TYPE_CHECKING from weakref import WeakKeyDictionary from typing_extensions import Literal, Self from textual import events if TYPE_CHECKING: from...
187
6,435
textual
src/textual/widgets/_loading_indicator.py
.py
from __future__ import annotations from time import time from typing import TYPE_CHECKING from rich.style import Style from rich.text import Text if TYPE_CHECKING: from textual.app import RenderResult from textual import on from textual.color import Gradient from textual.events import InputEvent, Mount from tex...
94
2,545
textual
src/textual/widgets/_select.py
.py
from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING, Generic, Hashable, Iterable, TypeVar import rich.repr from rich.console import RenderableType from rich.text import Text from textual import events, on from textual.binding import Binding from textual.containers im...
720
23,970
textual
src/textual/widgets/_selection_list.py
.py
"""Provides a selection list widget, allowing one or more items to be selected.""" from __future__ import annotations from dataclasses import dataclass from typing import Callable, ClassVar, Generic, Iterable, TypeVar, cast from rich.repr import Result from rich.segment import Segment from rich.style import Style fr...
716
25,078
textual
src/textual/widgets/_tabs.py
.py
from __future__ import annotations from dataclasses import dataclass from typing import ClassVar import rich.repr from rich.style import Style from rich.text import Text from textual import events from textual.app import ComposeResult, RenderResult from textual.await_complete import AwaitComplete from textual.bindin...
875
27,190
textual
src/textual/widgets/_label.py
.py
"""Provides a simple Label widget.""" from __future__ import annotations from typing import Literal from textual.visual import VisualType from textual.widgets._static import Static LabelVariant = Literal["success", "error", "warning", "primary", "secondary", "accent"] class Label(Static): """A simple label wi...
74
1,762
textual
src/textual/widgets/_digits.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, cast from rich.align import Align, AlignMethod if TYPE_CHECKING: from textual.app import RenderResult from textual.geometry import Size from textual.renderables.digits import Digits as DigitsRenderable from textual.selection import Selection f...
113
3,478
textual
src/textual/widgets/text_area.py
.py
from textual._text_area_theme import TextAreaTheme from textual.document._document import ( Document, DocumentBase, EditResult, Location, Selection, ) from textual.document._document_navigator import DocumentNavigator from textual.document._edit import Edit from textual.document._history import Edit...
44
1,025
textual
src/textual/widgets/_tooltip.py
.py
from __future__ import annotations from textual.widgets import Static class Tooltip(Static, inherit_css=False): DEFAULT_CSS = """ Tooltip { layer: _tooltips; margin: 1 0; padding: 1 2; background: $panel; width: auto; height: auto; constrain: inside inf...
25
519
textual
src/textual/widgets/collapsible.py
.py
from textual.widgets._collapsible import CollapsibleTitle __all__ = ["CollapsibleTitle"]
4
90
textual
src/textual/widgets/_tab_pane.py
.py
from textual.widgets._tabbed_content import TabPane __all__ = ["TabPane"]
4
75
textual
src/textual/widgets/_toast.py
.py
"""Widgets for showing notification messages in toasts.""" from __future__ import annotations from typing import ClassVar from textual import on from textual.containers import Container from textual.content import Content from textual.css.query import NoMatches from textual.events import Click, Mount from textual.no...
207
5,976
textual
src/textual/widgets/_radio_set.py
.py
"""Provides a RadioSet widget, which groups radio buttons.""" from __future__ import annotations from typing import ClassVar, Optional import rich.repr from rich.console import RenderableType from textual import _widget_navigation from textual.binding import Binding, BindingType from textual.containers import Verti...
316
11,492
textual
src/textual/widgets/_switch.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, ClassVar from rich.console import RenderableType if TYPE_CHECKING: from textual.app import RenderResult from typing_extensions import Self from textual.binding import Binding, BindingType from textual.events import Click from textual.geome...
222
6,305
textual
src/textual/document/_syntax_aware_document.py
.py
from __future__ import annotations try: from tree_sitter import Language, Node, Parser, Query, QueryCursor, Tree TREE_SITTER = True except ImportError: TREE_SITTER = False from textual.document._document import Document, EditResult, Location, _utf8_encode _UINT32_MAX = 0xFFFFFFFF class SyntaxAwareDoc...
235
7,915
textual
src/textual/document/_wrapped_document.py
.py
from __future__ import annotations from bisect import bisect_right from rich.text import Text from textual._cells import cell_len, cell_width_to_column_index from textual._wrap import compute_wrap_offsets from textual.document._document import DocumentBase, Location from textual.expand_tabs import expand_tabs_inline...
455
17,779
textual
src/textual/document/_document.py
.py
from __future__ import annotations from abc import ABC, abstractmethod from dataclasses import dataclass from functools import lru_cache from typing import TYPE_CHECKING, NamedTuple, Tuple, overload from typing_extensions import Literal, get_args if TYPE_CHECKING: from tree_sitter import Node, Query from textua...
474
15,067
textual
src/textual/document/_history.py
.py
from __future__ import annotations import time from collections import deque from dataclasses import dataclass, field from textual.document._edit import Edit class HistoryException(Exception): """Indicates misuse of the EditHistory API. For example, trying to undo() an Edit that has yet to be done. """...
184
7,061
textual
src/textual/document/_document_navigator.py
.py
import re from bisect import bisect, bisect_left, bisect_right from typing import Any, Sequence from textual._cells import cell_len from textual.document._document import Location from textual.document._wrapped_document import WrappedDocument from textual.geometry import Offset, clamp class DocumentNavigator: ""...
471
18,340
textual
src/textual/document/_edit.py
.py
from __future__ import annotations from dataclasses import dataclass, field from typing import TYPE_CHECKING from textual.document._document import EditResult, Location, Selection if TYPE_CHECKING: from textual.widgets import TextArea @dataclass class Edit: """Implements the Undoable protocol to replace te...
152
5,707
textual
src/textual/layouts/horizontal.py
.py
from __future__ import annotations from fractions import Fraction from typing import TYPE_CHECKING from textual._resolve import resolve_box_models from textual.geometry import NULL_OFFSET, Region, Size from textual.layout import ArrangeResult, Layout, WidgetPlacement if TYPE_CHECKING: from textual.geometry impor...
121
3,867
textual
src/textual/layouts/vertical.py
.py
from __future__ import annotations from fractions import Fraction from typing import TYPE_CHECKING from textual._resolve import resolve_box_models from textual.geometry import NULL_OFFSET, Region, Size from textual.layout import ArrangeResult, Layout, WidgetPlacement if TYPE_CHECKING: from textual.geometry impor...
125
3,913
textual
src/textual/layouts/grid.py
.py
from __future__ import annotations from fractions import Fraction from typing import TYPE_CHECKING, Iterable from textual._resolve import resolve from textual.css.scalar import Scalar from textual.geometry import NULL_OFFSET, Region, Size, Spacing from textual.layout import ArrangeResult, Layout, WidgetPlacement from...
377
13,661
textual
src/textual/layouts/factory.py
.py
from __future__ import annotations from textual.layout import Layout from textual.layouts.grid import GridLayout from textual.layouts.horizontal import HorizontalLayout from textual.layouts.stream import StreamLayout from textual.layouts.vertical import VerticalLayout LAYOUT_MAP: dict[str, type[Layout]] = { "hori...
38
881
textual
src/textual/layouts/stream.py
.py
from __future__ import annotations from itertools import zip_longest from typing import TYPE_CHECKING from textual.geometry import NULL_OFFSET, Region, Size from textual.layout import ArrangeResult, Layout, WidgetPlacement if TYPE_CHECKING: from textual.widget import Widget class StreamLayout(Layout): """A...
150
5,169
textual
src/textual/drivers/_writer_thread.py
.py
from __future__ import annotations import threading from queue import Queue from typing import IO from typing_extensions import Final MAX_QUEUED_WRITES: Final[int] = 30 class WriterThread(threading.Thread): """A thread / file-like to do writes to stdout in the background.""" def __init__(self, file: IO[st...
69
1,733
textual
src/textual/drivers/windows_driver.py
.py
from __future__ import annotations import asyncio import sys from threading import Event, Thread from typing import TYPE_CHECKING, Callable from textual.driver import Driver from textual.drivers import win32 from textual.drivers._writer_thread import WriterThread if TYPE_CHECKING: from textual.app import App c...
142
4,486
textual
src/textual/drivers/_byte_stream.py
.py
from __future__ import annotations import io from collections import deque from typing import ( Callable, Deque, Generator, Generic, Iterable, NamedTuple, Tuple, TypeVar, ) from typing_extensions import TypeAlias class ParseError(Exception): """Parse related errors.""" class Pa...
158
4,052
textual
src/textual/drivers/_input_reader_windows.py
.py
import os import sys from threading import Event from typing import Iterator class InputReader: """Read input from stdin.""" def __init__(self, timeout: float = 0.1) -> None: """ Args: timeout: Seconds to block for input. """ self._fileno = sys.__stdin__.fileno() ...
34
830
textual
src/textual/drivers/linux_inline_driver.py
.py
from __future__ import annotations import asyncio import os import selectors import signal import sys import termios import tty from codecs import getincrementaldecoder from threading import Event, Thread from typing import TYPE_CHECKING, Any import rich.repr from textual import events from textual._loop import loop...
326
10,600
textual
src/textual/drivers/web_driver.py
.py
""" The Remote driver uses the following packet structure. 1 byte for packet type. "D" for data, "M" for meta. 4 byte little endian integer for the size of the payload. Arbitrary payload. """ from __future__ import annotations import asyncio import json import os import signal import sys from codecs import getinc...
355
12,324
textual
src/textual/drivers/linux_driver.py
.py
from __future__ import annotations import asyncio import os import selectors import signal import sys import termios import tty from codecs import getincrementaldecoder from threading import Event, Thread from typing import TYPE_CHECKING, Any, Final import rich.repr from textual import constants, events from textual...
486
16,950
textual
src/textual/drivers/_input_reader_linux.py
.py
import os import selectors import sys from threading import Event from typing import Iterator class InputReader: """Read input from stdin.""" def __init__(self, timeout: float = 0.1) -> None: """ Args: timeout: Seconds to block for input. """ self._fileno = sys.__...
41
1,165
textual
src/textual/drivers/headless_driver.py
.py
from __future__ import annotations import asyncio from textual import events from textual.driver import Driver from textual.geometry import Size class HeadlessDriver(Driver): """A do-nothing driver for testing.""" @property def is_headless(self) -> bool: """Is the driver running in 'headless' m...
67
1,888
textual
src/textual/drivers/win32.py
.py
from __future__ import annotations import ctypes import msvcrt import sys import threading from asyncio import AbstractEventLoop, run_coroutine_threadsafe from ctypes import Structure, Union, byref, wintypes from ctypes.wintypes import BOOL, CHAR, DWORD, HANDLE, SHORT, UINT, WCHAR, WORD from typing import IO, TYPE_CHE...
305
9,697
textual
src/textual/drivers/_input_reader.py
.py
import sys __all__ = ["InputReader"] WINDOWS = sys.platform == "win32" if WINDOWS: from textual.drivers._input_reader_windows import InputReader else: from textual.drivers._input_reader_linux import InputReader
11
222
textual
src/textual/renderables/background_screen.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Iterable from rich.console import Console, ConsoleOptions, RenderResult from rich.segment import Segment from rich.style import Style from textual.color import Color if TYPE_CHECKING: from textual.screen import Screen class BackgroundScreen:...
99
2,975
textual
src/textual/renderables/_blend_colors.py
.py
from __future__ import annotations from rich.color import Color def blend_colors(color1: Color, color2: Color, ratio: float) -> Color: """Given two RGB colors, return a color that sits some distance between them in RGB color space. Args: color1: The first color. color2: The second color....
28
732
textual
src/textual/renderables/bar.py
.py
from __future__ import annotations from rich.console import Console, ConsoleOptions, RenderResult from rich.style import Style, StyleType from rich.text import Text from textual.color import Gradient class Bar: """Thin horizontal bar with a portion highlighted. Args: highlight_range: The range to h...
156
5,112
textual
src/textual/renderables/digits.py
.py
from __future__ import annotations from rich.console import Console, ConsoleOptions, RenderResult from rich.measure import Measurement from rich.segment import Segment from rich.style import Style, StyleType DIGITS = " 0123456789+-^x:ABCDEF$£€()" DIGITS3X3_BOLD = """\ ┏━┓ ┃ ┃ ┗━┛ ╺┓ ┃ ╺┻╸ ╺━┓ ┏━┛ ┗━╸ ╺━┓ ━┫ ╺━┛ ...
254
3,692
textual
src/textual/renderables/sparkline.py
.py
from __future__ import annotations import statistics from fractions import Fraction from typing import Callable, Generic, Iterable, Sequence, TypeVar from rich.color import Color from rich.console import Console, ConsoleOptions, RenderResult from rich.measure import Measurement from rich.segment import Segment from r...
166
5,475
textual
src/textual/renderables/tint.py
.py
from __future__ import annotations from typing import Iterable from rich.console import RenderableType from rich.segment import Segment from rich.style import Style from rich.terminal_theme import TerminalTheme from textual.color import TRANSPARENT, Color from textual.filter import ANSIToTruecolor class Tint: ...
87
2,605
textual
src/textual/renderables/text_opacity.py
.py
import functools from typing import Iterable, Tuple, cast from rich.cells import cell_len from rich.color import Color from rich.console import Console, ConsoleOptions, RenderableType, RenderResult from rich.segment import Segment from rich.style import Style from rich.terminal_theme import TerminalTheme from textual...
160
5,827
textual
src/textual/renderables/gradient.py
.py
from __future__ import annotations from math import cos, pi, sin from typing import Sequence from rich.console import Console, ConsoleOptions, RenderResult from rich.segment import Segment from rich.style import Style from textual.color import Color, Gradient class VerticalGradient: """Draw a vertical gradient...
171
4,631
textual
src/textual/renderables/styled.py
.py
from typing import TYPE_CHECKING from rich.measure import Measurement from rich.segment import Segment if TYPE_CHECKING: from rich.console import Console, ConsoleOptions, RenderableType, RenderResult from rich.style import StyleType class Styled: """A renderable which allows you to apply a style before ...
51
1,937
textual
src/textual/renderables/blank.py
.py
from __future__ import annotations from rich.style import Style as RichStyle from textual.color import Color from textual.content import Style from textual.css.styles import RulesMap from textual.strip import Strip from textual.visual import RenderOptions, Visual class Blank(Visual): """Draw solid background co...
43
1,359
textual
src/textual/css/types.py
.py
from __future__ import annotations from typing import Tuple from typing_extensions import Literal from textual.color import Color DockEdge = Literal["none", "top", "right", "bottom", "left"] EdgeType = Literal[ "", "ascii", "none", "hidden", "blank", "round", "solid", "thick", "b...
93
2,164
textual
src/textual/css/scalar_animation.py
.py
from __future__ import annotations from typing import TYPE_CHECKING from textual._animator import Animation, EasingFunction from textual._types import AnimationLevel, CallbackType from textual.css.scalar import Scalar, ScalarOffset if TYPE_CHECKING: from textual.css.styles import StylesBase from textual.widg...
99
3,159
textual
src/textual/css/_styles_builder.py
.py
from __future__ import annotations from typing import Iterable, NoReturn, cast import rich.repr from textual._border import BorderValue, normalize_border_value from textual._cells import cell_len from textual._duration import _duration_as_seconds from textual._easing import EASING from textual.color import TRANSPARE...
1,317
49,495
textual
src/textual/css/parse.py
.py
from __future__ import annotations import dataclasses import re from functools import lru_cache from typing import Iterable, Iterator, NoReturn from textual.css._help_renderables import HelpText from textual.css._styles_builder import DeclarationError, StylesBuilder from textual.css.errors import UnresolvedVariableEr...
489
17,000
textual
src/textual/css/errors.py
.py
from __future__ import annotations from rich.console import Console, ConsoleOptions, RenderResult from textual.css._help_renderables import HelpText from textual.css.tokenizer import Token, TokenError class DeclarationError(Exception): def __init__(self, name: str, token: Token, message: str | HelpText) -> None...
51
1,304
textual
src/textual/css/_help_text.py
.py
from __future__ import annotations from dataclasses import dataclass from typing import Iterable, Sequence from typing_extensions import Literal from textual.color import ColorParseError from textual.css._error_tools import friendly_list from textual.css._help_renderables import Bullet, Example, HelpText from textua...
859
30,032
textual
src/textual/css/stylesheet.py
.py
from __future__ import annotations import os from collections import defaultdict from itertools import chain from operator import itemgetter from pathlib import Path, PurePath from typing import Final, Iterable, NamedTuple, Sequence, cast import rich.repr from rich.console import Console, ConsoleOptions, RenderableTy...
738
27,148
textual
src/textual/css/model.py
.py
from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from functools import partial from typing import TYPE_CHECKING, Iterable import rich.repr from textual.css._help_renderables import HelpText from textual.css.styles import Styles from textual.css.tokenize import Token f...
307
8,750
textual
src/textual/css/constants.py
.py
from __future__ import annotations import typing if typing.TYPE_CHECKING: from typing_extensions import Final VALID_VISIBILITY: Final = {"visible", "hidden"} VALID_DISPLAY: Final = {"block", "none"} VALID_BORDER: Final = { "ascii", "blank", "dashed", "double", "heavy", "hidden", "hkey...
134
2,629
textual
src/textual/css/tokenize.py
.py
from __future__ import annotations import re from typing import TYPE_CHECKING, ClassVar, Iterable from textual.css.tokenizer import Expect, Token, Tokenizer if TYPE_CHECKING: from textual.css.types import CSSLocation PERCENT = r"-?\d+\.?\d*%" DECIMAL = r"-?\d+\.?\d*" COMMA = r"\s*,\s*" OPEN_BRACE = r"\(\s*" CLO...
350
11,258
textual
src/textual/css/transition.py
.py
from typing import NamedTuple class Transition(NamedTuple): duration: float = 1.0 easing: str = "linear" delay: float = 0.0 def __str__(self) -> str: duration, easing, delay = self if delay: return f"{duration:.1f}s {easing} {delay:.1f}" elif easing != "linear": ...
17
417
textual
src/textual/css/styles.py
.py
from __future__ import annotations import weakref from dataclasses import dataclass, field from functools import partial from operator import attrgetter from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, Literal, cast import rich.repr from rich.style import Style from typing_extensions import TypedD...
1,529
52,117
textual
src/textual/css/match.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Iterable from textual.css.model import CombinatorType, Selector, SelectorSet if TYPE_CHECKING: from textual.dom import DOMNode def match(selector_sets: Iterable[SelectorSet], node: DOMNode) -> bool: """Check if a given node matches any of...
75
2,390
textual
src/textual/css/_style_properties.py
.py
""" Style properties are descriptors which allow the ``Styles`` object to accept different types when setting attributes. This gives the developer more freedom in how to express style information. Descriptors also play nicely with Mypy, which is aware that attributes can have different types when setting and getting. ...
1,259
43,257
textual
src/textual/css/tokenizer.py
.py
from __future__ import annotations import re from typing import TYPE_CHECKING, NamedTuple import rich.repr from rich.console import Group, RenderableType from rich.highlighter import ReprHighlighter from rich.padding import Padding from rich.panel import Panel from rich.text import Text from textual.css._error_tools...
385
11,826
textual
src/textual/css/query.py
.py
""" This module contains the `DOMQuery` class and related objects. A DOMQuery is a set of DOM nodes returned by [query][textual.dom.DOMNode.query]. The set of nodes may be further refined with [filter][textual.css.query.DOMQuery.filter] and [exclude][textual.css.query.DOMQuery.exclude]. Additional methods apply actio...
509
15,732
textual
src/textual/css/_error_tools.py
.py
from __future__ import annotations from typing import Iterable def friendly_list( words: Iterable[str], joiner: str = "or", omit_empty: bool = True ) -> str: """Generate a list of words as readable prose. >>> friendly_list(["foo", "bar", "baz"]) "'foo', 'bar', or 'baz'" Args: words: A l...
31
743
textual
src/textual/css/scalar.py
.py
from __future__ import annotations import re from enum import Enum, unique from fractions import Fraction from functools import lru_cache from typing import Iterable, NamedTuple import rich.repr from textual.geometry import Offset, Size, clamp class ScalarError(Exception): """Base class for exceptions raised b...
382
9,948
textual
src/textual/css/_help_renderables.py
.py
from __future__ import annotations from typing import Iterable import rich.repr from rich.console import Console, ConsoleOptions, RenderResult from rich.highlighter import ReprHighlighter from rich.markup import render from rich.text import Text _highlighter = ReprHighlighter() def _markup_and_highlight(text: str)...
98
2,833
Hello-Python
Backend/type_hints.py
.py
# Clase en vídeo: https://youtu.be/_y9qQZXE24A?t=1810 ### Type Hints ### my_string_variable = "My String variable" print(my_string_variable) print(type(my_string_variable)) my_string_variable = 5 print(my_string_variable) print(type(my_string_variable)) my_typed_variable: str = "My typed String variable" print(my_t...
20
446
Hello-Python
Backend/FastAPI/main.py
.py
# Clase en vídeo: https://youtu.be/_y9qQZXE24A ### Hola Mundo ### # Documentación oficial: https://fastapi.tiangolo.com/es/ # Instala FastAPI: pip install "fastapi[all]" from fastapi import FastAPI from routers import products, users, basic_auth_users, jwt_auth_users, users_db from fastapi.staticfiles import Static...
52
1,315
Hello-Python
Backend/FastAPI/routers/users_db.py
.py
# Clase en vídeo: https://youtu.be/_y9qQZXE24A?t=20480 ### Users DB API ### from fastapi import APIRouter, HTTPException, status from db.models.user import User from db.schemas.user import user_schema, users_schema from db.client import db_client from bson import ObjectId router = APIRouter( prefix="/userdb", ...
81
2,014
Hello-Python
Backend/FastAPI/routers/users.py
.py
# Clase en vídeo: https://youtu.be/_y9qQZXE24A?t=5382 ### Users API ### from fastapi import APIRouter, HTTPException from pydantic import BaseModel # Inicia el server: uvicorn users:app --reload router = APIRouter() class User(BaseModel): id: int name: str surname: str url: str age: int user...
98
2,342
Hello-Python
Backend/FastAPI/routers/basic_auth_users.py
.py
# Clase en vídeo: https://youtu.be/_y9qQZXE24A?t=14094 ### Users API con autorización OAuth2 básica ### from fastapi import APIRouter, Depends, HTTPException, status from pydantic import BaseModel from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm router = APIRouter( prefix="/basicauth"...
91
2,327
Hello-Python
Backend/FastAPI/routers/products.py
.py
# Clase en vídeo: https://youtu.be/_y9qQZXE24A?t=12475 ### Products API ### from fastapi import APIRouter router = APIRouter( prefix="/products", tags=["products"], responses={404: {"message": "No encontrado"}} ) products_list = ["Producto 1", "Producto 2", "Producto 3", "Producto 4", "Producto 5"] @r...
24
464
Hello-Python
Backend/FastAPI/routers/jwt_auth_users.py
.py
# Clase en vídeo: https://youtu.be/_y9qQZXE24A?t=17664 ### Users API con autorización OAuth2 JWT ### from fastapi import APIRouter, Depends, HTTPException, status from pydantic import BaseModel from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm from jose import jwt, JWTError from passlib.con...
116
3,136
Hello-Python
Backend/FastAPI/db/schemas/user.py
.py
# Clase en vídeo (22/12/2022): https://www.twitch.tv/videos/1686104006 ### User schema ### def user_schema(user) -> dict: return {"id": str(user["_id"]), "username": user["username"], "email": user["email"]} def users_schema(users) -> list: return [user_schema(user) for user in users...
13
323
Hello-Python
Backend/FastAPI/db/models/user.py
.py
# Clase en vídeo: https://youtu.be/_y9qQZXE24A?t=20480 ### User model ### from pydantic import BaseModel from typing import Optional class User(BaseModel): id: Optional[str] = None username: str email: str
13
223
Hello-Python
Basic/09_loops.py
.py
# Clase en vídeo: https://youtu.be/Kp4Mvapo5kc?t=23822 ### Loops ### # While my_condition = 0 while my_condition < 10: print(my_condition) my_condition += 2 else: # Es opcional print("Mi condición es mayor o igual que 10") print("La ejecución continúa") while my_condition < 20: my_condition += 1 ...
61
1,162
Hello-Python
Basic/00_helloworld.py
.py
# Clase en vídeo: https://youtu.be/Kp4Mvapo5kc ### Hola Mundo ### # Nuestro hola mundo en Python print("Hola Python") print('Hola Python') # Esto es un comentario """ Este es un comentario en varias líneas """ ''' Este también es un comentario en varias líneas ''' # Cómo consultar el tipo de dato print(type("Soy ...
30
547
Hello-Python
Basic/13_modules.py
.py
# Clase en vídeo: https://youtu.be/Kp4Mvapo5kc?t=34583 ### Modules ### from math import pi as PI_VALUE import math from my_module import sumValue, printValue import my_module my_module.sumValue(5, 3, 1) my_module.printValue("Hola Python!") sumValue(5, 3, 1) printValue("Hola python") print(math.pi) print(math.pow...
23
347
Hello-Python
Basic/12_exceptions.py
.py
# Clase en vídeo: https://youtu.be/Kp4Mvapo5kc?t=32030 ### Exception Handling ### numberOne = 5 numberTwo = 1 numberTwo = "1" # Excepción base: try except try: print(numberOne + numberTwo) print("No se ha producido un error") except: # Se ejecuta si se produce una excepción print("Se ha producido un...
51
1,192
Hello-Python
Basic/06_sets.py
.py
# Clase en vídeo: https://youtu.be/Kp4Mvapo5kc?t=16335 ### Sets ### # Definición my_set = set() my_other_set = {} print(type(my_set)) print(type(my_other_set)) # Inicialmente es un diccionario my_other_set = {"Brais", "Moure", 35} print(type(my_other_set)) print(len(my_other_set)) # Inserción my_other_set.add(...
58
1,083
Hello-Python
Basic/04_lists.py
.py
# Clase en vídeo: https://youtu.be/Kp4Mvapo5kc?t=10872 ### Lists ### # Definición my_list = list() my_other_list = [] print(len(my_list)) my_list = [35, 24, 62, 52, 30, 30, 17] print(my_list) print(len(my_list)) my_other_list = [35, 1.77, "Brais", "Moure"] print(type(my_list)) print(type(my_other_list)) # Acce...
95
1,577