28
28
"""
29
29
30
30
31
- from __future__ import print_function
32
31
33
32
import os
34
33
import ast
@@ -65,7 +64,7 @@ def glom_cli(target, spec, indent, debug, inspect):
65
64
try :
66
65
result = glom .glom (target , spec )
67
66
except GlomError as ge :
68
- print ('%s: %s' % ( ge .__class__ .__name__ , ge ) )
67
+ print (f' { ge .__class__ .__name__ } : { ge } ' )
69
68
return 1
70
69
71
70
if not indent :
@@ -170,10 +169,10 @@ def mw_get_target(next_, posargs_, target_file, target_format, spec_file, spec_f
170
169
raise UsageError ('expected spec file or spec argument, not both' )
171
170
elif spec_file :
172
171
try :
173
- with open (spec_file , 'r' ) as f :
172
+ with open (spec_file ) as f :
174
173
spec_text = f .read ()
175
- except IOError as ose :
176
- raise UsageError ('could not read spec file %r , got: %s' % ( spec_file , ose ) )
174
+ except OSError as ose :
175
+ raise UsageError (f 'could not read spec file { spec_file !r } , got: { ose } ' )
177
176
178
177
if not spec_text :
179
178
spec = Path ()
@@ -195,9 +194,9 @@ def mw_get_target(next_, posargs_, target_file, target_format, spec_file, spec_f
195
194
target_text = sys .stdin .read ()
196
195
elif target_file :
197
196
try :
198
- target_text = open (target_file , 'r' ).read ()
199
- except IOError as ose :
200
- raise UsageError ('could not read target file %r , got: %s' % ( target_file , ose ) )
197
+ target_text = open (target_file ).read ()
198
+ except OSError as ose :
199
+ raise UsageError (f 'could not read target file { target_file !r } , got: { ose } ' )
201
200
elif not target_text and not isatty (sys .stdin ):
202
201
target_text = sys .stdin .read ()
203
202
@@ -218,7 +217,7 @@ def _from_glom_import_star():
218
217
219
218
def _eval_python_full_spec (py_text ):
220
219
name = '__cli_glom_spec__'
221
- code_str = '%s = %s' % ( name , py_text )
220
+ code_str = f' { name } = { py_text } '
222
221
env = _from_glom_import_star ()
223
222
spec = _compile_code (code_str , name = name , env = env )
224
223
return spec
0 commit comments