1616
1717import requests
1818import semver
19- from colorama import Fore , Style
20- from colorama import init as colorama_init
2119from markdownify import markdownify
2220
2321from typings import drupal , osv
22+ from helpers .text import Text
2423from user_agent import user_agent
2524
26- colorama_init ()
27-
2825
2926def fetch_drupal_node (nid : str ) -> drupal .Node :
3027 """
@@ -354,11 +351,11 @@ def patch_advisory(sa_id: str, sa_advisory: drupal.Advisory) -> bool:
354351
355352 if before == sa_advisory ['field_affected_versions' ]:
356353 sa_advisory ['field_affected_versions' ] = after
357- print (' \\ - ' + success_string ('patched affected versions' ))
354+ print (' \\ - ' + Text . success ('patched affected versions' ))
358355 return True
359356 print (
360357 ' \\ - '
361- + warning_string (
358+ + Text . warning (
362359 f'skipped patching as affected version is now "{ sa_advisory ["field_affected_versions" ]} "'
363360 )
364361 )
@@ -382,14 +379,14 @@ def build_osv_advisory(
382379 # we expect that the downloader has excluded PSA type entries, but
383380 # we still guard against them here just in case one slips through
384381 if sa_advisory ['field_is_psa' ] == '1' :
385- print (' \\ -' + error_string ('skipping as it is a psa? (this should not happen)' ))
382+ print (' \\ -' + Text . error ('skipping as it is a psa? (this should not happen)' ))
386383 return None
387384
388385 # there's not really much we can do if there isn't an affected version
389386 # todo: since build_affected_ranges throws if this isn't present, it might
390387 # make more sense to use that, with a custom exception class
391388 if sa_advisory ['field_affected_versions' ] is None :
392- print (' \\ - ' + notice_string ('skipping as we do not have any affected versions' ))
389+ print (' \\ - ' + Text . notice ('skipping as we do not have any affected versions' ))
393390 return None
394391
395392 osv_advisory : osv .Vulnerability = {
@@ -469,7 +466,7 @@ def generate_osv_advisories() -> None:
469466 if is_existing_advisory_ahead (name , sa_id , osv_advisory ['modified' ]):
470467 print (
471468 ' \\ - '
472- + error_string (
469+ + Text . error (
473470 'error: current modified date is ahead of the proposed modified date (is your cache up to date?)'
474471 )
475472 )
@@ -480,21 +477,5 @@ def generate_osv_advisories() -> None:
480477 f .write ('\n ' )
481478
482479
483- def notice_string (message : str ) -> str :
484- return f'{ Fore .YELLOW } { Style .DIM } { message } { Style .RESET_ALL } '
485-
486-
487- def success_string (message : str ) -> str :
488- return f'{ Fore .GREEN } { message } { Style .RESET_ALL } '
489-
490-
491- def warning_string (message : str ) -> str :
492- return f'{ Fore .YELLOW } { message } { Style .RESET_ALL } '
493-
494-
495- def error_string (message : str ) -> str :
496- return f'{ Fore .RED } { message } { Style .RESET_ALL } '
497-
498-
499480if __name__ == '__main__' :
500481 generate_osv_advisories ()
0 commit comments