Skip to content

Commit b03f85c

Browse files
Minor improvements.
1 parent fbb6dba commit b03f85c

6 files changed

Lines changed: 20 additions & 20 deletions

File tree

CHANGES-LOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Help this project by [Donation](DONATE.md)
66
Changes log
77
-----------
88

9+
### 2.3.5
10+
11+
Minor improvements.
12+
913
### 2.3.4
1014

1115
Added a new method to `log21.Logger` class: `log21.Logger.clear_line`. This method clears the current line in the

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ python setup.py install
5353
Changes
5454
-------
5555

56-
### 2.3.4
56+
### 2.3.5
5757

58-
Added a new method to `log21.Logger` class: `log21.Logger.clear_line`. This method clears the current line in the
59-
console and moves the cursor to the beginning of the line.
58+
Minor improvements.
6059

6160
[Full Changes Log](https://github.com/MPCodeWriter21/log21/blob/master/CHANGES-LOG.md)
6261

log21/ProgressBar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# log21.ProgressBar.py
22
# CodeWriter21
33

4-
import os as _os
4+
import shutil as _shutil
55

66
from typing import Dict as _Dict, Any as _Any
77

@@ -61,7 +61,7 @@ def __init__(self, *args, width: int = None, show_percentage: bool = True, prefi
6161
# Sets a default value for the width
6262
if width is None:
6363
try:
64-
width = _os.get_terminal_size().columns - 1
64+
width = _shutil.get_terminal_size().columns - 1
6565
except OSError:
6666
width = 50
6767
if width < 1:

log21/StreamHandler.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import os as _os
55
import re as _re
6+
import shutil as _shutil
67

78
from logging import StreamHandler as _StreamHandler
89
from log21.Colors import ansi_escape as _ansi_escape, get_colors as _gc, hex_escape as _hex_escape
@@ -36,7 +37,8 @@ def check_cr(self, record):
3637
if file_descriptor:
3738
file_descriptor = file_descriptor()
3839
if file_descriptor in (1, 2): # stdout or stderr
39-
self.stream.write('\r' + (' ' * (_os.get_terminal_size(file_descriptor)[0] - 1)) + '\r')
40+
self.stream.write(
41+
'\r' + (' ' * (_shutil.get_terminal_size(file_descriptor).columns - 1)) + '\r')
4042
index = record.msg.rfind('\r')
4143
find = _re.compile(r'(\x1b\[(?:\d+(?:;(?:\d+))*)m)')
4244
record.msg = _gc(*find.split(record.msg[:index])) + record.msg[index + 1:]
@@ -65,18 +67,13 @@ def clear_line(self, length: int = None):
6567
:param length: The length of the line to clear.
6668
:return:
6769
"""
68-
if IS_WINDOWS:
69-
file_descriptor = getattr(self.stream, 'fileno', None)
70-
if file_descriptor:
71-
file_descriptor = file_descriptor()
72-
if file_descriptor in (1, 2):
73-
if length is None:
74-
length = _os.get_terminal_size(file_descriptor)[0]
75-
self.stream.write('\r' + (' ' * (length - 1)) + '\r')
76-
else:
77-
if length is None:
78-
length = _os.get_terminal_size()[0]
79-
self.stream.write('\r' + (' ' * (length - 1)) + '\r')
70+
file_descriptor = getattr(self.stream, 'fileno', None)
71+
if file_descriptor:
72+
file_descriptor = file_descriptor()
73+
if file_descriptor in (1, 2):
74+
if length is None:
75+
length = _shutil.get_terminal_size(file_descriptor).columns
76+
self.stream.write('\r' + (' ' * (length - 1)) + '\r')
8077

8178

8279
# A stream handler that supports colorizing.

log21/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from log21.Formatters import ColorizingFormatter, DecolorizingFormatter
2222
from log21.Colors import Colors, get_color, get_colors, ansi_escape, get_color_name, closest_color
2323

24-
__version__ = "2.3.4"
24+
__version__ = "2.3.5"
2525
__author__ = "CodeWriter21 (Mehrad Pooryoussof)"
2626
__github__ = "Https://GitHub.com/MPCodeWriter21/log21"
2727
__all__ = ['ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter', 'DecolorizingFormatter',

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
long_description = file.read()
88

99
DESCRIPTION = 'A simple logging package that helps you log colorized messages in Windows console.'
10-
VERSION = '2.3.4'
10+
VERSION = '2.3.5'
1111

1212
setup(
1313
name='log21',

0 commit comments

Comments
 (0)