From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/bash/
Date: Sun, 10 Jul 2011 21:37:49 +0000 (UTC) [thread overview]
Message-ID: <780400ffe4ed184315686cca84244b8ad0f10c94.mgorny@gentoo> (raw)
commit: 780400ffe4ed184315686cca84244b8ad0f10c94
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 10 21:38:21 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 10 21:38:21 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=780400ff
BashServer: implement optimised get_env().
---
gentoopm/bash/bashserver.py | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/gentoopm/bash/bashserver.py b/gentoopm/bash/bashserver.py
index 7e490ee..8fb8e09 100644
--- a/gentoopm/bash/bashserver.py
+++ b/gentoopm/bash/bashserver.py
@@ -51,12 +51,23 @@ class BashServer(BashParser):
self._bashproc.stdin.write('\n'.encode('ASCII'))
self._bashproc.stdin.flush()
- def __getitem__(self, k):
- self._bashproc.stdin.write(('${%s}\n' % k).encode('ASCII'))
- self._bashproc.stdin.flush()
-
+ def _read1(self):
f = self._bashproc.stdout
buf = ' '
while buf[-1] != '\0':
buf += f.read(1)
return buf[1:-1].decode('utf-8')
+
+ def __getitem__(self, k):
+ self._bashproc.stdin.write(('${%s}\n' % k).encode('ASCII'))
+ self._bashproc.stdin.flush()
+
+ return self._read1()
+
+ def get_env(self, *varlist):
+ q = ' '.join(['"${%s}"' % v for v in varlist])
+ self._bashproc.stdin.write(('%s\n' % q).encode('ASCII'))
+ self._bashproc.stdin.flush()
+
+ ret = [self._read1() for v in varlist]
+ return dict(zip(varlist, ret))
next reply other threads:[~2011-07-10 21:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-10 21:37 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-08-05 8:50 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/bash/ Michał Górny
2013-08-04 12:52 Michał Górny
2011-07-17 21:21 Michał Górny
2011-07-15 16:08 Michał Górny
2011-07-15 16:08 Michał Górny
2011-07-15 16:08 Michał Górny
2011-07-15 13:32 Michał Górny
2011-07-15 12:34 Michał Górny
2011-07-10 21:37 Michał Górny
2011-07-10 21:37 Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=780400ffe4ed184315686cca84244b8ad0f10c94.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox