Skip to content

Commit

Permalink
use logger
Browse files Browse the repository at this point in the history
  • Loading branch information
affemitkaraffe committed Jul 19, 2023
1 parent ac272f5 commit 59c77fc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/style_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def compare_dfs(df_to, df_from):
return "\n".join([f"{key},{value}" for key, value in coll_to.items()])


def summarize_tts(df):
def summarize_tts(df, logger):
repo_grps = df.groupby(by='repo')
summary = repo_grps['tone_tags'].value_counts().reset_index(name='count')

Expand All @@ -69,7 +69,7 @@ def summarize_tts(df):
'tone_tags'] != 'untagged')]['tone_tags'].count()).reset_index(name='count')
total_tts["tone_tags"] = "total"
except TypeError as e:
print(e)
logger.warning(e.__str__() + "\n*total* is set to 0 for all repos")
total_tts = pd.DataFrame([['os', 'total', 0], ['premium', 'total', 0]], columns=['repo', 'tone_tags', 'count'])

unique_rules = repo_grps['id'].nunique().to_frame().reset_index()
Expand Down Expand Up @@ -100,7 +100,7 @@ def __main__():
all_rows_to.extend(rows_to)
df_to = DataFrame(rows_to, columns=headers)
df_from = DataFrame(rows_from, columns=headers)
locale_summary = summarize_tts(df_to)
locale_summary = summarize_tts(df_to, logger)

logger.debug(locale_summary)
open(summary_filepath, 'w').write(locale_summary.to_string(index=False))
Expand All @@ -110,7 +110,7 @@ def __main__():

df_all_to = DataFrame(all_rows_to, columns=headers)

all_summary = summarize_tts(df_all_to)
all_summary = summarize_tts(df_all_to, logger)
all_filepath = os.path.join(cli.args.out_dir, 'all_time_summary.txt')
open(all_filepath, 'w').write(all_summary.to_string(index=False))

Expand Down

0 comments on commit 59c77fc

Please sign in to comment.