|
2 | 2 | # copied from: https://raw.githubusercontent.com/kakwa/py-ascii-graph/09ca5901be94ec3563bdcc25d6396e18fd8ca5df/ascii_graph/__init__.py |
3 | 3 | # copied from: https://raw.githubusercontent.com/nyurik/py-ascii-graph/fix-python310/ascii_graph/__init__.py |
4 | 4 | """ |
| 5 | + |
5 | 6 | from __future__ import unicode_literals |
6 | 7 |
|
7 | 8 | import copy |
@@ -115,8 +116,7 @@ def __init__( |
115 | 116 |
|
116 | 117 | @staticmethod |
117 | 118 | def _len_noansi(string): |
118 | | - l = len(re.sub("\x1b[^m]*m", "", string)) |
119 | | - return l |
| 119 | + return len(re.sub("\x1b[^m]*m", "", string)) |
120 | 120 |
|
121 | 121 | def _trans_hr(self, value): |
122 | 122 | if self.divider is None: |
@@ -165,7 +165,6 @@ def _get_thresholds(self, data): |
165 | 165 |
|
166 | 166 | # If we have a list of values for the item |
167 | 167 | if isinstance(value, Iterable): |
168 | | - icount = 0 |
169 | 168 | maxvalue = 0 |
170 | 169 | minvalue = 0 |
171 | 170 | for ivalue, icolor in value: |
@@ -235,14 +234,12 @@ def _gen_graph_string_part( |
235 | 234 | all_width = max_value + abs(min_neg_value) |
236 | 235 |
|
237 | 236 | if all_width == 0: |
238 | | - bar_width = 0 |
239 | 237 | neg_width = 0 |
240 | | - pos_width = 0 |
241 | 238 | else: |
242 | 239 | neg_width = int( |
243 | 240 | abs(float(min_neg_value)) * float(graph_length) / float(all_width) |
244 | 241 | ) |
245 | | - pos_width = int(abs(max_value) * graph_length / all_width) |
| 242 | + int(abs(max_value) * graph_length / all_width) |
246 | 243 |
|
247 | 244 | if isinstance(value, Iterable): |
248 | 245 | accuvalue = 0 |
@@ -372,14 +369,14 @@ def _sanitize_string(self, string): |
372 | 369 | input_type = type(string) |
373 | 370 | if input_type is str: |
374 | 371 | if sys.version < "3": |
375 | | - info = unicode(string) |
| 372 | + info = unicode(string) # noqa: F821 |
376 | 373 | else: |
377 | 374 | info = string |
378 | 375 | elif input_type is unicode_type: |
379 | 376 | info = string |
380 | 377 | elif input_type is int or input_type is float: |
381 | 378 | if sys.version < "3": |
382 | | - info = unicode(string) |
| 379 | + info = unicode(string) # noqa: F821 |
383 | 380 | else: |
384 | 381 | info = str(string) |
385 | 382 | return info |
@@ -441,7 +438,7 @@ def graph(self, label=None, data=[]): |
441 | 438 | san_data = self._sanitize_data(data) |
442 | 439 | all_thre = self._get_thresholds(san_data) |
443 | 440 |
|
444 | | - if not label is None: |
| 441 | + if label is not None: |
445 | 442 | san_label = self._sanitize_string(label) |
446 | 443 | label_len = self._len_noansi(san_label) |
447 | 444 | else: |
@@ -477,7 +474,7 @@ def graph(self, label=None, data=[]): |
477 | 474 | # calcul of the real line length |
478 | 475 | real_line_length = min_line_length |
479 | 476 |
|
480 | | - if not label is None: |
| 477 | + if label is not None: |
481 | 478 | result.append(san_label) |
482 | 479 | result.append(Pyasciigraph._u(self.titlebar) * real_line_length) |
483 | 480 |
|
|
0 commit comments