File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,28 @@ def _func_keys(self, arg):
308
308
# should we also return the indices of a list?
309
309
return list (arg .keys ())
310
310
311
+ @signature (
312
+ {'type' : 'string' },
313
+ {'type' : 'number' },
314
+ {'type' : 'string' , 'optional' : True })
315
+ def _func_pad_left (self , text , width , padding = ' ' ):
316
+ return self ._pad_impl (lambda : text .rjust (width , padding ), padding )
317
+
318
+ @signature (
319
+ {'type' : 'string' },
320
+ {'type' : 'number' },
321
+ {'type' : 'string' , 'optional' : True })
322
+ def _func_pad_right (self , text , width , padding = ' ' ):
323
+ return self ._pad_impl (lambda : text .ljust (width , padding ), padding )
324
+
325
+ def _pad_impl (self , func , padding ):
326
+ if len (padding ) != 1 :
327
+ raise exceptions .JMESPathError (
328
+ 'syntax-error: pad_right() expects $padding to have a '
329
+ 'single character, but received `{}` instead.'
330
+ .format (padding ))
331
+ return func ()
332
+
311
333
@signature (
312
334
{'type' : 'string' },
313
335
{'type' : 'string' },
You can’t perform that action at this time.
0 commit comments