Return a mapping with a single 'emails' key with a value that is a list of mappings for emails detected in the file at `location`. Return only up to `threshold` values. Return all values if `threshold` is 0. If test_mode is True, the scan will be slow for testing purpose and pause
(
location,
threshold=50,
test_slow_mode=False,
test_error_mode=False,
**kwargs,
)
| 80 | |
| 81 | |
| 82 | def get_emails( |
| 83 | location, |
| 84 | threshold=50, |
| 85 | test_slow_mode=False, |
| 86 | test_error_mode=False, |
| 87 | **kwargs, |
| 88 | ): |
| 89 | """ |
| 90 | Return a mapping with a single 'emails' key with a value that is a list of |
| 91 | mappings for emails detected in the file at `location`. |
| 92 | Return only up to `threshold` values. Return all values if `threshold` is 0. |
| 93 | |
| 94 | If test_mode is True, the scan will be slow for testing purpose and pause |
| 95 | for one second. |
| 96 | """ |
| 97 | if test_error_mode: |
| 98 | raise ScancodeError('Triggered email failure') |
| 99 | |
| 100 | if test_slow_mode: |
| 101 | import time |
| 102 | time.sleep(1) |
| 103 | |
| 104 | from cluecode.finder import find_emails |
| 105 | results = [] |
| 106 | |
| 107 | found_emails = ((em, ln) for (em, ln) in find_emails(location) if em) |
| 108 | if threshold: |
| 109 | found_emails = islice(found_emails, threshold) |
| 110 | |
| 111 | for email, line_num in found_emails: |
| 112 | result = {} |
| 113 | results.append(result) |
| 114 | result['email'] = email |
| 115 | result['start_line'] = line_num |
| 116 | result['end_line'] = line_num |
| 117 | return dict(emails=results) |
| 118 | |
| 119 | |
| 120 | def get_urls(location, threshold=50, **kwargs): |
nothing calls this directly
no test coverage detected