File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 4
4
"""
5
5
6
6
7
- def pad (value : str , return_type = str ) -> """Pad binary value with zeros""" :
7
+ def pad (value , return_type ):
8
+ '''
9
+ Pad binary value with zeros
10
+ :param value: string
11
+ :param return_type: string
12
+ '''
13
+ if type (value ) is not str :
14
+ raise TypeError ("pad only accepts str, not {}" .format (str (type (value ))))
8
15
if len (value ) % 4 != 0 :
9
16
pad_amount = 4 - (len (value ) % 4 )
10
17
return return_type (('0' * pad_amount ) + value )
11
18
else :
12
19
return return_type (value )
13
20
14
21
15
- def to_string (binary_array : list , delimiter = ' ' ) -> """Convert binary array to string""" :
16
- return delimiter .join (binary_array )
22
+ def to_string (binary_array , delimiter = ' ' ):
23
+ """
24
+ Convert binary array to string
25
+ """
26
+ if type (binary_array ) is not list :
27
+ raise TypeError ("to_string only accepts lists, not {}" .format (str (type (value ))))
28
+ return delimiter .join (binary_array )
You can’t perform that action at this time.
0 commit comments