diff --git a/README.md b/README.md index 69d8f2f..2938209 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ DirectMap2M: 8187904 kB } ``` -- Search: +- Search (is case insensitive): ``` >>> mem.search('Swap') diff --git a/STATS b/STATS index fa296d2..bd574f0 100644 --- a/STATS +++ b/STATS @@ -1,32 +1,32 @@ Analyzing: https://github.com/c0ding/hazelnut/blob/master/hazelnut/core.py - Total Lines: 37 + Total Lines: 38 - Code Lines: 26 (70.2702%) - Blank Lines: 8 (21.6216%) + Code Lines: 28 (73.6842%) + Blank Lines: 9 (23.6842%) - Comment Lines: 3 (8.10810%) - Doc String Lines: 0 (0.0%) - Inline Comments: 1 - Doc Strings: 0 - Total Comments: 4 + Comment Lines: 1 (2.63157%) + Doc String Lines: 0 (0.0%) + Inline Comments: 1 + Doc Strings: 0 + Total Comments: 2 - Longest Code Line: 47 - Shortest Code Line: 8 [return d] + Longest Code Line: 47 + Shortest Code Line: 8 [return d] - Longest Comment Line: 65 - Shortest Comment Line: 23 [# -*- coding: utf-8 ...] + Longest Comment Line: 23 + Shortest Comment Line: 23 [# -*- coding: utf-8 ...] - Imports: 0 - Functions: 6 - Classes: 1 - If Statements: 0 - Try Statements: 0 - Except Statements: 0 - Print Statements: 0 - Assignments: 10 - Variables: 9 + Imports: 1 + Functions: 6 + Classes: 1 + If Statements: 0 + Try Statements: 0 + Except Statements: 0 + Print Statements: 0 + Assignments: 11 + Variables: 10 Done analyzing: https://github.com/c0ding/hazelnut/blob/master/hazelnut/core.py @@ -36,32 +36,32 @@ Analyzing: https://github.com/c0ding/hazelnut/blob/master/hazelnut/__init__.py - Total Lines: 10 + Total Lines: 10 - Code Lines: 7 (70.0%) - Blank Lines: 2 (20.0%) + Code Lines: 7 (70.0%) + Blank Lines: 2 (20.0%) - Comment Lines: 1 (10.0%) - Doc String Lines: 0 (0.0%) - Inline Comments: 1 - Doc Strings: 0 - Total Comments: 2 + Comment Lines: 1 (10.0%) + Doc String Lines: 0 (0.0%) + Inline Comments: 1 + Doc Strings: 0 + Total Comments: 2 - Longest Code Line: 47 - Shortest Code Line: 20 [__version__ = '0.1a'] + Longest Code Line: 47 + Shortest Code Line: 19 [__version__ = '0.2'] - Longest Comment Line: 23 - Shortest Comment Line: 23 [# -*- coding: utf-8 ...] + Longest Comment Line: 23 + Shortest Comment Line: 23 [# -*- coding: utf-8 ...] - Imports: 1 - Functions: 0 - Classes: 0 - If Statements: 0 - Try Statements: 0 - Except Statements: 0 - Print Statements: 0 - Assignments: 5 - Variables: 5 + Imports: 1 + Functions: 0 + Classes: 0 + If Statements: 0 + Try Statements: 0 + Except Statements: 0 + Print Statements: 0 + Assignments: 5 + Variables: 5 Done analyzing: https://github.com/c0ding/hazelnut/blob/master/hazelnut/__init__.py diff --git a/hazelnut/__init__.py b/hazelnut/__init__.py index 9ef0ba6..c0b3023 100644 --- a/hazelnut/__init__.py +++ b/hazelnut/__init__.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- __title__ = 'hazelnut' -__version__ = '0.1' +__version__ = '0.2' __author__ = 'Martin Simon ' __repo__ = 'https://github.com/c0ding/hazelnut' __license__ = 'Apache v2.0 License' diff --git a/hazelnut/core.py b/hazelnut/core.py index be10321..520921a 100644 --- a/hazelnut/core.py +++ b/hazelnut/core.py @@ -1,8 +1,10 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import re + __title__ = 'hazelnut' -__version__ = '0.1' +__version__ = '0.2' __author__ = 'Martin Simon ' __repo__ = 'https://github.com/c0ding/hazelnut' __license__ = 'Apache v2.0 License' @@ -29,9 +31,8 @@ def dict(self): d = dict(x.strip().split(None, 1) for x in f) return d - def search(self, inp): + def search(self, user_inp): with open(self.get_path(), 'r') as f: - match = [s for s in f if inp in s] - # will have to figure out a way to make this case insensitive. - # mem.search('Swap') and mem.search('swap') should both match. - return match + matcher = re.compile(user_inp, re.IGNORECASE) + match = filter(matcher.match, f) + return match diff --git a/setup.py b/setup.py index c4e70ba..fc537cb 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name = 'hazelnut', - version = '0.1', + version = '0.2', url = 'https://github.com/c0ding/hazelnut', download_url = 'https://github.com/c0ding/hazelnut/archive/master.zip', author = 'Martin Simon',