pygments-shell-console 0.4__tar.gz → 0.6.0__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.
Files changed (22) hide show
  1. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/PKG-INFO +1 -1
  2. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/git_lexer.py +6 -0
  3. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/pyproject.toml +1 -1
  4. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/shellconsole_lexer.py +8 -7
  5. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/test/test_git.py +85 -1
  6. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/.github/workflows/publish-to-pypi.yml +0 -0
  7. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/.gitignore +0 -0
  8. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/README.md +0 -0
  9. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/examples/git_lg.example +0 -0
  10. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/examples/git_log.example +0 -0
  11. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/examples/git_show.example +0 -0
  12. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/examples/status.example +0 -0
  13. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/examples/test.exmpl +0 -0
  14. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/examples/test.sh +0 -0
  15. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/shellconsole_style.py +0 -0
  16. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/test/__init__.py +0 -0
  17. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/test/test_git_branch.py +0 -0
  18. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/test/test_git_log.py +0 -0
  19. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/test/test_git_pretty_log.py +0 -0
  20. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/test/test_git_show.py +0 -0
  21. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/test/test_git_status.py +0 -0
  22. {pygments_shell_console-0.4 → pygments_shell_console-0.6.0}/test/test_prompts.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pygments-shell-console
3
- Version: 0.4
3
+ Version: 0.6.0
4
4
  Requires-Dist: pygments
5
5
  Description-Content-Type: text/markdown
6
6
 
@@ -26,6 +26,9 @@ STANDARD_TYPES.update({
26
26
  Token.Git.CommitMessage: 'git-cm',
27
27
  Token.Git.CommitAuthor: 'git-ca',
28
28
  Token.Git.Hint: 'git-hint',
29
+ Token.Git.Warning: 'git-warning',
30
+ Token.Git.Error: 'git-error',
31
+ Token.Git.Fatal: 'git-fatal',
29
32
  Token.Git.Refs: 'git-r',
30
33
  Token.Git.Untracked: 'git-untr',
31
34
  Token.Git.Modified: 'git-mod',
@@ -49,7 +52,10 @@ class GitLexer(RegexLexer):
49
52
  tokens = {
50
53
  'root': [
51
54
  (r'\n', Whitespace),
55
+ (r'^error:(.*?)\n', Token.Git.Error),
56
+ (r'^fatal:(.*?)\n', Token.Git.Fatal),
52
57
  (r'^hint:(.*?)\n', Token.Git.Hint),
58
+ (r'^warning:(.*?)\n', Token.Git.Warning),
53
59
  (r'^.*$\n', Generic.Output),
54
60
  (r'[^\n]+', Generic.Output),
55
61
  ]
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pygments-shell-console" # change this to a package name for your plugin
7
- version = "0.4"
7
+ version = "0.6.0"
8
8
  dependencies = ["pygments"]
9
9
  readme = "README.md"
10
10
 
@@ -17,6 +17,7 @@ import re
17
17
  __all__ = ['ShellConsoleLexer']
18
18
 
19
19
  STANDARD_TYPES.update({
20
+ Token.Generic.Prompt.Whitespace: 'gp-w',
20
21
  Token.Generic.Prompt.UserHost: 'gp-uh',
21
22
  Token.Generic.Prompt.Directory: 'gp-d',
22
23
  Token.Generic.Prompt.GitBranch: 'gp-gb',
@@ -54,18 +55,18 @@ class ShellConsoleLexer(Lexer):
54
55
 
55
56
  _ps1_tokens = [
56
57
  Token.Generic.Prompt.VirtualEnv,
57
- Whitespace,
58
+ Token.Generic.Prompt.Whitespace,
58
59
  Token.Generic.Prompt.UserHost,
59
- Whitespace,
60
+ Token.Generic.Prompt.Whitespace,
60
61
  Token.Generic.Prompt, # Separator: colon
61
- Whitespace, # Separator: space
62
- Whitespace,
62
+ Token.Generic.Prompt.Whitespace, # Separator: space
63
+ Token.Generic.Prompt.Whitespace,
63
64
  Token.Generic.Prompt.Directory,
64
- Whitespace,
65
+ Token.Generic.Prompt.Whitespace,
65
66
  Token.Generic.Prompt.GitBranch,
66
- Whitespace,
67
+ Token.Generic.Prompt.Whitespace,
67
68
  Token.Generic.Prompt,
68
- Whitespace
69
+ Token.Generic.Prompt.Whitespace,
69
70
  ]
70
71
 
71
72
 
@@ -33,7 +33,7 @@ def test_git_command_with_hint():
33
33
  (Token.Text, "desc"),
34
34
  (Token.Text.Whitespace, "\n"),
35
35
  # Output
36
- (Token.Generic.Output, "error: the branch 'desc' is not fully merged.\n"),
36
+ (Token.Git.Error, "error: the branch 'desc' is not fully merged.\n"),
37
37
  (Token.Git.Hint, "hint: If you are sure you want to delete it, run 'git branch -D desc'.\n"),
38
38
  (Token.Git.Hint, "hint: Disable this message with \"git config advice.forceDeleteBranch false\".\n"),
39
39
  ]
@@ -71,3 +71,87 @@ def test_git_command_with_empty_hint():
71
71
  (Token.Git.Hint, "hint:\n"),
72
72
  (Token.Git.Hint, "hint: git config --global init.defaultBranch <name>\n"),
73
73
  ]
74
+
75
+ def test_git_command_with_warning():
76
+ lexer = ShellConsoleLexer()
77
+ text = (
78
+ "user@host:~/directory $ git push origin main\n"
79
+ "warning: redirecting to url\n"
80
+ )
81
+
82
+ tokens = list(lexer.get_tokens(text))
83
+ assert tokens == [
84
+ # Prompt
85
+ (Token.Generic.Prompt.UserHost, "user@host"),
86
+ (Token.Generic.Prompt, ":"),
87
+ (Token.Generic.Prompt.Directory, "~/directory"),
88
+ (Token.Text.Whitespace, " "),
89
+ (Token.Generic.Prompt, "$"),
90
+ (Token.Text.Whitespace, " "),
91
+ (Token.Text, "git"),
92
+ (Token.Text.Whitespace, " "),
93
+ (Token.Text, "push"),
94
+ (Token.Text.Whitespace, " "),
95
+ (Token.Text, "origin"),
96
+ (Token.Text.Whitespace, " "),
97
+ (Token.Text, "main"),
98
+ (Token.Text.Whitespace, "\n"),
99
+ # Output
100
+ (Token.Git.Warning, "warning: redirecting to url\n"),
101
+ ]
102
+
103
+ def test_git_command_with_error():
104
+ lexer = ShellConsoleLexer()
105
+ text = (
106
+ "user@host:~/directory $ git push origin main\n"
107
+ "error: src refspec main does not match any.\n"
108
+ )
109
+
110
+ tokens = list(lexer.get_tokens(text))
111
+ assert tokens == [
112
+ # Prompt
113
+ (Token.Generic.Prompt.UserHost, "user@host"),
114
+ (Token.Generic.Prompt, ":"),
115
+ (Token.Generic.Prompt.Directory, "~/directory"),
116
+ (Token.Text.Whitespace, " "),
117
+ (Token.Generic.Prompt, "$"),
118
+ (Token.Text.Whitespace, " "),
119
+ (Token.Text, "git"),
120
+ (Token.Text.Whitespace, " "),
121
+ (Token.Text, "push"),
122
+ (Token.Text.Whitespace, " "),
123
+ (Token.Text, "origin"),
124
+ (Token.Text.Whitespace, " "),
125
+ (Token.Text, "main"),
126
+ (Token.Text.Whitespace, "\n"),
127
+ # Output
128
+ (Token.Git.Error, "error: src refspec main does not match any.\n"),
129
+ ]
130
+
131
+ def test_git_command_with_fatal():
132
+ lexer = ShellConsoleLexer()
133
+ text = (
134
+ "user@host:~/directory $ git push origin main\n"
135
+ "fatal: src refspec main does not match any.\n"
136
+ )
137
+
138
+ tokens = list(lexer.get_tokens(text))
139
+ assert tokens == [
140
+ # Prompt
141
+ (Token.Generic.Prompt.UserHost, "user@host"),
142
+ (Token.Generic.Prompt, ":"),
143
+ (Token.Generic.Prompt.Directory, "~/directory"),
144
+ (Token.Text.Whitespace, " "),
145
+ (Token.Generic.Prompt, "$"),
146
+ (Token.Text.Whitespace, " "),
147
+ (Token.Text, "git"),
148
+ (Token.Text.Whitespace, " "),
149
+ (Token.Text, "push"),
150
+ (Token.Text.Whitespace, " "),
151
+ (Token.Text, "origin"),
152
+ (Token.Text.Whitespace, " "),
153
+ (Token.Text, "main"),
154
+ (Token.Text.Whitespace, "\n"),
155
+ # Output
156
+ (Token.Git.Fatal, "fatal: src refspec main does not match any.\n"),
157
+ ]