File tree Expand file tree Collapse file tree 24 files changed +618
-126
lines changed
lib/python3/dist-packages/stdisplay Expand file tree Collapse file tree 24 files changed +618
-126
lines changed Original file line number Diff line number Diff line change 3838 build-essential debhelper dh-python dh-apparmor
3939 git config --global --add safe.directory "$GITHUB_WORKSPACE"
4040 - uses : actions/checkout@v4
41-
4241 - name : Test build
4342 run : |
4443 dpkg-buildpackage -b -i -us -uc
4746 run : |
4847 set -o xtrace
4948 ./run-tests
49+ git clone https://github.com/nickboucher/trojan-source
50+ ./unicode-testscript
Original file line number Diff line number Diff line change 22line-length = 79
33[tool .mypy ]
44strict =" yes"
5+ [tool .pylint .'SIMILARITIES' ]
6+ min-similarity-lines =10
57[tool .pylint .'FORMAT' ]
68expected-line-ending-format =" LF"
79max-line-length =79
Original file line number Diff line number Diff line change @@ -5,13 +5,14 @@ pyrc="${git_toplevel}/pyproject.toml"
55pythonpath=" ${git_toplevel} /usr/lib/python3/dist-packages"
66export PYTHONPATH=" ${pythonpath}${PYTHONPATH+" :${PYTHONPATH} " } "
77
8- pytest=(python3 -m pytest -o ' python_files=*.py' )
8+ pytest=(python3 -m pytest -o ' python_files=tests/ *.py' )
99black=(black --config=" ${pyrc} " --color --diff --check)
1010pylint=(pylint --rcfile=" ${pyrc} " )
1111mypy=(mypy --config-file=" ${pyrc} " )
1212
1313cd " ${pythonpath} /stdisplay/"
14- " ${pytest[@]} " " ${@ } "
14+ # Ideally, these variables should be ignored by the tests...
15+ NO_COLOR=" " COLORTERM=" " TERM=" xterm-direct" " ${pytest[@]} " " ${@ } "
1516" ${black[@]} " .
1617find . -type f -name " *.py" -print0 | xargs -0 " ${pylint[@]} "
1718" ${mypy[@]} " .
Original file line number Diff line number Diff line change 33# # Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
44# # See the file COPYING for copying conditions.
55
6- # # NOTE:
7- # # Assumes folder 'trojan-source' in the home folder.
8- # #
9- # # cd ~
10- # # git clone git@github.com:nickboucher/trojan-source.git
11-
12- # # TODO: Convert into proper unit test and/or CI.
13-
146# set -x
157set -e
168set -o nounset
179set -o pipefail
1810set -o errtrace
1911
20- if [ " $( id -u) " = 0 ]; then
21- printf " %s\n" " $0 : ERROR: No need to run as root!" >&2
22- exit 1
12+ if [ " $( id -u) " = 0 ] && [ -z " ${GITHUB_WORKSPACE :- } " ] ; then
13+ printf " %s\n" " $0 : ERROR: No need to run as root!" >&2
14+ exit 1
2315fi
2416
2517folder_list=" Assembly Bash C C# C++ Go Java JavaScript Python RegEx Rust Solidity"
Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2+ # pylint: disable=missing-module-docstring
23
34## SPDX-FileCopyrightText: 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
45## SPDX-FileCopyrightText: 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
56##
67## SPDX-License-Identifier: AGPL-3.0-or-later
78
8- """Safely print stdin or file to stdout."""
9-
10- from fileinput import input as file_input
11- from sys import stdin , stdout
12- from stdisplay .stdisplay import stdisplay
13-
14-
15- def main () -> None :
16- """Safely print stdin or file to stdout."""
17- stdin .reconfigure (errors = "ignore" ) # type: ignore
18- ## File input reads stdin when no file is provided or file is '-'.
19- for untrusted_text in file_input (encoding = "ascii" , errors = "replace" ):
20- stdout .write (stdisplay (untrusted_text ))
21- stdout .flush ()
22-
9+ from stdisplay .stcat import main
2310
2411if __name__ == "__main__" :
2512 main ()
Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2+ # pylint: disable=missing-module-docstring
23
34## SPDX-FileCopyrightText: 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
45## SPDX-FileCopyrightText: 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
56##
67## SPDX-License-Identifier: AGPL-3.0-or-later
78
8- """
9- Safely print stdin or file to stdout with tweaks
10- (trim trailing whitespace, ensure final newline).
11- """
12-
13- from fileinput import input as file_input
14- from sys import stdin , stdout
15- from stdisplay .stdisplay import stdisplay
16-
17-
18- def main () -> None :
19- """
20- main
21- """
22- stdin .reconfigure (errors = "ignore" ) # type: ignore
23-
24- for line in file_input (encoding = "ascii" , errors = "replace" ):
25- stdout .write (stdisplay (line ).rstrip () + "\n " )
26-
27- stdout .flush ()
28-
9+ from stdisplay .stcatn import main
2910
3011if __name__ == "__main__" :
3112 main ()
Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2+ # pylint: disable=missing-module-docstring
23
34## SPDX-FileCopyrightText: 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
45## SPDX-FileCopyrightText: 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
56##
67## SPDX-License-Identifier: AGPL-3.0-or-later
78
8- """Safely print argument to stdout with echo's formatting."""
9-
10- from sys import argv , stdout
11- from stdisplay .stdisplay import stdisplay
12-
13-
14- def main () -> None :
15- """Safely print argument to stdout with echo's formatting."""
16- if len (argv ) > 1 :
17- untrusted_text = " " .join (argv [1 :])
18- stdout .write (stdisplay (untrusted_text ))
19- stdout .write ("\n " )
20- stdout .flush ()
21-
9+ from stdisplay .stecho import main
2210
2311if __name__ == "__main__" :
2412 main ()
Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2+ # pylint: disable=missing-module-docstring
23
34## SPDX-FileCopyrightText: 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
45## SPDX-FileCopyrightText: 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
56##
67## SPDX-License-Identifier: AGPL-3.0-or-later
78
8- """Safely print argument to stdout."""
9-
10- from sys import argv , stdout
11- from stdisplay .stdisplay import stdisplay
12-
13-
14- def main () -> None :
15- """Safely print argument to stdout."""
16- if len (argv ) > 1 :
17- untrusted_text = "" .join (argv [1 :])
18- stdout .write (stdisplay (untrusted_text ))
19- stdout .flush ()
20-
9+ from stdisplay .stprint import main
2110
2211if __name__ == "__main__" :
2312 main ()
Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2+ # pylint: disable=missing-module-docstring
23
34## SPDX-FileCopyrightText: 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
45## SPDX-FileCopyrightText: 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
56##
67## SPDX-License-Identifier: AGPL-3.0-or-later
78
8- """Safely print stdin to stdout or file."""
9-
10- from sys import argv , stdin , stdout
11- import shutil
12- from tempfile import NamedTemporaryFile
13- from stdisplay .stdisplay import stdisplay
14-
15-
16- def main () -> None :
17- """Safely print stdin to stdout or file."""
18- untrusted_text_list = []
19- stdin .reconfigure (errors = "ignore" ) # type: ignore
20- for untrusted_text in stdin :
21- untrusted_text_list .append (untrusted_text )
22- if len (argv ) == 1 :
23- stdout .write (stdisplay ("" .join (untrusted_text_list )))
24- stdout .flush ()
25- else :
26- with NamedTemporaryFile (mode = "w" , delete = False ) as temp_file :
27- temp_file .write (stdisplay ("" .join (untrusted_text_list )))
28- temp_file .flush ()
29- for file in argv [1 :]:
30- shutil .copy2 (temp_file .name , file )
31- temp_file .close ()
32-
9+ from stdisplay .stsponge import main
3310
3411if __name__ == "__main__" :
3512 main ()
Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2+ # pylint: disable=missing-module-docstring
23
34## SPDX-FileCopyrightText: 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
45## SPDX-FileCopyrightText: 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
56##
67## SPDX-License-Identifier: AGPL-3.0-or-later
78
8- """Safely print stdin to stdout and file."""
9- from sys import argv , stdin , stdout
10- from stdisplay .stdisplay import stdisplay
11-
12-
13- def main () -> None :
14- """Safely print stdin to stdout and file."""
15- untrusted_text_list = []
16- stdin .reconfigure (errors = "ignore" ) # type: ignore
17- for untrusted_text in stdin :
18- untrusted_text_list .append (untrusted_text )
19- stdout .write (stdisplay (untrusted_text ))
20- stdout .flush ()
21- if len (argv ) > 1 :
22- for file_arg in argv [1 :]:
23- with open (file_arg , mode = "w" , encoding = "ascii" ) as file :
24- file .write (stdisplay ("" .join (untrusted_text_list )))
25-
9+ from stdisplay .sttee import main
2610
2711if __name__ == "__main__" :
2812 main ()
You can’t perform that action at this time.
0 commit comments