* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/, pym/portage/util/
@ 2011-07-01 8:47 Zac Medico
0 siblings, 0 replies; 6+ messages in thread
From: Zac Medico @ 2011-07-01 8:47 UTC (permalink / raw
To: gentoo-commits
commit: 799c576de2afb31cea67cb2b186051bcdae29b1e
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 1 08:47:14 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jul 1 08:47:14 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=799c576d
varexpand: remove escaped newline characters
This fixes a regression reported in bug 365033, comment #14.
---
pym/portage/tests/util/test_varExpand.py | 8 +++++---
pym/portage/util/__init__.py | 7 +++++--
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/pym/portage/tests/util/test_varExpand.py b/pym/portage/tests/util/test_varExpand.py
index 9dd488e..4af8f80 100644
--- a/pym/portage/tests/util/test_varExpand.py
+++ b/pym/portage/tests/util/test_varExpand.py
@@ -25,9 +25,10 @@ class VarExpandTestCase(TestCase):
"""
We want to behave like bash does when expanding a variable
assignment in a sourced file, in which case it performs
- backslash removal for \\ and \$ but nothing more. Note that
- we don't handle escaped quotes here, since genconfig() uses
- shlex to handle that earlier.
+ backslash removal for \\ and \$ but nothing more. It also
+ removes escaped newline characters. Note that we don't
+ handle escaped quotes here, since genconfig() uses shlex
+ to handle that earlier.
"""
varDict = {}
@@ -43,6 +44,7 @@ class VarExpandTestCase(TestCase):
("\\n", "\\n"),
("\\r", "\\r"),
("\\t", "\\t"),
+ ("\\\n", ""),
("\\\"", "\\\""),
("\\'", "\\'"),
]
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 85b2ada..5468e28 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -687,8 +687,9 @@ def varexpand(mystring, mydict=None):
# echo -e, but that's not needed for our purposes. We want to
# behave like bash does when expanding a variable assignment
# in a sourced file, in which case it performs backslash
- # removal for \\ and \$ but nothing more. Note that we don't
- # handle escaped quotes here, since getconfig() uses shlex
+ # removal for \\ and \$ but nothing more. It also removes
+ # escaped newline characters. Note that we don't handle
+ # escaped quotes here, since getconfig() uses shlex
# to handle that earlier.
if (pos+1>=len(mystring)):
newstring=newstring+mystring[pos]
@@ -698,6 +699,8 @@ def varexpand(mystring, mydict=None):
pos = pos + 2
if a in ("\\", "$"):
newstring = newstring + a
+ elif a == "\n":
+ pass
else:
newstring = newstring + mystring[pos-2:pos]
continue
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/, pym/portage/util/
@ 2018-06-27 3:32 Zac Medico
0 siblings, 0 replies; 6+ messages in thread
From: Zac Medico @ 2018-06-27 3:32 UTC (permalink / raw
To: gentoo-commits
commit: deb87a465306d05146d7eb55d27d7d89943725c0
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 24 21:42:52 2018 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jun 27 03:15:08 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=deb87a46
{,PKG_}INSTALL_MASK: support trailing slash (bug 658322)
Fix the python INSTALL_MASK implementation so that a trailing slash
matches a directory, for compatibility with the previous bash
implementation.
Fixes: 3416876c0ee7 ("{,PKG_}INSTALL_MASK: python implementation")
Bug: https://bugs.gentoo.org/658322
pym/portage/tests/util/test_install_mask.py | 129 ++++++++++++++++++++++++++++
pym/portage/util/install_mask.py | 7 +-
2 files changed, 134 insertions(+), 2 deletions(-)
diff --git a/pym/portage/tests/util/test_install_mask.py b/pym/portage/tests/util/test_install_mask.py
new file mode 100644
index 000000000..f651eb4b7
--- /dev/null
+++ b/pym/portage/tests/util/test_install_mask.py
@@ -0,0 +1,129 @@
+# Copyright 2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+from portage.util.install_mask import InstallMask
+
+
+class InstallMaskTestCase(TestCase):
+
+ def testTrailingSlash(self):
+ """
+ Test that elements with a trailing slash match a directory
+ but not a regular file.
+ """
+ cases = (
+ (
+ '/foo/bar/ -/foo/bar/*.foo -*.baz',
+ (
+ (
+ 'foo/bar/baz',
+ True,
+ ),
+ (
+ 'foo/bar/',
+ True,
+ ),
+ # /foo/bar/ does not match
+ (
+ 'foo/bar',
+ False,
+ ),
+ # this is excluded
+ (
+ 'foo/bar/baz.foo',
+ False,
+ ),
+ # this is excluded
+ (
+ 'foo/bar/baz.baz',
+ False,
+ ),
+ (
+ 'foo/bar/baz.bar',
+ True,
+ ),
+ )
+ ),
+ (
+ '/foo/bar -/foo/bar/*.foo -*.baz',
+ (
+ (
+ 'foo/bar/baz',
+ True,
+ ),
+ # /foo/bar matches both foo/bar/ and foo/bar
+ (
+ 'foo/bar/',
+ True,
+ ),
+ (
+ 'foo/bar',
+ True,
+ ),
+ # this is excluded
+ (
+ 'foo/bar/baz.foo',
+ False,
+ ),
+ # this is excluded
+ (
+ 'foo/bar/baz.baz',
+ False,
+ ),
+ (
+ 'foo/bar/baz.bar',
+ True,
+ ),
+ )
+ ),
+ (
+ '/foo*',
+ (
+ (
+ 'foo',
+ True,
+ ),
+ (
+ 'foo/',
+ True,
+ ),
+ (
+ 'foobar',
+ True,
+ ),
+ (
+ 'foobar/',
+ True,
+ ),
+ )
+ ),
+ (
+ '/foo*/',
+ (
+ (
+ 'foo',
+ False,
+ ),
+ (
+ 'foo/',
+ True,
+ ),
+ (
+ 'foobar',
+ False,
+ ),
+ (
+ 'foobar/',
+ True,
+ ),
+ )
+ ),
+ )
+
+ for install_mask_str, paths in cases:
+ install_mask = InstallMask(install_mask_str)
+ for path, expected in paths:
+ self.assertEqual(install_mask.match(path), expected,
+ 'unexpected match result for "{}" with path {}'.\
+ format(install_mask_str, path))
diff --git a/pym/portage/util/install_mask.py b/pym/portage/util/install_mask.py
index 1667d883a..32627eb05 100644
--- a/pym/portage/util/install_mask.py
+++ b/pym/portage/util/install_mask.py
@@ -41,10 +41,13 @@ class InstallMask(object):
pattern = pattern[1:]
# absolute path pattern
if pattern.startswith('/'):
+ # handle trailing slash for explicit directory match
+ if path.endswith('/'):
+ pattern = pattern.rstrip('/') + '/'
# match either exact path or one of parent dirs
# the latter is done via matching pattern/*
if (fnmatch.fnmatch(path, pattern[1:])
- or fnmatch.fnmatch(path, pattern[1:] + '/*')):
+ or fnmatch.fnmatch(path, pattern[1:].rstrip('/') + '/*')):
ret = is_inclusive
# filename
else:
@@ -118,7 +121,7 @@ def install_mask_dir(base_dir, install_mask, onerror=None):
except IndexError:
break
- if install_mask.match(dir_path[base_dir_len:]):
+ if install_mask.match(dir_path[base_dir_len:] + '/'):
try:
os.rmdir(dir_path)
except OSError:
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/, pym/portage/util/
@ 2017-04-20 19:39 Zac Medico
0 siblings, 0 replies; 6+ messages in thread
From: Zac Medico @ 2017-04-20 19:39 UTC (permalink / raw
To: gentoo-commits
commit: c8c038fd4c201a582c420004b5ff759f28fe626b
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 19 04:39:31 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Apr 20 19:39:00 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c8c038fd
digraph: add update and clear methods
Also, optimize the add method to avoid creating a lot of
duplicate priorities when called by the update method.
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>
pym/portage/tests/util/test_digraph.py | 4 +++-
pym/portage/util/digraph.py | 26 ++++++++++++++++++++++++--
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/pym/portage/tests/util/test_digraph.py b/pym/portage/tests/util/test_digraph.py
index f519536d3..01e075c99 100644
--- a/pym/portage/tests/util/test_digraph.py
+++ b/pym/portage/tests/util/test_digraph.py
@@ -88,7 +88,9 @@ class DigraphTest(TestCase):
g.add("D", "A", 2)
f = g.clone()
- for x in g, f:
+ h = digraph()
+ h.update(f)
+ for x in g, f, h:
self.assertEqual(bool(x), True)
self.assertEqual(x.contains("A"), True)
self.assertEqual(x.firstzero(), None)
diff --git a/pym/portage/util/digraph.py b/pym/portage/util/digraph.py
index 99b24fa1d..ba0e81c07 100644
--- a/pym/portage/util/digraph.py
+++ b/pym/portage/util/digraph.py
@@ -44,8 +44,10 @@ class digraph(object):
priorities = []
self.nodes[node][1][parent] = priorities
self.nodes[parent][0][node] = priorities
- priorities.append(priority)
- priorities.sort()
+
+ if not priorities or priorities[-1] is not priority:
+ priorities.append(priority)
+ priorities.sort()
def discard(self, node):
"""
@@ -73,6 +75,26 @@ class digraph(object):
del self.nodes[node]
self.order.remove(node)
+ def update(self, other):
+ """
+ Add all nodes and edges from another digraph instance.
+ """
+ for node in other.order:
+ children, parents, node = other.nodes[node]
+ if parents:
+ for parent, priorities in parents.items():
+ for priority in priorities:
+ self.add(node, parent, priority=priority)
+ else:
+ self.add(node, None)
+
+ def clear(self):
+ """
+ Remove all nodes and edges.
+ """
+ self.nodes.clear()
+ del self.order[:]
+
def difference_update(self, t):
"""
Remove all given nodes from node_set. This is more efficient
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/, pym/portage/util/
@ 2014-01-22 4:49 Jesus Rivero
0 siblings, 0 replies; 6+ messages in thread
From: Jesus Rivero @ 2014-01-22 4:49 UTC (permalink / raw
To: gentoo-commits
commit: dece844592b73a84330024bcf81fdcebcb6ff1c3
Author: Jesus Rivero <neurogeek <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 00:29:31 2014 +0000
Commit: Jesus Rivero <neurogeek <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 00:29:31 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=dece8445
Added support for variable expansion in source command argument in make.conf
---
.../tests/util/make.conf.example.source_test | 6 ++++++
.../tests/util/make.conf.example.source_test_after | 7 +++++++
pym/portage/tests/util/test_getconfig.py | 22 +++++++++++++++++++++-
pym/portage/util/__init__.py | 9 +++++++--
4 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/pym/portage/tests/util/make.conf.example.source_test b/pym/portage/tests/util/make.conf.example.source_test
new file mode 100644
index 0000000..c0b1c16
--- /dev/null
+++ b/pym/portage/tests/util/make.conf.example.source_test
@@ -0,0 +1,6 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# Contains local system settings for Portage system
+
+# Test make.conf for variable expansion in source tokens.
+source "$PORTAGE_BASE_PATH/make.conf.example.source_test_after"
diff --git a/pym/portage/tests/util/make.conf.example.source_test_after b/pym/portage/tests/util/make.conf.example.source_test_after
new file mode 100644
index 0000000..e41913e
--- /dev/null
+++ b/pym/portage/tests/util/make.conf.example.source_test_after
@@ -0,0 +1,7 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# Contains local system settings for Portage system
+
+# Test make.conf for variable expansion in source tokens.
+# We should see this variable in getconfig result
+PASSES_SOURCING_TEST="True"
diff --git a/pym/portage/tests/util/test_getconfig.py b/pym/portage/tests/util/test_getconfig.py
index c7ab360..e7b638f 100644
--- a/pym/portage/tests/util/test_getconfig.py
+++ b/pym/portage/tests/util/test_getconfig.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Gentoo Foundation
+# Copyright 2010-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import tempfile
@@ -8,6 +8,7 @@ from portage import _unicode_encode
from portage.const import PORTAGE_BASE_PATH
from portage.tests import TestCase
from portage.util import getconfig
+from portage.exception import ParseError
class GetConfigTestCase(TestCase):
"""
@@ -31,6 +32,25 @@ class GetConfigTestCase(TestCase):
for k, v in self._cases.items():
self.assertEqual(d[k], v)
+ def testGetConfigSourceLex(self):
+
+ base = os.path.dirname(__file__)
+ make_conf_file = os.path.join(base,
+ 'make.conf.example.source_test')
+
+ d = getconfig(make_conf_file,
+ allow_sourcing=True, expand={"PORTAGE_BASE_PATH" : base})
+
+ # PASSES_SOURCING_TEST should exist in getconfig result
+ self.assertIsNotNone(d)
+ self.assertEqual("True", d['PASSES_SOURCING_TEST'])
+
+ # With allow_sourcing : True and empty expand map, this should
+ # Throw a FileNotFound exception
+ self.assertRaisesMsg("An empty expand map should throw an exception",
+ ParseError, getconfig, *(make_conf_file,),
+ **{'allow_sourcing' : True, 'expand' : {}})
+
def testGetConfigProfileEnv(self):
# Test the mode which is used to parse /etc/env.d and /etc/profile.env.
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 24553da..614b2b3 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2004-2013 Gentoo Foundation
+# Copyright 2004-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from __future__ import unicode_literals
@@ -593,8 +593,13 @@ class _getconfig_shlex(shlex.shlex):
shlex.shlex.__init__(self, **kwargs)
self.__portage_tolerant = portage_tolerant
+ def allow_sourcing(self, var_expand_map):
+ self.source = portage._native_string("source")
+ self.var_expand_map = var_expand_map
+
def sourcehook(self, newfile):
try:
+ newfile = varexpand(newfile, self.var_expand_map)
return shlex.shlex.sourcehook(self, newfile)
except EnvironmentError as e:
if e.errno == PermissionDenied.errno:
@@ -694,7 +699,7 @@ def getconfig(mycfg, tolerant=False, allow_sourcing=False, expand=True,
string.ascii_letters + "~!@#$%*_\:;?,./-+{}")
lex.quotes = portage._native_string("\"'")
if allow_sourcing:
- lex.source = portage._native_string("source")
+ lex.allow_sourcing(expand_map)
while True:
key = _unicode_decode(lex.get_token())
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/, pym/portage/util/
@ 2012-05-12 22:17 Zac Medico
0 siblings, 0 replies; 6+ messages in thread
From: Zac Medico @ 2012-05-12 22:17 UTC (permalink / raw
To: gentoo-commits
commit: 75ff9dea4e2bc141e53acaf7edb43f8b54fc56e5
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May 12 22:16:23 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 12 22:16:23 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=75ff9dea
test_digraph: fix get_cycles for PYTHONHASHSEED
---
pym/portage/tests/util/test_digraph.py | 7 ++++---
pym/portage/util/digraph.py | 15 +++++++++++----
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/pym/portage/tests/util/test_digraph.py b/pym/portage/tests/util/test_digraph.py
index 4fb1f95..4e858cf 100644
--- a/pym/portage/tests/util/test_digraph.py
+++ b/pym/portage/tests/util/test_digraph.py
@@ -198,10 +198,11 @@ class DigraphTest(TestCase):
self.assertEqual(x.shortest_path("C", "A"), ["C", "A"])
self.assertEqual(x.shortest_path("A", "C", ignore_priority=0), ["A", "B", "C"])
self.assertEqual(x.shortest_path("C", "A", ignore_priority=0), ["C", "A"])
- cycles = set(tuple(y) for y in x.get_cycles())
- self.assertEqual(cycles, set([("C", "A"), ("A", "B"), ("A", "C")]))
+ cycles = set(frozenset(y) for y in x.get_cycles())
+ self.assertEqual(cycles, set([frozenset(["A", "B"]), frozenset(["A", "C"]), frozenset(["B", "C"])]))
x.remove_edge("A", "B")
- self.assertEqual(x.get_cycles(), [["C", "A"], ["A", "C"], ["C", "B"]])
+ cycles = set(frozenset(y) for y in x.get_cycles())
+ self.assertEqual(cycles, set([frozenset(["A", "C"]), frozenset(["C", "B"])]))
x.difference_update(["C"])
self.assertEqual(x.all_nodes(), ["A", "B"])
portage.util.noiselimit = -2
diff --git a/pym/portage/util/digraph.py b/pym/portage/util/digraph.py
index 1bbe10f..f3ae658 100644
--- a/pym/portage/util/digraph.py
+++ b/pym/portage/util/digraph.py
@@ -317,16 +317,23 @@ class digraph(object):
"""
all_cycles = []
for node in self.nodes:
+ # If we have multiple paths of the same length, we have to
+ # return them all, so that we always get the same results
+ # even with PYTHONHASHSEED="random" enabled.
shortest_path = None
+ candidates = []
for child in self.child_nodes(node, ignore_priority):
path = self.shortest_path(child, node, ignore_priority)
if path is None:
continue
- if not shortest_path or len(shortest_path) > len(path):
+ if not shortest_path or len(shortest_path) >= len(path):
shortest_path = path
- if shortest_path:
- if not max_length or len(shortest_path) <= max_length:
- all_cycles.append(shortest_path)
+ candidates.append(path)
+ if shortest_path and \
+ (not max_length or len(shortest_path) <= max_length):
+ for path in candidates:
+ if len(path) == len(shortest_path):
+ all_cycles.append(path)
return all_cycles
# Backward compatibility
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/, pym/portage/util/
@ 2011-06-28 9:09 Zac Medico
0 siblings, 0 replies; 6+ messages in thread
From: Zac Medico @ 2011-06-28 9:09 UTC (permalink / raw
To: gentoo-commits
commit: e63823dd8358f50559fa616313cdde3ceaf104ed
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 28 09:06:36 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jun 28 09:06:36 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e63823dd
varexpand: handle backslashes like more like bash
For backslash expansion, this function used to behave like echo
-e, but that's not needed for our purposes. We want to behave like
bash does when expanding a variable assignment in a sourced file,
in which case it performs backslash removal for \\ and \$ but nothing
more. This will fix bash compatibility for the case reported in
bug #365033.
---
pym/portage/tests/util/test_varExpand.py | 33 ++++++++++++++++++++++++-
pym/portage/util/__init__.py | 39 ++++++++++--------------------
2 files changed, 45 insertions(+), 27 deletions(-)
diff --git a/pym/portage/tests/util/test_varExpand.py b/pym/portage/tests/util/test_varExpand.py
index 30aa390..9dd488e 100644
--- a/pym/portage/tests/util/test_varExpand.py
+++ b/pym/portage/tests/util/test_varExpand.py
@@ -1,5 +1,5 @@
# test_varExpand.py -- Portage Unit Testing Functionality
-# Copyright 2006 Gentoo Foundation
+# Copyright 2006-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from portage.tests import TestCase
@@ -21,6 +21,37 @@ class VarExpandTestCase(TestCase):
msg="Got %s != %s, from varexpand( %s, %s )" % \
( result, varDict[key], "${%s}" % key, varDict ) )
+ def testVarExpandBackslashes(self):
+ """
+ We want to behave like bash does when expanding a variable
+ assignment in a sourced file, in which case it performs
+ backslash removal for \\ and \$ but nothing more. Note that
+ we don't handle escaped quotes here, since genconfig() uses
+ shlex to handle that earlier.
+ """
+
+ varDict = {}
+ tests = [
+ ("\\", "\\"),
+ ("\\\\", "\\"),
+ ("\\\\\\", "\\\\"),
+ ("\\\\\\\\", "\\\\"),
+ ("\\$", "$"),
+ ("\\\\$", "\\$"),
+ ("\\a", "\\a"),
+ ("\\b", "\\b"),
+ ("\\n", "\\n"),
+ ("\\r", "\\r"),
+ ("\\t", "\\t"),
+ ("\\\"", "\\\""),
+ ("\\'", "\\'"),
+ ]
+ for test in tests:
+ result = varexpand( test[0], varDict )
+ self.assertFalse( result != test[1],
+ msg="Got %s != %s from varexpand( %s, %s )" \
+ % ( result, test[1], test[0], varDict ) )
+
def testVarExpandDoubleQuotes(self):
varDict = { "a":"5" }
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 8c53522..ece0806 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -683,37 +683,24 @@ def varexpand(mystring, mydict=None):
newstring=newstring+" "
pos=pos+1
elif (mystring[pos]=="\\"):
- #backslash expansion time
+ # For backslash expansion, this function used to behave like
+ # echo -e, but that's not needed for our purposes. We want to
+ # behave like bash does when expanding a variable assignment
+ # in a sourced file, in which case it performs backslash
+ # removal for \\ and \$ but nothing more. Note that we don't
+ # handle escaped quotes here, since genconfig() uses shlex
+ # to handle that earlier.
if (pos+1>=len(mystring)):
newstring=newstring+mystring[pos]
break
else:
- a=mystring[pos+1]
- pos=pos+2
- if a=='a':
- newstring=newstring+chr(0o07)
- elif a=='b':
- newstring=newstring+chr(0o10)
- elif a=='e':
- newstring=newstring+chr(0o33)
- elif (a=='f') or (a=='n'):
- newstring=newstring+chr(0o12)
- elif a=='r':
- newstring=newstring+chr(0o15)
- elif a=='t':
- newstring=newstring+chr(0o11)
- elif a=='v':
- newstring=newstring+chr(0o13)
- elif a in ('\'', '"'):
- # Quote removal is handled by shlex.
+ a = mystring[pos + 1]
+ pos = pos + 2
+ if a in ("\\", "$"):
+ newstring = newstring + a
+ else:
newstring = newstring + mystring[pos-2:pos]
- continue
- elif a!='\n':
- # Remove backslash only, as bash does. This takes care
- # of \\. Note that we don't handle quotes here since
- # quote removal is handled by shlex.
- newstring=newstring+mystring[pos-1:pos]
- continue
+ continue
elif (mystring[pos]=="$") and (mystring[pos-1]!="\\"):
pos=pos+1
if mystring[pos]=="{":
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-06-27 3:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-01 8:47 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/, pym/portage/util/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2018-06-27 3:32 Zac Medico
2017-04-20 19:39 Zac Medico
2014-01-22 4:49 Jesus Rivero
2012-05-12 22:17 Zac Medico
2011-06-28 9:09 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox