Skip to content

Increase flexibility of bruteforce signature extration#166

Open
RonRademaker wants to merge 6 commits into
mailgun:masterfrom
RonRademaker:more-flexible-bruteforce
Open

Increase flexibility of bruteforce signature extration#166
RonRademaker wants to merge 6 commits into
mailgun:masterfrom
RonRademaker:more-flexible-bruteforce

Conversation

@RonRademaker

Copy link
Copy Markdown

Allows overriding line length, max line length (useful if you expect disclaimers) and greetings (useful from a language perspective) when extracting signatures bruteforce

@mailgun-ci

Copy link
Copy Markdown

Can one of the admins verify this patch?

@obukhov-sergey

Copy link
Copy Markdown
Member

@mailgun-ci test this please

@obukhov-sergey obukhov-sergey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, minor comments, syntax error fails tests

Comment thread talon/signature/extractor.py Outdated
"""

@abstractmethod
def extract_signature(self, message: str):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nosetests --with-xunit --with-coverage --cover-xml --cover-package=talon
EE
======================================================================
ERROR: Failure: SyntaxError (invalid syntax (extractor.py, line 36))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/lib/jenkins/shiningpanda/jobs/b20cb595/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
...
    from talon.signature.extractor import BruteForceExtractor
  File "/var/lib/jenkins/workspace/lib-py-talon-pr/talon/signature/extractor.py", line 36
    def extract_signature(self, message: str):
                                       ^
SyntaxError: invalid syntax

Comment thread talon/signature/bruteforce.py Outdated
"""
match = RE_SIGNATURE_CANDIDATE.match(markers[::-1])
return candidate[-match.end('candidate'):] if match else []
brute_force_extractor = BruteForceExtractor(max_lines=SIGNATURE_MAX_LINES, max_line_length=TOO_LONG_SIGNATURE_LINE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd skip the parameters since you set the defaults.

Comment thread talon/signature/extractor.py Outdated
@@ -0,0 +1,195 @@
"""
Module with object oriented approach to

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity - why the comment lines are so short? I know shorter lines are easier to read but usually 80 chars is ok. Functions that go on for many lines become hard to read just like lines stretching for many chars.

@RonRademaker

Copy link
Copy Markdown
Author

Thanks for the feedback, I processed it

@obukhov-sergey

Copy link
Copy Markdown
Member

@mailgun-ci test this please

@obukhov-sergey

Copy link
Copy Markdown
Member

@RonRademaker sorry for delay with the merge, can you plz add abc to setup.py to make tests pass?

@obukhov-sergey obukhov-sergey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests fail with ImportError: cannot import name ABC. Plz add abc to setup.py.

@RonRademaker

Copy link
Copy Markdown
Author

Any way I can locally run the tests to see if they pass before pushing changes?

@obukhov-sergey

Copy link
Copy Markdown
Member

@mailgun-ci test this please

@obukhov-sergey

Copy link
Copy Markdown
Member

@RonRademaker sure, just run nosetests from the repo folder, you might need to "pip install nose" and "pip install mock", they're also in test_require part of setup.py; we plan to migrate to travis ci as well, so that you don't have to run tests yourself locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants