proxygen
shell_quoting Namespace Reference

Classes

class  ShellQuoted
 

Functions

def shell_quote (s)
 
def raw_shell (s)
 
def shell_join (delim, it)
 
def path_join (args)
 
def shell_comment (c)
 

Function Documentation

def shell_quoting.path_join (   args)

Definition at line 87 of file shell_quoting.py.

References raw_shell(), and shell_quote().

Referenced by shell_quoting.ShellQuoted.format(), and fbcode_builder.FBCodeBuilder.github_project_workdir().

87 def path_join(*args):
88  'Joins ShellQuoted and raw pieces of paths to make a shell-quoted path'
89  return ShellQuoted(os.path.join(*[
90  raw_shell(shell_quote(s)) for s in args
91  ]))
92 
93 
def raw_shell(s)
def shell_quote(s)
def path_join(args)
def shell_quoting.raw_shell (   s)

Definition at line 75 of file shell_quoting.py.

References folly.format().

Referenced by shell_builder.ShellFBCodeBuilder._render_impl(), docker_builder.DockerFBCodeBuilder._render_impl(), shell_quoting.ShellQuoted.format(), parse_args.parse_args_to_fbcode_builder_opts(), path_join(), shell_comment(), and shell_join().

75 def raw_shell(s):
76  'Not a member of ShellQuoted so we get a useful error for raw strings'
77  if isinstance(s, ShellQuoted):
78  return s.do_not_use_raw_str
79  raise RuntimeError('{0} should have been ShellQuoted'.format(s))
80 
81 
def raw_shell(s)
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
Definition: Format.h:271
def shell_quoting.shell_comment (   c)

Definition at line 94 of file shell_quoting.py.

References folly.format(), raw_shell(), and replace().

Referenced by shell_builder.ShellFBCodeBuilder.comment(), docker_builder.DockerFBCodeBuilder.comment(), and shell_quoting.ShellQuoted.format().

95  'Do not shell-escape raw strings in comments, but do handle line breaks.'
96  return ShellQuoted('# {c}').format(c=ShellQuoted(
97  (raw_shell(c) if isinstance(c, ShellQuoted) else c)
98  .replace('\n', '\n# ')
99  ))
100 
def raw_shell(s)
void BENCHFUN() replace(size_t iters, size_t arg)
def shell_comment(c)
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
Definition: Format.h:271
def shell_quoting.shell_join (   delim,
  it 
)
def shell_quoting.shell_quote (   s)

Definition at line 69 of file shell_quoting.py.

References replace().

Referenced by shell_quoting.ShellQuoted.format(), and path_join().

69 def shell_quote(s):
70  'Quotes a string if it is not already quoted'
71  return s if isinstance(s, ShellQuoted) \
72  else ShellQuoted("'" + str(s).replace("'", "'\\''") + "'")
73 
74 
def shell_quote(s)
void BENCHFUN() replace(size_t iters, size_t arg)