id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
17,600 | thematicbreak.py | rafalp_Misago/misago/parser/postprocessors/thematicbreak.py | from .removerepeats import RemoveRepeatsPostProcessor
class RemoveThematicBreaksRepeatsPostProcessor(RemoveRepeatsPostProcessor):
checked_types = ["thematic-break-bbcode", "thematic-break"]
| 196 | Python | .py | 3 | 62.333333 | 75 | 0.858639 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,601 | quote.py | rafalp_Misago/misago/parser/postprocessors/quote.py | from ..parser import Parser
from .block import BlockPostProcessor
class QuoteBBCodePostProcessor(BlockPostProcessor):
opening_type = "quote-bbcode-open"
closing_type = "quote-bbcode-close"
def wrap_block(
self,
parser: Parser,
opening_block: dict,
closing_block: dict,
... | 619 | Python | .py | 20 | 22.75 | 51 | 0.593277 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,602 | block.py | rafalp_Misago/misago/parser/postprocessors/block.py | from ..parser import Parser
class BlockPostProcessor:
opening_type: str
closing_type: str
def __call__(self, parser: Parser, ast: list[dict]) -> list[dict]:
new_ast: list[dict] = []
stack: list[tuple[dict, list[dict]]] = []
for block_ast in ast:
if block_ast["type"] =... | 1,896 | Python | .py | 46 | 28.282609 | 84 | 0.532863 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,603 | removerepeats.py | rafalp_Misago/misago/parser/postprocessors/removerepeats.py | from ..parser import Parser
class RemoveRepeatsPostProcessor:
checked_types: list[str]
def __call__(self, parser: Parser, ast: list[dict]) -> list[dict]:
new_ast: list[dict] = []
for node in ast:
if (
node["type"] in self.checked_types
and new_ast
... | 581 | Python | .py | 16 | 24.9375 | 70 | 0.527728 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,604 | __init__.py | rafalp_Misago/misago/parser/postprocessors/__init__.py | from .block import BlockPostProcessor
from .quote import QuoteBBCodePostProcessor
from .removerepeats import RemoveRepeatsPostProcessor
from .spoiler import SpoilerBBCodePostProcessor
from .thematicbreak import RemoveThematicBreaksRepeatsPostProcessor
__all__ = [
"BlockPostProcessor",
"QuoteBBCodePostProcessor... | 553 | Python | .py | 17 | 29.529412 | 67 | 0.827715 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,605 | spoiler.py | rafalp_Misago/misago/parser/postprocessors/spoiler.py | from ..parser import Parser
from .block import BlockPostProcessor
class SpoilerBBCodePostProcessor(BlockPostProcessor):
opening_type = "spoiler-bbcode-open"
closing_type = "spoiler-bbcode-close"
def wrap_block(
self,
parser: Parser,
opening_block: dict,
closing_block: dict... | 586 | Python | .py | 19 | 22.894737 | 53 | 0.609236 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,606 | thematicbreak.py | rafalp_Misago/misago/parser/patterns/thematicbreak.py | from ..parser import Parser, Pattern
class ThematicBreakMarkdown(Pattern):
pattern_type: str = "thematic-break"
pattern: str = (
r"(\n|^) {0,3}((-\s*-\s*-(\s*-)*)|(_\s*_\s*_(\s*_)*)|(\*\s*\*\s*\*(\s*\*)*))\s*(\n|$)"
)
def parse(
self, parser: Parser, match: str, parents: list[str]
... | 654 | Python | .py | 17 | 32.647059 | 94 | 0.565769 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,607 | escape.py | rafalp_Misago/misago/parser/patterns/escape.py | import re
from ..parser import Parser, Pattern
ESCAPE = r"\\(_|[^\w\s])"
class Escape(Pattern):
pattern_type: str = "escape"
pattern: str = ESCAPE
def parse(
self, parser: Parser, match: str, parents: list[str]
) -> dict | list[dict]:
return {"type": self.pattern_type, "character": ... | 445 | Python | .py | 13 | 29.769231 | 66 | 0.643026 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,608 | quote.py | rafalp_Misago/misago/parser/patterns/quote.py | from ..parser import Parser, Pattern
class QuoteMarkdown(Pattern):
pattern_type: str = "quote"
pattern: str = r"(\n|^) ? ? ?>.*(\n ? ? ?>.*)*"
def parse(
self, parser: Parser, match: str, parents: list[str]
) -> dict | list[dict]:
content = clean_quote_markdown_content(match)
... | 1,761 | Python | .py | 46 | 30.804348 | 84 | 0.575133 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,609 | urls.py | rafalp_Misago/misago/parser/patterns/urls.py | import re
from functools import cached_property
from django.utils.crypto import get_random_string
from ..parents import has_invalid_parent
from ..parser import Parser, Pattern
MAIL_RE = re.compile(r"^\w+[.-_+\w]*@[-\w]+(.\w+)+$")
URL_RE = re.compile(
r"^(((https?)|(ftps?))://)?\w+(([-_\w])?\w+)*(\.\w+(([-_\w])?\... | 9,200 | Python | .py | 233 | 29.656652 | 88 | 0.535514 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,610 | code.py | rafalp_Misago/misago/parser/patterns/code.py | import re
from textwrap import dedent
from ..parser import Parser, Pattern
BLOCK_START = r"(\n|^)"
BLOCK_END = r"(\s+)?($|\n)"
CODE_FENCE = r"(```(.+)?\n(.|\n)+?\n```)"
CODE_FENCE_ALT = r"(~~~(.+)?\n(.|\n)+?\n~~~)"
CODE_FENCE_CONTENTS = re.compile(r"(?P<syntax>(.+))?\n(?P<code>(.|\n)+)\n")
class FencedCodeMarkdown... | 2,613 | Python | .py | 65 | 32.184615 | 80 | 0.554984 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,611 | __init__.py | rafalp_Misago/misago/parser/patterns/__init__.py | from ..parser import Pattern
from .bbcode import (
BoldBBCode,
InlineBBCodePattern,
ItalicsBBCode,
StrikethroughBBCode,
SubscriptBBCode,
SuperscriptBBCode,
UnderlineBBCode,
)
from .code import (
CodeBBCode,
FencedCodeMarkdown,
IndentedCodeMarkdown,
InlineCodeMarkdown,
)
from... | 2,405 | Python | .py | 93 | 22.376344 | 69 | 0.772708 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,612 | markdown.py | rafalp_Misago/misago/parser/patterns/markdown.py | from ..parents import has_invalid_parent
from ..parser import Parser, Pattern
class InlineMarkdownPattern(Pattern):
pattern_type: str
pattern: str
pattern_length: int
invalid_parents: set[str] | None = None
def parse(
self, parser: Parser, match: str, parents: list[str]
) -> dict | li... | 2,016 | Python | .py | 46 | 37.521739 | 84 | 0.64176 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,613 | lists.py | rafalp_Misago/misago/parser/patterns/lists.py | import re
from textwrap import dedent
from ..parser import Parser, Pattern
LIST_PATTERN = (
r"(\n|^)" # List is preceded by a new line or the start of the text
r" *(([-*+]|(1[.)]))( +.+)?(\n+|$))" # First list item
r"( *([-*+]|([0-9]+[.)]))( +.+)?(\n+|$))*" # Next list items
)
LIST_CONTENTS = re.compil... | 3,491 | Python | .py | 89 | 25.741573 | 82 | 0.463155 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,614 | headings.py | rafalp_Misago/misago/parser/patterns/headings.py | from ..parser import Parser, Pattern
class AtxHeading(Pattern):
pattern_type: str = "heading"
pattern: str = r"(\n|^)#{1,6}.*"
def parse(
self, parser: Parser, match: str, parents: list[str]
) -> dict | list[dict]:
content = match.strip()
level = 0
while content.start... | 1,255 | Python | .py | 37 | 23.810811 | 60 | 0.508685 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,615 | bbcode.py | rafalp_Misago/misago/parser/patterns/bbcode.py | from ..parents import has_invalid_parent
from ..parser import Parser, Pattern
class InlineBBCodePattern(Pattern):
pattern_type: str
pattern: str
invalid_parents: set[str] | None = None
@staticmethod
def create_pattern(bbcode: str) -> str:
return r"\[" + bbcode + r"\](.|\n)*?\[\/" + bbcode... | 2,190 | Python | .py | 47 | 40.510638 | 84 | 0.691149 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,616 | mention.py | rafalp_Misago/misago/parser/patterns/mention.py | from ..parents import has_invalid_parent
from ..parser import Parser, Pattern
from .urls import UrlBBCode, UrlMarkdown
class Mention(Pattern):
pattern_type: str = "mention"
pattern: str = r"(?<!\w)@[a-zA-Z0-9-_]+"
invalid_parents: set[str] = {UrlBBCode.pattern_type, UrlMarkdown.pattern_type}
def pars... | 566 | Python | .py | 11 | 46.090909 | 82 | 0.675136 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,617 | spoiler.py | rafalp_Misago/misago/parser/patterns/spoiler.py | from ..parser import Parser, Pattern
class SpoilerBBCodeOpen(Pattern):
pattern_type: str = "spoiler-bbcode-open"
pattern: str = r"\[spoiler(=.*?)?\]"
def parse(self, parser: Parser, match: str, parents: list[str]) -> dict:
summary = parser.reverse_reservations(match[8:-1].strip("\"' ="))
... | 660 | Python | .py | 15 | 37.2 | 76 | 0.628527 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,618 | conftest.py | rafalp_Misago/misago/parser/tests/conftest.py | from textwrap import dedent
import pytest
from ...permissions.proxy import UserPermissionsProxy
from ..context import create_parser_context
from ..factory import create_parser
@pytest.fixture
def parser(parser_context):
return create_parser(parser_context)
@pytest.fixture
def parser_context(dynamic_settings, ... | 759 | Python | .py | 21 | 32 | 68 | 0.767857 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,619 | test_headings.py | rafalp_Misago/misago/parser/tests/test_headings.py | def test_empty_atx_heading(parse_markup):
result = parse_markup("#")
assert result == [
{
"type": "heading",
"level": 1,
"children": [],
}
]
def test_atx_heading_with_text(parse_markup):
result = parse_markup("# Hello World!")
assert result == [
... | 4,506 | Python | .py | 165 | 17.436364 | 66 | 0.424832 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,620 | test_lists.py | rafalp_Misago/misago/parser/tests/test_lists.py | def test_unordered_list(parse_markup):
result = parse_markup("- Lorem")
assert result == [
{
"type": "list",
"ordered": False,
"sign": "-",
"items": [
{
"type": "list-item",
"children": [
... | 28,159 | Python | .py | 909 | 9.678768 | 92 | 0.185704 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,621 | test_block_postprocessor.py | rafalp_Misago/misago/parser/tests/test_block_postprocessor.py | from unittest.mock import Mock
import pytest
from ..parser import Parser
from ..postprocessors import BlockPostProcessor
class PostProcessor(BlockPostProcessor):
opening_type = "mock-open"
closing_type = "mock-close"
def wrap_block(
self,
parser: Parser,
opening_block: dict,
... | 8,409 | Python | .py | 299 | 16.180602 | 83 | 0.378248 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,622 | test_indented_code.py | rafalp_Misago/misago/parser/tests/test_indented_code.py | def test_indented_code(parse_markup):
result = parse_markup(
"""
Code:
lorem ipsum
"""
)
assert result == [
{
"type": "paragraph",
"children": [{"type": "text", "text": "Code:"}],
},
{
"type": "code-indented",
... | 1,451 | Python | .py | 62 | 13.725806 | 61 | 0.403496 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,623 | test_thematic_break.py | rafalp_Misago/misago/parser/tests/test_thematic_break.py | def test_thematic_break(parse_markup):
result = parse_markup("---")
assert result == [
{"type": "thematic-break"},
]
def test_thematic_break_with_asterisks(parse_markup):
result = parse_markup("***")
assert result == [
{"type": "thematic-break"},
]
def test_thematic_break_wit... | 2,404 | Python | .py | 81 | 21.222222 | 63 | 0.494582 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,624 | test_inline_bbcode.py | rafalp_Misago/misago/parser/tests/test_inline_bbcode.py | def test_inline_bbcode_with_text(parse_markup):
result = parse_markup("Hello [b]guest[/b]!")
assert result == [
{
"type": "paragraph",
"children": [
{"type": "text", "text": "Hello "},
{
"type": "bold-bbcode",
... | 5,393 | Python | .py | 175 | 17.611429 | 70 | 0.356291 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,625 | test_quote_bbcode.py | rafalp_Misago/misago/parser/tests/test_quote_bbcode.py | def test_quote_bbcode(parse_markup):
result = parse_markup("[quote]Hello world![/quote]")
assert result == [
{
"type": "quote-bbcode",
"author": None,
"post": None,
"children": [
{
"type": "paragraph",
... | 5,545 | Python | .py | 177 | 19.740113 | 77 | 0.424617 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,626 | test_escaping.py | rafalp_Misago/misago/parser/tests/test_escaping.py | from ..patterns import unescape_markup
def test_escaped_atx_heading(parse_markup):
result = parse_markup("\\# Lorem ipsum")
assert result == [
{
"type": "paragraph",
"children": [
{"type": "escape", "character": "#"},
{"type": "text", "text": " L... | 1,271 | Python | .py | 38 | 23.710526 | 66 | 0.469388 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,627 | test_autolink.py | rafalp_Misago/misago/parser/tests/test_autolink.py | def test_autolink(parse_markup):
result = parse_markup("Hello <https://image.com/>!")
assert result == [
{
"type": "paragraph",
"children": [
{"type": "text", "text": "Hello "},
{
"type": "auto-link",
"image"... | 3,235 | Python | .py | 103 | 18.951456 | 87 | 0.377885 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,628 | test_code_bbcode.py | rafalp_Misago/misago/parser/tests/test_code_bbcode.py | def test_code_bbcode_can_be_one_liner(parse_markup):
result = parse_markup(
"""
[code]alert("hello!")[/code]
"""
)
assert result == [
{
"type": "code-bbcode",
"syntax": None,
"code": 'alert("hello!")',
}
]
def test_code_bbcode... | 4,247 | Python | .py | 182 | 14.587912 | 72 | 0.419985 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,629 | test_spoiler_bbcode.py | rafalp_Misago/misago/parser/tests/test_spoiler_bbcode.py | def test_spoiler_bbcode(parse_markup):
result = parse_markup("[spoiler]Hello world![/spoiler]")
assert result == [
{
"type": "spoiler-bbcode",
"summary": None,
"children": [
{
"type": "paragraph",
"children": [{"... | 2,634 | Python | .py | 82 | 20.853659 | 80 | 0.444138 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,630 | test_html.py | rafalp_Misago/misago/parser/tests/test_html.py | import pytest
from ..html import complete_markup_html, render_ast_to_html
from ..metadata import create_ast_metadata
@pytest.mark.parametrize(
"markup",
(
"# Hello world!",
"## Hello world!",
"### Hello world!",
"#### Hello world!",
"##### Hello world!",
"#####... | 14,325 | Python | .py | 318 | 39.358491 | 88 | 0.690267 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,631 | test_parser.py | rafalp_Misago/misago/parser/tests/test_parser.py | from textwrap import dedent
from ..parser import Parser
def parse(value: str) -> list[dict]:
return Parser()(dedent(value).strip())
def test_parser_parses_single_paragraph():
result = parse("Hello world!")
assert result == [
{
"type": "paragraph",
"children": [
... | 3,032 | Python | .py | 102 | 19.735294 | 63 | 0.452798 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,632 | test_template_tags.py | rafalp_Misago/misago/parser/tests/test_template_tags.py | from django.template import Context, Template
from ..html import complete_markup_html, render_ast_to_html
from ..metadata import create_ast_metadata
def render(template_str, context: dict | None = None):
base_template = "{%% load misago_markup %%} %s"
context = Context(context or {})
template = Template(... | 764 | Python | .py | 15 | 47.2 | 74 | 0.731183 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,633 | test_context.py | rafalp_Misago/misago/parser/tests/test_context.py | from unittest.mock import Mock
import pytest
from ...permissions.proxy import UserPermissionsProxy
from ..context import create_parser_context
def test_create_parser_context_creates_context_from_request(
dynamic_settings, cache_versions, user
):
request = Mock(
settings=dynamic_settings,
cac... | 4,136 | Python | .py | 107 | 32.672897 | 85 | 0.73775 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,634 | test_urls.py | rafalp_Misago/misago/parser/tests/test_urls.py | def test_url(parse_markup):
result = parse_markup("Hello [link label](https://image.com/)!")
assert result == [
{
"type": "paragraph",
"children": [
{"type": "text", "text": "Hello "},
{
"type": "url",
"href"... | 14,033 | Python | .py | 422 | 19.338863 | 88 | 0.365097 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,635 | test_quote.py | rafalp_Misago/misago/parser/tests/test_quote.py | def test_empty_quote_is_removed(parse_markup):
result = parse_markup("> ")
assert result == []
def test_single_line_quote(parse_markup):
result = parse_markup("> Lorem ipsum")
assert result == [
{
"type": "quote",
"children": [
{
"typ... | 2,664 | Python | .py | 88 | 14.818182 | 69 | 0.311916 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,636 | test_inline_code.py | rafalp_Misago/misago/parser/tests/test_inline_code.py | def test_inline_code(parse_markup):
result = parse_markup("Hello `world`.")
assert result == [
{
"type": "paragraph",
"children": [
{"type": "text", "text": "Hello "},
{"type": "code-inline", "code": "world"},
{"type": "text", "text... | 2,556 | Python | .py | 74 | 23.891892 | 79 | 0.441748 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,637 | test_metadata.py | rafalp_Misago/misago/parser/tests/test_metadata.py | from ..metadata import create_ast_metadata
def test_create_ast_metadata_creates_metadata_for_empty_ast(parser_context):
metadata = create_ast_metadata(parser_context, [])
assert metadata["outbound-links"] == set()
assert metadata["usernames"] == set()
assert metadata["users"] == {}
def test_create_a... | 9,369 | Python | .py | 266 | 18.109023 | 86 | 0.335168 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,638 | test_plaintext.py | rafalp_Misago/misago/parser/tests/test_plaintext.py | import pytest
from ..metadata import create_ast_metadata
from ..plaintext import PlainTextFormat, render_ast_to_plaintext
@pytest.mark.parametrize(
"markup",
(
"# Hello world!",
"## Hello world!",
"### Hello world!",
"#### Hello world!",
"##### Hello world!",
"... | 19,338 | Python | .py | 467 | 35.610278 | 88 | 0.692332 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,639 | test_inline_markdown.py | rafalp_Misago/misago/parser/tests/test_inline_markdown.py | import pytest
def test_emphasis_whole_word(parse_markup):
result = parse_markup(f"Hello *word*.")
assert result == [
{
"type": "paragraph",
"children": [
{"type": "text", "text": "Hello "},
{
"type": "emphasis",
... | 24,413 | Python | .py | 773 | 19.021992 | 76 | 0.381373 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,640 | test_forum_address.py | rafalp_Misago/misago/parser/tests/test_forum_address.py | from unittest.mock import Mock
import pytest
from django.test import override_settings
from ..forumaddress import ForumAddress
@pytest.mark.parametrize(
"link",
(
"https://misago-project.org/",
"http://misago-project.org/",
"http://misago-project.org",
"misago-project.org",
... | 1,948 | Python | .py | 58 | 28.275862 | 88 | 0.670213 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,641 | test_mention.py | rafalp_Misago/misago/parser/tests/test_mention.py | def test_mention(parse_markup):
result = parse_markup("Hello @Bob_Boberston!")
assert result == [
{
"type": "paragraph",
"children": [
{"type": "text", "text": "Hello "},
{
"type": "mention",
"username": "Bob... | 430 | Python | .py | 15 | 16.466667 | 51 | 0.366265 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,642 | test_images.py | rafalp_Misago/misago/parser/tests/test_images.py | def test_image(parse_markup):
result = parse_markup("Hello !(https://image.com/img.jpg)!")
assert result == [
{
"type": "paragraph",
"children": [
{"type": "text", "text": "Hello "},
{
"type": "image",
"alt":... | 9,869 | Python | .py | 303 | 20.481848 | 87 | 0.406152 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,643 | test_fenced_code.py | rafalp_Misago/misago/parser/tests/test_fenced_code.py | def test_fenced_code_supports_backticks(parse_markup):
result = parse_markup(
"""
```
alert("hello!")
```
"""
)
assert result == [
{
"type": "code",
"syntax": None,
"code": 'alert("hello!")',
}
]
def test_fence... | 3,209 | Python | .py | 149 | 12.637584 | 72 | 0.376397 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,644 | render_ast_node_to_html.py | rafalp_Misago/misago/parser/hooks/render_ast_node_to_html.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..context import ParserContext
class RenderAstNodeToHtmlHookAction(Protocol):
"""
A standard Misago function used to create an HTML representation of the abstract
syntax tree's node or the next ... | 3,369 | Python | .py | 95 | 28.336842 | 84 | 0.648824 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,645 | get_ast_metadata_users_queryset.py | rafalp_Misago/misago/parser/hooks/get_ast_metadata_users_queryset.py | from typing import TYPE_CHECKING, Iterable, Protocol
from django.contrib.auth import get_user_model
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..context import ParserContext
User = get_user_model()
class GetAstMetadataUsersQuerysetHookAction(Protocol):
"""
A standard Misago functio... | 3,376 | Python | .py | 83 | 34.807229 | 84 | 0.721488 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,646 | create_parser.py | rafalp_Misago/misago/parser/hooks/create_parser.py | from typing import TYPE_CHECKING, Callable, Protocol
from ...plugins.hooks import FilterHook
from ..parser import Parser, Pattern
if TYPE_CHECKING:
from ..context import ParserContext
class CreateParserHookAction(Protocol):
"""
A standard Misago function used to create a markup parser instance or the
... | 4,398 | Python | .py | 113 | 32.20354 | 83 | 0.675561 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,647 | update_ast_metadata_users.py | rafalp_Misago/misago/parser/hooks/update_ast_metadata_users.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..context import ParserContext
class UpdateAstMetadataUsersHookAction(Protocol):
"""
A standard Misago function used to update the metadata with users from the database,
or the next filter funct... | 2,638 | Python | .py | 72 | 30.347222 | 88 | 0.692854 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,648 | complete_markup_html.py | rafalp_Misago/misago/parser/hooks/complete_markup_html.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..context import ParserContext
class CompleteMarkupHtmlHookAction(Protocol):
"""
A standard Misago function used to complete an HTML representation of parsed markup
or the next filter function f... | 2,861 | Python | .py | 76 | 31.394737 | 89 | 0.695921 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,649 | __init__.py | rafalp_Misago/misago/parser/hooks/__init__.py | from .complete_markup_html import complete_markup_html_hook
from .create_parser import create_parser_hook
from .get_ast_metadata_users_queryset import get_ast_metadata_users_queryset_hook
from .render_ast_node_to_html import render_ast_node_to_html_hook
from .render_ast_node_to_plaintext import render_ast_node_to_plain... | 936 | Python | .py | 20 | 43.95 | 81 | 0.777049 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,650 | render_ast_node_to_plaintext.py | rafalp_Misago/misago/parser/hooks/render_ast_node_to_plaintext.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..context import ParserContext
class RenderAstNodeToPlainTextHookAction(Protocol):
"""
A standard Misago function used to create a plain text representation of the
abstract syntax tree's node or... | 3,453 | Python | .py | 90 | 31.977778 | 86 | 0.676311 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,651 | update_ast_metadata.py | rafalp_Misago/misago/parser/hooks/update_ast_metadata.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..context import ParserContext
class UpdateAstMetadataHookAction(Protocol):
"""
A standard Misago function used to update the metadata with data from the Abstract
Syntax Tree representation of p... | 3,730 | Python | .py | 100 | 30.74 | 87 | 0.680145 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,652 | setup_parser_context.py | rafalp_Misago/misago/parser/hooks/setup_parser_context.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..context import ParserContext
class SetupParserContextHookAction(Protocol):
"""
A standard Misago function used to setup the Parser Context data class
instance or the next filter function from ... | 2,396 | Python | .py | 62 | 32.790323 | 85 | 0.71143 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,653 | update_ast_metadata_from_node.py | rafalp_Misago/misago/parser/hooks/update_ast_metadata_from_node.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..context import ParserContext
class UpdateAstMetadataFromNodeHookAction(Protocol):
"""
A standard Misago function used to update the metadata from an individual node
from the Abstract Syntax Tr... | 3,892 | Python | .py | 101 | 31.564356 | 88 | 0.677161 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,654 | signals.py | rafalp_Misago/misago/categories/signals.py | from django.dispatch import Signal, receiver
from ..users.signals import anonymize_user_data, username_changed
from .models import Category
delete_category_content = Signal()
move_category_content = Signal()
@receiver([anonymize_user_data, username_changed])
def update_usernames(sender, **kwargs):
Category.obje... | 436 | Python | .py | 10 | 40.6 | 70 | 0.7891 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,655 | models.py | rafalp_Misago/misago/categories/models.py | from django.db import models
from mptt.managers import TreeManager
from mptt.models import MPTTModel, TreeForeignKey
from ..acl.cache import clear_acl_cache
from ..acl.models import BaseRole
from ..conf import settings
from ..core.utils import slugify
from ..plugins.models import PluginDataModel
from ..threads.threadt... | 6,482 | Python | .py | 150 | 36.14 | 88 | 0.693858 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,656 | enums.py | rafalp_Misago/misago/categories/enums.py | from enum import IntEnum, StrEnum
from django.utils.translation import pgettext_lazy
class CategoryTree(IntEnum):
THREADS = 0
PRIVATE_THREADS = 1
class CategoryTreeDeprecated(IntEnum):
PRIVATE_THREADS = 0
THREADS = 1
class CategoryChildrenComponent(StrEnum):
FULL = "full"
DROPDOWN = "drop... | 958 | Python | .py | 32 | 21.03125 | 82 | 0.586696 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,657 | proxy.py | rafalp_Misago/misago/categories/proxy.py | from collections import defaultdict
from functools import cached_property
from ..permissions.proxy import UserPermissionsProxy
from .categories import get_categories
class CategoriesProxy:
user_permissions: UserPermissionsProxy
cache_versions: dict
_threads_paths: dict[list[dict]]
def __init__(self,... | 3,624 | Python | .py | 87 | 31.137931 | 85 | 0.595787 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,658 | serializers.py | rafalp_Misago/misago/categories/serializers.py | from django.urls import reverse
from rest_framework import serializers
from ..core.serializers import MutableFields
from ..core.utils import format_plaintext_for_html
from .models import Category
__all__ = ["CategorySerializer"]
def last_activity_detail(f):
"""util for serializing last activity details"""
... | 4,387 | Python | .py | 126 | 24.650794 | 88 | 0.579433 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,659 | components.py | rafalp_Misago/misago/categories/components.py | from typing import TYPE_CHECKING, Union
from django.contrib.auth import get_user_model
from django.contrib.auth.models import AnonymousUser
from django.http import HttpRequest
from ..permissions.enums import CategoryPermission
from ..permissions.proxy import UserPermissionsProxy
from ..readtracker.tracker import (
... | 6,842 | Python | .py | 180 | 30.333333 | 88 | 0.65659 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,660 | urls.py | rafalp_Misago/misago/categories/urls.py | from django.urls import path
from . import views
urlpatterns = [
path("categories/", views.index, name="categories", kwargs={"is_index": False}),
]
| 154 | Python | .py | 5 | 28.6 | 84 | 0.721088 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,661 | apps.py | rafalp_Misago/misago/categories/apps.py | from django.apps import AppConfig
class MisagoCategoriesConfig(AppConfig):
name = "misago.categories"
label = "misago_categories"
verbose_name = "Misago Categories"
def ready(self):
from . import signals as _
| 236 | Python | .py | 7 | 28.857143 | 40 | 0.725664 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,662 | mptt.py | rafalp_Misago/misago/categories/mptt.py | from .models import Category
MPTTData = tuple[int, int, int]
def heal_category_trees() -> int:
trees: set[int] = set()
categories: dict[int, dict] = {}
queryset = Category.objects.values(
"id",
"parent_id",
"tree_id",
"level",
"lft",
"rght",
).order_by... | 2,021 | Python | .py | 54 | 29.425926 | 85 | 0.597742 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,663 | permissions.py | rafalp_Misago/misago/categories/permissions.py | from django import forms
from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.utils.translation import pgettext_lazy
from ..acl import algebra
from ..acl.decorators import return_boolean
from ..admin.forms import YesNoSwitch
from .models import Category, CategoryRole, RoleCat... | 4,100 | Python | .py | 94 | 36.06383 | 87 | 0.665743 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,664 | categories.py | rafalp_Misago/misago/categories/categories.py | from typing import Any
from django.core.cache import cache
from django.urls import reverse
from ..cache.enums import CacheName
from ..permissions.enums import CategoryPermission
from ..permissions.proxy import UserPermissionsProxy
from .hooks import (
get_categories_query_values_hook,
get_category_data_hook,
... | 3,103 | Python | .py | 86 | 30.709302 | 82 | 0.671567 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,665 | views.py | rafalp_Misago/misago/categories/views.py | from typing import TYPE_CHECKING
from django.contrib import messages
from django.db import transaction
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect, render
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import pgettext
from ..... | 3,289 | Python | .py | 77 | 37.12987 | 86 | 0.723217 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,666 | 0012_categories_trees_ids.py | rafalp_Misago/misago/categories/migrations/0012_categories_trees_ids.py | # Generated by Django 4.2.7 on 2023-12-19 18:07
from django.db import migrations
from ..enums import CategoryTree, CategoryTreeDeprecated
def change_default_categories_trees_ids(apps, schema_editor):
# Swaps tree ids for threads and private threads around
Category = apps.get_model("misago_categories", "Cate... | 762 | Python | .py | 17 | 39.882353 | 76 | 0.753388 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,667 | 0002_default_categories.py | rafalp_Misago/misago/categories/migrations/0002_default_categories.py | from django.db import migrations
from ...core.utils import slugify
from ..enums import CategoryTreeDeprecated
_ = lambda s: s
def create_default_categories_tree(apps, schema_editor):
Category = apps.get_model("misago_categories", "Category")
Category.objects.create(
special_role="private_threads",
... | 1,129 | Python | .py | 37 | 23.594595 | 71 | 0.648474 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,668 | 0006_moderation_queue_roles.py | rafalp_Misago/misago/categories/migrations/0006_moderation_queue_roles.py | from django.db import migrations
_ = lambda s: s
def create_default_categories_roles(apps, schema_editor):
CategoryRole = apps.get_model("misago_categories", "CategoryRole")
CategoryRole.objects.create(
name=_("In moderation queue"),
permissions={
# threads perms
"mis... | 666 | Python | .py | 17 | 31.176471 | 72 | 0.652648 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,669 | 0009_auto_20221101_2111.py | rafalp_Misago/misago/categories/migrations/0009_auto_20221101_2111.py | # Generated by Django 3.2.15 on 2022-11-01 21:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("misago_categories", "0008_auto_20190518_1659"),
]
operations = [
migrations.AddField(
model_name="category",
name="c... | 598 | Python | .py | 18 | 24.888889 | 74 | 0.604167 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,670 | 0001_initial.py | rafalp_Misago/misago/categories/migrations/0001_initial.py | import django.db.models.deletion
import mptt.fields
from django.conf import settings
from django.db import migrations, models
from ...acl.models import permissions_default
class Migration(migrations.Migration):
initial = True
dependencies = [
("misago_acl", "0001_initial"),
migrations.swappa... | 6,014 | Python | .py | 155 | 20.709677 | 88 | 0.423471 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,671 | 0010_alter_rolecategoryacl_category_role.py | rafalp_Misago/misago/categories/migrations/0010_alter_rolecategoryacl_category_role.py | # Generated by Django 4.2.7 on 2023-11-13 19:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("misago_categories", "0009_auto_20221101_2111"),
]
operations = [
migrations.AlterField(
model_na... | 559 | Python | .py | 17 | 24.588235 | 60 | 0.622677 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,672 | 0013_new_behaviors.py | rafalp_Misago/misago/categories/migrations/0013_new_behaviors.py | # Generated by Django 4.2.10 on 2024-06-13 16:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("misago_categories", "0012_categories_trees_ids"),
]
operations = [
migrations.AddField(
model_name="category",
name... | 1,652 | Python | .py | 51 | 21.803922 | 59 | 0.560777 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,673 | 0005_auto_20170303_2027.py | rafalp_Misago/misago/categories/migrations/0005_auto_20170303_2027.py | # Generated by Django 1.10.5 on 2017-03-03 20:27
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("misago_categories", "0004_category_last_thread")]
operations = [
migrations.AddField(
model_name="category",
name="require_edits_a... | 749 | Python | .py | 21 | 26.52381 | 71 | 0.617931 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,674 | 0008_auto_20190518_1659.py | rafalp_Misago/misago/categories/migrations/0008_auto_20190518_1659.py | # Generated by Django 2.2.1 on 2019-05-18 16:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("misago_categories", "0007_best_answers_roles")]
operations = [
migrations.AlterField(
model_name="category",
name="level",
... | 722 | Python | .py | 21 | 25.190476 | 69 | 0.611191 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,675 | 0007_best_answers_roles.py | rafalp_Misago/misago/categories/migrations/0007_best_answers_roles.py | # Generated by Django 1.11.9 on 2018-03-18 20:40
from django.db import migrations
_ = lambda s: s
def create_default_categories_roles(apps, schema_editor):
CategoryRole = apps.get_model("misago_categories", "CategoryRole")
CategoryRole.objects.create(
name=_("Q&A user"),
permissions={
... | 1,125 | Python | .py | 30 | 28.1 | 73 | 0.593376 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,676 | 0011_plugin_data.py | rafalp_Misago/misago/categories/migrations/0011_plugin_data.py | # Generated by Django 4.2.7 on 2023-12-05 19:22
import django.contrib.postgres.indexes
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("misago_categories", "0010_alter_rolecategoryacl_category_role"),
]
operations = [
migrations.AddField(... | 683 | Python | .py | 20 | 25.75 | 77 | 0.622155 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,677 | 0003_categories_roles.py | rafalp_Misago/misago/categories/migrations/0003_categories_roles.py | from django.db import migrations
_ = lambda s: s
def create_default_categories_roles(apps, schema_editor):
CategoryRole = apps.get_model("misago_categories", "CategoryRole")
CategoryRole.objects.create(
name=_("See only"),
permissions={
# categories perms
"misago.cate... | 4,686 | Python | .py | 125 | 25.64 | 77 | 0.524972 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,678 | 0004_category_last_thread.py | rafalp_Misago/misago/categories/migrations/0004_category_last_thread.py | import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("misago_threads", "0001_initial"),
("misago_categories", "0003_categories_roles"),
]
operations = [
migrations.AddField(
model_name="categ... | 656 | Python | .py | 21 | 21.142857 | 61 | 0.55538 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,679 | test_component.py | rafalp_Misago/misago/categories/tests/test_component.py | from unittest.mock import Mock
import pytest
from django.utils import timezone
from ...permissions.enums import CategoryPermission
from ...permissions.proxy import UserPermissionsProxy
from ...testutils import (
grant_category_group_permissions,
remove_category_group_permissions,
)
from ..components import ge... | 9,877 | Python | .py | 232 | 37.357759 | 88 | 0.718264 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,680 | test_category_model_manager.py | rafalp_Misago/misago/categories/tests/test_category_model_manager.py | from ..models import Category
def test_category_manager_returns_private_threads(private_threads_category):
category = Category.objects.private_threads()
assert category == private_threads_category
assert category.special_role == "private_threads"
def test_category_manager_returns_root_category(root_cat... | 1,014 | Python | .py | 18 | 51.611111 | 78 | 0.766497 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,681 | test_categories_proxy.py | rafalp_Misago/misago/categories/tests/test_categories_proxy.py | from ...categories.models import Category
from ...permissions.enums import CategoryPermission
from ...permissions.proxy import UserPermissionsProxy
from ...testutils import (
grant_category_group_permissions,
remove_category_group_permissions,
)
from ..categories import get_category_data
from ..proxy import Cat... | 18,130 | Python | .py | 418 | 37.263158 | 88 | 0.733678 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,682 | test_prunecategories.py | rafalp_Misago/misago/categories/tests/test_prunecategories.py | from datetime import timedelta
from io import StringIO
from django.core.management import call_command
from django.test import TestCase
from django.utils import timezone
from ...threads import test
from ..management.commands import prunecategories
from ..models import Category
class PruneCategoriesTests(TestCase):
... | 5,787 | Python | .py | 129 | 35.75969 | 77 | 0.655621 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,683 | test_mark_as_read.py | rafalp_Misago/misago/categories/tests/test_mark_as_read.py | from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...readtracker.models import ReadCategory, ReadThread
from ...test import assert_contains
@override_dynamic_settings(index_view="threads")
def test_categories_view_mark_as_read_displays_categories_for_guests(
default_category... | 2,400 | Python | .py | 60 | 34.65 | 87 | 0.716315 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,684 | test_synchronizecategories.py | rafalp_Misago/misago/categories/tests/test_synchronizecategories.py | from io import StringIO
from django.core.management import call_command
from django.test import TestCase
from ...threads import test
from ..management.commands import synchronizecategories
from ..models import Category
class SynchronizeCategoriesTests(TestCase):
def test_categories_sync(self):
"""comman... | 1,039 | Python | .py | 23 | 38.173913 | 82 | 0.705765 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,685 | test_healcategorytrees.py | rafalp_Misago/misago/categories/tests/test_healcategorytrees.py | from io import StringIO
from django.core.management import call_command
from ...cache.enums import CacheName
from ...cache.test import assert_invalidates_cache
from ..management.commands import healcategorytrees
from ..models import Category
def run_command():
"""Run the management command"""
command = heal... | 1,089 | Python | .py | 27 | 35.925926 | 73 | 0.748571 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,686 | test_heal_category_trees.py | rafalp_Misago/misago/categories/tests/test_heal_category_trees.py | import pytest
from ..delete import delete_category
from ..models import Category
from ..mptt import heal_category_trees
@pytest.fixture
def clear_categories(db):
for category in Category.objects.order_by("-lft"):
delete_category(category)
def create_category(
tree_id: int,
level: int,
lft: ... | 3,936 | Python | .py | 98 | 34.836735 | 80 | 0.677122 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,687 | test_categories_view.py | rafalp_Misago/misago/categories/tests/test_categories_view.py | from datetime import timedelta
from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...permissions.enums import CategoryPermission
from ...test import assert_contains, assert_not_contains
from ...testutils import (
grant_category_group_permissions,
remove_category_group_perm... | 8,887 | Python | .py | 204 | 38.730392 | 87 | 0.761286 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,688 | test_category_model.py | rafalp_Misago/misago/categories/tests/test_category_model.py | from ...threads.test import post_thread
from ..models import Category
def assert_category_is_empty(category: Category):
assert category.last_post_on is None
assert category.last_thread is None
assert category.last_thread_title is None
assert category.last_thread_slug is None
assert category.last_p... | 3,877 | Python | .py | 86 | 39.930233 | 79 | 0.752262 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,689 | test_get_categories.py | rafalp_Misago/misago/categories/tests/test_get_categories.py | from unittest.mock import ANY
from ...permissions.enums import CategoryPermission
from ...permissions.proxy import UserPermissionsProxy
from ...testutils import grant_category_group_permissions
from ..categories import get_categories, get_category_data
def grant_categories_permissions(user, categories):
for cate... | 5,943 | Python | .py | 171 | 27.883041 | 88 | 0.671548 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,690 | synchronizecategories.py | rafalp_Misago/misago/categories/management/commands/synchronizecategories.py | import time
from django.core.management.base import BaseCommand
from ....core.management.progressbar import show_progress
from ...models import Category
class Command(BaseCommand):
help = "Synchronizes categories"
def handle(self, *args, **options):
categories_to_sync = Category.objects.count()
... | 1,030 | Python | .py | 22 | 38.727273 | 71 | 0.673695 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,691 | healcategorytrees.py | rafalp_Misago/misago/categories/management/commands/healcategorytrees.py | from django.core.management.base import BaseCommand
from ....acl.cache import clear_acl_cache
from ....cache.enums import CacheName
from ....cache.versions import invalidate_cache
from ...mptt import heal_category_trees
class Command(BaseCommand):
"""
This command rebuilds the category trees in the database.... | 903 | Python | .py | 22 | 34.590909 | 77 | 0.704467 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,692 | prunecategories.py | rafalp_Misago/misago/categories/management/commands/prunecategories.py | from datetime import timedelta
from django.core.management.base import BaseCommand
from django.utils import timezone
from ...models import Category
class Command(BaseCommand):
"""
This command is intended to work as CRON job fired
every few days (or more often) to execute categories pruning policies
... | 2,100 | Python | .py | 46 | 31.5 | 76 | 0.575208 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,693 | __init__.py | rafalp_Misago/misago/categories/admin/__init__.py | from django.urls import path
from django.utils.translation import pgettext_lazy
from .views.perms import (
CategoryPermissions,
CategoryRolesList,
DeleteCategoryRole,
EditCategoryRole,
NewCategoryRole,
RoleCategoriesACL,
)
class MisagoAdminExtension:
def register_urlpatterns(self, urlpatt... | 1,541 | Python | .py | 45 | 24.4 | 82 | 0.585906 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,694 | forms.py | rafalp_Misago/misago/categories/admin/forms.py | from django import forms
from django.utils.translation import pgettext_lazy
from ..models import CategoryRole
class CategoryRoleForm(forms.ModelForm):
name = forms.CharField(label=pgettext_lazy("admin category role form", "Role name"))
class Meta:
model = CategoryRole
fields = ["name"]
def... | 1,280 | Python | .py | 32 | 31.9375 | 88 | 0.659128 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,695 | perms.py | rafalp_Misago/misago/categories/admin/views/perms.py | from django.contrib import messages
from django.shortcuts import redirect
from django.utils.translation import pgettext_lazy
from ....acl.admin.forms import get_permissions_forms
from ....acl.admin.views import RoleAdmin, RolesList
from ....acl.cache import clear_acl_cache
from ....acl.models import Role
from ....admi... | 8,399 | Python | .py | 185 | 33.291892 | 86 | 0.598996 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,696 | test_permissions_admin_views.py | rafalp_Misago/misago/categories/admin/tests/test_permissions_admin_views.py | from django.urls import reverse
from ....acl import ACL_CACHE
from ....acl.models import Role
from ....acl.admin.test import mock_role_form_data
from ....admin.test import AdminTestCase
from ....cache.test import assert_invalidates_cache
from ...models import Category, CategoryRole
def create_data(data_dict):
re... | 13,591 | Python | .py | 319 | 31.056426 | 88 | 0.578561 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,697 | get_categories_page_component.py | rafalp_Misago/misago/categories/hooks/get_categories_page_component.py | from typing import Protocol
from django.http import HttpRequest
from ...plugins.hooks import FilterHook
class GetCategoriesPageComponentHookAction(Protocol):
"""
A standard Misago function used to build a `dict` with data for
the categories list component, used to display the list of categories on
t... | 2,594 | Python | .py | 68 | 32.411765 | 82 | 0.70947 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,698 | __init__.py | rafalp_Misago/misago/categories/hooks/__init__.py | from .get_categories_page_component import get_categories_page_component_hook
from .get_categories_page_metatags import get_categories_page_metatags_hook
from .get_categories_query_values import get_categories_query_values_hook
from .get_category_data import get_category_data_hook
| 282 | Python | .py | 4 | 69.5 | 77 | 0.848921 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,699 | get_categories_page_metatags.py | rafalp_Misago/misago/categories/hooks/get_categories_page_metatags.py | from typing import Protocol
from django.http import HttpRequest
from ...metatags.metatag import MetaTag
from ...plugins.hooks import FilterHook
class GetCategoriesPageMetatagsHookAction(Protocol):
"""
A standard Misago function used to get metatags for the categories page.
# Arguments
## `request:... | 2,813 | Python | .py | 71 | 33.070423 | 92 | 0.696746 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |