1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655
|
From: Python Applications Packaging Team
<python-apps-team@lists.alioth.debian.org>
Date: Mon, 30 Mar 2020 19:58:56 +0200
Subject: port-to-python3
Bug: https://github.com/ejwa/gitinspector/pull/223
---
gitinspector/blame.py | 30 +++++++++++++++---------------
gitinspector/changes.py | 28 ++++++++++++++--------------
gitinspector/clone.py | 2 +-
gitinspector/comment.py | 2 +-
gitinspector/config.py | 12 ++++++------
gitinspector/extensions.py | 10 +++++-----
gitinspector/filtering.py | 12 ++++++------
gitinspector/format.py | 12 ++++++------
gitinspector/gitinspector.py | 40 ++++++++++++++++++++--------------------
gitinspector/gravatar.py | 6 +++---
gitinspector/help.py | 8 ++++----
gitinspector/interval.py | 2 +-
gitinspector/localization.py | 6 +++---
gitinspector/metrics.py | 34 +++++++++++++++++-----------------
gitinspector/optval.py | 2 +-
gitinspector/outputable.py | 6 +++---
gitinspector/responsibilities.py | 20 ++++++++++----------
gitinspector/terminal.py | 2 +-
gitinspector/timeline.py | 16 ++++++++--------
gitinspector/version.py | 6 +++---
tests/test_comment.py | 31 +++++++++++++++----------------
21 files changed, 143 insertions(+), 144 deletions(-)
--- a/gitinspector/blame.py
+++ b/gitinspector/blame.py
@@ -17,24 +17,24 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-from localization import N_
-from outputable import Outputable
-from changes import FileDiff
-import comment
+
+
+from .localization import N_
+from .outputable import Outputable
+from .changes import FileDiff
+from . import comment
import datetime
-import extensions
-import filtering
-import format
-import gravatar
-import interval
+from . import extensions
+from . import filtering
+from . import format
+from . import gravatar
+from . import interval
import json
import multiprocessing
import re
import subprocess
import sys
-import terminal
+from . import terminal
import textwrap
import threading
@@ -145,9 +145,9 @@
if FileDiff.get_extension(row) in extensions.get_located() and FileDiff.is_valid_extension(row) and not \
filtering.set_filtered(FileDiff.get_filename(row)):
- blame_command = filter(None, ["git", "blame", "--line-porcelain", "-w"] + \
+ blame_command = [_f for _f in ["git", "blame", "--line-porcelain", "-w"] + \
(["-C", "-C", "-M"] if hard else []) +
- [interval.get_since(), interval.get_ref(), "--", row])
+ [interval.get_since(), interval.get_ref(), "--", row] if _f]
thread = BlameThread(useweeks, changes, blame_command, FileDiff.get_extension(row),
self.blames, row.strip())
thread.daemon = True
@@ -190,7 +190,7 @@
def get_summed_blames(self):
summed_blames = {}
- for i in self.blames.items():
+ for i in list(self.blames.items()):
if summed_blames.get(i[0][0], None) == None:
summed_blames[i[0][0]] = BlameEntry()
--- a/gitinspector/changes.py
+++ b/gitinspector/changes.py
@@ -17,21 +17,21 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-from localization import N_
-from outputable import Outputable
+
+
+from .localization import N_
+from .outputable import Outputable
import datetime
-import extensions
-import filtering
-import format
-import gravatar
-import interval
+from . import extensions
+from . import filtering
+from . import format
+from . import gravatar
+from . import interval
import json
import multiprocessing
import os
import subprocess
-import terminal
+from . import terminal
import textwrap
import threading
@@ -125,10 +125,10 @@
thread.start()
def run(self):
- git_log_r = subprocess.Popen(filter(None, ["git", "log", "--reverse", "--pretty=%cd|%H|%aN|%aE",
+ git_log_r = subprocess.Popen([_f for _f in ["git", "log", "--reverse", "--pretty=%cd|%H|%aN|%aE",
"--stat=100000,8192", "--no-merges", "-w", interval.get_since(),
interval.get_until(), "--date=short"] + (["-C", "-C", "-M"] if self.hard else []) +
- [self.first_hash + self.second_hash]), bufsize=1, stdout=subprocess.PIPE).stdout
+ [self.first_hash + self.second_hash] if _f], bufsize=1, stdout=subprocess.PIPE).stdout
lines = git_log_r.readlines()
git_log_r.close()
@@ -185,8 +185,8 @@
def __init__(self, hard):
self.commits = []
- git_log_hashes_r = subprocess.Popen(filter(None, ["git", "rev-list", "--reverse", "--no-merges",
- interval.get_since(), interval.get_until(), "HEAD"]), bufsize=1,
+ git_log_hashes_r = subprocess.Popen([_f for _f in ["git", "rev-list", "--reverse", "--no-merges",
+ interval.get_since(), interval.get_until(), "HEAD"] if _f], bufsize=1,
stdout=subprocess.PIPE).stdout
lines = git_log_hashes_r.readlines()
git_log_hashes_r.close()
--- a/gitinspector/clone.py
+++ b/gitinspector/clone.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import unicode_literals
+
import shutil
import subprocess
--- a/gitinspector/comment.py
+++ b/gitinspector/comment.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import unicode_literals
+
__comment_begining__ = { "java": "/*", "c": "/*", "cc": "/*", "cpp": "/*", "cs": "/*", "h": "/*", "hh": "/*", "hpp": "/*",
"hs": "{-", "html": "<!--", "php": "/*", "py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*",
--- a/gitinspector/config.py
+++ b/gitinspector/config.py
@@ -17,12 +17,12 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import unicode_literals
-import extensions
-import filtering
-import format
-import interval
-import optval
+
+from . import extensions
+from . import filtering
+from . import format
+from . import interval
+from . import optval
import os
import subprocess
--- a/gitinspector/extensions.py
+++ b/gitinspector/extensions.py
@@ -17,11 +17,11 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-from localization import N_
-from outputable import Outputable
-import terminal
+
+
+from .localization import N_
+from .outputable import Outputable
+from . import terminal
import textwrap
DEFAULT_EXTENSIONS = ["java", "c", "cc", "cpp", "h", "hh", "hpp", "py", "glsl", "rb", "js", "sql"]
--- a/gitinspector/filtering.py
+++ b/gitinspector/filtering.py
@@ -17,13 +17,13 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-from localization import N_
-from outputable import Outputable
+
+
+from .localization import N_
+from .outputable import Outputable
import re
import subprocess
-import terminal
+from . import terminal
import textwrap
__filters__ = {"file": [set(), set()], "author": [set(), set()], "email": [set(), set()], "revision": [set(), set()],
@@ -63,7 +63,7 @@
return False
def __find_commit_message__(sha):
- git_show_r = subprocess.Popen(filter(None, ["git", "show", "-s", "--pretty=%B", "-w", sha]), bufsize=1,
+ git_show_r = subprocess.Popen([_f for _f in ["git", "show", "-s", "--pretty=%B", "-w", sha] if _f], bufsize=1,
stdout=subprocess.PIPE).stdout
commit_message = git_show_r.read()
--- a/gitinspector/format.py
+++ b/gitinspector/format.py
@@ -17,14 +17,14 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-import localization
-import version
+
+
+from . import localization
+from . import version
import base64
-import basedir
+from . import basedir
import os
-import terminal
+from . import terminal
import textwrap
import time
import zipfile
--- a/gitinspector/gitinspector.py
+++ b/gitinspector/gitinspector.py
@@ -18,33 +18,33 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-import localization
+
+
+from . import localization
localization.init()
import atexit
-import basedir
-import blame
-import changes
-import clone
-import config
-import extensions
-import filtering
-import format
-import help
-import interval
+from . import basedir
+from . import blame
+from . import changes
+from . import clone
+from . import config
+from . import extensions
+from . import filtering
+from . import format
+from . import help
+from . import interval
import getopt
-import metrics
+from . import metrics
import os
-import optval
-import outputable
-import responsibilities
+from . import optval
+from . import outputable
+from . import responsibilities
import sys
-import terminal
-import timeline
-import version
+from . import terminal
+from . import timeline
+from . import version
class Runner:
def __init__(self):
--- a/gitinspector/gravatar.py
+++ b/gitinspector/gravatar.py
@@ -17,12 +17,12 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import unicode_literals
+
try:
from urllib.parse import urlencode
except:
- from urllib import urlencode
-import format
+ from urllib.parse import urlencode
+from . import format
import hashlib
def get_url(email, size=20):
--- a/gitinspector/help.py
+++ b/gitinspector/help.py
@@ -17,10 +17,10 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-from extensions import DEFAULT_EXTENSIONS
-from format import __available_formats__
+
+
+from .extensions import DEFAULT_EXTENSIONS
+from .format import __available_formats__
import sys
__doc__ = _("""Usage: {0} [OPTION]... [REPOSITORY]
--- a/gitinspector/interval.py
+++ b/gitinspector/interval.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import unicode_literals
+
try:
from shlex import quote
--- a/gitinspector/localization.py
+++ b/gitinspector/localization.py
@@ -17,11 +17,11 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
+
+
try:
- import basedir
+ from . import basedir
except:
import gitinspector.basedir as basedir
--- a/gitinspector/metrics.py
+++ b/gitinspector/metrics.py
@@ -17,14 +17,14 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-from localization import N_
-from outputable import Outputable
-from changes import FileDiff
-import comment
-import filtering
-import interval
+
+
+from .localization import N_
+from .outputable import Outputable
+from .changes import FileDiff
+from . import comment
+from . import filtering
+from . import interval
import re
import subprocess
@@ -139,17 +139,17 @@
if metrics_logic.eloc:
print("\n" + _(ELOC_INFO_TEXT) + ":")
- for i in sorted(set([(j, i) for (i, j) in metrics_logic.eloc.items()]), reverse = True):
+ for i in sorted(set([(j, i) for (i, j) in list(metrics_logic.eloc.items())]), reverse = True):
print(_("{0} ({1} estimated lines of code)").format(i[1], str(i[0])))
if metrics_logic.cyclomatic_complexity:
print("\n" + _(CYCLOMATIC_COMPLEXITY_TEXT) + ":")
- for i in sorted(set([(j, i) for (i, j) in metrics_logic.cyclomatic_complexity.items()]), reverse = True):
+ for i in sorted(set([(j, i) for (i, j) in list(metrics_logic.cyclomatic_complexity.items())]), reverse = True):
print(_("{0} ({1} in cyclomatic complexity)").format(i[1], str(i[0])))
if metrics_logic.cyclomatic_complexity_density:
print("\n" + _(CYCLOMATIC_COMPLEXITY_DENSITY_TEXT) + ":")
- for i in sorted(set([(j, i) for (i, j) in metrics_logic.cyclomatic_complexity_density.items()]), reverse = True):
+ for i in sorted(set([(j, i) for (i, j) in list(metrics_logic.cyclomatic_complexity_density.items())]), reverse = True):
print(_("{0} ({1:.3f} in cyclomatic complexity density)").format(i[1], i[0]))
def output_html(self):
@@ -161,7 +161,7 @@
if metrics_logic.eloc:
metrics_xml += "<div><h4>" + _(ELOC_INFO_TEXT) + ".</h4>"
- for num, i in enumerate(sorted(set([(j, i) for (i, j) in metrics_logic.eloc.items()]), reverse = True)):
+ for num, i in enumerate(sorted(set([(j, i) for (i, j) in list(metrics_logic.eloc.items())]), reverse = True)):
metrics_xml += "<div class=\"" + __get_metrics_score__(__metric_eloc__[FileDiff.get_extension(i[1])], i[0]) + \
(" odd\">" if num % 2 == 1 else "\">") + \
_("{0} ({1} estimated lines of code)").format(i[1], str(i[0])) + "</div>"
@@ -169,7 +169,7 @@
if metrics_logic.cyclomatic_complexity:
metrics_xml += "<div><h4>" + _(CYCLOMATIC_COMPLEXITY_TEXT) + "</h4>"
- for num, i in enumerate(sorted(set([(j, i) for (i, j) in metrics_logic.cyclomatic_complexity.items()]), reverse = True)):
+ for num, i in enumerate(sorted(set([(j, i) for (i, j) in list(metrics_logic.cyclomatic_complexity.items())]), reverse = True)):
metrics_xml += "<div class=\"" + __get_metrics_score__(METRIC_CYCLOMATIC_COMPLEXITY_THRESHOLD, i[0]) + \
(" odd\">" if num % 2 == 1 else "\">") + \
_("{0} ({1} in cyclomatic complexity)").format(i[1], str(i[0])) + "</div>"
@@ -177,7 +177,7 @@
if metrics_logic.cyclomatic_complexity_density:
metrics_xml += "<div><h4>" + _(CYCLOMATIC_COMPLEXITY_DENSITY_TEXT) + "</h4>"
- for num, i in enumerate(sorted(set([(j, i) for (i, j) in metrics_logic.cyclomatic_complexity_density.items()]), reverse = True)):
+ for num, i in enumerate(sorted(set([(j, i) for (i, j) in list(metrics_logic.cyclomatic_complexity_density.items())]), reverse = True)):
metrics_xml += "<div class=\"" + __get_metrics_score__(METRIC_CYCLOMATIC_COMPLEXITY_DENSITY_THRESHOLD, i[0]) + \
(" odd\">" if num % 2 == 1 else "\">") + \
_("{0} ({1:.3f} in cyclomatic complexity density)").format(i[1], i[0]) + "</div>"
@@ -195,21 +195,21 @@
eloc_xml = ""
if metrics_logic.eloc:
- for i in sorted(set([(j, i) for (i, j) in metrics_logic.eloc.items()]), reverse = True):
+ for i in sorted(set([(j, i) for (i, j) in list(metrics_logic.eloc.items())]), reverse = True):
eloc_xml += "\t\t\t<estimated-lines-of-code>\n"
eloc_xml += "\t\t\t\t<file-name>" + i[1] + "</file-name>\n"
eloc_xml += "\t\t\t\t<value>" + str(i[0]) + "</value>\n"
eloc_xml += "\t\t\t</estimated-lines-of-code>\n"
if metrics_logic.cyclomatic_complexity:
- for i in sorted(set([(j, i) for (i, j) in metrics_logic.cyclomatic_complexity.items()]), reverse = True):
+ for i in sorted(set([(j, i) for (i, j) in list(metrics_logic.cyclomatic_complexity.items())]), reverse = True):
eloc_xml += "\t\t\t<cyclomatic-complexity>\n"
eloc_xml += "\t\t\t\t<file-name>" + i[1] + "</file-name>\n"
eloc_xml += "\t\t\t\t<value>" + str(i[0]) + "</value>\n"
eloc_xml += "\t\t\t</cyclomatic-complexity>\n"
if metrics_logic.cyclomatic_complexity_density:
- for i in sorted(set([(j, i) for (i, j) in metrics_logic.cyclomatic_complexity_density.items()]), reverse = True):
+ for i in sorted(set([(j, i) for (i, j) in list(metrics_logic.cyclomatic_complexity_density.items())]), reverse = True):
eloc_xml += "\t\t\t<cyclomatic-complexity-density>\n"
eloc_xml += "\t\t\t\t<file-name>" + i[1] + "</file-name>\n"
eloc_xml += "\t\t\t\t<value>{0:.3f}</value>\n".format(i[0])
--- a/gitinspector/optval.py
+++ b/gitinspector/optval.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import unicode_literals
+
import getopt
class InvalidOptionArgument(Exception):
--- a/gitinspector/outputable.py
+++ b/gitinspector/outputable.py
@@ -17,9 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-import format
+
+
+from . import format
class Outputable(object):
def output_html(self):
--- a/gitinspector/responsibilities.py
+++ b/gitinspector/responsibilities.py
@@ -17,15 +17,15 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-from localization import N_
-from outputable import Outputable
-import blame
-import changes
-import format
-import gravatar
-import terminal
+
+
+from .localization import N_
+from .outputable import Outputable
+from . import blame
+from . import changes
+from . import format
+from . import gravatar
+from . import terminal
import textwrap
class ResponsibiltyEntry:
@@ -36,7 +36,7 @@
def get(hard, useweeks, author_name):
author_blames = {}
- for i in blame.get(hard, useweeks, changes.get(hard)).blames.items():
+ for i in list(blame.get(hard, useweeks, changes.get(hard)).blames.items()):
if (author_name == i[0][0]):
total_rows = i[1].rows - i[1].comments
if total_rows > 0:
--- a/gitinspector/terminal.py
+++ b/gitinspector/terminal.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
+
import codecs
import os
import platform
--- a/gitinspector/timeline.py
+++ b/gitinspector/timeline.py
@@ -17,14 +17,14 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
-from localization import N_
-from outputable import Outputable
+
+
+from .localization import N_
+from .outputable import Outputable
import datetime
-import format
-import gravatar
-import terminal
+from . import format
+from . import gravatar
+from . import terminal
import textwrap
class TimelineData:
@@ -70,7 +70,7 @@
return self.total_changes_by_period[period]
def get_authors(self):
- return sorted(set([(i[0][0], self.changes.get_latest_email_by_author(i[0][0])) for i in self.entries.items()]))
+ return sorted(set([(i[0][0], self.changes.get_latest_email_by_author(i[0][0])) for i in list(self.entries.items())]))
def get_author_signs_in_period(self, author, period, multiplier):
authorinfo = self.entries.get((author, period), None)
--- a/gitinspector/version.py
+++ b/gitinspector/version.py
@@ -17,11 +17,11 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-from __future__ import unicode_literals
+
+
try:
- import localization
+ from . import localization
localization.init()
except:
import gitinspector.localization
--- a/tests/test_comment.py
+++ b/tests/test_comment.py
@@ -20,31 +20,30 @@
from __future__ import unicode_literals
import os
import sys
-import unittest2
+import unittest
import gitinspector.comment
def __test_extension__(commented_file, extension):
- base = os.path.dirname(os.path.realpath(__file__))
- tex_file = open(base + commented_file, "r")
- tex = tex_file.readlines()
- tex_file.close()
+ base = os.path.dirname(os.path.realpath(__file__))
+ tex_file = open(base + commented_file, "r")
+ tex = tex_file.readlines()
+ tex_file.close()
- is_inside_comment = False
- comment_counter = 0
- for i in tex:
- i = i.decode("utf-8", "replace")
- (_, is_inside_comment) = gitinspector.comment.handle_comment_block(is_inside_comment, extension, i)
- if is_inside_comment or gitinspector.comment.is_comment(extension, i):
- comment_counter += 1
+ is_inside_comment = False
+ comment_counter = 0
+ for i in tex:
+ (_, is_inside_comment) = gitinspector.comment.handle_comment_block(is_inside_comment, extension, i)
+ if is_inside_comment or gitinspector.comment.is_comment(extension, i):
+ comment_counter += 1
- return comment_counter
+ return comment_counter
-class TexFileTest(unittest2.TestCase):
+class TexFileTest(unittest.TestCase):
def test(self):
- comment_counter = __test_extension__("/resources/commented_file.tex", "tex")
- self.assertEqual(comment_counter, 30)
+ comment_counter = __test_extension__("/resources/commented_file.tex", "tex")
+ self.assertEqual(comment_counter, 30)
-class CppFileTest(unittest2.TestCase):
+class CppFileTest(unittest.TestCase):
def test(self):
- comment_counter = __test_extension__("/resources/commented_file.cpp", "cpp")
- self.assertEqual(comment_counter, 25)
+ comment_counter = __test_extension__("/resources/commented_file.cpp", "cpp")
+ self.assertEqual(comment_counter, 25)
|