Projects STRLCPY maigret Commits 28835204
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    maigret/maigret.py
    skipped 31 lines
    32 32   save_txt_report,
    33 33   SUPPORTED_JSON_REPORT_FORMATS,
    34 34   save_json_report,
     35 + get_plaintext_report,
    35 36  )
    36 37  from .sites import MaigretDatabase
    37 38  from .submit import submit_dialog
    skipped 608 lines
    646 647   filename = report_filepath_tpl.format(username=username, postfix='.pdf')
    647 648   save_pdf_report(filename, report_context)
    648 649   query_notify.warning(f'PDF report on all usernames saved in {filename}')
     650 + 
     651 + text_report = get_plaintext_report(report_context)
     652 + if text_report:
     653 + query_notify.info('Short text report:')
     654 + print(text_report)
     655 + 
    649 656   # update database
    650 657   db.save_to_file(args.db_file)
    651 658   
    skipped 13 lines
  • ■ ■ ■ ■ ■
    maigret/notify.py
    skipped 204 lines
    205 205   else:
    206 206   print(f"[*] {title} {message} on:")
    207 207   
    208  - def warning(self, message, symbol="-"):
    209  - msg = f"[{symbol}] {message}"
     208 + def _colored_print(self, fore_color, msg):
    210 209   if self.color:
    211  - print(Style.BRIGHT + Fore.YELLOW + msg)
     210 + print(Style.BRIGHT + fore_color + msg)
    212 211   else:
    213 212   print(msg)
     213 + 
     214 + def warning(self, message, symbol="-"):
     215 + msg = f"[{symbol}] {message}"
     216 + self._colored_print(Fore.YELLOW, msg)
     217 + 
     218 + def info(self, message, symbol="*"):
     219 + msg = f"[{symbol}] {message}"
     220 + self._colored_print(Fore.BLUE, msg)
    214 221   
    215 222   def update(self, result, is_similar=False):
    216 223   """Notify Update.
    skipped 83 lines
  • ■ ■ ■ ■ ■ ■
    maigret/report.py
    skipped 69 lines
    70 70   generate_json_report(username, results, f, report_type=report_type)
    71 71   
    72 72   
     73 +def get_plaintext_report(context: dict) -> str:
     74 + output = (context['brief'] + " ").replace('. ', '.\n')
     75 + interests = list(map(lambda x: x[0], context.get('interests_tuple_list', [])))
     76 + countries = list(map(lambda x: x[0], context.get('countries_tuple_list', [])))
     77 + if countries:
     78 + output += f'Countries: {", ".join(countries)}\n'
     79 + if interests:
     80 + output += f'Interests (tags): {", ".join(interests)}\n'
     81 + return output.strip()
     82 + 
     83 + 
    73 84  """
    74 85  REPORTS GENERATING
    75 86  """
    skipped 139 lines
    215 226   
    216 227   return {
    217 228   "username": first_username,
     229 + # TODO: return brief list
    218 230   "brief": brief,
    219 231   "results": username_results,
    220 232   "first_seen": first_seen,
    skipped 141 lines
  • ■ ■ ■ ■ ■ ■
    tests/test_report.py
    skipped 15 lines
    16 16   generate_report_template,
    17 17   generate_report_context,
    18 18   generate_json_report,
     19 + get_plaintext_report,
    19 20  )
    20 21  from maigret.result import QueryResult, QueryStatus
    21 22  from maigret.sites import MaigretSite
    skipped 325 lines
    347 348   
    348 349   assert os.path.exists(report_name)
    349 350   
     351 + 
     352 +def test_text_report():
     353 + context = generate_report_context(TEST)
     354 + report_text = get_plaintext_report(context)
     355 + 
     356 + for brief_part in SUPPOSED_BRIEF.split():
     357 + assert brief_part in report_text
     358 + assert 'us' in report_text
     359 + assert 'photo' in report_text
     360 + 
Please wait...
Page is in error, reload to recover