public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
Date: Mon, 16 Jun 2014 03:40:18 +0000 (UTC)	[thread overview]
Message-ID: <1402607510.fda51375fed8b54e264e4577fb3d72385bbffa17.dol-sen@gentoo> (raw)

commit:     fda51375fed8b54e264e4577fb3d72385bbffa17
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 23 18:37:51 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=fda51375

config.py: Adds proxies() @property function

Since remotedb.py and tar.py both made use of the same code
that determined available proxies, the code has been moved to a
function in config.py and both files have been changed to make use
of this function as a value.

---
 layman/config.py       | 23 ++++++++++++++++++++++-
 layman/overlays/tar.py | 10 +---------
 layman/remotedb.py     | 11 ++---------
 3 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/layman/config.py b/layman/config.py
index 40ee90a..9d2bc7f 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -66,7 +66,6 @@ def read_layman_config(config=None, defaults=None, output=None):
                 overlays.update(["file://" + _path])
         config.set('MAIN', 'overlays', '\n'.join(overlays))
 
-
 # establish the eprefix, initially set so eprefixify can
 # set it on install
 EPREFIX = "@GENTOO_PORTAGE_EPREFIX@"
@@ -280,6 +279,28 @@ class BareConfig(object):
         """
         return option.lower() in ['yes', 'true', 'y', 't']
 
+    @property
+    def proxies(self):
+        """
+        Reads the config options to determine the available proxies.
+
+        @param config: config options dict.
+        @rtype dict
+        """
+        proxies = {}
+
+        for proxy in ['http_proxy', 'https_proxy']:
+            if self.config and self.config.get('MAIN', proxy):
+                proxies[proxy.split('_')[0]] = self.config.get('MAIN', proxy)
+            elif self.get_option(proxy):
+                proxies[proxy.split('_')[0]] = self.get_option(proxy)
+            elif os.getenv(proxy):
+                proxies[proxy.split('_')[0]] = os.getenv(proxy)
+        if self.config and proxies == {}:
+            self.output.debug("Warning: unable to determine proxies.", 6)
+
+        return proxies
+
 
 class OptionConfig(BareConfig):
     """This subclasses BareCongig adding functions to make overriding

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index d2c1cc9..a819475 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -88,19 +88,11 @@ class TarOverlay(OverlaySource):
 
     def __init__(self, parent, config, _location, ignore = 0):
 
-        self.proxies = {}
-
-        for proxy in ['http_proxy', 'https_proxy']:
-            if config[proxy]:
-                self.proxies[proxy.split('_')[0]] = config[proxy]
-            elif os.getenv(proxy):
-                self.proxies[proxy.split('_')[0]] = os.getenv(proxy)
-
-
         super(TarOverlay, self).__init__(parent,
             config, _location, ignore)
 
         self.output = config['output']
+        self.proxies = config.proxies
         self.subpath = None
 
     def __eq__(self, other):

diff --git a/layman/remotedb.py b/layman/remotedb.py
index 175aeb5..f883799 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -57,15 +57,8 @@ class RemoteDB(DbBase):
         self.output = config['output']
         self.detached_urls = []
         self.signed_urls = []
-
-        self.proxies = {}
-
-        for proxy in ['http_proxy', 'https_proxy']:
-            if config[proxy]:
-                self.proxies[proxy.split('_')[0]] = config[proxy]
-            elif os.getenv(proxy):
-                self.proxies[proxy.split('_')[0]] = os.getenv(proxy)
-
+        self.proxies = config.proxies
+        
         self.urls  = [i.strip()
             for i in config['overlays'].split('\n') if len(i)]
 


WARNING: multiple messages have this Message-ID (diff)
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/
Date: Mon, 16 Jun 2014 03:37:28 +0000 (UTC)	[thread overview]
Message-ID: <1402607510.fda51375fed8b54e264e4577fb3d72385bbffa17.dol-sen@gentoo> (raw)
Message-ID: <20140616033728.Cm3EAG43JHjdjXz2hdJgoagO9iVwQU0viZvSYM6qMeQ@z> (raw)

commit:     fda51375fed8b54e264e4577fb3d72385bbffa17
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 23 18:37:51 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=fda51375

config.py: Adds proxies() @property function

Since remotedb.py and tar.py both made use of the same code
that determined available proxies, the code has been moved to a
function in config.py and both files have been changed to make use
of this function as a value.

---
 layman/config.py       | 23 ++++++++++++++++++++++-
 layman/overlays/tar.py | 10 +---------
 layman/remotedb.py     | 11 ++---------
 3 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/layman/config.py b/layman/config.py
index 40ee90a..9d2bc7f 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -66,7 +66,6 @@ def read_layman_config(config=None, defaults=None, output=None):
                 overlays.update(["file://" + _path])
         config.set('MAIN', 'overlays', '\n'.join(overlays))
 
-
 # establish the eprefix, initially set so eprefixify can
 # set it on install
 EPREFIX = "@GENTOO_PORTAGE_EPREFIX@"
@@ -280,6 +279,28 @@ class BareConfig(object):
         """
         return option.lower() in ['yes', 'true', 'y', 't']
 
+    @property
+    def proxies(self):
+        """
+        Reads the config options to determine the available proxies.
+
+        @param config: config options dict.
+        @rtype dict
+        """
+        proxies = {}
+
+        for proxy in ['http_proxy', 'https_proxy']:
+            if self.config and self.config.get('MAIN', proxy):
+                proxies[proxy.split('_')[0]] = self.config.get('MAIN', proxy)
+            elif self.get_option(proxy):
+                proxies[proxy.split('_')[0]] = self.get_option(proxy)
+            elif os.getenv(proxy):
+                proxies[proxy.split('_')[0]] = os.getenv(proxy)
+        if self.config and proxies == {}:
+            self.output.debug("Warning: unable to determine proxies.", 6)
+
+        return proxies
+
 
 class OptionConfig(BareConfig):
     """This subclasses BareCongig adding functions to make overriding

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index d2c1cc9..a819475 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -88,19 +88,11 @@ class TarOverlay(OverlaySource):
 
     def __init__(self, parent, config, _location, ignore = 0):
 
-        self.proxies = {}
-
-        for proxy in ['http_proxy', 'https_proxy']:
-            if config[proxy]:
-                self.proxies[proxy.split('_')[0]] = config[proxy]
-            elif os.getenv(proxy):
-                self.proxies[proxy.split('_')[0]] = os.getenv(proxy)
-
-
         super(TarOverlay, self).__init__(parent,
             config, _location, ignore)
 
         self.output = config['output']
+        self.proxies = config.proxies
         self.subpath = None
 
     def __eq__(self, other):

diff --git a/layman/remotedb.py b/layman/remotedb.py
index 175aeb5..f883799 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -57,15 +57,8 @@ class RemoteDB(DbBase):
         self.output = config['output']
         self.detached_urls = []
         self.signed_urls = []
-
-        self.proxies = {}
-
-        for proxy in ['http_proxy', 'https_proxy']:
-            if config[proxy]:
-                self.proxies[proxy.split('_')[0]] = config[proxy]
-            elif os.getenv(proxy):
-                self.proxies[proxy.split('_')[0]] = os.getenv(proxy)
-
+        self.proxies = config.proxies
+        
         self.urls  = [i.strip()
             for i in config['overlays'].split('\n') if len(i)]
 


             reply	other threads:[~2014-06-16  3:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16  3:40 Brian Dolbec [this message]
2014-06-16  3:37 ` [gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/ Brian Dolbec
  -- strict thread matches above, loose matches on Subject: below --
2020-04-24 20:59 [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16  3:40 Brian Dolbec
2014-06-16  3:37 [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16  3:40 ` [gentoo-commits] proj/layman:master " Brian Dolbec
2011-09-24  6:07 Brian Dolbec
2011-08-24 14:02 Brian Dolbec
2011-08-21 16:42 Brian Dolbec
2011-08-11  3:24 Brian Dolbec
2011-08-07  2:29 Brian Dolbec
2011-08-06 18:29 Brian Dolbec
2011-07-30 16:53 Brian Dolbec
2011-07-29  6:11 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-02-14  6:00 Brian Dolbec
2011-02-14  6:00 Brian Dolbec
2011-02-14  6:00 Brian Dolbec
2011-02-14  6:00 Brian Dolbec
2011-02-14  6:00 Brian Dolbec

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=1402607510.fda51375fed8b54e264e4577fb3d72385bbffa17.dol-sen@gentoo \
    --to=brian.dolbec@gmail.com \
    --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