pygments-shell-console 0.0.1__tar.gz → 0.0.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.0.1 → pygments_shell_console-0.0.3}/PKG-INFO +1 -1
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.3}/git_lexer.py +31 -1
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.3}/pyproject.toml +1 -1
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.3}/shellconsole_lexer.py +31 -19
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.3}/shellconsole_style.py +4 -0
- pygments_shell_console-0.0.3/test.exmpl +67 -0
- pygments_shell_console-0.0.3/test.sh +2 -0
- pygments_shell_console-0.0.1/test.exmpl +0 -27
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.3}/.github/workflows/publish-to-pypi.yml +0 -0
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.3}/.gitignore +0 -0
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.3}/README.md +0 -0
|
@@ -20,9 +20,12 @@ STANDARD_TYPES.update({
|
|
|
20
20
|
Token.Git.CommitMessage: 'git-cm',
|
|
21
21
|
Token.Git.CommitAuthor: 'git-ca',
|
|
22
22
|
Token.Git.Refs: 'git-r',
|
|
23
|
+
Token.Git.Untracked: 'git-untr',
|
|
24
|
+
Token.Git.Modified: 'git-mod',
|
|
25
|
+
Token.Git.Staged: 'git-stg',
|
|
23
26
|
})
|
|
24
27
|
|
|
25
|
-
class
|
|
28
|
+
class GitLogLexer(Lexer):
|
|
26
29
|
name = "Git"
|
|
27
30
|
aliases = ["git"]
|
|
28
31
|
filenames = ['*.git']
|
|
@@ -80,3 +83,30 @@ class GitLexer(Lexer):
|
|
|
80
83
|
|
|
81
84
|
else:
|
|
82
85
|
yield match.start(), Generic.Output, line
|
|
86
|
+
|
|
87
|
+
class GitStatusLexer(RegexLexer):
|
|
88
|
+
tokens = {
|
|
89
|
+
'root': [
|
|
90
|
+
(r'\s*Untracked files:\n', Text, 'untracked'),
|
|
91
|
+
(r'\s*Changes not staged for commit:\n', Text, 'modified'),
|
|
92
|
+
(r'\s*Changes to be committed:\n', Text, 'staged'),
|
|
93
|
+
],
|
|
94
|
+
'untracked': [
|
|
95
|
+
(r'^\s+\(.*\)\n', Text),
|
|
96
|
+
(r'^[^\n]+\n', Token.Git.Untracked),
|
|
97
|
+
(r'^\s+\n', Text, '#pop'),
|
|
98
|
+
],
|
|
99
|
+
'modified': [
|
|
100
|
+
(r'^\s+\(.*\)\n', Text),
|
|
101
|
+
(r'^[^\n]+\n', Token.Git.Modified),
|
|
102
|
+
(r'^\s+\n', Text, '#pop'),
|
|
103
|
+
],
|
|
104
|
+
'staged': [
|
|
105
|
+
(r'^\s+\(.*\)\n', Text),
|
|
106
|
+
(r'^[^\n]+\n', Token.Git.Staged),
|
|
107
|
+
(r'^\s+\n', Text, '#pop'),
|
|
108
|
+
],
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
@@ -8,7 +8,7 @@ from pygments.token import Token, Punctuation, Whitespace, \
|
|
|
8
8
|
from pygments.lexers.diff import DiffLexer
|
|
9
9
|
from pygments.lexers.shell import BashLexer
|
|
10
10
|
from pygments.lexers.diff import DiffLexer
|
|
11
|
-
from git_lexer import
|
|
11
|
+
from git_lexer import GitLogLexer, GitStatusLexer
|
|
12
12
|
from pygments.token import STANDARD_TYPES
|
|
13
13
|
|
|
14
14
|
import re
|
|
@@ -45,15 +45,17 @@ class ShellConsoleLexer(Lexer):
|
|
|
45
45
|
def get_tokens_unprocessed(self, text):
|
|
46
46
|
innerlexer = self._innerLexerCls(**self.options)
|
|
47
47
|
difflexer = DiffLexer()
|
|
48
|
-
|
|
48
|
+
gitloglexer = GitLogLexer()
|
|
49
|
+
gitstatuslexer = GitStatusLexer()
|
|
49
50
|
|
|
50
51
|
pos = 0
|
|
51
52
|
# Bash command
|
|
52
53
|
curcode = ''
|
|
53
54
|
insertions = []
|
|
54
55
|
backslash_continuation = False
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
|
|
57
|
+
custom_lexer = None
|
|
58
|
+
output = ""
|
|
57
59
|
|
|
58
60
|
for match in line_re.finditer(text):
|
|
59
61
|
line = match.group()
|
|
@@ -76,8 +78,16 @@ class ShellConsoleLexer(Lexer):
|
|
|
76
78
|
# To support output lexers (say diff output), the output
|
|
77
79
|
# needs to be broken by prompts whenever the output lexer
|
|
78
80
|
# changes.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
|
|
82
|
+
if output:
|
|
83
|
+
if custom_lexer:
|
|
84
|
+
for i, t, v in custom_lexer.get_tokens_unprocessed(output):
|
|
85
|
+
# print(f"\n2. yielding pos={pos+i}, t={t}, v={v}")
|
|
86
|
+
yield pos+i, t, v
|
|
87
|
+
else:
|
|
88
|
+
yield pos, Generic.Output, output
|
|
89
|
+
output = ''
|
|
90
|
+
custom_lexer = None
|
|
81
91
|
|
|
82
92
|
if not insertions:
|
|
83
93
|
pos = match.start()
|
|
@@ -127,19 +137,14 @@ class ShellConsoleLexer(Lexer):
|
|
|
127
137
|
# print(f"\n1. yielding pos={pos+i}, t={t}, v={v}")
|
|
128
138
|
yield pos+i, t, v
|
|
129
139
|
|
|
130
|
-
if
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
# print(f"\n2. yielding pos={match.start()+i}, t={t}, v={v}")
|
|
139
|
-
yield match.start()+i, t, v
|
|
140
|
-
else:
|
|
141
|
-
# print(f"\n3. yielding pos={match.start()}, t={Generic.Output}, v={line}")
|
|
142
|
-
yield match.start(), Generic.Output, line
|
|
140
|
+
if 'diff' in curcode:
|
|
141
|
+
custom_lexer = difflexer
|
|
142
|
+
elif curcode.startswith('git lg'):
|
|
143
|
+
custom_lexer = gitloglexer
|
|
144
|
+
elif curcode.startswith('git status'):
|
|
145
|
+
custom_lexer = gitstatuslexer
|
|
146
|
+
|
|
147
|
+
output += line
|
|
143
148
|
insertions = []
|
|
144
149
|
curcode = ''
|
|
145
150
|
|
|
@@ -148,3 +153,10 @@ class ShellConsoleLexer(Lexer):
|
|
|
148
153
|
innerlexer.get_tokens_unprocessed(curcode)):
|
|
149
154
|
# print(f"\n4. yielding pos={pos+i}, t={t}, v={v}")
|
|
150
155
|
yield pos+i, t, v
|
|
156
|
+
if output:
|
|
157
|
+
if custom_lexer:
|
|
158
|
+
for i, t, v in custom_lexer.get_tokens_unprocessed(output):
|
|
159
|
+
# print(f"\n2. yielding pos={pos+i}, t={t}, v={v}")
|
|
160
|
+
yield pos+i, t, v
|
|
161
|
+
else:
|
|
162
|
+
yield pos, Generic.Output, output
|
|
@@ -19,5 +19,9 @@ class ShellConsoleStyle(Style):
|
|
|
19
19
|
Token.Git.CommitMessage: "#FFFFFF",
|
|
20
20
|
Token.Git.CommitAuthor: "#aaaaaa",
|
|
21
21
|
Token.Git.Refs: "#00ffff",
|
|
22
|
+
|
|
23
|
+
Token.Git.Untracked: "#f00",
|
|
24
|
+
Token.Git.Modified: "#f00",
|
|
25
|
+
Token.Git.Staged: "#008000",
|
|
22
26
|
})
|
|
23
27
|
del styles[Token.Generic.Prompt]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
joapuiib@FP:~/git_tutorial (main) $ echo "Hello world!" \
|
|
2
|
+
&& cd /tmp
|
|
3
|
+
|
|
4
|
+
(venv) joapuiib@FP:~/git_tutorial (main) $ git diff
|
|
5
|
+
diff --git a/README.md b/README.md
|
|
6
|
+
index 6d747b3..ff524e4 100644
|
|
7
|
+
--- a/README.md
|
|
8
|
+
+++ b/README.md
|
|
9
|
+
@@ -1,2 +1,4 @@
|
|
10
|
+
# Tutorial de Git
|
|
11
|
+
Estem aprenent a utilitzar Git!
|
|
12
|
+
+
|
|
13
|
+
+Hem modificat un fitxer existent.
|
|
14
|
+
-Hem eliminat un fitxer.
|
|
15
|
+
|
|
16
|
+
joapuiib@FP:~/git_tutorial (main) $ git push
|
|
17
|
+
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
|
|
18
|
+
To /home/joapuiib/gitflow_example/remot
|
|
19
|
+
0fb88ef..9e34bb0 develop -> develop
|
|
20
|
+
joapuiib@FP:~/git_tutorial (main) $ git lga
|
|
21
|
+
* f853946 - (7 minutes ago) README: Afegits autors - Mar (origin/feature/author)
|
|
22
|
+
| * cc8c388 - (9 minutes ago) LICENSE: Afegida llicència - Pau (origin/feature/license)
|
|
23
|
+
|/
|
|
24
|
+
| * 9e34bb0 - (15 minutes ago) README: Afegida descripció del projecte - Anna (HEAD -> develop, origin/develop, feature/readme, origin/feature/readme)
|
|
25
|
+
|/
|
|
26
|
+
* 0fb88ef - (29 minutes ago) 1. Primer commit - Joan Puigcerver (origin/main, origin/HEAD, main)
|
|
27
|
+
|
|
28
|
+
[user@host ~ (main)] $ echo "Hello, world!"
|
|
29
|
+
|
|
30
|
+
(venv) [user@host ~] $ echo "Hello, world!"
|
|
31
|
+
(venv) [user@host ~] $ ls -l
|
|
32
|
+
|
|
33
|
+
joapuiib@fp:~/01_introduccio (main) $ git status
|
|
34
|
+
On branch main
|
|
35
|
+
|
|
36
|
+
No commits yet
|
|
37
|
+
|
|
38
|
+
Untracked files:
|
|
39
|
+
(use "git add <file>..." to include in what will be committed)
|
|
40
|
+
README.md
|
|
41
|
+
|
|
42
|
+
Changes not staged for commit:
|
|
43
|
+
(use "git add <file>..." to update what will be committed)
|
|
44
|
+
(use "git restore <file>..." to discard changes in working directory)
|
|
45
|
+
deleted: README.md
|
|
46
|
+
modified: mkdocs.yml
|
|
47
|
+
modified: requirements.txt
|
|
48
|
+
|
|
49
|
+
Changes to be committed:
|
|
50
|
+
(use "git rm --cached <file>..." to unstage)
|
|
51
|
+
new file: README.md
|
|
52
|
+
|
|
53
|
+
joapuiib@FP:~/01_introduccio (main) $ git show 8e70293
|
|
54
|
+
commit 8e702933d5dbec9ee71100a1599ae4491085e1aa
|
|
55
|
+
Author: Joan Puigcerver Ibáñez <j.puigcerveribanez@edu.gva.es>
|
|
56
|
+
Date: Fri Oct 13 16:06:59 2023 +0200
|
|
57
|
+
|
|
58
|
+
Added README.md
|
|
59
|
+
|
|
60
|
+
diff --git a/README.md b/README.md
|
|
61
|
+
new file mode 100644
|
|
62
|
+
index 0000000..6d747b3
|
|
63
|
+
--- /dev/null
|
|
64
|
+
+++ b/README.md
|
|
65
|
+
@@ -0,0 +1,2 @@
|
|
66
|
+
+# 01 - Introducció a Git
|
|
67
|
+
+Estem aprenent a utilitzar Git!
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
joapuiib@FP:~/git_tutorial (main) $ echo "Hello world!"
|
|
2
|
-
(venv) joapuiib@FP:~/git_tutorial (main) $ git diff
|
|
3
|
-
diff --git a/README.md b/README.md
|
|
4
|
-
index 6d747b3..ff524e4 100644
|
|
5
|
-
--- a/README.md
|
|
6
|
-
+++ b/README.md
|
|
7
|
-
@@ -1,2 +1,4 @@
|
|
8
|
-
# Tutorial de Git
|
|
9
|
-
Estem aprenent a utilitzar Git!
|
|
10
|
-
+
|
|
11
|
-
+Hem modificat un fitxer existent.
|
|
12
|
-
-Hem eliminat un fitxer.
|
|
13
|
-
joapuiib@FP:~/git_tutorial (main) $ git push
|
|
14
|
-
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
|
|
15
|
-
To /home/joapuiib/gitflow_example/remot
|
|
16
|
-
0fb88ef..9e34bb0 develop -> develop
|
|
17
|
-
joapuiib@FP:~/git_tutorial (main) $ git lga
|
|
18
|
-
* f853946 - (7 minutes ago) README: Afegits autors - Mar (origin/feature/author)
|
|
19
|
-
| * cc8c388 - (9 minutes ago) LICENSE: Afegida llicència - Pau (origin/feature/license)
|
|
20
|
-
|/
|
|
21
|
-
| * 9e34bb0 - (15 minutes ago) README: Afegida descripció del projecte - Anna (HEAD -> develop, origin/develop, feature/readme, origin/feature/readme)
|
|
22
|
-
|/
|
|
23
|
-
* 0fb88ef - (29 minutes ago) 1. Primer commit - Joan Puigcerver (origin/main, origin/HEAD, main)
|
|
24
|
-
[user@host ~ (main)] $ echo "Hello, world!"
|
|
25
|
-
(venv) [user@host ~] $ echo "Hello, world!"
|
|
26
|
-
(example) $ ls -l
|
|
27
|
-
|
{pygments_shell_console-0.0.1 → pygments_shell_console-0.0.3}/.github/workflows/publish-to-pypi.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|