Beispiel #1
0
 def command(self, value):
     if is_non_string_iterable(value):
         it = iter(value)
         cmd = EscapedString.disallow(next(it))
         args_str = ' '.join(self.escape_string(x) for x in it)
         value = "%s %s" % (cmd, args_str)
     else:
         value = EscapedString.disallow(value)
     self._addline(value)
Beispiel #2
0
 def command(self, value):
     if hasattr(value, '__iter__'):
         it = iter(value)
         cmd = EscapedString.disallow(it.next())
         args_str = ' '.join(self.escape_string(x) for x in it)
         value = "%s %s" % (cmd, args_str)
     else:
         value = EscapedString.disallow(value)
     self._addline(value)
Beispiel #3
0
 def command(self, value):
     if hasattr(value, '__iter__'):
         it = iter(value)
         cmd = EscapedString.disallow(it.next())
         args_str = ' '.join(self.escape_string(x) for x in it)
         value = "%s %s" % (cmd, args_str)
     else:
         value = EscapedString.disallow(value)
     self._addline(value)
Beispiel #4
0
    def escape_string(self, value):
        value = EscapedString.promote(value)
        value = value.expanduser()
        result = ''

        for is_literal, txt in value.strings:
            if is_literal:
                txt = self._escape_quotes(self._escape_vars(txt))
            else:
                txt = self._escape_quotes(txt)
            result += txt
        return result
Beispiel #5
0
Datei: csh.py Projekt: rvsiy/rez
    def escape_string(self, value):
        value = EscapedString.promote(value)
        value = value.expanduser()
        result = ''

        for is_literal, txt in value.strings:
            if is_literal:
                txt = pipes.quote(txt)
                if not txt.startswith("'"):
                    txt = "'%s'" % txt
            else:
                txt = txt.replace('"', '"\\""')
                txt = txt.replace('!', '\\!')
                txt = '"%s"' % txt
            result += txt
        return result
Beispiel #6
0
    def escape_string(self, value):
        value = EscapedString.promote(value)
        value = value.expanduser()
        result = ''

        for is_literal, txt in value.strings:
            if is_literal:
                txt = pipes.quote(txt)
                if not txt.startswith("'"):
                    txt = "'%s'" % txt
            else:
                txt = txt.replace('\\', '\\\\')
                txt = txt.replace('"', '\\"')
                txt = '"%s"' % txt
            result += txt
        return result
Beispiel #7
0
    def escape_string(self, value):
        """Escape the <, >, ^, and & special characters reserved by Windows.

        Args:
            value (str/EscapedString): String or already escaped string.

        Returns:
            str: The value escaped for Windows.

        """
        value = EscapedString.promote(value)
        value = value.expanduser()
        result = ''

        for is_literal, txt in value.strings:
            if is_literal:
                txt = self._escape_quotes(self._escape_vars(txt))
            else:
                txt = self._escape_quotes(txt)
            result += txt
        return result
Beispiel #8
0
Datei: cmd.py Projekt: sdot-b/rez
    def escape_string(self, value):
        """Escape the <, >, ^, and & special characters reserved by Windows.

        Args:
            value (str/EscapedString): String or already escaped string.

        Returns:
            str: The value escaped for Windows.

        """
        value = EscapedString.promote(value)
        value = value.expanduser()
        result = ''

        for is_literal, txt in value.strings:
            if is_literal:
                txt = self._escaper(txt)
                # Note that cmd uses ^% while batch files use %% to escape %
                txt = self._env_var_regex.sub(r"%%\1%%", txt)
            else:
                txt = self._escaper(txt)
            result += txt
        return result
Beispiel #9
0
Datei: csh.py Projekt: rvsiy/rez
 def alias(self, key, value):
     value = EscapedString.disallow(value)
     self._addline("alias %s '%s';" % (key, value))
Beispiel #10
0
 def alias(self, key, value):
     value = EscapedString.disallow(value)
     cmd = "function {key}() {{ {value} $args }}"
     self._addline(cmd.format(key=key, value=value))
Beispiel #11
0
 def alias(self, key, value):
     value = EscapedString.disallow(value)
     # TODO: Find a way to properly escape paths in alias() calls that also
     # contain args
     cmd = "function {key}() {{ {value} $args }}"
     self._addline(cmd.format(key=key, value=value))
Beispiel #12
0
 def comment(self, value):
     value = EscapedString.demote(value)
     for line in value.split('\n'):
         self._addline('# %s' % line)
Beispiel #13
0
 def comment(self, value):
     value = EscapedString.demote(value)
     for line in value.split('\n'):
         self._addline('# %s' % line)
Beispiel #14
0
 def alias(self, key, value):
     value = EscapedString.disallow(value)
     cmd = 'function {key}() {{ {value} "$@"; }};export -f {key};'
     self._addline(cmd.format(key=key, value=value))
Beispiel #15
0
 def alias(self, key, value):
     value = EscapedString.disallow(value)
     cmd = 'function {key}() {{ {value} "$@"; }};export -f {key};'
     self._addline(cmd.format(key=key, value=value))
 def alias(self, key, value):
     value = EscapedString.disallow(value)
     self._addline("alias %s '%s';" % (key, value))