%global _empty_manifest_terminate_build 0 Name: python-py-term Version: 0.7 Release: 1 Summary: Python module to style terminal output, moving and positioning the cursor. License: MIT URL: https://github.com/gravmatt/py-term Source0: https://mirrors.nju.edu.cn/pypi/web/packages/70/98/defbe69cd13dc59e83f36c40317bbc0181b8bc1b89234da144bd89bcfd55/py-term-0.7.tar.gz BuildArch: noarch %description # py-term Python module to style terminal output, moving and positioning the cursor. **Python 2 and 3 compatible** ![alt text](pyterm.jpg "See? amazing!") ## Installation Install through **pip**. ``` $ pip install py-term ``` or get from source ``` $ git clone https://github.com/gravmatt/py-term.git $ cd py-term $ python setup.py install ``` ## Import module Import the module into your python project. ``` import term ``` ## Usage ``` term.write('Hello, ') term.write('Python!') > Hello, Python! term.writeLine('Hello') term.writeLine('Python!') > Hello > Python! ``` ## Style output The first argument is the text output and all following arguments are for styling. ``` term.writeLine(text, *style) Or text = term.format(text, *style) term.writeLine(text) ``` ### Usage ``` term.writeLine('Hello, Python!') term.writeLine('This text line will be green', term.green) term.writeLine('Reverse the green color', term.green, term.reverse) ``` Or ``` output = term.format('Hello, ', term.green) + term.format('Python!', term.blue, term.bold) term.writeLine(output) term.write(term.format('All in one line', term.reverse)) ``` #### Text align **Center align** ``` # term.textCenter(text) term.writeLine(term.textCenter('Super Python!')) ``` **Right align** ``` # term.textRight(text) term.writeLine(term.textRight('Rene Tanczos (@gravmatt)')) ( Function term.right() to align text is depricated because of naming conflicts! ) ``` ##### Style attributes | Code | Description | | :-------------------- | :----------------------------------- | | term.off | All attributes off | | term.bold | Bold | | term.dim | Dim | | term.underscore | Underscore (monochrome display only) | | term.blink | Blink | | term.reverse | Reverse | | term.hide | Hide | ##### Text color | Code | Color | | :----------------- | :---------- | | term.black | Black | | term.red | Red | | term.green | Green | | term.yellow | Yellow | | term.blue | Blue | | term.magenta | Magenta | | term.cyan | Cyan | | term.white | White | ##### Background color | Code | Color | | :------------------- | :---------- | | term.bgblack | Black | | term.bgred | Red | | term.bggreen | Green | | term.bgyellow | Yellow | | term.bgblue | Blue | | term.bgMagenta | Magenta | | term.bgcyan | Cyan | | term.bgwhite | White | ## Remove style attributes Removes style characters. (Good to call before you count a string) ``` term.strip(formatted_text) hello = term.red + 'hello, world' + term.off print hello # '\x1b[31mhello, world\x1b[0m\x1b[27m' print term.strip(hello) # hello, world ``` ## Highlighting text Simple highlighting of unformatted text strings ``` def callback(matching_text): return term.blue + matching_text + term.off output, match_count, array_of_positions = term.highlight(regex_pattern, text, callback) ``` Return a tuple. output (index 0) = formatted text output match_count (index 1) = match count of the pattern array_of_positions (index 2) = array of tuples with start and stop points of the matches [(4, 6), (9, 11), ..] ## Set title ``` term.setTitle('Hello Terminal') # or clear it term.clearTitle() ``` ## Set tab name ``` term.setTab('Hello Tab') # or clear it term.clearTab() ``` ## Cursor position Move the cursor to a specific position. ``` term.pos(line, column) term.pos(2, 15) ``` Get the size of the terminal (lines and columns) ``` (30, 100) = term.getSize() # (lines, colums) = term.getSize() ``` Move the cursor to the home position (1, 1). ``` term.homePos() ``` Moves the current cursor position up, down, left or right by the specified value. ``` term.up(value=1) term.down(value=1) term.left(value=1) term.right(value=1) ``` Saves the current cursor position. ``` term.saveCursor() ``` Restore the previously stored cursor position. ``` term.restoreCursor() ``` Clear the terminal screen. ``` term.clear() ``` Clear the entire line on the current cursor position. ``` term.clearLine() ``` Clear line from the current cursor position to the end. ``` term.clearLineFromPos() ``` Clear line from begin to current cursor position. ``` term.clearLineToPos() ``` ## Licence The MIT License (MIT) Copyright (c) 2015-2021 René Tanczos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. %package -n python3-py-term Summary: Python module to style terminal output, moving and positioning the cursor. Provides: python-py-term BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-py-term # py-term Python module to style terminal output, moving and positioning the cursor. **Python 2 and 3 compatible** ![alt text](pyterm.jpg "See? amazing!") ## Installation Install through **pip**. ``` $ pip install py-term ``` or get from source ``` $ git clone https://github.com/gravmatt/py-term.git $ cd py-term $ python setup.py install ``` ## Import module Import the module into your python project. ``` import term ``` ## Usage ``` term.write('Hello, ') term.write('Python!') > Hello, Python! term.writeLine('Hello') term.writeLine('Python!') > Hello > Python! ``` ## Style output The first argument is the text output and all following arguments are for styling. ``` term.writeLine(text, *style) Or text = term.format(text, *style) term.writeLine(text) ``` ### Usage ``` term.writeLine('Hello, Python!') term.writeLine('This text line will be green', term.green) term.writeLine('Reverse the green color', term.green, term.reverse) ``` Or ``` output = term.format('Hello, ', term.green) + term.format('Python!', term.blue, term.bold) term.writeLine(output) term.write(term.format('All in one line', term.reverse)) ``` #### Text align **Center align** ``` # term.textCenter(text) term.writeLine(term.textCenter('Super Python!')) ``` **Right align** ``` # term.textRight(text) term.writeLine(term.textRight('Rene Tanczos (@gravmatt)')) ( Function term.right() to align text is depricated because of naming conflicts! ) ``` ##### Style attributes | Code | Description | | :-------------------- | :----------------------------------- | | term.off | All attributes off | | term.bold | Bold | | term.dim | Dim | | term.underscore | Underscore (monochrome display only) | | term.blink | Blink | | term.reverse | Reverse | | term.hide | Hide | ##### Text color | Code | Color | | :----------------- | :---------- | | term.black | Black | | term.red | Red | | term.green | Green | | term.yellow | Yellow | | term.blue | Blue | | term.magenta | Magenta | | term.cyan | Cyan | | term.white | White | ##### Background color | Code | Color | | :------------------- | :---------- | | term.bgblack | Black | | term.bgred | Red | | term.bggreen | Green | | term.bgyellow | Yellow | | term.bgblue | Blue | | term.bgMagenta | Magenta | | term.bgcyan | Cyan | | term.bgwhite | White | ## Remove style attributes Removes style characters. (Good to call before you count a string) ``` term.strip(formatted_text) hello = term.red + 'hello, world' + term.off print hello # '\x1b[31mhello, world\x1b[0m\x1b[27m' print term.strip(hello) # hello, world ``` ## Highlighting text Simple highlighting of unformatted text strings ``` def callback(matching_text): return term.blue + matching_text + term.off output, match_count, array_of_positions = term.highlight(regex_pattern, text, callback) ``` Return a tuple. output (index 0) = formatted text output match_count (index 1) = match count of the pattern array_of_positions (index 2) = array of tuples with start and stop points of the matches [(4, 6), (9, 11), ..] ## Set title ``` term.setTitle('Hello Terminal') # or clear it term.clearTitle() ``` ## Set tab name ``` term.setTab('Hello Tab') # or clear it term.clearTab() ``` ## Cursor position Move the cursor to a specific position. ``` term.pos(line, column) term.pos(2, 15) ``` Get the size of the terminal (lines and columns) ``` (30, 100) = term.getSize() # (lines, colums) = term.getSize() ``` Move the cursor to the home position (1, 1). ``` term.homePos() ``` Moves the current cursor position up, down, left or right by the specified value. ``` term.up(value=1) term.down(value=1) term.left(value=1) term.right(value=1) ``` Saves the current cursor position. ``` term.saveCursor() ``` Restore the previously stored cursor position. ``` term.restoreCursor() ``` Clear the terminal screen. ``` term.clear() ``` Clear the entire line on the current cursor position. ``` term.clearLine() ``` Clear line from the current cursor position to the end. ``` term.clearLineFromPos() ``` Clear line from begin to current cursor position. ``` term.clearLineToPos() ``` ## Licence The MIT License (MIT) Copyright (c) 2015-2021 René Tanczos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. %package help Summary: Development documents and examples for py-term Provides: python3-py-term-doc %description help # py-term Python module to style terminal output, moving and positioning the cursor. **Python 2 and 3 compatible** ![alt text](pyterm.jpg "See? amazing!") ## Installation Install through **pip**. ``` $ pip install py-term ``` or get from source ``` $ git clone https://github.com/gravmatt/py-term.git $ cd py-term $ python setup.py install ``` ## Import module Import the module into your python project. ``` import term ``` ## Usage ``` term.write('Hello, ') term.write('Python!') > Hello, Python! term.writeLine('Hello') term.writeLine('Python!') > Hello > Python! ``` ## Style output The first argument is the text output and all following arguments are for styling. ``` term.writeLine(text, *style) Or text = term.format(text, *style) term.writeLine(text) ``` ### Usage ``` term.writeLine('Hello, Python!') term.writeLine('This text line will be green', term.green) term.writeLine('Reverse the green color', term.green, term.reverse) ``` Or ``` output = term.format('Hello, ', term.green) + term.format('Python!', term.blue, term.bold) term.writeLine(output) term.write(term.format('All in one line', term.reverse)) ``` #### Text align **Center align** ``` # term.textCenter(text) term.writeLine(term.textCenter('Super Python!')) ``` **Right align** ``` # term.textRight(text) term.writeLine(term.textRight('Rene Tanczos (@gravmatt)')) ( Function term.right() to align text is depricated because of naming conflicts! ) ``` ##### Style attributes | Code | Description | | :-------------------- | :----------------------------------- | | term.off | All attributes off | | term.bold | Bold | | term.dim | Dim | | term.underscore | Underscore (monochrome display only) | | term.blink | Blink | | term.reverse | Reverse | | term.hide | Hide | ##### Text color | Code | Color | | :----------------- | :---------- | | term.black | Black | | term.red | Red | | term.green | Green | | term.yellow | Yellow | | term.blue | Blue | | term.magenta | Magenta | | term.cyan | Cyan | | term.white | White | ##### Background color | Code | Color | | :------------------- | :---------- | | term.bgblack | Black | | term.bgred | Red | | term.bggreen | Green | | term.bgyellow | Yellow | | term.bgblue | Blue | | term.bgMagenta | Magenta | | term.bgcyan | Cyan | | term.bgwhite | White | ## Remove style attributes Removes style characters. (Good to call before you count a string) ``` term.strip(formatted_text) hello = term.red + 'hello, world' + term.off print hello # '\x1b[31mhello, world\x1b[0m\x1b[27m' print term.strip(hello) # hello, world ``` ## Highlighting text Simple highlighting of unformatted text strings ``` def callback(matching_text): return term.blue + matching_text + term.off output, match_count, array_of_positions = term.highlight(regex_pattern, text, callback) ``` Return a tuple. output (index 0) = formatted text output match_count (index 1) = match count of the pattern array_of_positions (index 2) = array of tuples with start and stop points of the matches [(4, 6), (9, 11), ..] ## Set title ``` term.setTitle('Hello Terminal') # or clear it term.clearTitle() ``` ## Set tab name ``` term.setTab('Hello Tab') # or clear it term.clearTab() ``` ## Cursor position Move the cursor to a specific position. ``` term.pos(line, column) term.pos(2, 15) ``` Get the size of the terminal (lines and columns) ``` (30, 100) = term.getSize() # (lines, colums) = term.getSize() ``` Move the cursor to the home position (1, 1). ``` term.homePos() ``` Moves the current cursor position up, down, left or right by the specified value. ``` term.up(value=1) term.down(value=1) term.left(value=1) term.right(value=1) ``` Saves the current cursor position. ``` term.saveCursor() ``` Restore the previously stored cursor position. ``` term.restoreCursor() ``` Clear the terminal screen. ``` term.clear() ``` Clear the entire line on the current cursor position. ``` term.clearLine() ``` Clear line from the current cursor position to the end. ``` term.clearLineFromPos() ``` Clear line from begin to current cursor position. ``` term.clearLineToPos() ``` ## Licence The MIT License (MIT) Copyright (c) 2015-2021 René Tanczos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. %prep %autosetup -n py-term-0.7 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-py-term -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Wed Apr 12 2023 Python_Bot - 0.7-1 - Package Spec generated