Skip to content

Commit 6ae4c69

Browse files
author
Martin Simon
committed
v.0.2
search method is now case insensitive
1 parent 55ab396 commit 6ae4c69

File tree

5 files changed

+52
-51
lines changed

5 files changed

+52
-51
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ DirectMap2M: 8187904 kB
119119
}
120120
```
121121

122-
- Search:
122+
- Search (is case insensitive):
123123

124124
```
125125
>>> mem.search('Swap')

STATS

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11

22
Analyzing: https://github.com/c0ding/hazelnut/blob/master/hazelnut/core.py
33

4-
Total Lines: 37
4+
Total Lines: 38
55

6-
Code Lines: 26 (70.2702%)
7-
Blank Lines: 8 (21.6216%)
6+
Code Lines: 28 (73.6842%)
7+
Blank Lines: 9 (23.6842%)
88

9-
Comment Lines: 3 (8.10810%)
10-
Doc String Lines: 0 (0.0%)
11-
Inline Comments: 1
12-
Doc Strings: 0
13-
Total Comments: 4
9+
Comment Lines: 1 (2.63157%)
10+
Doc String Lines: 0 (0.0%)
11+
Inline Comments: 1
12+
Doc Strings: 0
13+
Total Comments: 2
1414

15-
Longest Code Line: 47
16-
Shortest Code Line: 8 [return d]
15+
Longest Code Line: 47
16+
Shortest Code Line: 8 [return d]
1717

18-
Longest Comment Line: 65
19-
Shortest Comment Line: 23 [# -*- coding: utf-8 ...]
18+
Longest Comment Line: 23
19+
Shortest Comment Line: 23 [# -*- coding: utf-8 ...]
2020

21-
Imports: 0
22-
Functions: 6
23-
Classes: 1
24-
If Statements: 0
25-
Try Statements: 0
26-
Except Statements: 0
27-
Print Statements: 0
28-
Assignments: 10
29-
Variables: 9
21+
Imports: 1
22+
Functions: 6
23+
Classes: 1
24+
If Statements: 0
25+
Try Statements: 0
26+
Except Statements: 0
27+
Print Statements: 0
28+
Assignments: 11
29+
Variables: 10
3030

3131

3232
Done analyzing: https://github.com/c0ding/hazelnut/blob/master/hazelnut/core.py
@@ -36,32 +36,32 @@
3636

3737
Analyzing: https://github.com/c0ding/hazelnut/blob/master/hazelnut/__init__.py
3838

39-
Total Lines: 10
39+
Total Lines: 10
4040

41-
Code Lines: 7 (70.0%)
42-
Blank Lines: 2 (20.0%)
41+
Code Lines: 7 (70.0%)
42+
Blank Lines: 2 (20.0%)
4343

44-
Comment Lines: 1 (10.0%)
45-
Doc String Lines: 0 (0.0%)
46-
Inline Comments: 1
47-
Doc Strings: 0
48-
Total Comments: 2
44+
Comment Lines: 1 (10.0%)
45+
Doc String Lines: 0 (0.0%)
46+
Inline Comments: 1
47+
Doc Strings: 0
48+
Total Comments: 2
4949

50-
Longest Code Line: 47
51-
Shortest Code Line: 20 [__version__ = '0.1a']
50+
Longest Code Line: 47
51+
Shortest Code Line: 19 [__version__ = '0.2']
5252

53-
Longest Comment Line: 23
54-
Shortest Comment Line: 23 [# -*- coding: utf-8 ...]
53+
Longest Comment Line: 23
54+
Shortest Comment Line: 23 [# -*- coding: utf-8 ...]
5555

56-
Imports: 1
57-
Functions: 0
58-
Classes: 0
59-
If Statements: 0
60-
Try Statements: 0
61-
Except Statements: 0
62-
Print Statements: 0
63-
Assignments: 5
64-
Variables: 5
56+
Imports: 1
57+
Functions: 0
58+
Classes: 0
59+
If Statements: 0
60+
Try Statements: 0
61+
Except Statements: 0
62+
Print Statements: 0
63+
Assignments: 5
64+
Variables: 5
6565

6666

6767
Done analyzing: https://github.com/c0ding/hazelnut/blob/master/hazelnut/__init__.py

hazelnut/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
__title__ = 'hazelnut'
5-
__version__ = '0.1'
5+
__version__ = '0.2'
66
__author__ = 'Martin Simon <[email protected]>'
77
__repo__ = 'https://github.com/c0ding/hazelnut'
88
__license__ = 'Apache v2.0 License'

hazelnut/core.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
import re
5+
46
__title__ = 'hazelnut'
5-
__version__ = '0.1'
7+
__version__ = '0.2'
68
__author__ = 'Martin Simon <[email protected]>'
79
__repo__ = 'https://github.com/c0ding/hazelnut'
810
__license__ = 'Apache v2.0 License'
@@ -29,9 +31,8 @@ def dict(self):
2931
d = dict(x.strip().split(None, 1) for x in f)
3032
return d
3133

32-
def search(self, inp):
34+
def search(self, user_inp):
3335
with open(self.get_path(), 'r') as f:
34-
match = [s for s in f if inp in s]
35-
# will have to figure out a way to make this case insensitive.
36-
# mem.search('Swap') and mem.search('swap') should both match.
37-
return match
36+
matcher = re.compile(user_inp, re.IGNORECASE)
37+
match = filter(matcher.match, f)
38+
return match

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name = 'hazelnut',
8-
version = '0.1',
8+
version = '0.2',
99
url = 'https://github.com/c0ding/hazelnut',
1010
download_url = 'https://github.com/c0ding/hazelnut/archive/master.zip',
1111
author = 'Martin Simon',

0 commit comments

Comments
 (0)