1111import warnings
1212from datetime import datetime
1313import logging
14+ import shutil
1415import fosslight_dependency .constant as const
1516from collections import defaultdict
1617from fosslight_util .set_log import init_log
3334_exclude_dir = ['node_moduels' , 'venv' ]
3435
3536
37+ def get_terminal_size ():
38+ size = shutil .get_terminal_size ()
39+ return size .lines
40+
41+
42+ def paginate_file (file_path ):
43+ lines_per_page = get_terminal_size () - 1
44+ with open (file_path , 'r' , encoding = 'utf8' ) as file :
45+ lines = file .readlines ()
46+
47+ for i in range (0 , len (lines ), lines_per_page ):
48+ os .system ('clear' if os .name == 'posix' else 'cls' )
49+ print ('' .join (lines [i : i + lines_per_page ]))
50+ if i + lines_per_page < len (lines ):
51+ input ("Press Enter to see the next page..." )
52+
53+
3654def find_package_manager (input_dir , abs_path_to_exclude = []):
3755 ret = True
3856 manifest_file_name = []
@@ -227,7 +245,15 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
227245 graph_path = os .path .abspath (graph_path )
228246 try :
229247 converter = GraphConvertor (scan_item .file_items [_PKG_NAME ])
230- converter .save (graph_path , graph_size )
248+ growth_factor_per_node = 10
249+ node_count_threshold = 20
250+ node_count = len (scan_item .file_items [_PKG_NAME ])
251+ if node_count > node_count_threshold :
252+ new_size = tuple (x + (node_count * growth_factor_per_node ) for x in graph_size )
253+ else :
254+ new_size = graph_size
255+ new_size = tuple ((((x + 99 ) // 100 ) * 100 ) for x in new_size )
256+ converter .save (graph_path , new_size )
231257 logger .info (f"Output graph image file: { graph_path } " )
232258 except Exception as e :
233259 logger .error (f'Fail to make graph image: { e } ' )
@@ -324,9 +350,9 @@ def main():
324350 if args .graph_size :
325351 graph_size = args .graph_size
326352 if args .direct : # --direct option
327- if args .direct == 'true' :
353+ if args .direct == 'true' or args . direct == 'True' :
328354 direct = True
329- elif args .direct == 'false' :
355+ elif args .direct == 'false' or args . direct == 'False' :
330356 direct = False
331357 if args .notice : # --notice option
332358 try :
@@ -337,8 +363,10 @@ def main():
337363 data_path = os .path .join (base_path , 'LICENSES' )
338364 print (f"*** { _PKG_NAME } open source license notice ***" )
339365 for ff in os .listdir (data_path ):
340- f = open (os .path .join (data_path , ff ), 'r' , encoding = 'utf8' )
341- print (f .read ())
366+ source_file = os .path .join (data_path , ff )
367+ destination_file = os .path .join (base_path , ff )
368+ paginate_file (source_file )
369+ shutil .copyfile (source_file , destination_file )
342370 sys .exit (0 )
343371
344372 run_dependency_scanner (package_manager , input_dir , output_dir , pip_activate_cmd , pip_deactivate_cmd ,
0 commit comments