Skip to content

Commit

Permalink
πŸ—“ Jul 23, 2022 11:18:22 PM
Browse files Browse the repository at this point in the history
πŸ”§ fix #12
πŸ” version 2.0.0
πŸ› fix bug with RipgrepOut spelling
πŸ› fix numeric arguments cast to string
πŸ§ͺ tests added/updated
  • Loading branch information
securisec committed Jul 24, 2022
1 parent 3af7356 commit 5266547
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
24 changes: 11 additions & 13 deletions ripgrepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
from json import dumps, loads
from functools import wraps
from timeit import default_timer
from pkg_resources import get_distribution
import logging

__version__ = get_distribution("ripgrepy").version


def _logger(func):
Expand Down Expand Up @@ -82,7 +80,7 @@ def as_json(self) -> str:
:rtype: str
"""
if "--json" not in self.command:
raise TypeError("To use as_dict, use the json() method")
raise TypeError("To use as_json, use the json() method")
out = self._output.splitlines()
holder = []
for line in out:
Expand Down Expand Up @@ -205,12 +203,12 @@ def __init__(self, regex_pattern: str, path: str, rg_path: str = "rg"):
self.run_rg = self.run

@_logger
def run(self) -> RipgrepOut:
def run(self) -> RipGrepOut:
"""
Returns an instace of the Ripgrepy object
:return: self
:rtype: RipgrepOut
:rtype: RipGrepOut
"""
self.command.append(self.regex_pattern)
self.command.append(self.path)
Expand Down Expand Up @@ -244,7 +242,7 @@ def after_context(self, number: int) -> Ripgrepy:
:rtype: Ripgrepy
"""
self.command.append("--after-context")
self.command.append(number)
self.command.append(str(number))
return self

@_logger
Expand All @@ -260,7 +258,7 @@ def before_context(self, number: int) -> Ripgrepy:
:rtype: Ripgrepy
"""
self.command.append("--before-context")
self.command.append(number)
self.command.append(str(number))
return self

@_logger
Expand All @@ -280,7 +278,7 @@ def context(self, number: int) -> Ripgrepy:
:rtype: Ripgrepy
"""
self.command.append("--context")
self.command.append(number)
self.command.append(str(number))
return self

@_logger
Expand Down Expand Up @@ -496,7 +494,7 @@ def dfa_size_limit(self, num_suffix: int) -> Ripgrepy:
:rtype: Ripgrepy
"""
self.command.append('--dfa-size-limit')
self.command.append(num_suffix)
self.command.append(str(num_suffix))
return self

@_logger
Expand Down Expand Up @@ -856,7 +854,7 @@ def max_columns(self, num: int) -> Ripgrepy:
:rtype: Ripgrepy
"""
self.command.append("--max-columns")
self.command.append(num)
self.command.append(str(num))
return self

@_logger
Expand Down Expand Up @@ -890,7 +888,7 @@ def max_count(self, num: int) -> Ripgrepy:
:rtype: Ripgrepy
"""
self.command.append("--max-count")
self.command.append(num)
self.command.append(str(num))
return self

@_logger
Expand All @@ -910,7 +908,7 @@ def max_depth(self, num: int) -> Ripgrepy:
:rtype: Ripgrepy
"""
self.command.append("--max-depth")
self.command.append(num)
self.command.append(str(num))
return self

@_logger
Expand Down Expand Up @@ -1743,7 +1741,7 @@ def threads(self, num: int) -> Ripgrepy:
:rtype: Ripgrepy
"""
self.command.append("--threads")
self.command.append(num)
self.command.append(str(num))
return self

@_logger
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
from os import path

__version__ = '1.1.0'
__version__ = '2.0.0'
__author__ = 'Hapsida @securisec'

this_directory = path.abspath(path.dirname(__file__))
Expand Down
9 changes: 5 additions & 4 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from ripgrepy import Ripgrepy

rg = Ripgrepy('lol', '.').json().run()
def test_base():
rg = Ripgrepy('lol', '.').context(1).json().run()

print(rg.as_string)
print(rg.as_dict)
print(rg.as_json)
print(rg.as_string)
print(rg.as_dict)
print(rg.as_json)

0 comments on commit 5266547

Please sign in to comment.