Skip to content

Commit 1bfefe5

Browse files
committed
Simplified logic in commenting of libraries when compiling examples.
1 parent a59ffb0 commit 1bfefe5

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

codebender_testing/disqus.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,29 @@ def get_disqus_sso(self, user):
5757
sig = hmac.HMAC(self.DISQUS_API_SECRET, '%s %s' % (message, timestamp), hashlib.sha1).hexdigest()
5858
return "{0} {1} {2}".format(message, sig, timestamp)
5959

60-
def update_comment(self, sketch, results, current_date, log_entry, openFailFlag, counter, total_sketches):
61-
# Comment examples
62-
if not openFailFlag:
63-
log_entry = self.handle_example_comment(sketch, results, current_date, log_entry)
64-
65-
# Comment libraries when finished commenting the examples
60+
def update_comment(self, sketch, results, current_date, log_entry, openFailFlag, total_sketches):
61+
# Comment libraries
6662
library_match = re.match(r'.+\/example\/(.+)\/.+', sketch)
6763
library = None
64+
library_to_comment = None
6865
if library_match:
6966
library = library_match.group(1)
7067
if not self.last_library:
7168
self.last_library = library
69+
library_to_comment = library
7270

73-
library_to_comment = None
74-
if self.last_library and self.last_library not in self.examples_without_library and library != self.last_library:
75-
library_to_comment = self.last_library
76-
if library and library not in self.examples_without_library and counter >= total_sketches-1:
71+
if library != self.last_library:
7772
library_to_comment = library
73+
7874
if library_to_comment:
7975
log_entry = self.handle_library_comment(library_to_comment, current_date, log_entry)
8076

8177
self.last_library = library
8278

79+
# Comment examples
80+
if not openFailFlag:
81+
log_entry = self.handle_example_comment(sketch, results, current_date, log_entry)
82+
8383
return log_entry
8484

8585
def handle_library_comment(self, library, current_date, log):

codebender_testing/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def compile_sketches(self, sketches, iframe=False, project_view=False, logfile=N
575575
total_sketches = len(urls_to_visit)
576576
tic = time.time()
577577

578-
for counter, sketch in enumerate(urls_to_visit):
578+
for sketch in urls_to_visit:
579579
# Read the boards map in case current sketch/example requires a special board configuration
580580
boards = BOARDS_DB['default_boards']
581581
url_fragments = urlparse(sketch)
@@ -629,7 +629,7 @@ def compile_sketches(self, sketches, iframe=False, project_view=False, logfile=N
629629

630630
# Update Disqus comments
631631
if compile_type in ['library', 'target_library'] and comment:
632-
log_entry = disqus_wrapper.update_comment(sketch, results, current_date, log_entry, openFailFlag, counter, total_sketches)
632+
log_entry = disqus_wrapper.update_comment(sketch, results, current_date, log_entry, openFailFlag, total_sketches)
633633

634634
# Dump the test results to `logfile`.
635635
with open(log_file, 'w') as f:

0 commit comments

Comments
 (0)