pygments-shell-console 0.8.1__tar.gz → 0.8.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/.github/workflows/publish-to-pypi.yml +3 -3
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/PKG-INFO +2 -2
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/git_lexer.py +10 -7
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/pyproject.toml +1 -1
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/shellconsole_lexer.py +7 -3
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/test/test_git_pretty_log.py +61 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/test/test_prompts.py +10 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/.gitignore +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/README.md +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/examples/git_lg.example +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/examples/git_log.example +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/examples/git_show.example +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/examples/status.example +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/examples/test.exmpl +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/examples/test.sh +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/shellconsole_style.py +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/test/__init__.py +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/test/test_git.py +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/test/test_git_branch.py +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/test/test_git_log.py +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/test/test_git_merge.py +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/test/test_git_show.py +0 -0
- {pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/test/test_git_status.py +0 -0
{pygments_shell_console-0.8.1 → pygments_shell_console-0.8.3}/.github/workflows/publish-to-pypi.yml
RENAMED
|
@@ -13,12 +13,12 @@ jobs:
|
|
|
13
13
|
permissions:
|
|
14
14
|
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
|
15
15
|
steps:
|
|
16
|
-
- name: Set up Python 3.
|
|
16
|
+
- name: Set up Python 3.12
|
|
17
17
|
uses: actions/checkout@master
|
|
18
|
-
- name: Set up Python 3.
|
|
18
|
+
- name: Set up Python 3.12
|
|
19
19
|
uses: actions/setup-python@v1
|
|
20
20
|
with:
|
|
21
|
-
python-version: 3.
|
|
21
|
+
python-version: 3.12
|
|
22
22
|
- name: Install pypa/build
|
|
23
23
|
run: >-
|
|
24
24
|
python -m
|
|
@@ -80,8 +80,10 @@ class GitPrettyLogLexer(Lexer):
|
|
|
80
80
|
r'(-)', # 13. Commit separator
|
|
81
81
|
r'( +)', # 14. Space
|
|
82
82
|
r'([0-9A-Za-zÀ-ÖØ-öø-ÿ ]*[0-9A-Za-zÀ-ÖØ-öø-ÿ]+)', # 15. Author
|
|
83
|
-
r'( *)',
|
|
84
|
-
r'(
|
|
83
|
+
r'( *)', # 16. Space
|
|
84
|
+
r'(\([\w ->,:]+\))?', # 17. Refs
|
|
85
|
+
r'( *)', # 18. Space
|
|
86
|
+
r'(#[^\n]*)?', # 19. Comment
|
|
85
87
|
r'\n', # End
|
|
86
88
|
]
|
|
87
89
|
|
|
@@ -103,6 +105,8 @@ class GitPrettyLogLexer(Lexer):
|
|
|
103
105
|
15: Token.Git.CommitAuthor,
|
|
104
106
|
16: Whitespace,
|
|
105
107
|
17: Token.Git.Refs,
|
|
108
|
+
18: Whitespace,
|
|
109
|
+
19: Comment,
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
def get_tokens_unprocessed(self, text):
|
|
@@ -116,12 +120,11 @@ class GitPrettyLogLexer(Lexer):
|
|
|
116
120
|
|
|
117
121
|
## Line is log
|
|
118
122
|
if match_log:
|
|
119
|
-
for i in range(1, len(match_log.groups())):
|
|
123
|
+
for i in range(1, len(match_log.groups()) + 1):
|
|
120
124
|
if match_log.group(i):
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
yield match_log.start(i), Generic.Output, match_log.group(i)
|
|
125
|
+
token = self._log_tokens.get(i, Generic.Output)
|
|
126
|
+
yield match_log.start(i), token, match_log.group(i)
|
|
127
|
+
|
|
125
128
|
yield match.end(), Whitespace, '\n'
|
|
126
129
|
elif match_branch_line:
|
|
127
130
|
yield match.start(), Token.Git.BranchLine, line
|
|
@@ -38,15 +38,19 @@ class ShellConsoleLexer(Lexer):
|
|
|
38
38
|
r'(?P<venv>\([^\)]*\))?', # Virtualenv
|
|
39
39
|
r'(\s*)?', # Whitespace
|
|
40
40
|
r'\[?', # Start bracketed prompt
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
r'(?:', # Start of user@host:directory
|
|
43
|
+
r'(?P<user_host>[^\n$%#]+@[^\s$%#]+?)', # user@host
|
|
42
44
|
r'(\s*)', # Whitespace
|
|
43
45
|
r'(?:(\:)|(\s+))?', # Separator: colon or space
|
|
44
46
|
r'(\s*)', # Whitespace
|
|
45
|
-
r'(?P<current_dir>[^\s\]
|
|
47
|
+
r'(?P<current_dir>[^\s\]:$%#]+)', # Current directory
|
|
48
|
+
r')?', # End of user@host:directory
|
|
49
|
+
|
|
46
50
|
r'(?:(\s+)(?P<git_branch>\([^)]+\)))?', # Whitespace + Git branch
|
|
47
51
|
r'\]?', # End bracketed prompt
|
|
48
52
|
r'(\s*)', # Whitespace
|
|
49
|
-
r'((?:[$%]|(
|
|
53
|
+
r'((?:[$%]|(?<=user_host):\s*#)\n?)',
|
|
50
54
|
r'(\s*)', # Whitespace
|
|
51
55
|
r'(?P<command>.*\n?)' # Command
|
|
52
56
|
]
|
|
@@ -277,3 +277,64 @@ def test_git_log_with_commit_message_commas():
|
|
|
277
277
|
(Token.Git.CommitAuthor, "Joan Puigcerver"),
|
|
278
278
|
(Token.Text.Whitespace, "\n"),
|
|
279
279
|
]
|
|
280
|
+
|
|
281
|
+
def test_git_log_with_comment_at_the_end():
|
|
282
|
+
lexer = ShellConsoleLexer()
|
|
283
|
+
text = (
|
|
284
|
+
"user@host:~/directory (main) $ git lg\n"
|
|
285
|
+
"* f853946 - (7 minutes ago) README: Afegits autors - Mar (main) # This is a comment\n"
|
|
286
|
+
"* 0fb88ef - (29 minutes ago) Canvis A, B i C - Joan Puigcerver # This is a comment"
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
tokens = list(lexer.get_tokens(text))
|
|
290
|
+
|
|
291
|
+
assert tokens == [
|
|
292
|
+
(Token.Generic.Prompt.UserHost, "user@host"),
|
|
293
|
+
(Token.Generic.Prompt, ":"),
|
|
294
|
+
(Token.Generic.Prompt.Directory, "~/directory"),
|
|
295
|
+
(Token.Generic.Prompt.Whitespace, " "),
|
|
296
|
+
(Token.Generic.Prompt.GitBranch, "(main)"),
|
|
297
|
+
(Token.Generic.Prompt.Whitespace, " "),
|
|
298
|
+
(Token.Generic.Prompt, "$"),
|
|
299
|
+
(Token.Generic.Prompt.Whitespace, " "),
|
|
300
|
+
(Token.Text, "git"),
|
|
301
|
+
(Token.Text.Whitespace, " "),
|
|
302
|
+
(Token.Text, "lg"),
|
|
303
|
+
(Token.Text.Whitespace, "\n"),
|
|
304
|
+
# First commit
|
|
305
|
+
(Token.Generic.Output, "*",),
|
|
306
|
+
(Token.Text.Whitespace, " "),
|
|
307
|
+
(Token.Git.CommitHash, "f853946"),
|
|
308
|
+
(Token.Text.Whitespace, " "),
|
|
309
|
+
(Token.Generic.Output, "-"),
|
|
310
|
+
(Token.Text.Whitespace, " "),
|
|
311
|
+
(Token.Git.CommitDate, "(7 minutes ago)"),
|
|
312
|
+
(Token.Text.Whitespace, " "),
|
|
313
|
+
(Token.Git.CommitMessage, "README: Afegits autors"),
|
|
314
|
+
(Token.Text.Whitespace, " "),
|
|
315
|
+
(Token.Generic.Output, "-"),
|
|
316
|
+
(Token.Text.Whitespace, " "),
|
|
317
|
+
(Token.Git.CommitAuthor, "Mar"),
|
|
318
|
+
(Token.Text.Whitespace, " "),
|
|
319
|
+
(Token.Git.Refs, "(main)"),
|
|
320
|
+
(Token.Text.Whitespace, " "),
|
|
321
|
+
(Token.Comment, "# This is a comment"),
|
|
322
|
+
(Token.Text.Whitespace, "\n"),
|
|
323
|
+
# Second commit
|
|
324
|
+
(Token.Generic.Output, "*"),
|
|
325
|
+
(Token.Text.Whitespace, " "),
|
|
326
|
+
(Token.Git.CommitHash, "0fb88ef"),
|
|
327
|
+
(Token.Text.Whitespace, " "),
|
|
328
|
+
(Token.Generic.Output, "-"),
|
|
329
|
+
(Token.Text.Whitespace, " "),
|
|
330
|
+
(Token.Git.CommitDate, "(29 minutes ago)"),
|
|
331
|
+
(Token.Text.Whitespace, " "),
|
|
332
|
+
(Token.Git.CommitMessage, "Canvis A, B i C"),
|
|
333
|
+
(Token.Text.Whitespace, " "),
|
|
334
|
+
(Token.Generic.Output, "-"),
|
|
335
|
+
(Token.Text.Whitespace, " "),
|
|
336
|
+
(Token.Git.CommitAuthor, "Joan Puigcerver"),
|
|
337
|
+
(Token.Text.Whitespace, " "),
|
|
338
|
+
(Token.Comment, "# This is a comment"),
|
|
339
|
+
(Token.Text.Whitespace, "\n"),
|
|
340
|
+
]
|
|
@@ -27,6 +27,16 @@ def test_empty_root_bash_prompt_not_allowed():
|
|
|
27
27
|
(Token.Generic.Output, "# echo Hello\n"),
|
|
28
28
|
]
|
|
29
29
|
|
|
30
|
+
def test_multiple_hashtag_with_spaces():
|
|
31
|
+
lexer = ShellConsoleLexer()
|
|
32
|
+
prompt = " ## echo Hello"
|
|
33
|
+
|
|
34
|
+
tokens = list(lexer.get_tokens(prompt))
|
|
35
|
+
|
|
36
|
+
assert tokens == [
|
|
37
|
+
(Token.Generic.Output, " ## echo Hello\n"),
|
|
38
|
+
]
|
|
39
|
+
|
|
30
40
|
def test_basic_bash_prompt():
|
|
31
41
|
lexer = ShellConsoleLexer()
|
|
32
42
|
prompt = "user@host:~$"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|