[gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/

2020-04-24 Thread Brian Dolbec
commit: ae11c78123120e8c0a399e806dad224504aad574
Author: Brian Dolbec  gentoo  org>
AuthorDate: Fri Apr 24 12:35:38 2020 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Fri Apr 24 13:56:12 2020 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=ae11c781

Add additional debug statements to trace a py3.7, py3.8 error

Signed-off-by: Brian Dolbec  gentoo.org>

 layman/db.py   |  1 +
 layman/overlays/overlay.py | 19 ++-
 layman/remotedb.py |  5 -
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/layman/db.py b/layman/db.py
index d67ea87..9b32952 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -111,6 +111,7 @@ class DB(DbBase):
 if overlay.name not in self.overlays.keys():
 if not self._check_official(overlay):
 return False
+self.output.debug('RemoteDB.__init__(), DB.add overlay.add() 
call', 4)
 result = overlay.add(self.config['storage'])
 if result == 0:
 if 'priority' in self.config.keys():

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 9cbeb99..03829a8 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -95,8 +95,9 @@ class Overlay(object):
 def add(self, base):
 res = 1
 first_s = True
-
+self.output.debug('Overlay.add()', 5)
 self.sources = self.filter_protocols(self.sources)
+self.output.debug('Overlay.add(), filtered protocols, sources:' + 
str(self.sources), 5)
 if not self.sources:
 msg = 'Overlay.add() error: overlay "%(name)s" does not support '\
   ' the given\nprotocol(s) %(protocol)s and cannot be '\
@@ -110,10 +111,12 @@ class Overlay(object):
 if not first_s:
 self.output.info('\nTrying next source of listed sources...', 
4)
 try:
+self.output.debug('Overlay.add(), s.add(base)', 5)
 res = s.add(base)
 if res == 0:
 # Worked, throw other sources away
 self.sources = [s]
+self.output.debug('Overlay.add(), back from s.add(base)', 
5)
 break
 except Exception as error:
 self.output.warn(str(error), 4)
@@ -132,11 +135,17 @@ class Overlay(object):
 from the overlay's sources.
 '''
 _sources = []
-if not self.config['protocol_filter']:
+self.output.debug('Overlay.filter_protocols()', 5)
+self.output.debug('Overlay.filter_protocols() filters:' + 
str(type(self.config['protocol_filter'])), 5)
+if not self.config['protocol_filter'] and not 
self.config['protocol_filter'] == []:
+self.output.debug('Overlay.filter_protocols() no protocol_filter, 
returning', 5)
 return sources
-
+self.output.debug('Overlay.filter_protocols() sources:' + 
str(sources), 5)
 for source in sources:
+self.output.debug('Overlay.filter_protocols() source:' + 
str(type(source)), 5)
+self.output.debug('Overlay.filter_protocols() filters:' + 
str(self.config['protocol_filter']), 5)
 for protocol in self.config['protocol_filter']:
+self.output.debug('Overlay.filter_protocols() protocol: ' + 
protocol + ' ' + str(type(protocol)), 5)
 protocol = protocol.lower()
 #re.search considers "\+" as the literal "+".
 if protocol == 'git+ssh':
@@ -144,7 +153,7 @@ class Overlay(object):
 protocol += '://'
 if re.search('^' + protocol, source.src):
 _sources.append(source)
-
+self.output.debug('Overlay.filter_protocols(), returning sources' + 
str(_sources), 5)
 return _sources
 
 
@@ -792,7 +801,7 @@ class Overlay(object):
 try:
 res = self.sources[0].update(base, src)
 if res == 0:
-# Updating it worked, no need to bother 
+# Updating it worked, no need to bother
 # checking other sources.
 self.sources[0].src = src
 result = True

diff --git a/layman/remotedb.py b/layman/remotedb.py
index 2df0c63..6e75bec 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -83,15 +83,18 @@ class RemoteDB(DbBase):
 self.output.debug('RemoteDB.__init__(), paths to load = %s' 
%str(paths),
 2)
 if config['nocheck']:
+self.output.debug('RemoteDB.__init__(), ignore = 2', 5)
 ignore = 2
 else:
+self.output.debug('RemoteDB.__init__(), ignore = 0', 5)
 ignore = 0
 
 #quiet = int(config['quietness']) < 3
-
+self.output.debug('RemoteDB.__init__(), DbBase.__init__() call', 5)
 DbBase.__init__(self, config, paths=paths, 

[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-08-27 Thread Devan Franchini
commit: 4c8a81001eb813a4ec25584cacdd97c87f176c84
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Aug 28 03:47:35 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 28 03:47:38 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=4c8a8100

overlay.py: Fixes method of assigning owner info if contact attrib is found

Prior to this commit the overlay would not set the owner info if the
contact attribute was found, breaking backwards compatibility. To allow
for this backwards compatibility while maintaining multiple owner
support layman will be defaulting to the contact attribute if it is
present in any XML overlays.

 layman/overlays/overlay.py | 49 --
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 8052d4c..9cbeb99 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -454,32 +454,35 @@ class Overlay(object):
 _owners = xml.findall('owner')
 self.owners = []
 
-for _owner in _owners:
-owner = {}
+# For backwards compatibility with older Overlay XML formats
+# default to this.
+if 'contact' in xml.attrib:
+owner = {'email': encode(xml.attrib['contact']),
+ 'name': None}
+self.owners.append(owner)
+else:
+for _owner in _owners:
+owner = {}
 
-_email = _owner.find('email')
-_name = _owner.find('name')
+_email = _owner.find('email')
+_name = _owner.find('name')
 
-if _name != None:
-owner['name'] = encode(strip_text(_name))
-else:
-owner['name'] = None
-if _email != None:
-owner['email'] = encode(strip_text(_email))
-else:
-owner['email'] = None
-msg = 'Overlay from_xml(), %(name)s is missing an '\
-  'owner.email entry!' % {'name': self.name}
-if not ignore:
-raise Exception(msg)
-elif ignore == 1:
-self.output.warn(msg, 4)
+if _name != None:
+owner['name'] = encode(strip_text(_name))
+else:
+owner['name'] = None
+if _email != None:
+owner['email'] = encode(strip_text(_email))
+else:
+owner['email'] = None
+msg = 'Overlay from_xml(), %(name)s is missing an '\
+  'owner.email entry!' % {'name': self.name}
+if not ignore:
+raise Exception(msg)
+elif ignore == 1:
+self.output.warn(msg, 4)
 
-# For backwards compatibility with older Overlay XML formats.
-if not _email and not _name and 'contact' in xml.attrib:
-owner['email'] = encode(xml.attrib['contact'])
-owner['name'] = None
-self.owners.append(owner)
+self.owners.append(owner)
 
 _desc = xml.findall('description')
 if _desc != None:



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-08-27 Thread Devan Franchini
commit: 8363c11894f9fc724f1c5d46d115c3d5919cbc37
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Aug 28 02:54:22 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 28 02:54:26 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=8363c118

overlay.py: Modifies __eq__ attribute requirements

The previous method still made use of owner_name and owner_email to see
if the two were equal while it should've been checking for the owners
overlay attribute.

 layman/overlays/overlay.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 11536d4..8052d4c 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -76,8 +76,8 @@ class Overlay(object):
 
 
 def __eq__(self, other):
-for i in ('descriptions', 'homepage', 'name', 'owner_email',
-'owner_name', 'priority', 'status'):
+for i in ('descriptions', 'homepage', 'name', 'owners', 'priority',
+  'status'):
 if getattr(self, i) != getattr(other, i):
 return False
 for i in self.sources + other.sources:



[gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/db_modules/sqlite_db/

2015-08-27 Thread Devan Franchini
commit: 03f39c1a46149d472797e4adb6654705579c412c
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Aug 28 00:36:37 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 28 00:36:40 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=03f39c1a

Adds multiple owner support to layman overlays

 layman/db_modules/sqlite_db/sqlite_db.py |  69 -
 layman/overlays/overlay.py   | 164 ++-
 2 files changed, 137 insertions(+), 96 deletions(-)

diff --git a/layman/db_modules/sqlite_db/sqlite_db.py 
b/layman/db_modules/sqlite_db/sqlite_db.py
index 22ae5f3..a3305a7 100644
--- a/layman/db_modules/sqlite_db/sqlite_db.py
+++ b/layman/db_modules/sqlite_db/sqlite_db.py
@@ -172,12 +172,21 @@ class DBHandler(object):
 cursor.execute('''SELECT Owner_Email, Owner_Name FROM 
 Overlay_Owner JOIN Overlay USING (Overlay_ID) JOIN Owner USING 
 (Owner_ID) WHERE Overlay_ID = ?''', (overlay_id,))
-owner_info = cursor.fetchall()[0]
-
-overlay['owner_email'] = owner_info[0]
-
-if len(owner_info)  1:
-overlay['owner_name'] = owner_info[1]
+owner_info = cursor.fetchall()
+overlay['owner'] = []
+
+for _owner in owner_info:
+owner = {}
+if _owner[0]:
+owner['email'] = _owner[0]
+else:
+owner['email'] = None
+if len(_owner)  1:
+if _owner[1]:
+owner['name'] = _owner[1]
+else:
+owner['name'] = None
+overlay['owner'].append(owner)
 
 cursor.execute('''SELECT Description FROM Description JOIN 
 Overlay USING (Overlay_ID) WHERE Overlay_ID = ?''',
@@ -225,7 +234,7 @@ class DBHandler(object):
 '''
 overlay_id = None
 owner_id = None
-source_ids = []
+source_id = None
 cursor = None
 
 cursor = connection.cursor()
@@ -239,22 +248,37 @@ class DBHandler(object):
 (overlay.name,))
 overlay_id = cursor.fetchone()[0]
 
-cursor.execute('''INSERT INTO Owner ( Owner_Name, Owner_Email ) 
-VALUES ( ?, ? )''', (overlay.owner_name, overlay.owner_email,))
-connection.commit()
+for owner in overlay.owners:
+_name = owner['name']
+_email = owner['email']
+
+cursor.execute('''INSERT INTO Owner ( Owner_Name, Owner_Email ) 
+VALUES ( ?, ? )''', (owner['name'], owner['email'],))
+connection.commit()
+
+if _name != None:
+cursor.execute('''SELECT Owner_ID from Owner WHERE 
+Owner_Email = ? AND Owner_Name = ?''', (_email, _name,))
+else:
+cursor.execute('''SELECT Owner_ID from Owner WHERE 
+Owner_Email = ?''', (_email,))
+owner_id = cursor.fetchone()[0]
 
-cursor.execute('''SELECT Owner_ID from Owner WHERE Owner_Email = ?;''',
-(overlay.owner_email,))
-owner_id = cursor.fetchone()[0]
+cursor.execute('''INSERT INTO Overlay_Owner ( Overlay_ID, 
+Owner_ID ) VALUES ( ?, ? )''', (overlay_id, owner_id,))
 
 for source in overlay.sources:
 cursor.execute('''INSERT INTO Source ( Type, Branch, URL )
 VALUES ( ?, ?, ? )''', (source.type_key, source.branch,
 source.src,))
 connection.commit()
+
 cursor.execute('''SELECT Source_ID FROM Source WHERE URL = ?;''',
 (source.src,))
-source_ids.append(cursor.fetchone()[0])
+source_id = cursor.fetchone()[0]
+
+cursor.execute('''INSERT INTO Overlay_Source ( Overlay_ID, 
+Source_ID ) VALUES ( ?, ? )''', (overlay_id, source_id, ))
 
 for description in overlay.descriptions:
 cursor.execute('''INSERT INTO Description ( Overlay_ID, 
@@ -264,13 +288,6 @@ class DBHandler(object):
 cursor.execute('''INSERT INTO Feed ( Overlay_ID, Feed ) VALUES ( ?,
  ? )''', (overlay_id, feed,))
 
-cursor.execute('''INSERT INTO Overlay_Owner ( Overlay_ID, Owner_ID ) 
-VALUES ( ?, ? )''', (overlay_id, owner_id,))
-
-for source_id in source_ids:
-cursor.execute('''INSERT INTO Overlay_Source ( Overlay_ID, 
-Source_ID ) VALUES ( ?, ? )''', (overlay_id, source_id,))
-
 connection.commit()
 
 
@@ -280,7 +297,7 @@ class DBHandler(object):
 '''
 cursor = None
 overlay_id = 0
-owner_id = 0
+owner_ids = []
 source_ids = []
 
 if overlay.name in self.overlays:
@@ -295,7 +312,7 @@ class DBHandler(object):
 
 

[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-08-27 Thread Devan Franchini
commit: bd5d65f3a1c6030fa63f6f3972a67f688d015cbc
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu Aug 27 17:36:22 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Thu Aug 27 17:36:22 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=bd5d65f3

overlay.py: Improves to_json() setting of descriptions

 layman/overlays/overlay.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 31fe400..defa4e3 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -661,9 +661,7 @@ class Overlay(object):
 if self.license != None:
 repo['@license'] = self.license
 repo['name'] = self.name
-repo['description'] = []
-for i in self.descriptions:
-repo['description'].append(i)
+repo['description'] = [i for i in self.descriptions]
 if self.homepage != None:
 repo['homepage'] = self.homepage
 if self.irc != None:



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-08-03 Thread Devan Franchini
commit: 16752532c5f7e3dd74745f4ca093278f8c71a90f
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Mon Aug  3 20:26:41 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Mon Aug  3 20:26:41 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=16752532

overlay.py: Reorganizes imports and cleans up init params

 layman/overlays/overlay.py | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 8f31a76..31fe400 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -32,9 +32,12 @@ __version__ = 0.2
 #
 
#---
 
-import sys, re, os, os.path
 import codecs
 import locale
+import os
+import os.path
+import re
+import sys
 import xml.etree.ElementTree as ET # Python 2.5
 
 from  layman.compatibility import encode
@@ -56,8 +59,7 @@ WHITESPACE_REGEX = re.compile('\s+')
 class Overlay(object):
 ''' Derive the real implementations from this.'''
 
-def __init__(self, config, json=None, ovl_dict=None, xml=None,
-ignore = 0):
+def __init__(self, config, json=None, ovl_dict=None, xml=None, ignore=0):
 self.config = config
 self.output = config['output']
 self.module_controller = Modules(path=MOD_PATH,



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-07-21 Thread Devan Franchini
commit: 8133bd98d60e3e1ed38fa75662ae9b070a156336
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 21 16:37:53 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Tue Jul 21 16:37:53 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=8133bd98

overlay.py: Adds optional license attribute to overlay object

 layman/overlays/overlay.py | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index c6a0cee..8f31a76 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -237,6 +237,11 @@ class Overlay(object):
 else:
 self.priority = 50
 
+if 'license' in overlay:
+self.license = encode(overlay['license'])
+else:
+self.license = None
+
 if 'homepage' in overlay:
 self.homepage = encode(overlay['homepage'])
 else:
@@ -352,6 +357,11 @@ class Overlay(object):
 else:
 self.priority = 50
 
+if '@license' in json:
+self.license = encode(json['@license'])
+else:
+self.license = None
+
 if 'homepage' in json:
 self.homepage = encode(json['homepage'])
 else:
@@ -486,6 +496,11 @@ class Overlay(object):
 else:
 self.priority = 50
 
+if 'license' in xml.attrib:
+self.license = encode(xml.attrib['license'])
+else:
+self.license = None
+
 h = xml.find('homepage')
 l = xml.find('link')
 
@@ -641,6 +656,8 @@ class Overlay(object):
 repo['@quality'] = self.quality
 if self.status != None:
 repo['@status'] = self.status
+if self.license != None:
+repo['@license'] = self.license
 repo['name'] = self.name
 repo['description'] = []
 for i in self.descriptions:
@@ -677,6 +694,8 @@ class Overlay(object):
 repo.attrib['status'] = self.status
 repo.attrib['quality'] = self.quality
 repo.attrib['priority'] = str(self.priority)
+if self.license != None:
+repo.attrib['license'] = self.license
 name = ET.Element('name')
 name.text = self.name
 repo.append(name)



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-07-14 Thread Devan Franchini
commit: cf8329cb7218173bba6cc57ed8f43e54e8ec9775
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 14 15:15:54 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Tue Jul 14 15:15:54 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=cf8329cb

overlay.py: Adds better error handling for missing source entries

 layman/overlays/overlay.py | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 6e289b6..c6a0cee 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -160,10 +160,13 @@ class Overlay(object):
 msg = 'Overlay from_dict(), name entry missing from dictionary!'
 raise Exception(msg)
 
-_sources = overlay['source']
+if 'source' in overlay:
+_sources = overlay['source']
+else:
+_sources = None
 
 if _sources == None:
-msg = 'Overlay from_dict(), %(name)s is missing a source'\
+msg = 'Overlay from_dict(), %(name)s is missing a source '\
   'entry!' % {'name': self.name}
 raise Exception(msg)
 
@@ -267,10 +270,13 @@ class Overlay(object):
 msg = 'Overlay from_json(), name entry missing from json!'
 raise Exception(msg)
 
-_sources = json['source']
+if 'source' in json:
+_sources = json['source']
+else:
+_sources = None
 
 if _sources == None:
-msg = 'Overlay from_json(), %(name)s is missing a source'\
+msg = 'Overlay from_json(), %(name)s is missing a source '\
   'entry!' % {'name': self.name}
 raise Exception(msg)
 



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-07-13 Thread Devan Franchini
commit: 9128580881ba70dbd1bd08e4cdcd8731a46699cd
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Mon Jul 13 18:52:15 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Mon Jul 13 18:52:17 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=91285808

overlay.py: Modifies error message for missing name entry

If the Overlay object has no name then trying to use the name would
result in erroneous or illogical reporting.

 layman/overlays/overlay.py | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index de0a035..024989c 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -157,8 +157,7 @@ class Overlay(object):
 if _name != None:
 self.name = encode(_name)
 else:
-msg = 'Overlay from dict(), %(name)s is missing a name entry!'\
-  % {'name': self.name}
+msg = 'Overlay from_dict(), name entry missing from dictionary!'
 raise Exception(msg)
 
 _sources = overlay['source']
@@ -383,8 +382,7 @@ class Overlay(object):
 elif 'name' in xml.attrib:
 self.name = encode(xml.attrib['name'])
 else:
-msg = 'Overlay from_xml(), %(name)s is missing a name entry!'\
-  % {'name': self.name}
+msg = 'Overlay from_xml(), name entry missing from xml!'
 raise Exception(msg)
 
 _sources = xml.findall('source')



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-07-13 Thread Devan Franchini
commit: 73aa4d1bc690dbef69c0c00dfc629209a3a8540e
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Mon Jul 13 19:00:41 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Mon Jul 13 19:00:41 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=73aa4d1b

overlay.py: Corrects else on line 316

 layman/overlays/overlay.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 024989c..cf99499 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -313,7 +313,7 @@ class Overlay(object):
   'entry!' % {'name': self.name}
 if not ignore:
 raise Exception(msg)
-else ignore == 1:
+elif ignore == 1:
 self.output.warn(msg, 4)
 
  if 'description' in overlay:



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-07-13 Thread Devan Franchini
commit: 8279886d04bb1469753144c1d204fd1ae20f528f
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Mon Jul 13 19:05:30 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Mon Jul 13 19:05:30 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=8279886d

overlay.py: Fixes any other mistakes made in haste

 layman/overlays/overlay.py | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index cf99499..82e2f9f 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -316,7 +316,7 @@ class Overlay(object):
 elif ignore == 1:
 self.output.warn(msg, 4)
 
- if 'description' in overlay:
+if 'description' in overlay:
 self.descriptions = []
 _descs = overlay['description']
 for d in _descs:
@@ -602,7 +602,10 @@ class Overlay(object):
 
 def source_types(self):
 for i in self.sources:
-yield i.typedef is_official(self):
+yield i.type
+
+
+def is_official(self):
 '''
 Is the overlay official?
 '''



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-07-13 Thread Devan Franchini
commit: e4162f49357e04722e8db20493e15538e657c3bd
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Mon Jul 13 18:36:51 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Mon Jul 13 18:36:54 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=e4162f49

overlay.py: Adds json support for overlay definitions

Also reorganizes functions alphabetically.

 layman/overlays/overlay.py | 658 +++--
 1 file changed, 403 insertions(+), 255 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 423b91e..de0a035 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -56,7 +56,7 @@ WHITESPACE_REGEX = re.compile('\s+')
 class Overlay(object):
 ''' Derive the real implementations from this.'''
 
-def __init__(self, config, xml=None, ovl_dict=None,
+def __init__(self, config, json=None, ovl_dict=None, xml=None,
 ignore = 0):
 self.config = config
 self.output = config['output']
@@ -69,6 +69,59 @@ class Overlay(object):
 self.from_xml(xml, ignore)
 elif ovl_dict is not None:
 self.from_dict(ovl_dict, ignore)
+elif json is not None:
+self.from_json(ovl_dict, ignore)
+
+
+def __eq__(self, other):
+for i in ('descriptions', 'homepage', 'name', 'owner_email',
+'owner_name', 'priority', 'status'):
+if getattr(self, i) != getattr(other, i):
+return False
+for i in self.sources + other.sources:
+if not i in self.sources:
+return False
+if not i in other.sources:
+return False
+return True
+
+
+def __ne__(self, other):
+return not self.__eq__(other)
+
+
+def add(self, base):
+res = 1
+first_s = True
+
+self.sources = self.filter_protocols(self.sources)
+if not self.sources:
+msg = 'Overlay.add() error: overlay %(name)s does not support '\
+  ' the given\nprotocol(s) %(protocol)s and cannot be '\
+  'installed.'\
+  % {'name': self.name,
+ 'protocol': str(self.config['protocol_filter'])}
+self.output.error(msg)
+return 1
+
+for s in self.sources:
+if not first_s:
+self.output.info('\nTrying next source of listed sources...', 
4)
+try:
+res = s.add(base)
+if res == 0:
+# Worked, throw other sources away
+self.sources = [s]
+break
+except Exception as error:
+self.output.warn(str(error), 4)
+first_s = False
+return res
+
+
+def delete(self, base):
+assert len(self.sources) == 1
+return self.sources[0].delete(base)
 
 
 def filter_protocols(self, sources):
@@ -93,6 +146,226 @@ class Overlay(object):
 return _sources
 
 
+def from_dict(self, overlay, ignore):
+'''
+Process an overlay dictionary definition
+'''
+msg = 'Overlay from_dict(); overlay %(ovl)s' % {'ovl': str(overlay)}
+self.output.debug(msg, 6)
+
+_name = overlay['name']
+if _name != None:
+self.name = encode(_name)
+else:
+msg = 'Overlay from dict(), %(name)s is missing a name entry!'\
+  % {'name': self.name}
+raise Exception(msg)
+
+_sources = overlay['source']
+
+if _sources == None:
+msg = 'Overlay from_dict(), %(name)s is missing a source'\
+  'entry!' % {'name': self.name}
+raise Exception(msg)
+
+def create_dict_overlay_source(source_):
+_src, _type, _sub = source_
+self.ovl_type = _type
+try:
+_class = self.module_controller.get_class(_type)
+except InvalidModuleName:
+_class = self.module_controller.get_class('stub')
+
+_location = encode(_src)
+if _sub:
+self.branch = encode(_sub)
+else:
+self.branch = None
+
+return _class(parent=self, config=self.config,
+_location=_location, ignore=ignore)
+
+self.sources = [create_dict_overlay_source(e) for e in _sources]
+
+if 'owner_name' in overlay:
+_owner = overlay['owner_name']
+self.owner_name = encode(_owner)
+else:
+self.owner_name = None
+
+if 'owner_email' in overlay:
+_email = overlay['owner_email']
+self.owner_email = encode(_email)
+else:
+self.owner_email = None
+msg = 'Overlay from_dict(), %(name)s is missing an 
owner.email'\
+  ' entry!' % {'name': self.name}
+if not 

[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-07-13 Thread Devan Franchini
commit: 9a56f1ac6a40446ea8cc210a25621e9ad1ccbe80
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Mon Jul 13 22:46:34 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Mon Jul 13 22:46:34 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=9a56f1ac

overlay.py: Renames overlay variable to json to match parameter

 layman/overlays/overlay.py | 56 +++---
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 82e2f9f..6e289b6 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -70,7 +70,7 @@ class Overlay(object):
 elif ovl_dict is not None:
 self.from_dict(ovl_dict, ignore)
 elif json is not None:
-self.from_json(ovl_dict, ignore)
+self.from_json(json, ignore)
 
 
 def __eq__(self, other):
@@ -257,17 +257,17 @@ class Overlay(object):
 '''
 Process a json overlay definition
 '''
-msg = 'Overlay from_json(); overlay %(ovl)s' % {'ovl': str(overlay)}
+msg = 'Overlay from_json(); overlay %(ovl)s' % {'ovl': str(json)}
 self.output.debug(msg, 6)
 
-_name = overlay['name']
+_name = json['name']
 if _name != None:
 self.name = encode(_name)
 else:
 msg = 'Overlay from_json(), name entry missing from json!'
 raise Exception(msg)
 
-_sources = overlay['source']
+_sources = json['source']
 
 if _sources == None:
 msg = 'Overlay from_json(), %(name)s is missing a source'\
@@ -300,13 +300,13 @@ class Overlay(object):
 
 self.sources = [create_json_overlay_source(e) for e in _sources]
 
-if 'name' in overlay['owner']:
-self.owner_name = encode(overlay['owner']['name'])
+if 'name' in json['owner']:
+self.owner_name = encode(json['owner']['name'])
 else:
 self.owner_name = None
 
-if 'email' in overlay['owner']:
-self.owner_email = encode(overlay['owner']['email'])
+if 'email' in json['owner']:
+self.owner_email = encode(json['owner']['email'])
 else:
 self.owner_email = None
 msg = 'Overlay from_json(), %(name)s is missing an 
owner.email'\
@@ -316,49 +316,49 @@ class Overlay(object):
 elif ignore == 1:
 self.output.warn(msg, 4)
 
-if 'description' in overlay:
+if 'description' in json:
 self.descriptions = []
-_descs = overlay['description']
+_descs = json['description']
 for d in _descs:
-d = WHITESPACE_REGEX.sub(' ', d['#text'])
+d = WHITESPACE_REGEX.sub(' ', d)
 self.descriptions.append(encode(d))
 else:
 self.descriptions = ['']
+msg = 'Overlay from_json() %(name)s is missing description'\
+  'entry!' % {'name': self.name}
 if not ignore:
-raise Exception('Overlay from_json(), ' + self.name +
-' is missing a description entry!')
+raise Exception(msg)
 elif ignore == 1:
-self.output.warn('Overlay from_json(), ' + self.name +
-' is missing a description entry!', 4)
+self.output.warn(msg, 4)
 
-if '@status' in overlay:
-self.status = encode(overlay['@status'])
+if '@status' in json:
+self.status = encode(json['@status'])
 else:
 self.status = None
 
 self.quality = 'experimental'
-if '@quality' in overlay:
-if overlay['@quality'] in set(QUALITY_LEVELS):
-self.quality = encode(overlay['@quality'])
+if '@quality' in json:
+if json['@quality'] in set(QUALITY_LEVELS):
+self.quality = encode(json['@quality'])
 
-if '@priority' in overlay:
-self.priority = int(overlay['@priority'])
+if '@priority' in json:
+self.priority = int(json['@priority'])
 else:
 self.priority = 50
 
-if 'homepage' in overlay:
-self.homepage = encode(overlay['homepage'])
+if 'homepage' in json:
+self.homepage = encode(json['homepage'])
 else:
 self.homepage = None
 
-if 'feed' in overlay:
+if 'feed' in json:
 self.feeds = [encode(e) \
-for e in overlay['feed']]
+for e in json['feed']]
 else:
 self.feeds = None
 
-if 'irc' in overlay:
-self.irc = encode(overlay['irc'])
+if 'irc' in json:
+self.irc = encode(json['irc'])
 else:
 self.irc = None
 



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-07-10 Thread Devan Franchini
commit: d8b97485f50a4922476787ec1052a55e69ae22cb
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Jul 10 16:14:02 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Jul 10 16:14:08 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=d8b97485

overlay.py: Quick code cleanup

 layman/overlays/overlay.py | 113 -
 1 file changed, 70 insertions(+), 43 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 1ecd509..e4195cf 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -11,14 +11,16 @@
 # (c) 2005 - 2009 Gunnar Wrobel
 # (c) 2009Sebastian Pipping
 # (c) 2009Christian Groschupp
+# (c) 2015Devan Franchini
 # Distributed under the terms of the GNU General Public License v2
 #
 # Author(s):
 # Gunnar Wrobel wro...@gentoo.org
 # Sebastian Pipping sebast...@pipping.org
 # Christian Groschupp christ...@groschupp.org
+# Devan Franchini twitch...@gentoo.org
 #
-''' Basic overlay class.'''
+'''Basic overlay class.'''
 
 from __future__ import unicode_literals
 
@@ -92,8 +94,9 @@ class Overlay(object):
 
 
 def from_xml(self, xml, ignore):
-Process an xml overlay definition
-
+'''
+Process an xml overlay definition
+'''
 def strip_text(node):
 res = node.text
 if res is None:
@@ -101,15 +104,18 @@ class Overlay(object):
 return res.strip()
 
 _name = xml.find('name')
+
 if _name != None:
 self.name = encode(strip_text(_name))
 elif 'name' in xml.attrib:
 self.name = encode(xml.attrib['name'])
 else:
-raise Exception('Overlay from_xml(), ' + self.name + \
-'is missing a name entry!')
+msg = 'Overlay from_xml(), %(name)s is missing a name entry!'\
+  % {'name': self.name}
+raise Exception(msg)
 
 _sources = xml.findall('source')
+
 # new xml format
 if _sources != []:
 _sources = [e for e in _sources if 'type' in e.attrib]
@@ -124,6 +130,7 @@ class Overlay(object):
 _branch = ''
 _type = source_elem.attrib['type']
 self.ovl_type = _type
+
 if 'branch' in source_elem.attrib:
 _branch = source_elem.attrib['branch']
 
@@ -133,23 +140,25 @@ class Overlay(object):
 _class = self.module_controller.get_class('stub')
 
 _location = encode(strip_text(source_elem))
-
 self.branch = _branch
 
 return _class(parent=self, config=self.config,
 _location=_location, ignore=ignore)
 
 if not len(_sources):
-raise Exception('Overlay from_xml(), ' + self.name + \
-' is missing a source entry!')
+msg = 'Overlay from_xml(), %(name) is missing a source entry!'\
+  % {'name': self.name}
+raise Exception(msg)
 
 self.sources = [create_overlay_source(e) for e in _sources]
 
 _owner = xml.find('owner')
+
 if _owner == None:
 _email = None
 else:
 _email = _owner.find('email')
+
 if _owner != None and _email != None:
 self.owner_email = encode(strip_text(_email))
 _name = _owner.find('name')
@@ -163,12 +172,12 @@ class Overlay(object):
 else:
 self.owner_email = ''
 self.owner_name = None
+msg = 'Overlay from_xml(), %(name)s is mising an '\
+  'owner.email entry!' % {'name': self.name}
 if not ignore:
-raise Exception('Overlay  from_xml(), ' + self.name + \
-' is missing an owner.email entry!')
+raise Exception(msg)
 elif ignore == 1:
-self.output.warn('Overlay ' + self.name + ' is missing a '
- 'owner.email entry!', 4)
+self.output.warn(msg, 4)
 
 _desc = xml.findall('description')
 if _desc != None:
@@ -178,12 +187,12 @@ class Overlay(object):
 self.descriptions.append(encode(d))
 else:
 self.descriptions = ['']
+msg = 'Overlay from_xml(), %(name)s is missing a '\
+  'description entry!' % {'name': self.name}
 if not ignore:
-raise Exception('Overlay  from_xml(), ' + self.name + \
-' is missing a description entry!')
+raise Exception(msg)
 elif ignore == 1:
-self.output.warn('Overlay ' + self.name + ' is missing a '
- 'description entry!', 4)
+self.output.warn(msg, 4)
 
 if 'status' in 

[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-03-26 Thread Devan Franchini
commit: f581549abe1d807c9d6d84d76978a08c8394ee3b
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu Mar 26 18:13:45 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Thu Mar 26 18:13:45 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=f581549a

overlay.py: Adds overlay source protocol filtering

 layman/overlays/overlay.py | 35 +--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 55ef8a8..59aa74b 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -69,6 +69,29 @@ class Overlay(object):
 self.from_dict(ovl_dict, ignore)
 
 
+def filter_protocols(self, sources, create_source_func):
+'''
+Filters any protocols not specified in self.config['protocol_order']
+from the overlay's sources.
+'''
+_sources = []
+if not 'protocol_order' in self.config.keys():
+return [create_source_func(e) for e in sources]
+
+for e in sources:
+source = create_source_func(e)
+for protocol in self.config['protocol_order']:
+protocol = protocol.lower()
+#re.search considers \+ as the literal +.
+if protocol == 'git+ssh':
+protocol = 'git\+ssh'
+protocol += '://'
+if re.search('^' + protocol, source.src):
+_sources.append(source)
+
+return _sources
+
+
 def from_xml(self, xml, ignore):
 Process an xml overlay definition
 
@@ -121,7 +144,7 @@ class Overlay(object):
 raise Exception('Overlay from_xml(), ' + self.name + \
 ' is missing a source entry!')
 
-self.sources = [create_overlay_source(e) for e in _sources]
+self.sources = self.filter_protocols(_sources, create_overlay_source)
 
 _owner = xml.find('owner')
 if _owner == None:
@@ -231,7 +254,7 @@ class Overlay(object):
 return _class(parent=self, config=self.config,
 _location=_location, ignore=ignore)
 
-self.sources = [create_dict_overlay_source(e) for e in _sources]
+self.sources = self.filter_protocols(_sources, 
create_dict_overlay_source)
 
 if 'owner_name' in overlay:
 _owner = overlay['owner_name']
@@ -379,6 +402,14 @@ class Overlay(object):
 def add(self, base):
 res = 1
 first_s = True
+
+if 'protocol_order' in self.config.keys() and not self.sources:
+msg = 'Overlay.add() error: overlay %s does not support any of'\
+  ' the given\nprotocols %s and cannot be installed.'\
+  % (self.name, str(self.config['protocol_order']))
+self.output.error(msg)
+return 1
+
 for s in self.sources:
 if not first_s:
 self.output.info(\nTrying next source of listed sources..., 
4)



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-03-26 Thread Devan Franchini
commit: e0f317c1e3443b8b43fe11033897624dbda83483
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu Mar 26 23:47:36 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Thu Mar 26 23:47:36 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=e0f317c1

overlay.py: Closes off interpolation tuple for error message in update()

 layman/overlays/overlay.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 2257373..fa728f6 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -435,7 +435,7 @@ class Overlay(object):
 if not self.sources or not available_srcs:
 msg = 'Overlay.update() error: overlay %s does not support the'\
   'given protocol(s) %s and cannot be updated.'\
-  % (self.name, str(self.config['protocol_order'])
+  % (self.name, str(self.config['protocol_order']))
 self.output.error(msg)
 return 1
 



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2015-03-26 Thread Devan Franchini
commit: a263463472cee1763e9e6abb915b015ee1de0cb7
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu Mar 26 23:06:25 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Thu Mar 26 23:06:27 2015 +
URL:https://gitweb.gentoo.org/proj/layman.git/commit/?id=a2634634

overlay.py: Modifies the implementation of filter_protocols

This modification allows for layman to only filter protocols
when running Overlay.add() and Overlay.update(), preventing
redundant code and checks along the way.

X-Gentoo-Bug: 542342
X-Gentoo-Bug-URL: https://bugs.gentoo.org/542342

 layman/overlays/overlay.py | 29 +++--
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 59aa74b..2257373 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -69,17 +69,16 @@ class Overlay(object):
 self.from_dict(ovl_dict, ignore)
 
 
-def filter_protocols(self, sources, create_source_func):
+def filter_protocols(self, sources):
 '''
 Filters any protocols not specified in self.config['protocol_order']
 from the overlay's sources.
 '''
 _sources = []
-if not 'protocol_order' in self.config.keys():
-return [create_source_func(e) for e in sources]
+if not self.config['protocol_order']:
+return sources
 
-for e in sources:
-source = create_source_func(e)
+for source in sources:
 for protocol in self.config['protocol_order']:
 protocol = protocol.lower()
 #re.search considers \+ as the literal +.
@@ -144,7 +143,7 @@ class Overlay(object):
 raise Exception('Overlay from_xml(), ' + self.name + \
 ' is missing a source entry!')
 
-self.sources = self.filter_protocols(_sources, create_overlay_source)
+self.sources = [create_overlay_source(e) for e in _sources]
 
 _owner = xml.find('owner')
 if _owner == None:
@@ -254,7 +253,7 @@ class Overlay(object):
 return _class(parent=self, config=self.config,
 _location=_location, ignore=ignore)
 
-self.sources = self.filter_protocols(_sources, 
create_dict_overlay_source)
+self.sources = [create_dict_overlay_source(e) for e in _sources]
 
 if 'owner_name' in overlay:
 _owner = overlay['owner_name']
@@ -403,9 +402,10 @@ class Overlay(object):
 res = 1
 first_s = True
 
-if 'protocol_order' in self.config.keys() and not self.sources:
-msg = 'Overlay.add() error: overlay %s does not support any of'\
-  ' the given\nprotocols %s and cannot be installed.'\
+self.sources = filter_protocols(self.sources)
+if not self.sources:
+msg = 'Overlay.add() error: overlay %s does not support the'\
+  ' given\nprotocol(s) %s and cannot be installed.'\
   % (self.name, str(self.config['protocol_order']))
 self.output.error(msg)
 return 1
@@ -430,6 +430,15 @@ class Overlay(object):
 first_src = True
 result = False
 
+self.sources = filter_protocols(self.sources)
+available_srcs = filter_protocols(available_srcs)
+if not self.sources or not available_srcs:
+msg = 'Overlay.update() error: overlay %s does not support the'\
+  'given protocol(s) %s and cannot be updated.'\
+  % (self.name, str(self.config['protocol_order'])
+self.output.error(msg)
+return 1
+
 if isinstance(available_srcs, str):
 available_srcs = [available_srcs]
 



[gentoo-commits] proj/layman:master commit in: layman/overlays/modules/bzr/, etc/, layman/overlays/modules/tar/, ...

2015-02-07 Thread Devan Franchini
commit: 33be1c1e3e55d17e601bbe1f30e08582b9419e5e
Author: Brian Dolbec dolsen AT gentoo DOT org
AuthorDate: Thu Feb  5 17:22:23 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Sat Feb  7 20:48:38 2015 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=33be1c1e

Pyflakes import and whitespace cleanup

---
 etc/layman.cfg |  2 +-
 layman/overlays/modules/bzr/bzr.py |  4 ++--
 layman/overlays/modules/cvs/cvs.py | 15 +++
 layman/overlays/modules/git/git.py |  4 +---
 layman/overlays/modules/mercurial/mercurial.py |  3 +--
 layman/overlays/modules/squashfs/squashfs.py   |  2 --
 layman/overlays/modules/svn/svn.py |  3 +--
 layman/overlays/modules/tar/tar.py |  1 -
 8 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/etc/layman.cfg b/etc/layman.cfg
index 2a8eabf..2aa7dd7 100644
--- a/etc/layman.cfg
+++ b/etc/layman.cfg
@@ -58,7 +58,7 @@ repos_conf : /etc/portage/repos.conf/layman.conf
 auto_sync : Yes
 
 #---
-# Repository config types used by layman 
+# Repository config types used by layman
 # (repos.conf, make.conf)
 
 conf_type : repos.conf

diff --git a/layman/overlays/modules/bzr/bzr.py 
b/layman/overlays/modules/bzr/bzr.py
index 03b0730..75163c6 100644
--- a/layman/overlays/modules/bzr/bzr.py
+++ b/layman/overlays/modules/bzr/bzr.py
@@ -58,7 +58,7 @@ class BzrOverlay(OverlaySource):
 if source.endswith(/):
 return source
 return source + '/'
-
+
 def add(self, base):
 '''Add overlay.'''
 
@@ -82,7 +82,7 @@ class BzrOverlay(OverlaySource):
 def update(self, base, src):
 '''
 Updates overlay src-url.
-
+
 @params base: base location where all overlays are installed.
 @params src: source URL.
 '''

diff --git a/layman/overlays/modules/cvs/cvs.py 
b/layman/overlays/modules/cvs/cvs.py
index 3dc6469..7c558ae 100644
--- a/layman/overlays/modules/cvs/cvs.py
+++ b/layman/overlays/modules/cvs/cvs.py
@@ -26,7 +26,6 @@ __version__ = $Id$
 #
 
#---
 
-import xml.etree.ElementTree as ET # Python 2.5
 import re
 
 from   layman.utils import path, run_command
@@ -78,16 +77,16 @@ class CvsOverlay(OverlaySource):
 def update(self, base, src):
 '''
 Updates overlay src-url.
-
+
 @params base: base location where all overlays are installed.
 @params src: source URL.
 '''
-
+
 if not self.supported():
 return 1
 
 target = path([base, self.parent.name])
-
+
 # First echo the new repository to CVS/Root
 args = [src, '', '/CVS/Root']
 result = run_command(self.config, 'echo', args, cmd='echo',
@@ -96,12 +95,12 @@ class CvsOverlay(OverlaySource):
 if result == 0:
 location = src.split(':')[3]
 old_location = self.src.split(':/')[3]
-
+
 # Check if the repository location needs to be updated too.
 if not location == old_location:
 location = re.sub('/', '\/', location)
 old_location = re.sub('/', '\/', old_location)
-
+
 expression = 's/' + old_location + '/' + location + '/'
 
 # sed -i 's/old_location/new_location/ 
target/CVS/Repository
@@ -110,8 +109,8 @@ class CvsOverlay(OverlaySource):
 return run_command(self.config, 'sed', args, cmd='sed',
cwd=target)
 
-return result
-
+return result
+
 
 def sync(self, base):
 '''Sync overlay.'''

diff --git a/layman/overlays/modules/git/git.py 
b/layman/overlays/modules/git/git.py
index 228c2af..341e4e6 100644
--- a/layman/overlays/modules/git/git.py
+++ b/layman/overlays/modules/git/git.py
@@ -26,8 +26,6 @@ __version__ = $Id: git.py 146 2006-05-27 09:52:36Z wrobel $
 #
 
#---
 
-import xml.etree.ElementTree as ET
-
 from   layman.utils import path, run_command
 from   layman.overlays.source   import OverlaySource, require_supported
 
@@ -110,7 +108,7 @@ class GitOverlay(OverlaySource):
 def update(self, base, src):
 '''
 Update overlay src-url
-
+
 @params base: base location where all overlays are installed.
 @params src:  source URL.
 '''

diff --git a/layman/overlays/modules/mercurial/mercurial.py 
b/layman/overlays/modules/mercurial/mercurial.py
index 0b5e7e5..b104936 100644
--- a/layman/overlays/modules/mercurial/mercurial.py
+++ b/layman/overlays/modules/mercurial/mercurial.py
@@ -28,7 +28,6 @@ __version__ = $Id: mercurial.py 236 2006-09-05 20:39:37Z 
wrobel $
 

[gentoo-commits] proj/layman:master commit in: layman/overlays/modules/mercurial/, layman/overlays/modules/cvs/, ...

2015-02-07 Thread Devan Franchini
commit: d3b710bbda6f523b1b1867bc4287e6ad52998389
Author: Brian Dolbec dolsen AT gentoo DOT org
AuthorDate: Thu Feb  5 17:20:32 2015 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Sat Feb  7 20:48:37 2015 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=d3b710bb

Split options for proper args passing

---
 etc/layman.cfg | 1 +
 layman/overlays/modules/bzr/bzr.py | 5 ++---
 layman/overlays/modules/cvs/cvs.py | 4 ++--
 layman/overlays/modules/darcs/darcs.py | 5 ++---
 layman/overlays/modules/git/git.py | 4 ++--
 layman/overlays/modules/mercurial/mercurial.py | 4 ++--
 layman/overlays/modules/rsync/rsync.py | 2 +-
 layman/overlays/modules/svn/svn.py | 4 ++--
 8 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/etc/layman.cfg b/etc/layman.cfg
index 7bf291e..2a8eabf 100644
--- a/etc/layman.cfg
+++ b/etc/layman.cfg
@@ -211,6 +211,7 @@ news_reporter: portage
 #
 # These commnad options will be added to the above commands
 # when the overlay is added or synced.
+# Use spaces to seperate command line arguments
 #
 #note: there are some options hardcoded in the backend
 #  scripts already.  All VCS types listed here are

diff --git a/layman/overlays/modules/bzr/bzr.py 
b/layman/overlays/modules/bzr/bzr.py
index 614f816..03b0730 100644
--- a/layman/overlays/modules/bzr/bzr.py
+++ b/layman/overlays/modules/bzr/bzr.py
@@ -72,8 +72,7 @@ class BzrOverlay(OverlaySource):
 
 # bzr get SOURCE TARGET
 if len(cfg_opts):
-args = ['branch', cfg_opts,
-src, target]
+args = ['branch'] + cfg_opts.split() + [src, target]
 else:
 args = ['branch', src, target]
 return self.postsync(
@@ -112,7 +111,7 @@ class BzrOverlay(OverlaySource):
 
 # bzr pull --overwrite SOURCE
 if len(cfg_opts):
-args = ['pull', cfg_opts, '--overwrite', self.src]
+args = ['pull'] + cfg_opts.split() + ['--overwrite', self.src]
 else:
 args = ['pull', '--overwrite', self.src]
 return self.postsync(

diff --git a/layman/overlays/modules/cvs/cvs.py 
b/layman/overlays/modules/cvs/cvs.py
index 62ad156..3dc6469 100644
--- a/layman/overlays/modules/cvs/cvs.py
+++ b/layman/overlays/modules/cvs/cvs.py
@@ -66,7 +66,7 @@ class CvsOverlay(OverlaySource):
 args.append('co')
 args.append('-d')
 if len(cfg_opts):
-args.append(cfg_opts)
+args.extend(cfg_opts.split())
 args.append(self.parent.name)
 args.append(self.branch)
 
@@ -129,7 +129,7 @@ class CvsOverlay(OverlaySource):
 args.append('update')
 args.append('-d')
 if len(cfg_opts):
-args.append(cfg_opts)
+args.extend(cfg_opts.split())
 return self.postsync(
 run_command(self.config, self.command(), args, cwd=target,
 cmd=self.type),

diff --git a/layman/overlays/modules/darcs/darcs.py 
b/layman/overlays/modules/darcs/darcs.py
index 9e951da..1960f8f 100644
--- a/layman/overlays/modules/darcs/darcs.py
+++ b/layman/overlays/modules/darcs/darcs.py
@@ -64,8 +64,7 @@ class DarcsOverlay(OverlaySource):
 
 # darcs get --partial SOURCE TARGET
 if len(cfg_opts):
-args = ['get', '--partial', cfg_opts,
-src, target]
+args = ['get', '--partial'] + cfg_opts.split() + [src, target]
 else:
 args = ['get', '--partial',
 src, target]
@@ -85,7 +84,7 @@ class DarcsOverlay(OverlaySource):
 
 # darcs pull --all SOURCE
 if len(cfg_opts):
-args = ['pull', '--all', cfg_opts, self.src]
+args = ['pull', '--all'] + cfg_opts.split() + [self.src]
 else:
 args = ['pull', '--all', self.src]
 return self.postsync(

diff --git a/layman/overlays/modules/git/git.py 
b/layman/overlays/modules/git/git.py
index f647139..228c2af 100644
--- a/layman/overlays/modules/git/git.py
+++ b/layman/overlays/modules/git/git.py
@@ -75,7 +75,7 @@ class GitOverlay(OverlaySource):
 if self.config['quiet']:
 args.append('-q')
 if len(cfg_opts):
-args.append(cfg_opts)
+args.extend(cfg_opts.split())
 args.append(self._fix_git_source(self.src))
 args.append(target)
 
@@ -137,7 +137,7 @@ class GitOverlay(OverlaySource):
 if self.config['quiet']:
 args.append('-q')
 if len(cfg_opts):
-args.append(cfg_opts)
+args.extend(cfg_opts.split())
 
 return self.postsync(
 run_command(self.config, self.command(), args, cwd=target,

diff --git a/layman/overlays/modules/mercurial/mercurial.py 
b/layman/overlays/modules/mercurial/mercurial.py
index fa32555..0b5e7e5 100644
--- 

[gentoo-commits] proj/layman:master commit in: layman/overlays/

2014-12-07 Thread Devan Franchini
commit: b6b75d3522151be7bb74c1f449f82f5a71250c4c
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Mon Dec  8 04:12:36 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Mon Dec  8 04:12:36 2014 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b6b75d35

archive.py: Adds kwargs-debug and modifies kwargs-info level to 5

---
 layman/overlays/archive.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/layman/overlays/archive.py b/layman/overlays/archive.py
index 5dca6a7..9963f04 100644
--- a/layman/overlays/archive.py
+++ b/layman/overlays/archive.py
@@ -50,7 +50,8 @@ class ArchiveOverlay(OverlaySource):
 connector_output = {
 'info': self.output.debug,
 'error': self.output.error,
-'kwargs-info': {'level': 2},
+'kwargs-info': {'level': 5},
+'kwargs-debug': {'level': 2},
 'kwargs-error': {'level': None},
 }
 



[gentoo-commits] proj/layman:master commit in: layman/overlays/modules/tar/

2014-09-28 Thread Devan Franchini
commit: 411135791c4194d61a815277a66f6e718b474814
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Sun Sep 28 19:59:11 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Sun Sep 28 19:59:11 2014 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=41113579

tar.py: fixes closing in iterable file extension list

---
 layman/overlays/modules/tar/tar.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/overlays/modules/tar/tar.py 
b/layman/overlays/modules/tar/tar.py
index ff6a9f0..9920dd8 100644
--- a/layman/overlays/modules/tar/tar.py
+++ b/layman/overlays/modules/tar/tar.py
@@ -60,7 +60,7 @@ class TarOverlay(ArchiveOverlay):
 @rtype str
 '''
 ext = '.tar.noidea'
-for i in [('tar.%s' % e) for e in FILE_EXTENSIONS[self.type]:
+for i in [('tar.%s' % e) for e in FILE_EXTENSIONS[self.type]]:
 candidate_ext = '.%s' % i
 if self.src.endswith(candidate_ext):
 ext = candidate_ext



[gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/overlays/modules/squashfs/, ...

2014-08-16 Thread Devan Franchini
commit: 0ac21e9def3acd529043f2e71799ca5330db1d6f
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Sun Aug 17 00:49:39 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Sun Aug 17 00:49:39 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=0ac21e9d

Moves archive.py to overlays

{squashfs, tar}.py: reflects moving of archive.py in dependencies.

---
 layman/overlays/{modules = }/archive.py | 0
 layman/overlays/modules/squashfs/squashfs.py | 8 
 layman/overlays/modules/tar/tar.py   | 8 
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/layman/overlays/modules/archive.py b/layman/overlays/archive.py
similarity index 100%
rename from layman/overlays/modules/archive.py
rename to layman/overlays/archive.py

diff --git a/layman/overlays/modules/squashfs/squashfs.py 
b/layman/overlays/modules/squashfs/squashfs.py
index d7307bd..48711ce 100644
--- a/layman/overlays/modules/squashfs/squashfs.py
+++ b/layman/overlays/modules/squashfs/squashfs.py
@@ -28,10 +28,10 @@ import os
 import shutil
 import sys
 
-from   layman.constantsimport FILE_EXTENSIONS
-from   layman.overlays.modules.archive import ArchiveOverlay
-from   layman.overlays.source  import require_supported
-from   layman.utilsimport path
+from   layman.constantsimport FILE_EXTENSIONS
+from   layman.overlays.archive import ArchiveOverlay
+from   layman.overlays.source  import require_supported
+from   layman.utilsimport path
 
 
#===
 #

diff --git a/layman/overlays/modules/tar/tar.py 
b/layman/overlays/modules/tar/tar.py
index 322b46c..ff6a9f0 100644
--- a/layman/overlays/modules/tar/tar.py
+++ b/layman/overlays/modules/tar/tar.py
@@ -28,10 +28,10 @@ __version__ = $Id: tar.py 310 2007-04-09 16:30:40Z wrobel 
$
 
 import sys
 
-from   layman.constantsimport FILE_EXTENSIONS
-from   layman.overlays.modules.archive import ArchiveOverlay
-from   layman.overlays.source  import require_supported
-from   layman.utilsimport run_command
+from   layman.constantsimport FILE_EXTENSIONS
+from   layman.overlays.archive import ArchiveOverlay
+from   layman.overlays.source  import require_supported
+from   layman.utilsimport run_command
 
 
#===
 #



[gentoo-commits] proj/layman:master commit in: layman/overlays/modules/squashfs/

2014-08-16 Thread Devan Franchini
commit: 8919396d5a73548a1720355bbcebab4efd9fa400
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Sun Aug 17 01:43:38 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Sun Aug 17 01:43:38 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=8919396d

squashfs.py: forces is_supported() to return True

---
 layman/overlays/modules/squashfs/squashfs.py | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/layman/overlays/modules/squashfs/squashfs.py 
b/layman/overlays/modules/squashfs/squashfs.py
index 48711ce..912bd62 100644
--- a/layman/overlays/modules/squashfs/squashfs.py
+++ b/layman/overlays/modules/squashfs/squashfs.py
@@ -131,10 +131,7 @@ class SquashfsOverlay(ArchiveOverlay):
 
 @rtype bool
 '''
-return require_supported(
-[(self.command(),  'squashfs', 'sys-fs/squashfs-tools'), ],
-self.output.warn)
-
+return True
 
 if __name__ == '__main__':
 import doctest



[gentoo-commits] proj/layman:master commit in: layman/overlays/modules/svn/

2014-08-16 Thread Devan Franchini
commit: 0b8c98934c9c1c1baf07fb56aad6e5c4fc9f3168
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Sun Aug 17 03:58:08 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Sun Aug 17 03:58:08 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=0b8c9893

svn.py: decodes stdout output if applicable

Fixes commit: f1db156a7d11e0bfb8d7b6a19f066c5d0b0fba5d
Thanks to Arfrever for his assistance in optimizing the code.

---
 layman/overlays/modules/svn/svn.py | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/layman/overlays/modules/svn/svn.py 
b/layman/overlays/modules/svn/svn.py
index 51bb487..586a9dc 100644
--- a/layman/overlays/modules/svn/svn.py
+++ b/layman/overlays/modules/svn/svn.py
@@ -22,6 +22,7 @@ __version__ = $Id: svn.py 236 2006-09-05 20:39:37Z wrobel $
 
 
 import os
+import sys
 from subprocess import PIPE, Popen
 
 #==
@@ -166,13 +167,18 @@ class SvnOverlay(OverlaySource):
 '''
 file_to_run = resolve_command(self.command(), self.output.error)[1]
 args =  .join([file_to_run,  upgrade, target])
-stdout, stderr = Popen(args, shell=True, stdout=PIPE, 
stderr=PIPE).communicate()
-if stdout:
-self.output.debug(SVN: check_upgrade()... have a valid pipe, 
-running upgrade, 4)
-upgrade_output = stdout.readline().split('\n')
-if upgrade_output:
-self.output.debug(  output: %s % upgrade_output, 4)
-self.output.debug(SVN: check_upgrade()... svn upgrade done, 4)
-stdout.terminate()
+pipe = Popen(args, shell=True, stdout=PIPE, stderr=PIPE)
+stdout = pipe.stdout.read()
+self.output.debug(SVN: check_upgrade()... running svn upgrade, 4)
+
+if sys.hexversion = 0x300:
+stdout = stdout.decode('UTF-8')
+
+upgrade_output = stdout.strip('\n')
+if upgrade_output:
+self.output.debug(  output: %r % upgrade_output, 4)
+self.output.debug(SVN: check_upgrade()... svn upgrade done, 4)
+pipe.terminate()
+pipe.stdout.close()
+pipe.stderr.close()
 return



[gentoo-commits] proj/layman:master commit in: layman/overlays/

2014-03-09 Thread Brian Dolbec
commit: 8f96019f53b570163ddcf21595fedca42bf4
Author: Brian Dolbec dolsen AT gentoo DOT org
AuthorDate: Tue Jan  7 06:01:12 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Mon Mar 10 03:16:58 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=8f96019f

Update svn's check_upgrade() for newer svn versions.

Add stderr=PIPE to silence any error messages from less than svn ver. 1.8.

zzzd

---
 layman/overlays/svn.py | 34 +-
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 4804925..20c09fb 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -131,27 +131,19 @@ class SvnOverlay(OverlaySource):
 return
 
 def check_upgrade(self, target):
-'''Code to check the installed svn version and
-run svn upgrade if needed.'''
+'''Code to run svn upgrade it only takes longer
+than checking if it does need an upgrade if it is
+actually needed.
+'''
 file_to_run = _resolve_command(self.command(), self.output.error)[1]
-args = file_to_run + ' -q --version'
-pipe = Popen(args, shell=True, stdout=PIPE)
+args =  .join([file_to_run,  upgrade, target])
+pipe = Popen(args, shell=True, stdout=PIPE, stderr=PIPE)
 if pipe:
-self.output.debug(SVN: check_upgrade()... have a valid pipe, 4)
-version = pipe.stdout.readline().strip('\n')
-self.output.debug(SVN: check_upgrade()... svn version found: %s
-% version, 4)
+self.output.debug(SVN: check_upgrade()... have a valid pipe, 
+running upgrade, 4)
+upgrade_output = pipe.stdout.readline().strip('\n')
+if upgrade_output:
+self.output.debug(  output: %s % upgrade_output, 4)
+self.output.debug(SVN: check_upgrade()... svn upgrade done, 4)
 pipe.terminate()
-if version = '1.7.0':
-self.output.debug(SVN: check_upgrade()... svn upgrade maybe,
-4)
-_path = path([target,'.svn/wc.db'])
-if not os.path.exists(_path):
-self.output.info(An svn upgrade needs to be run...,
-2)
-args = [upgrade]
-return self.run_command(self.command(), args,
-cwd=target, cmd=svn upgrade)
-return
-else:
-return
+return