diff options
author | romangraef <roman.graef@gmail.com> | 2018-06-03 13:46:20 +0200 |
---|---|---|
committer | romangraef <roman.graef@gmail.com> | 2018-06-03 13:46:20 +0200 |
commit | 2748ab3d274f67a2a701ba4f7d5d98ab2da6e025 (patch) | |
tree | f674b9bfb910841894549b6696dbc4d848d24d8d /lib/stats.py | |
download | tabsvsspaces-2748ab3d274f67a2a701ba4f7d5d98ab2da6e025.tar.gz tabsvsspaces-2748ab3d274f67a2a701ba4f7d5d98ab2da6e025.tar.bz2 tabsvsspaces-2748ab3d274f67a2a701ba4f7d5d98ab2da6e025.zip |
Initial commit
Diffstat (limited to 'lib/stats.py')
-rw-r--r-- | lib/stats.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/stats.py b/lib/stats.py new file mode 100644 index 0000000..42e4461 --- /dev/null +++ b/lib/stats.py @@ -0,0 +1,26 @@ +from collections import defaultdict +from typing import Set + + +class Statistics: + def __init__(self): + self.space_dict = defaultdict(int) + self.tab_dict = defaultdict(int) + self.mixed_line_dict = defaultdict(int) + self.mixed_files: Set[str] = set() + self.all_tabs = 0 + self.all_spaces = 0 + self.all_mixed = 0 + + def add_spaces(self, extension='', count=1): + self.space_dict[extension] += count + self.all_spaces += count + + def add_tabs(self, extension='', count=1): + self.tab_dict[extension] += count + self.all_tabs += count + + def add_mixed_line(self, extension='', count=1, filename=''): + self.mixed_line_dict[extension] += count + self.mixed_files.add(filename) + self.all_mixed += count |