@@ -89,14 +89,14 @@ def make_dirs(directory):
89
89
os .makedirs (directory )
90
90
91
91
92
- def print_feature_with_description (name : str , description : str = None , console_width : int = - 1 ):
92
+ def print_feature (name : str , description : str = None , console_width : int = - 1 ):
93
93
print (name , end = '' )
94
94
if description :
95
95
print (' ' * (console_width // 2 - len (name )) + ': ' + description , end = '' )
96
96
print ()
97
97
98
98
99
- def colored_print (text , color = None ):
99
+ def print_category (text , color = None ):
100
100
if color is None :
101
101
color = colorama .Back .GREEN
102
102
return print (color + colorama .Fore .BLACK + text + ' ' * (10 - len (text )) + colorama .Style .RESET_ALL )
@@ -106,41 +106,39 @@ def welcome_text():
106
106
locale .load_from (config .lang )
107
107
108
108
console_width = shutil .get_terminal_size ().columns
109
- print (
110
- (
111
- colorama .Back .BLACK + colorama .Fore .GREEN +
112
- locale .xcoder_header % config .version +
113
- colorama .Style .RESET_ALL
114
- ).center (console_width + 14 )
115
- )
109
+ print ((
110
+ colorama .Back .BLACK + colorama .Fore .GREEN +
111
+ locale .xcoder_header % config .version +
112
+ colorama .Style .RESET_ALL
113
+ ).center (console_width + 14 ))
116
114
print ('github.com/Vorono4ka/XCoder' .center (console_width ))
117
115
print (console_width * '-' )
118
116
119
- colored_print (locale .sc_label )
120
- print_feature_with_description (' 1 ' + locale .decode_sc , locale .decode_sc_description , console_width )
121
- print_feature_with_description (' 2 ' + locale .encode_sc , locale .encode_sc_description , console_width )
122
- print_feature_with_description (' 3 ' + locale .decode_by_parts , locale .decode_by_parts_description , console_width )
123
- print_feature_with_description (' 4 ' + locale .encode_by_parts , locale .encode_by_parts_description , console_width )
124
- print_feature_with_description (' 5 ' + locale .overwrite_by_parts , locale .overwrite_by_parts_description , console_width )
117
+ print_category (locale .sc_label )
118
+ print_feature (' 1 ' + locale .decode_sc , locale .decode_sc_description , console_width )
119
+ print_feature (' 2 ' + locale .encode_sc , locale .encode_sc_description , console_width )
120
+ print_feature (' 3 ' + locale .decode_by_parts , locale .decode_by_parts_description , console_width )
121
+ print_feature (' 4 ' + locale .encode_by_parts , locale .encode_by_parts_description , console_width )
122
+ print_feature (' 5 ' + locale .overwrite_by_parts , locale .overwrite_by_parts_description , console_width )
125
123
print (console_width * '-' )
126
124
127
- colored_print (locale .csv_label )
128
- print_feature_with_description (' 11 ' + locale .decompress_csv , locale .decompress_csv_description , console_width )
129
- print_feature_with_description (' 12 ' + locale .compress_csv , locale .compress_csv_description , console_width )
125
+ print_category (locale .csv_label )
126
+ print_feature (' 11 ' + locale .decompress_csv , locale .decompress_csv_description , console_width )
127
+ print_feature (' 12 ' + locale .compress_csv , locale .compress_csv_description , console_width )
130
128
print (console_width * '-' )
131
129
132
- colored_print (locale .other_features_label )
133
- print_feature_with_description (' 101 ' + locale .check_update , locale .version % config .version , console_width )
134
- print_feature_with_description (' 102 ' + locale .check_for_outdated )
135
- print_feature_with_description (' 103 ' + locale .reinit , locale .reinit_description , console_width )
136
- print_feature_with_description (' 104 ' + locale .change_lang , locale .change_lang_description % config .lang , console_width )
137
- print_feature_with_description (' 105 ' + locale .clear_dirs , locale .clean_dirs_description , console_width )
138
- print_feature_with_description (
130
+ print_category (locale .other_features_label )
131
+ print_feature (' 101 ' + locale .check_update , locale .version % config .version , console_width )
132
+ print_feature (' 102 ' + locale .check_for_outdated )
133
+ print_feature (' 103 ' + locale .reinit , locale .reinit_description , console_width )
134
+ print_feature (' 104 ' + locale .change_lang , locale .change_lang_description % config .lang , console_width )
135
+ print_feature (' 105 ' + locale .clear_dirs , locale .clean_dirs_description , console_width )
136
+ print_feature (
139
137
' 106 ' + locale .toggle_update_auto_checking ,
140
138
locale .enabled if config .auto_update else locale .disabled ,
141
139
console_width
142
140
)
143
- print_feature_with_description (' 107 ' + locale .exit )
141
+ print_feature (' 107 ' + locale .exit )
144
142
print (console_width * '-' )
145
143
146
144
choice = input (locale .choice )
@@ -354,12 +352,14 @@ def sc1_decode():
354
352
base_name = os .path .basename (file ).rsplit ('.' , 1 )[0 ]
355
353
356
354
with open (f'{ folder_export } /{ current_sub_path } /{ base_name } .xcod' , 'wb' ) as xcod_file :
357
- xcod_file .write (b'XCOD' + bool .to_bytes (use_lzham , 1 , 'big' ) + int .to_bytes (len (swf .textures ), 1 , 'big' ))
355
+ xcod_file .write (b'XCOD' + bool .to_bytes (use_lzham , 1 , 'big' ) +
356
+ int .to_bytes (len (swf .textures ), 1 , 'big' ))
358
357
359
358
for img_index in range (len (swf .textures )):
360
359
filename = base_name + '_' * img_index
361
- swf .textures [img_index ].image .save (f'{ folder_export } /{ current_sub_path } /textures/{ filename } .png' )
362
-
360
+ swf .textures [img_index ].image .save (
361
+ f'{ folder_export } /{ current_sub_path } /textures/{ filename } .png'
362
+ )
363
363
364
364
Console .info (locale .dec_sc )
365
365
@@ -436,7 +436,7 @@ def open_sc(input_filename: str):
436
436
#
437
437
if signature == Signatures .SCLZ :
438
438
use_lzham = True
439
- except Exception :
439
+ except TypeError :
440
440
Console .info (locale .decompression_error )
441
441
exit (1 )
442
442
@@ -471,7 +471,7 @@ def compile_sc(_dir, from_memory=None, img_data=None, folder_export=None):
471
471
use_lzham , = struct .unpack ('?' , sc_data .read (1 ))
472
472
sc_data .read (1 )
473
473
has_xcod = True
474
- except Exception :
474
+ except OSError :
475
475
Console .info (locale .not_xcod )
476
476
Console .info (locale .default_types )
477
477
@@ -609,7 +609,13 @@ def load_tags(self):
609
609
texture .load (self , tag , has_texture )
610
610
611
611
if has_texture :
612
- Console .info (locale .about_sc % (self .filename , texture_id , texture .pixel_type , texture .width , texture .height ))
612
+ Console .info (locale .about_sc % (
613
+ self .filename ,
614
+ texture_id ,
615
+ texture .pixel_type ,
616
+ texture .width ,
617
+ texture .height
618
+ ))
613
619
print ()
614
620
615
621
self .xcod_writer .write_ubyte (tag )
@@ -690,7 +696,10 @@ def place_sprites(xcod, folder, overwrite=False):
690
696
sheet_image = []
691
697
sheet_image_data = {'use_lzham' : use_lzham , 'data' : []}
692
698
for i in range (pictures_count ):
693
- file_type , sub_type , width , height = xcod .read_ubyte (), xcod .read_ubyte (), xcod .read_uint16 (), xcod .read_uint16 ()
699
+ file_type , sub_type , width , height = xcod .read_ubyte (), \
700
+ xcod .read_ubyte (), \
701
+ xcod .read_uint16 (), \
702
+ xcod .read_uint16 ()
694
703
sheet_image .append (
695
704
Image .open (f'{ folder } /textures/{ tex [i ]} ' )
696
705
if overwrite else
0 commit comments