* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-06-25 22:23 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-06-25 22:23 UTC (permalink / raw
To: gentoo-commits
commit: d79c036afe5ca03db247f66c83da760722a5ccf7
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Jun 25 16:30:54 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Jun 25 16:30:54 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=d79c036a
Add class to work with license groups
---
.../generic_metadata/license_groups.py | 68 ++++++++++++++++++-
1 files changed, 64 insertions(+), 4 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/license_groups.py b/gpackages/libs/package_info/generic_metadata/license_groups.py
index e30eb81..dc86f1b 100644
--- a/gpackages/libs/package_info/generic_metadata/license_groups.py
+++ b/gpackages/libs/package_info/generic_metadata/license_groups.py
@@ -1,5 +1,7 @@
from collections import defaultdict
-from ..generic import file_get_content, StrThatIgnoreCase
+from ..generic import file_get_content, StrThatIgnoreCase, ToStrMixin
+
+DEFAULT_FILE_PATH = '/usr/portage/profiles/license_groups'
def first_and_other(lst):
return (lst[0], lst[1:]) if len(lst) > 0 else (None, [])
@@ -36,11 +38,69 @@ def parse_groups(groups_str):
return lic_dct
-
-def load_groups(file_path = '/usr/portage/profiles/license_groups'):
+def load_groups(file_path = DEFAULT_FILE_PATH):
+ """Load file profiles/license_groups and represend it as dict
+ Args:
+ file_path -- full path to license_groups file, by default it
+ /usr/portage/profiles/license_groups
+ Returns:
+ dict with license group as key and set of licenses as value
+ Example:
+ {u'EULA': set([u'cadsoft', ...]), u'GPL-COMPATIBLE': set([...]), ...}
+ """
fc = file_get_content(file_path)
if fc is None:
- return []
+ return {}
return parse_groups(fc)
+
+
+class LicenseGroups(ToStrMixin):
+
+ def __init__(self, file_path = DEFAULT_FILE_PATH):
+ """Args:
+ file_path -- full path to license_groups file, by default it
+ /usr/portage/profiles/license_groups
+ """
+ self.groups_path = file_path
+ self.groups_dict = load_groups(file_path)
+ self.reverse_group_dict = self.gen_reverse_dict()
+
+ def gen_reverse_dict(self):
+ temp_dict = defaultdict(set)
+ for group, licenses in self.groups_dict.iteritems():
+ for lic in licenses:
+ temp_dict[lic].add(group)
+
+ return temp_dict
+
+ def get_licenses_by_group(self, group_name):
+ """Args:
+ group_name -- License group name
+
+ Returns:
+ return set of licenses that belong to group_name
+
+ Example:
+ get_licenses_by_group('OSI-APPROVED') -> set([u'AFL-3.0', ...])
+ """
+
+ return self.groups_dict[group_name]
+
+ def get_groups_by_license(self, license_name):
+ """Args:
+ license_name -- License name
+
+ Returns:
+ return set of license groups that belong to license
+
+ Example:
+ get_groups_by_license('GPL-1') -> set([u'FREE', ...])
+ """
+ return self.reverse_group_dict[license_name]
+
+
+ def __unicode__(self):
+ return unicode(self.groups_path)
+
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-06-25 22:23 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-06-25 22:23 UTC (permalink / raw
To: gentoo-commits
commit: 9fa3ac5f761b7f76be304f5b72304ac2e899ccb4
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Jun 25 21:23:20 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Jun 25 21:23:20 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=9fa3ac5f
Add default repo info
---
.../package_info/generic_metadata/repo_info.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/repo_info.py b/gpackages/libs/package_info/generic_metadata/repo_info.py
index 4d6a273..9316f34 100644
--- a/gpackages/libs/package_info/generic_metadata/repo_info.py
+++ b/gpackages/libs/package_info/generic_metadata/repo_info.py
@@ -32,7 +32,6 @@ class Enum(object):
def get_as_tuple(self):
return tuple([(num, item) for num, item in enumerate(self.list)])
-
REPO_TYPE = ( 'git',
'g-common',
'cvs' ,
@@ -46,7 +45,6 @@ REPO_TYPE = ( 'git',
REPOS_TYPE = Enum(REPO_TYPE)
-
@total_ordering
class SourcesObject(ToStrMixin):
@@ -130,6 +128,10 @@ class TreeMetadata(ToStrMixin):
elif repo_name is None:
return {'name': 'none',
'description': None,
+ 'quality': 'experimental',
+ 'official': False,
+ 'feeds': [],
+ 'sources': [],
}
else:
return layman_api.get_all_info(repo_name)[repo_name]
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-06-25 22:23 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-06-25 22:23 UTC (permalink / raw
To: gentoo-commits
commit: b1ca10a9ac31b5a0a99a26780b2a293a8a315790
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Jun 25 21:45:19 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Jun 25 21:45:19 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=b1ca10a9
Add docstrings to repo_info file
---
.../package_info/generic_metadata/repo_info.py | 21 ++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/repo_info.py b/gpackages/libs/package_info/generic_metadata/repo_info.py
index 9316f34..d9ba513 100644
--- a/gpackages/libs/package_info/generic_metadata/repo_info.py
+++ b/gpackages/libs/package_info/generic_metadata/repo_info.py
@@ -17,8 +17,11 @@ def _gen_funct(name):
return func
class Enum(object):
+ "Enum object"
def __init__(self, lst):
+ """Args:
+ lst -- list of strings"""
dct = {}
dct2 = {}
self.list = lst
@@ -30,6 +33,7 @@ class Enum(object):
self.num_dict = dct2
def get_as_tuple(self):
+ "Return tuple to use as choices in django model"
return tuple([(num, item) for num, item in enumerate(self.list)])
REPO_TYPE = ( 'git',
@@ -47,8 +51,12 @@ REPOS_TYPE = Enum(REPO_TYPE)
@total_ordering
class SourcesObject(ToStrMixin):
+ "Represent source of repository"
def __init__(self, source_tuple):
+ """Args:
+ source_tuple -- tuple (source_url, source_type, source_subpath)
+ """
self.source_url = source_tuple[0].lower()
self.source_type = REPOS_TYPE.repo_dict[source_tuple[1].lower()]
self.source_subpath = source_tuple[2]
@@ -70,6 +78,8 @@ class SourcesObject(ToStrMixin):
return self.source_url
class TreeMetadataMetaclass(type):
+ """Dynamicaly add properties by `simple_attrs` tuple
+ It gets this name from `_dct` dict in object"""
def __init__(cls, name, bases, dct):
super(TreeMetadataMetaclass, cls).__init__(name, bases, dct)
@@ -77,6 +87,7 @@ class TreeMetadataMetaclass(type):
setattr(cls, v, property(_gen_funct(v)))
class TreeMetadata(ToStrMixin):
+ "Represent metadata information about portage tree (overlay)"
__metaclass__ = TreeMetadataMetaclass
simple_attrs = ( 'name', 'description', 'supported', 'owner_name',
@@ -86,6 +97,10 @@ class TreeMetadata(ToStrMixin):
qualities = {'stable': 0 , 'testing': 1, 'experimental': 2}
def __init__(self, repo_name, dct = None):
+ """Args:
+ repo_name -- repository name
+ dct -- dict of params, could be None that it will be calculated
+ """
repo_name = self._find_real_repo_name(repo_name)
self.repo_name = repo_name
@@ -138,10 +153,12 @@ class TreeMetadata(ToStrMixin):
@property
def int_status(self):
+ "Return repostory status as int, int values a keys in `statuses`"
return self.statuses.get(self._dct['status'], 1)
@cached_property
def homepage(self):
+ "Return valid str homepage"
homepage = self._dct.get('homepage')
try:
validate_url(homepage)
@@ -152,6 +169,7 @@ class TreeMetadata(ToStrMixin):
@cached_property
def owner_email(self):
+ "Return valid str owner email"
email = self._dct.get('owner_email')
try:
validate_email(email)
@@ -162,6 +180,7 @@ class TreeMetadata(ToStrMixin):
@cached_property
def feeds(self):
+ "Return validated list of feeds"
ret = set()
for feed in self._dct.get('feeds', ()):
try:
@@ -174,6 +193,7 @@ class TreeMetadata(ToStrMixin):
@cached_property
def sources(self):
+ "Return list of `SourcesObject`s"
ret = set()
for source in self._dct['sources']:
ret.add(SourcesObject(source))
@@ -181,6 +201,7 @@ class TreeMetadata(ToStrMixin):
@property
def int_quality(self):
+ "Return repostory quality as int, int values a keys in `qualities`"
return self.qualities.get(self._dct['quality'], 2)
def __unicode__(self):
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-04 22:13 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-04 22:13 UTC (permalink / raw
To: gentoo-commits
commit: 84e75d1c5ee79991dbf48df7246fe3b95f89a563
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jul 3 22:59:34 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jul 3 22:59:34 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=84e75d1c
Fix bug in news metadata
---
.../libs/package_info/generic_metadata/news.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/news.py b/gpackages/libs/package_info/generic_metadata/news.py
index d84ac6b..a4f367d 100644
--- a/gpackages/libs/package_info/generic_metadata/news.py
+++ b/gpackages/libs/package_info/generic_metadata/news.py
@@ -60,7 +60,7 @@ class NewsItem(ToStrMixin):
self._fetch_news()
def _iter_news_items(self):
- pattern_str = self.N_ITEM_P % {'name': self.name}
+ pattern_str = self.N_ITEM_P % {'name': re.escape(self.name)}
pattern = re.compile(pattern_str)
for item in os.listdir(self.news_dir):
m = pattern.match(item)
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-04 22:13 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-04 22:13 UTC (permalink / raw
To: gentoo-commits
commit: 3f399ea32f38d1349f987aa4914dc5be8403b0b6
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jul 4 08:03:22 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jul 4 08:18:14 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=3f399ea3
Add "display if" to portage news
---
.../libs/package_info/generic_metadata/news.py | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/news.py b/gpackages/libs/package_info/generic_metadata/news.py
index 9e4e6fa..6f63da6 100644
--- a/gpackages/libs/package_info/generic_metadata/news.py
+++ b/gpackages/libs/package_info/generic_metadata/news.py
@@ -135,3 +135,14 @@ class NewsItemLang(AbstractNewsItem):
def message(self):
return self._mes_obj.get_payload()
+ @property
+ def if_installed(self):
+ return tuple(set(self._mes_obj.get_all('Display-If-Installed')))
+
+ @property
+ def if_keyword(self):
+ return tuple(set(self._mes_obj.get_all('Display-If-Keyword')))
+
+ @property
+ def if_profile(self):
+ return tuple(set(self._mes_obj.get_all('Display-If-Profile')))
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-12 22:16 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-12 22:16 UTC (permalink / raw
To: gentoo-commits
commit: f07f433029b2751bae0e6ac824af59a652a9b5be
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jul 11 22:26:21 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jul 11 22:26:21 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=f07f4330
Try detect date for corrupted date in changelog
---
.../generic_metadata/changelog_parse.py | 48 +++++++++++++++++--
1 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_parse.py b/gpackages/libs/package_info/generic_metadata/changelog_parse.py
index 9d213f1..0f638c4 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_parse.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_parse.py
@@ -1,8 +1,10 @@
import re
-from ..generic import ToStrMixin
+from ..generic import ToStrMixin, toint
from ..parse_cp import VERSIONS_RE_P, EbuildRevMixin
from ..validators import NAME_RE
-from datetime import datetime
+from datetime import datetime, date, MINYEAR
+import calendar
+from difflib import get_close_matches
DATE_FORMAT = '%d %b %Y'
@@ -28,9 +30,43 @@ changelog_m_re = re.compile(CHANGELOG_MESSAGE_RE_STR, re.S)
changelog_v_re = re.compile(CHANGELOG_VERSION_RE_STR)
clear_re = re.compile(r'\s+')
email_re = re.compile(r'(?P<email_name>[\w\.\-]+)@(?P<email_host>[\w\.\-]+)')
-
-def parse_date(date_str):
- return datetime.strptime(date_str, DATE_FORMAT).date()
+date_re = re.compile(CHANGELOG_DATE_RE_P)
+
+MONTH_TUPLE = tuple(calendar.month_abbr)[1:]
+
+def parse_date(date_str, traceback = False):
+ try:
+ mdate = datetime.strptime(date_str, DATE_FORMAT).date()
+ except ValueError:
+ if traceback:
+ raise
+ # Bad date format, humman error
+ # Add here logger
+ mdate = date.min
+ m = date_re.match(date_str)
+ if m is not None:
+ dct = m.groupdict()
+ day = dct['day']
+ month = dct['month']
+ year = dct['year']
+ if month not in MONTH_TUPLE:
+ months = get_close_matches(month, MONTH_TUPLE, 1)
+ if len(months) >=1:
+ month = months[0]
+ else:
+ month = MONTH_TUPLE[0]
+
+ month_num = MONTH_TUPLE.index(month) + 1
+ year_num = toint(year, MINYEAR)
+ day_num = toint(day, 1)
+ try:
+ mdate = date(year_num, month_num, day_num)
+ except ValueError:
+ mdate = date.min
+
+ return mdate
+
+ return mdate.date()
def date_str(date):
return date.strftime(DATE_FORMAT)
@@ -95,6 +131,8 @@ class ChangeLogMessage(ToStrMixin):
return self.header
def parse_changelog(changelog):
+ if not changelog:
+ raise StopIteration
lst = changelog.split("\n\n")
for item in lst:
if item.startswith('*'):
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-12 22:16 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-12 22:16 UTC (permalink / raw
To: gentoo-commits
commit: 509564ddef032fb11147fd96b68f63e5a402e43e
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jul 11 21:22:52 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jul 11 21:22:52 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=509564dd
Add changelog parser
---
.../generic_metadata/changelog_parse.py | 125 ++++++++++++++++++++
1 files changed, 125 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_parse.py b/gpackages/libs/package_info/generic_metadata/changelog_parse.py
new file mode 100644
index 0000000..9d213f1
--- /dev/null
+++ b/gpackages/libs/package_info/generic_metadata/changelog_parse.py
@@ -0,0 +1,125 @@
+import re
+from ..generic import ToStrMixin
+from ..parse_cp import VERSIONS_RE_P, EbuildRevMixin
+from ..validators import NAME_RE
+from datetime import datetime
+
+DATE_FORMAT = '%d %b %Y'
+
+CHANGELOG_DATE_RE_P = r"(?P<date>(?P<day>\d\d) " \
+ r"(?P<month>[A-Z][a-z]{2}) (?P<year>\d{4}))"
+
+CHANGELOG_MESSAGE_RE_STR = r"^\s+%(date)s; " \
+ r"(?:(?P<name>[^\<]+) )?\<(?P<email>[\w\@\.\-]+)\>" \
+ r"(?P<files>.*):(?P<message>.*)$" % {
+ 'date' : CHANGELOG_DATE_RE_P
+ }
+
+FULL_NAME_RE_STR = r"(?P<name>%(name)s)%(versions)s" % {
+ 'name' : NAME_RE,
+ 'versions' : VERSIONS_RE_P
+ }
+
+CHANGELOG_VERSION_RE_STR = "^\*%(name)s \(%(date)s\)$" % {
+ 'name' : FULL_NAME_RE_STR,
+ 'date' : CHANGELOG_DATE_RE_P
+ }
+changelog_m_re = re.compile(CHANGELOG_MESSAGE_RE_STR, re.S)
+changelog_v_re = re.compile(CHANGELOG_VERSION_RE_STR)
+clear_re = re.compile(r'\s+')
+email_re = re.compile(r'(?P<email_name>[\w\.\-]+)@(?P<email_host>[\w\.\-]+)')
+
+def parse_date(date_str):
+ return datetime.strptime(date_str, DATE_FORMAT).date()
+
+def date_str(date):
+ return date.strftime(DATE_FORMAT)
+
+def clear_spaces(text):
+ return clear_re.sub(' ', text)
+
+class ChangeLogVersion(ToStrMixin, EbuildRevMixin):
+
+ __slots__ = ('date', 'name', 'version', 'revision', '_cache')
+
+ def __init__(self, version_dict):
+ self.date = parse_date(version_dict['date'])
+ self.name = version_dict['name']
+ self.version = version_dict['version']
+ self.revision = version_dict['revision']
+
+ @property
+ def fullversion(self):
+ prefix = '-' + self.revision if self.revision else ''
+ return '%s%s' % (self.version, prefix)
+
+ @property
+ def fullname(self):
+ return '%s-%s' % (self.name, self.fullversion)
+
+ @property
+ def date_str(self):
+ return date_str(self.date)
+
+ def __unicode__(self):
+ return '%s (%s)' % (self.fullname, self.date_str)
+
+class ChangeLogMessage(ToStrMixin):
+
+ def __init__(self, message_dict):
+ self.date = parse_date(message_dict['date'])
+ self.email = message_dict['email'].strip()
+ name = message_dict['name']
+ if name:
+ name = name.decode('utf-8')
+ self.name = name.strip()
+ else:
+ self.name = None
+ self.files = map(lambda x: x.strip(), message_dict['files'].split(','))
+ self.message = clear_spaces(message_dict['message'])
+
+ @property
+ def date_str(self):
+ return date_str(self.date)
+
+ @property
+ def fullname(self):
+ name = self.name + ' ' if self.name else ''
+ return '%s<%s>' % (name, self.email)
+
+ @property
+ def header(self):
+ return '%s; %s' % (self.date_str, self.fullname)
+
+ def __unicode__(self):
+ return self.header
+
+def parse_changelog(changelog):
+ lst = changelog.split("\n\n")
+ for item in lst:
+ if item.startswith('*'):
+ for sitem in item.split('\n'):
+ v = changelog_v_re.match(item)
+ if v is not None:
+ yield ('version', v.groupdict())
+ continue
+ m = changelog_m_re.match(item)
+ if m is not None:
+ yield ('message', m.groupdict())
+ else:
+ yield ('comment', item)
+
+class ChangeLog(ToStrMixin):
+
+ def __init__(self, changelog_text):
+ self.items = []
+ for t, v in parse_changelog(changelog_text):
+ if t == 'version':
+ v = ChangeLogVersion(v)
+ elif t == 'message':
+ v = ChangeLogMessage(v)
+
+ self.items.append(v)
+
+ def __unicode__(self):
+ return 'changelog'
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-18 23:03 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-18 23:03 UTC (permalink / raw
To: gentoo-commits
commit: 4d5f86d2d9b6470c74793bfc7ef5d17368b679fb
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jul 18 19:47:44 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jul 18 19:47:44 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=4d5f86d2
Add notice
---
.../generic_metadata/changelog_parse.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_parse.py b/gpackages/libs/package_info/generic_metadata/changelog_parse.py
index 0f638c4..7d2c17f 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_parse.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_parse.py
@@ -32,6 +32,9 @@ clear_re = re.compile(r'\s+')
email_re = re.compile(r'(?P<email_name>[\w\.\-]+)@(?P<email_host>[\w\.\-]+)')
date_re = re.compile(CHANGELOG_DATE_RE_P)
+# Warning !!!
+# For working this part code correctly locale should be right switched
+# May be change localte manualy ?
MONTH_TUPLE = tuple(calendar.month_abbr)[1:]
def parse_date(date_str, traceback = False):
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-22 23:46 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-22 23:46 UTC (permalink / raw
To: gentoo-commits
commit: 83e33538e191185c4f35b77599950744c2de3b64
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jul 22 15:15:04 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jul 22 15:15:04 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=83e33538
Base changelog lexer
---
.../generic_metadata/changelog_highlight.py | 48 ++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
new file mode 100644
index 0000000..30494ce
--- /dev/null
+++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
@@ -0,0 +1,48 @@
+from pygments.lexer import RegexLexer, bygroups
+from pygments.token import *
+
+DATE_RE = r'\d\d [A-Z][a-z]{2} \d{4}'
+EMAIL_RE = r'[\w\.\-]+@(?:\w+\.)+\w+'
+
+# Literal.Date
+
+class ChangelogLexer(RegexLexer):
+ name = 'Changelog'
+ aliases = ['changelog']
+ filenames = ['Changelog']
+
+ tokens = {
+ 'root': [
+ (r'^# .*\n', Comment.Single), # Comment
+ (r'^(\*)(.+)( )(\()(%s)(\))' % DATE_RE, bygroups(Operator, String, Name, Punctuation, Keyword, Punctuation)),
+ #(r'^ ' , Whitespace, 'main'),
+ (r'^( )(%(date)s)(;)( +)([^<]*)(<)(%(email)s)(>)' % {'date': DATE_RE, 'email': EMAIL_RE},
+ bygroups(Whitespace, Keyword, Punctuation, Whitespace, Name.Variable, Punctuation, Number, Number ), 'main'), # Date
+ (EMAIL_RE, Number),
+ ],
+ 'main': [
+ (r' *\n\n', Punctuation, '#pop'),
+ (DATE_RE, Keyword), # Date
+ (EMAIL_RE, Number), # email
+ (r'(,| | )(\+[\w\.\-\+\/]+)', bygroups(Punctuation, Generic.Inserted)),
+ (r'(,| | )(\-[\w\.\-\+\/]+)', bygroups(Punctuation, Generic.Deleted)),
+ (r'(,| | )(\w[\w\.\-\+\/]+)', bygroups(Punctuation, Operator.Word)),
+ (r':( +|\n)', Punctuation, 'message'),
+ (r';|<|>|,', Punctuation),
+ (r' |\n', Whitespace),
+ ],
+ 'message': [
+ (r' *\n', Punctuation, '#pop:2'),
+ #(r'#\d+', String),
+ (r' ', Whitespace, 'message_text'),
+ ],
+ 'message_text': [
+ (r' *\n', Whitespace, '#pop'),
+ (r'(?i)bug #\d+', String),
+ (r'#\d+', String),
+ (r'(?i)bug \d+', String),
+ (r'\(|\)', Punctuation),
+ (r'[^#\n ]+', Generic),
+ (r' +', Whitespace),
+ ]
+ }
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-22 23:46 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-22 23:46 UTC (permalink / raw
To: gentoo-commits
commit: caa73b515a572f5f31102cfe52225724e4828c61
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jul 22 18:45:47 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jul 22 19:18:20 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=caa73b51
Lexer find bugs and keywords
---
.../generic_metadata/changelog_highlight.py | 46 ++++++++++++++-----
1 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
index 30494ce..ffd118f 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
@@ -1,11 +1,32 @@
from pygments.lexer import RegexLexer, bygroups
from pygments.token import *
+import re
DATE_RE = r'\d\d [A-Z][a-z]{2} \d{4}'
EMAIL_RE = r'[\w\.\-]+@(?:\w+\.)+\w+'
+ARCHES = [ u'alpha', u'amd64', u'amd64-fbsd', u'amd64-linux', u'arm',
+ u'arm-linux', u'hppa', u'hppa-hpux', u'ia64', u'ia64-hpux',
+ u'ia64-linux', u'm68k', u'm68k-mint', u'mips', u'ppc', u'ppc-aix',
+ u'ppc-macos', u'ppc-openbsd', u'ppc64', u's390', u'sh', u'sparc',
+ u'sparc-fbsd', u'sparc-solaris', u'sparc64-solaris', u'x64-freebsd',
+ u'x64-macos', u'x64-openbsd', u'x64-solaris', u'x86', u'x86-fbsd',
+ u'x86-freebsd', u'x86-interix', u'x86-linux', u'x86-macos',
+ u'x86-netbsd', u'x86-openbsd', u'x86-solaris', u'x86-winnt' ]
+
+KEYWORD_RE = r'[-~]?(?:%s)' % '|'.join(map(re.escape, ARCHES))
+
# Literal.Date
+Date = Literal.Date
+PackageName = Name.Namespace
+FilePlus = Generic.Inserted
+FileMinus = Generic.Deleted
+File = Operator.Word
+Email = Number
+AuthorName = Name.Variable
+Bug = String
+
class ChangelogLexer(RegexLexer):
name = 'Changelog'
aliases = ['changelog']
@@ -14,19 +35,18 @@ class ChangelogLexer(RegexLexer):
tokens = {
'root': [
(r'^# .*\n', Comment.Single), # Comment
- (r'^(\*)(.+)( )(\()(%s)(\))' % DATE_RE, bygroups(Operator, String, Name, Punctuation, Keyword, Punctuation)),
+ (r'^(\*)(.+)( )(\()(%s)(\))' % DATE_RE, bygroups(Operator, PackageName, Whitespace, Punctuation, Date, Punctuation)),
#(r'^ ' , Whitespace, 'main'),
(r'^( )(%(date)s)(;)( +)([^<]*)(<)(%(email)s)(>)' % {'date': DATE_RE, 'email': EMAIL_RE},
- bygroups(Whitespace, Keyword, Punctuation, Whitespace, Name.Variable, Punctuation, Number, Number ), 'main'), # Date
- (EMAIL_RE, Number),
+ bygroups(Whitespace, Date, Punctuation, Whitespace, AuthorName, Punctuation, Number, Punctuation), 'main'), # Date
+ (EMAIL_RE, Email),
],
'main': [
(r' *\n\n', Punctuation, '#pop'),
- (DATE_RE, Keyword), # Date
- (EMAIL_RE, Number), # email
- (r'(,| | )(\+[\w\.\-\+\/]+)', bygroups(Punctuation, Generic.Inserted)),
- (r'(,| | )(\-[\w\.\-\+\/]+)', bygroups(Punctuation, Generic.Deleted)),
- (r'(,| | )(\w[\w\.\-\+\/]+)', bygroups(Punctuation, Operator.Word)),
+ (EMAIL_RE, Email),
+ (r'(,| | )(\+[\w\.\-\+\/]+)', bygroups(Punctuation, FilePlus)),
+ (r'(,| | )(\-[\w\.\-\+\/]+)', bygroups(Punctuation, FileMinus)),
+ (r'(,| | )(\w[\w\.\-\+\/]+)', bygroups(Punctuation, File)),
(r':( +|\n)', Punctuation, 'message'),
(r';|<|>|,', Punctuation),
(r' |\n', Whitespace),
@@ -38,10 +58,12 @@ class ChangelogLexer(RegexLexer):
],
'message_text': [
(r' *\n', Whitespace, '#pop'),
- (r'(?i)bug #\d+', String),
- (r'#\d+', String),
- (r'(?i)bug \d+', String),
- (r'\(|\)', Punctuation),
+ (r'(?i)bug #\d+', Bug),
+ (r'#\d+', Bug),
+ (r'(?i)bug \d+', Bug),
+ (r'\(|\)|<|>', Punctuation),
+ (EMAIL_RE, Email),
+ #(KEYWORD_RE, Name.Variable),
(r'[^#\n ]+', Generic),
(r' +', Whitespace),
]
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-22 23:46 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-22 23:46 UTC (permalink / raw
To: gentoo-commits
commit: 8fab4fd9cc595500be935386ccc6cc7fc6216760
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jul 22 20:42:12 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jul 22 20:42:12 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=8fab4fd9
Add style for changelog highlight
---
.../generic_metadata/changelog_highlight.py | 78 ++++++++++++++++++++
1 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
index ffd118f..8dc8a37 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
@@ -1,4 +1,7 @@
from pygments.lexer import RegexLexer, bygroups
+from pygments.formatters import HtmlFormatter
+from pygments.formatters.html import _escape_html_table
+from pygments.style import Style
from pygments.token import *
import re
@@ -68,3 +71,78 @@ class ChangelogLexer(RegexLexer):
(r' +', Whitespace),
]
}
+
+class ChangelogHtmlFormater(HtmlFormatter):
+ def _format_lines(self, tokensource):
+ """
+ Copyed from pygments source litle modified.
+ """
+ nocls = self.noclasses
+ lsep = self.lineseparator
+ # for <span style=""> lookup only
+ getcls = self.ttype2class.get
+ c2s = self.class2style
+ escape_table = _escape_html_table
+
+ lspan = ''
+ line = ''
+ for ttype, value in tokensource:
+ if nocls:
+ cclass = getcls(ttype)
+ while cclass is None:
+ ttype = ttype.parent
+ cclass = getcls(ttype)
+ cspan = cclass and '<span style="%s">' % c2s[cclass][0] or ''
+ else:
+ cls = self._get_css_class(ttype)
+ cspan = cls and '<span class="%s">' % cls or ''
+
+ parts = value.translate(escape_table).split('\n')
+
+ # for all but the last line
+ for part in parts[:-1]:
+ part = self.token_decorate(ttype, part)
+ if line:
+ if lspan != cspan:
+ line += (lspan and '</span>') + cspan + part + \
+ (cspan and '</span>') + lsep
+ else: # both are the same
+ line += part + (lspan and '</span>') + lsep
+ yield 1, line
+ line = ''
+ elif part:
+ yield 1, cspan + part + (cspan and '</span>') + lsep
+ else:
+ yield 1, lsep
+ # for the last line
+ last = self.token_decorate(ttype, parts[-1])
+ if line and last:
+ if lspan != cspan:
+ line += (lspan and '</span>') + cspan + last
+ lspan = cspan
+ else:
+ line += last
+ elif last:
+ line = cspan + last
+ lspan = cspan
+ # else we neither have to open a new span nor set lspan
+
+ if line:
+ yield 1, line + (lspan and '</span>') + lsep
+
+ def token_decorate(self, token, value):
+ return value
+
+class ChangelogStyle(Style):
+ default_style = ""
+ styles = {
+ Comment: 'italic #888',
+ Date: '#F90',
+ FilePlus: 'bold #0F0',
+ FileMinus: 'bold #F00',
+ File: 'bold #C0A',
+ PackageName: 'bold',
+ Bug: '#E00',
+ Email: '#0CF',
+ AuthorName: 'bold #1C9',
+ }
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-22 23:46 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-22 23:46 UTC (permalink / raw
To: gentoo-commits
commit: fc488924244a2cce7cbada78bea847c64dfed23d
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jul 22 23:31:20 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jul 22 23:31:20 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=fc488924
Check exception for bad xml file
---
.../generic_metadata/category_metadata.py | 2 +-
.../generic_metadata/package_metadata.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/category_metadata.py b/gpackages/libs/package_info/generic_metadata/category_metadata.py
index 4950733..b498422 100644
--- a/gpackages/libs/package_info/generic_metadata/category_metadata.py
+++ b/gpackages/libs/package_info/generic_metadata/category_metadata.py
@@ -12,7 +12,7 @@ class CategoryMetadata(ToStrMixin):
self._descrs = {}
try:
self._metadata_xml = etree.parse(metadata_path)
- except IOError:
+ except (IOError, etree.ParseError):
pass
else:
self._parse_descrs()
diff --git a/gpackages/libs/package_info/generic_metadata/package_metadata.py b/gpackages/libs/package_info/generic_metadata/package_metadata.py
index 704a590..de2a246 100644
--- a/gpackages/libs/package_info/generic_metadata/package_metadata.py
+++ b/gpackages/libs/package_info/generic_metadata/package_metadata.py
@@ -14,7 +14,7 @@ class PackageMetaData(ToStrMixin):
self._maintainers = ()
try:
self._metadata_xml = etree.parse(metadata_path)
- except IOError:
+ except (IOError, etree.ParseError):
pass
else:
self._parse_all()
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-23 23:09 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-23 23:09 UTC (permalink / raw
To: gentoo-commits
commit: f8c14a56f2f62b66e4b27fc93f9d84330933d779
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Jul 23 14:37:48 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Jul 23 14:37:48 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=f8c14a56
Extend changelog lexer
---
.../generic_metadata/changelog_highlight.py | 42 +++++++++++++++-----
1 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
index 8dc8a37..8641ac8 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
@@ -1,12 +1,13 @@
-from pygments.lexer import RegexLexer, bygroups
+from pygments.lexer import RegexLexer, bygroups, include
from pygments.formatters import HtmlFormatter
from pygments.formatters.html import _escape_html_table
from pygments.style import Style
from pygments.token import *
import re
-DATE_RE = r'\d\d [A-Z][a-z]{2} \d{4}'
-EMAIL_RE = r'[\w\.\-]+@(?:\w+\.)+\w+'
+DATE_RE = r'\d\d? [A-Z][a-z]{2} \d{4}'
+EMAIL_RE = r'[\w\.\-\+]+@(?:[\w\-]+\.)+\w+'
+LINK_RE = r'https?:\/\/(?:[\w\-]+\.)+\w+(:?\/[\w\/\.\-\_\+\&\%]+)?'
ARCHES = [ u'alpha', u'amd64', u'amd64-fbsd', u'amd64-linux', u'arm',
u'arm-linux', u'hppa', u'hppa-hpux', u'ia64', u'ia64-hpux',
@@ -29,6 +30,7 @@ File = Operator.Word
Email = Number
AuthorName = Name.Variable
Bug = String
+Link = Keyword
class ChangelogLexer(RegexLexer):
name = 'Changelog'
@@ -39,19 +41,27 @@ class ChangelogLexer(RegexLexer):
'root': [
(r'^# .*\n', Comment.Single), # Comment
(r'^(\*)(.+)( )(\()(%s)(\))' % DATE_RE, bygroups(Operator, PackageName, Whitespace, Punctuation, Date, Punctuation)),
- #(r'^ ' , Whitespace, 'main'),
(r'^( )(%(date)s)(;)( +)([^<]*)(<)(%(email)s)(>)' % {'date': DATE_RE, 'email': EMAIL_RE},
bygroups(Whitespace, Date, Punctuation, Whitespace, AuthorName, Punctuation, Number, Punctuation), 'main'), # Date
(EMAIL_RE, Email),
+ (r' ', Whitespace),
+ include('bugs'),
+ (r'\(|\)|<|>', Punctuation),
+ include('email'),
+ include('link'),
+ #(KEYWORD_RE, Name.Variable),
+ (r'[^#\n ]+', Generic),
+ (r' +', Whitespace),
],
'main': [
(r' *\n\n', Punctuation, '#pop'),
(EMAIL_RE, Email),
(r'(,| | )(\+[\w\.\-\+\/]+)', bygroups(Punctuation, FilePlus)),
(r'(,| | )(\-[\w\.\-\+\/]+)', bygroups(Punctuation, FileMinus)),
- (r'(,| | )(\w[\w\.\-\+\/]+)', bygroups(Punctuation, File)),
- (r':( +|\n)', Punctuation, 'message'),
+ (r'(,| | )([\w\*][\w\.\-\+\/]+)', bygroups(Punctuation, File)),
+ (r': *\n *\n|:(?: +|\n)|: +', Punctuation, 'message'),
(r';|<|>|,', Punctuation),
+ include('link'),
(r' |\n', Whitespace),
],
'message': [
@@ -61,14 +71,24 @@ class ChangelogLexer(RegexLexer):
],
'message_text': [
(r' *\n', Whitespace, '#pop'),
+ include('bugs'),
+ (r'\(|\)|<|>', Punctuation),
+ include('email'),
+ include('link'),
+ #(KEYWORD_RE, Name.Variable),
+ (r' +', Whitespace),
+ (r'.', Generic),
+ ],
+ 'bugs' : [
(r'(?i)bug #\d+', Bug),
(r'#\d+', Bug),
(r'(?i)bug \d+', Bug),
- (r'\(|\)|<|>', Punctuation),
+ ],
+ 'email': [
(EMAIL_RE, Email),
- #(KEYWORD_RE, Name.Variable),
- (r'[^#\n ]+', Generic),
- (r' +', Whitespace),
+ ],
+ 'link': [
+ (LINK_RE, Link),
]
}
@@ -131,6 +151,8 @@ class ChangelogHtmlFormater(HtmlFormatter):
yield 1, line + (lspan and '</span>') + lsep
def token_decorate(self, token, value):
+ if token == Link:
+ value = '<a href="{0}" rel="nofollow">{0}</a>'.format(value)
return value
class ChangelogStyle(Style):
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-23 23:09 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-23 23:09 UTC (permalink / raw
To: gentoo-commits
commit: f7a8e1954931070ea95553b0f6e2aa752f3caa0b
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Jul 23 14:57:03 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Jul 23 14:57:03 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=f7a8e195
Add highlight function
---
.../generic_metadata/changelog_highlight.py | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
index 8641ac8..43f9586 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
@@ -1,8 +1,9 @@
from pygments.lexer import RegexLexer, bygroups, include
-from pygments.formatters import HtmlFormatter
+from pygments.formatters import HtmlFormatter, Terminal256Formatter
from pygments.formatters.html import _escape_html_table
from pygments.style import Style
from pygments.token import *
+from pygments import highlight
import re
DATE_RE = r'\d\d? [A-Z][a-z]{2} \d{4}'
@@ -43,7 +44,7 @@ class ChangelogLexer(RegexLexer):
(r'^(\*)(.+)( )(\()(%s)(\))' % DATE_RE, bygroups(Operator, PackageName, Whitespace, Punctuation, Date, Punctuation)),
(r'^( )(%(date)s)(;)( +)([^<]*)(<)(%(email)s)(>)' % {'date': DATE_RE, 'email': EMAIL_RE},
bygroups(Whitespace, Date, Punctuation, Whitespace, AuthorName, Punctuation, Number, Punctuation), 'main'), # Date
- (EMAIL_RE, Email),
+ include('email'),
(r' ', Whitespace),
include('bugs'),
(r'\(|\)|<|>', Punctuation),
@@ -72,7 +73,6 @@ class ChangelogLexer(RegexLexer):
'message_text': [
(r' *\n', Whitespace, '#pop'),
include('bugs'),
- (r'\(|\)|<|>', Punctuation),
include('email'),
include('link'),
#(KEYWORD_RE, Name.Variable),
@@ -167,4 +167,13 @@ class ChangelogStyle(Style):
Bug: '#E00',
Email: '#0CF',
AuthorName: 'bold #1C9',
+ #Error: 'bold underline #F00',
}
+
+def changelog_highlight(text):
+ return highlight(text, ChangelogLexer(),
+ ChangelogHtmlFormater(style = ChangelogStyle))
+
+def changelog_termial_highlight(text):
+ return highlight(text, ChangelogLexer(),
+ Terminal256Formatter(style = ChangelogStyle))
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-25 22:47 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-25 22:47 UTC (permalink / raw
To: gentoo-commits
commit: 5c60e28993f29170394a741f790579aa03bd1807
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jul 25 13:52:41 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jul 25 14:28:34 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=5c60e289
Add support maintainers in upstream
---
.../generic_metadata/package_metadata.py | 25 +++++++++++++++++--
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/package_metadata.py b/gpackages/libs/package_info/generic_metadata/package_metadata.py
index 54df840..a7339e4 100644
--- a/gpackages/libs/package_info/generic_metadata/package_metadata.py
+++ b/gpackages/libs/package_info/generic_metadata/package_metadata.py
@@ -14,6 +14,7 @@ class PackageMetaData(ToStrMixin):
self.descr = {'en': None}
self._herds = ()
self._maintainers = ()
+ self.upstream = None
try:
self._metadata_xml = etree.parse(metadata_path)
except (IOError, etree.ParseError):
@@ -50,7 +51,8 @@ class PackageMetaData(ToStrMixin):
def _parse_upstream(self):
upstream_xml = self._metadata_xml.find('upstream')
- self.upstream = Upstream(upstream_xml, self._metadata_path)
+ if upstream_xml is not None:
+ self.upstream = Upstream(upstream_xml, self._metadata_path)
@property
def description(self):
@@ -87,13 +89,21 @@ class Upstream(ToStrMixin):
setattr(self, name, res)
for name, attr_name in self.simple_attrs:
+ setattr(self, attr_name, None)
item = upstream_t.find(name)
- setattr(self, attr_name, item.text)
+ if item is not None:
+ setattr(self, attr_name, item.text)
for item in upstream_t.iterfind('remote-id'):
type = item.attrib.get('type')
self.remote_id[type] = item.text
-
+
+ maintainers = []
+ for maintainer in upstream_t.iterfind('maintainer'):
+ m = UpstreamMaintainer(maintainer)
+ maintainers.append(m)
+
+ self.maintainers = maintainers
@property
def main_doc(self):
@@ -101,3 +111,12 @@ class Upstream(ToStrMixin):
def __unicode__(self):
return self.metadata_path
+
+class UpstreamMaintainer(Maintainer):
+ status_dict = {'inactive' : 0, 'active': 1}
+
+ def __init__(self, xml_object):
+ super(UpstreamMaintainer, self).__init__(xml_object)
+ st = xml_object.attrib.get('status','inactive')
+ self.status = self.status_dict.get(st, 0)
+
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-25 22:47 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-25 22:47 UTC (permalink / raw
To: gentoo-commits
commit: 55efc8546b45ba0909a3dac180926ac15ee74ed2
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jul 24 09:48:08 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jul 24 09:48:08 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=55efc854
Add support of upstream in package metadata
---
.../generic_metadata/package_metadata.py | 38 ++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/package_metadata.py b/gpackages/libs/package_info/generic_metadata/package_metadata.py
index de2a246..54df840 100644
--- a/gpackages/libs/package_info/generic_metadata/package_metadata.py
+++ b/gpackages/libs/package_info/generic_metadata/package_metadata.py
@@ -5,6 +5,8 @@ from .my_etree import etree
# Maintainers
from .herds import Maintainer
+#TODO: Add support of restrict attribute !!!
+
class PackageMetaData(ToStrMixin):
def __init__(self, metadata_path):
@@ -23,6 +25,7 @@ class PackageMetaData(ToStrMixin):
self._parse_herds()
self._parse_description()
self._parse_maintainers()
+ self._parse_upstream()
def _parse_herds(self):
herd_set = set()
@@ -45,6 +48,10 @@ class PackageMetaData(ToStrMixin):
maintainers.add(maintainer)
self._maintainers = tuple(maintainers)
+ def _parse_upstream(self):
+ upstream_xml = self._metadata_xml.find('upstream')
+ self.upstream = Upstream(upstream_xml, self._metadata_path)
+
@property
def description(self):
return self.descr['en']
@@ -63,3 +70,34 @@ class PackageMetaData(ToStrMixin):
def __unicode__(self):
return self._metadata_path
+
+class Upstream(ToStrMixin):
+
+ simple_attrs = (('changelog', 'changelog'),
+ ('bugs-to', 'bugs_to'),)
+
+ def __init__(self, upstream_t, metadata_path):
+ self.metadata_path = metadata_path
+ self.remote_id = {}
+ for name in ('doc',):
+ res = {}
+ for item in upstream_t.iterfind(name):
+ lang = item.attrib.get('lang', 'en')
+ res[lang] = item.text
+ setattr(self, name, res)
+
+ for name, attr_name in self.simple_attrs:
+ item = upstream_t.find(name)
+ setattr(self, attr_name, item.text)
+
+ for item in upstream_t.iterfind('remote-id'):
+ type = item.attrib.get('type')
+ self.remote_id[type] = item.text
+
+
+ @property
+ def main_doc(self):
+ return self.doc.get('en')
+
+ def __unicode__(self):
+ return self.metadata_path
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-30 12:59 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-30 12:59 UTC (permalink / raw
To: gentoo-commits
commit: 87abd35a016bf1058748d4f775b37a1c0d0f2cb7
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jul 26 19:08:53 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jul 26 19:08:53 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=87abd35a
Add base glsa parser
---
.../libs/package_info/generic_metadata/glsa.py | 71 ++++++++++++++++++++
1 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/glsa.py b/gpackages/libs/package_info/generic_metadata/glsa.py
new file mode 100644
index 0000000..a3cb06d
--- /dev/null
+++ b/gpackages/libs/package_info/generic_metadata/glsa.py
@@ -0,0 +1,71 @@
+import os
+import os.path
+import re
+from .my_etree import etree
+from ..generic import ToStrMixin
+
+GLSA_FILE_RE = r'^glsa-\d{6}-\d{2}\.xml$'
+glsa_re = re.compile(GLSA_FILE_RE)
+
+def children_text(node):
+ parts = ([node.text] +
+ [etree.tostring(c) for c in node.getchildren()]
+ )
+ return ''.join(filter(None, parts))
+
+
+class GLSAs(ToStrMixin):
+
+ def __init__(self, repo_path = '/usr/portage'):
+ self.glsa_path = os.path.join(repo_path, 'metadata', 'glsa')
+ if not os.path.isdir(self.glsa_path):
+ raise ValueError
+ # For repr
+ self.repo_path = repo_path
+
+ def iter_glsa(self):
+ for name in os.listdir(self.glsa_path):
+ try:
+ i = GLSA(os.path.join(self.glsa_path, name))
+ except ValueError:
+ pass
+ else:
+ yield i
+
+ def __unicode__(self):
+ return self.repo_path
+
+class GLSA(ToStrMixin):
+
+ simple_attrs = ('synopsis', 'background', 'description',
+ 'workaround', 'resolution')
+
+ def __init__(self, file_name):
+ if not os.path.isfile(file_name):
+ raise ValueError
+
+ dir, name = os.path.split(file_name)
+ m = glsa_re.match(name)
+ if m is None:
+ raise ValueError
+
+ xml = etree.parse(file_name)
+
+ root = xml.getroot()
+ id = root.attrib.get('id')
+ self.glsa_id = id
+ self.title = root.find('title').text
+ for attr in self.simple_attrs:
+ node = root.find(attr)
+ if node is not None:
+ setattr(self, attr, children_text(node))
+ else:
+ setattr(self, attr, None)
+
+ impact_xml = root.find('impact')
+ self.impact_type = impact_xml.attrib.get('type')
+ self.impact = children_text(impact_xml)
+
+
+ def __unicode__(self):
+ return unicode(self.glsa_id)
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-30 12:59 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-30 12:59 UTC (permalink / raw
To: gentoo-commits
commit: 2e31efca2bdc9a8b423ae035c95cf0e4b33ba0d5
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jul 26 23:31:44 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jul 26 23:31:44 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=2e31efca
Add more properties to glsa parser
---
.../libs/package_info/generic_metadata/glsa.py | 21 ++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/glsa.py b/gpackages/libs/package_info/generic_metadata/glsa.py
index 91616e7..570aeb8 100644
--- a/gpackages/libs/package_info/generic_metadata/glsa.py
+++ b/gpackages/libs/package_info/generic_metadata/glsa.py
@@ -40,6 +40,10 @@ class GLSA(ToStrMixin):
simple_attrs = ('synopsis', 'background', 'description',
'workaround', 'resolution')
+ product_types = {'ebuild': 0,
+ 'information' : 1,
+ 'infrastructure' : 2}
+
def __init__(self, file_name):
if not os.path.isfile(file_name):
raise ValueError
@@ -66,6 +70,17 @@ class GLSA(ToStrMixin):
self.impact_type = impact_xml.attrib.get('type')
self.impact = children_text(impact_xml)
self._set_references(root)
+ self._set_bugs(root)
+
+ product_xml = root.find('product')
+ product_type = self.product_types[product_xml.attrib.get('type')]
+ self.product = (product_xml.text, product_type)
+
+ access_xml = root.find('access')
+ if access_xml is not None:
+ self.access = access_xml.text
+ else:
+ self.access = None
def _set_references(self, root):
@@ -77,6 +92,12 @@ class GLSA(ToStrMixin):
references.append((name, link))
self.references = references
+
+ def _set_bugs(self, root):
+ bugs = []
+ for bug_xml in root.iterfind('bug'):
+ bugs.append(bug_xml.text)
+ self.bugs = bugs
def __unicode__(self):
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-30 12:59 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-30 12:59 UTC (permalink / raw
To: gentoo-commits
commit: 9bce6808bcdb0d0caa19cad6fef832acbbe9da1f
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jul 26 23:15:30 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jul 26 23:15:30 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=9bce6808
Add references
---
.../libs/package_info/generic_metadata/glsa.py | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/glsa.py b/gpackages/libs/package_info/generic_metadata/glsa.py
index a3cb06d..91616e7 100644
--- a/gpackages/libs/package_info/generic_metadata/glsa.py
+++ b/gpackages/libs/package_info/generic_metadata/glsa.py
@@ -65,6 +65,18 @@ class GLSA(ToStrMixin):
impact_xml = root.find('impact')
self.impact_type = impact_xml.attrib.get('type')
self.impact = children_text(impact_xml)
+ self._set_references(root)
+
+
+ def _set_references(self, root):
+ references = []
+ references_xml = root.find('references')
+ for node in references_xml.iterfind('uri'):
+ link = node.attrib.get('link')
+ name = node.text
+ references.append((name, link))
+
+ self.references = references
def __unicode__(self):
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-30 12:59 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-30 12:59 UTC (permalink / raw
To: gentoo-commits
commit: 65bad05abe1e03cc14ce2ef1817ef9268a72d18b
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jul 29 16:15:25 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jul 29 16:15:25 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=65bad05a
Parse affected in glsa
---
.../libs/package_info/generic_metadata/glsa.py | 53 ++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/glsa.py b/gpackages/libs/package_info/generic_metadata/glsa.py
index 570aeb8..be29ce5 100644
--- a/gpackages/libs/package_info/generic_metadata/glsa.py
+++ b/gpackages/libs/package_info/generic_metadata/glsa.py
@@ -35,6 +35,41 @@ class GLSAs(ToStrMixin):
def __unicode__(self):
return self.repo_path
+class VersionCheck(ToStrMixin):
+ ranges = ('le', 'lt', 'eq', 'gt', 'ge', 'rlt', 'rle', 'rgt', 'rge')
+ types = {'unaffected' : 0, 'vulnerable' : 1}
+
+ def __init__(self, type, range, version):
+ if type in self.types:
+ self.type_num = self.types[type]
+ else:
+ raise ValueError
+
+ self.range = range
+ self.version = version
+
+ def __unicode__(self):
+ return 'test'
+
+class PackageMatch(ToStrMixin):
+
+ def __init__(self, name, archs, auto = False, versions = []):
+ self.name = name
+ self.archs = archs
+ self.auto = auto
+ for item in versions:
+ if not isinstance(item, VersionCheck):
+ raise ValueError
+ self.versions = versions
+
+ def add_version(self, version):
+ if not isinstance(version, VersionCheck):
+ raise ValueError
+ self.versions.append(version)
+
+ def __unicode__(self):
+ return self.name
+
class GLSA(ToStrMixin):
simple_attrs = ('synopsis', 'background', 'description',
@@ -82,6 +117,24 @@ class GLSA(ToStrMixin):
else:
self.access = None
+ self._set_affected(root)
+
+ def _set_affected(self, root):
+ affected_xml = root.find('affected')
+ packages = []
+ for package_xml in affected_xml.iterfind('package'):
+ name = package_xml.attrib.get('name')
+ archs = package_xml.attrib.get('arch')
+ auto = package_xml.attrib.get('auto')
+ package = PackageMatch(name, archs, auto)
+ for item in package_xml.iterchildren():
+ v = item.text
+ type = item.tag
+ range = item.attrib.get('range')
+ o = VersionCheck(type, range, v)
+ package.add_version(o)
+ packages.append(package)
+ self.affected = packages
def _set_references(self, root):
references = []
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-07-31 14:22 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-07-31 14:22 UTC (permalink / raw
To: gentoo-commits
commit: 261bf7f0bf9f72b13e79bfca7bf2c2ed99b64c64
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jul 31 13:54:40 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jul 31 13:54:40 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=261bf7f0
Fix link detection
---
.../generic_metadata/changelog_highlight.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
index b3d996e..d0b683e 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
@@ -8,7 +8,7 @@ import re
DATE_RE = r'\d\d? [A-Z][a-z]{2} \d{4}'
EMAIL_RE = r'[\w\.\-\+]+@(?:[\w\-]+\.)+\w+'
-LINK_RE = r'https?:\/\/(?:[\w\-]+\.)+\w+(:?\/[\w\/\.\-\_\+\&\%]+)?'
+LINK_RE = r'https?:\/\/(?:[\w\-]+\.)+\w+(:?\/[\w\/\.\-\_\+\&\%\?#=]+)?'
BUG_NUM_RE = r'(\d+)'
bugnum_re = re.compile(BUG_NUM_RE)
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-08-02 22:44 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-08-02 22:44 UTC (permalink / raw
To: gentoo-commits
commit: 2cea6ead4db286e6279c0002619f34dd76fc0a8d
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Aug 2 00:02:43 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Aug 2 00:02:43 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=2cea6ead
Fix bug with memory leak
---
.../libs/package_info/generic_metadata/use_info.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/use_info.py b/gpackages/libs/package_info/generic_metadata/use_info.py
index c60f093..6971d54 100644
--- a/gpackages/libs/package_info/generic_metadata/use_info.py
+++ b/gpackages/libs/package_info/generic_metadata/use_info.py
@@ -5,7 +5,7 @@ import os
__all__ = ('get_uses_info', 'get_local_uses_info', 'get_use_special_info')
-USES_RE = r'(?P<use>[a-zA-Z0-9\-]+) - (?P<description>.*)'
+USES_RE = r'(?P<use>[a-zA-Z0-9\-_]+) - (?P<description>.*)'
USES_DESC_RE = r'^%s$' % USES_RE
USES_LOCAL_DESC_RE = r'^(?P<package>[^#].*):%s$' % USES_RE
DESC_USE_RE = r'^(?P<name>[^\.]+)\.desc$'
@@ -14,7 +14,9 @@ use_re = re.compile(USES_DESC_RE)
use_local_re = re.compile(USES_LOCAL_DESC_RE)
desc_re = re.compile(DESC_USE_RE)
-def _get_info(filename, re_string, modify_function, res_var = {}):
+def _get_info(filename, re_string, modify_function, res_var = None):
+ if res_var is None:
+ res_var = {}
use_desc = open(filename, 'r').read()
uses_desc = use_desc.split("\n")
res_dict = res_var
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-08-02 22:44 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-08-02 22:44 UTC (permalink / raw
To: gentoo-commits
commit: a4e05092c97f7d36a9e98110230e9f8f30a6d53c
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Aug 1 23:22:46 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Aug 1 23:29:06 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=a4e05092
Add function for access to special use description
---
.../libs/package_info/generic_metadata/use_info.py | 26 +++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/use_info.py b/gpackages/libs/package_info/generic_metadata/use_info.py
index c04f640..c60f093 100644
--- a/gpackages/libs/package_info/generic_metadata/use_info.py
+++ b/gpackages/libs/package_info/generic_metadata/use_info.py
@@ -1,14 +1,18 @@
import re
from collections import defaultdict
+import os.path
+import os
-__all__ = ('get_uses_info', 'get_local_uses_info')
+__all__ = ('get_uses_info', 'get_local_uses_info', 'get_use_special_info')
USES_RE = r'(?P<use>[a-zA-Z0-9\-]+) - (?P<description>.*)'
USES_DESC_RE = r'^%s$' % USES_RE
USES_LOCAL_DESC_RE = r'^(?P<package>[^#].*):%s$' % USES_RE
+DESC_USE_RE = r'^(?P<name>[^\.]+)\.desc$'
use_re = re.compile(USES_DESC_RE)
use_local_re = re.compile(USES_LOCAL_DESC_RE)
+desc_re = re.compile(DESC_USE_RE)
def _get_info(filename, re_string, modify_function, res_var = {}):
use_desc = open(filename, 'r').read()
@@ -51,3 +55,23 @@ def get_local_uses_info(filename = '/usr/portage/profiles/use.local.desc'):
res_dict[match['use'].lower()][match['package']] = match['description']
return _get_info(filename, use_local_re, action, defaultdict(dict))
+
+def _set_prefixes(prefix, dct):
+ newdct = {}
+ for key, item in dct.iteritems():
+ newdct['%s_%s' % (prefix, key)] = item
+ return newdct
+
+def get_use_special_info(dirname = '/usr/portage/profiles/desc'):
+ uses = {}
+ for name in os.listdir(dirname):
+ m = desc_re.match(name)
+ if m is not None:
+ prefix = m.groupdict().get('name')
+ if prefix is None:
+ continue
+ filename = os.path.join(dirname, name)
+ uses.update(_set_prefixes(prefix, get_uses_info(filename)))
+ return uses
+
+
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-08-02 22:44 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-08-02 22:44 UTC (permalink / raw
To: gentoo-commits
commit: 87443ee34c8ff1e9e3bb4f285c27bc7a802cd0bc
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Aug 2 22:10:56 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Aug 2 22:10:56 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=87443ee3
Add docstring to use_info.py
---
.../libs/package_info/generic_metadata/use_info.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/use_info.py b/gpackages/libs/package_info/generic_metadata/use_info.py
index 6971d54..04a1835 100644
--- a/gpackages/libs/package_info/generic_metadata/use_info.py
+++ b/gpackages/libs/package_info/generic_metadata/use_info.py
@@ -65,6 +65,14 @@ def _set_prefixes(prefix, dct):
return newdct
def get_use_special_info(dirname = '/usr/portage/profiles/desc'):
+ """Args:
+ dirname -- full path to descrs files, /usr/portage/profiles/desc \
+ by default
+ Returns:
+ dict with use flag as key, and description as value
+ Example:
+ {'kernel_linux': 'KERNEL setting for system using the Linux ...', ...}
+ """
uses = {}
for name in os.listdir(dirname):
m = desc_re.match(name)
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-08-02 22:44 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-08-02 22:44 UTC (permalink / raw
To: gentoo-commits
commit: e0dc774175b38f254b348ec4cf25b8aaaa34adc3
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Aug 2 22:38:16 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Aug 2 22:38:16 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=e0dc7741
More right latest changelog message detection
---
.../generic_metadata/changelog_highlight.py | 63 ++++++++++++++++++++
1 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
index d0b683e..5ccbd5c 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
@@ -5,6 +5,7 @@ from pygments.style import Style
from pygments.token import *
from pygments import highlight
import re
+from collections import deque
DATE_RE = r'\d\d? [A-Z][a-z]{2} \d{4}'
EMAIL_RE = r'[\w\.\-\+]+@(?:[\w\-]+\.)+\w+'
@@ -140,6 +141,7 @@ class ChangelogHtmlFormater(HtmlFormatter):
last = self.token_decorate(ttype, parts[-1])
if line and last:
if lspan != cspan:
+
line += (lspan and '</span>') + cspan + last
lspan = cspan
else:
@@ -190,3 +192,64 @@ def changelog_termial_highlight(text):
def changelog_style_css():
f = ChangelogHtmlFormater(style = ChangelogStyle)
return f.get_style_defs()
+
+def group_tokens(text):
+ c = ChangelogLexer()
+ queue = deque()
+ group_type = None
+ group = []
+ for token, value in c.get_tokens(text):
+ queue.append((token, value))
+
+ if len(queue)>6:
+ token_q, value_q = queue[0]
+ if token_q == Operator and value_q == '*':
+ yield (group_type, group)
+ group_type = 'version'
+ group = []
+ elif token_q == Whitespace:
+ token2_q, value2_q = queue[1]
+ if token2_q == Date:
+ token3_q, value3_q = queue[2]
+ if token3_q == Punctuation:
+ yield (group_type, group)
+ group_type = 'message'
+ group = []
+
+ group.append(queue.popleft())
+
+ yield (group_type, group + list(queue))
+
+def latest_message_group(text):
+ for group_type, group in group_tokens(text):
+ if group_type == 'message':
+ return group
+
+def latest_group_messages_group(text):
+ groups = []
+ for group_type, group in group_tokens(text):
+ if group_type == 'version':
+ groups.append((group_type, group))
+ if group_type == 'message':
+ groups.append((group_type, group))
+ return groups
+
+def tokensgroup_to_toknes(groups):
+ tk = []
+ for group_type, group in groups:
+ tk += group
+ return tk
+
+def tokens_to_text(lex):
+ mystr = ''
+ for token, value in lex:
+ mystr += value
+ return mystr
+
+def latest_message(text):
+ return tokens_to_text(latest_message_group(text))
+
+def latest_group_messages(text):
+ groups = latest_group_messages_group(text)
+ return tokens_to_text(tokensgroup_to_toknes(groups))
+
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-08-02 23:18 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-08-02 23:18 UTC (permalink / raw
To: gentoo-commits
commit: d53882c162487c202140580c4e6f700bdd208ab9
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Aug 2 22:56:00 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Aug 2 22:56:00 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=d53882c1
Add docstrings to changelog_highlight.py
---
.../generic_metadata/changelog_highlight.py | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
index 5ccbd5c..5b2b503 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
@@ -37,6 +37,8 @@ Bug = String
Link = Keyword
class ChangelogLexer(RegexLexer):
+ "Pygments changelog lexer"
+
name = 'Changelog'
aliases = ['changelog']
filenames = ['Changelog']
@@ -96,6 +98,8 @@ class ChangelogLexer(RegexLexer):
}
class ChangelogHtmlFormater(HtmlFormatter):
+ "Pygments html changelog formater"
+
def _format_lines(self, tokensource):
"""
Copyed from pygments source litle modified.
@@ -167,6 +171,8 @@ class ChangelogHtmlFormater(HtmlFormatter):
return value
class ChangelogStyle(Style):
+ "Pygments style for gentoo changelog"
+
default_style = ""
styles = {
Comment: 'italic #888',
@@ -182,18 +188,29 @@ class ChangelogStyle(Style):
}
def changelog_highlight(text):
+ "Shortcut for generating highlighted changelog html output"
return highlight(text, ChangelogLexer(),
ChangelogHtmlFormater(style = ChangelogStyle))
def changelog_termial_highlight(text):
+ """Shortcut for generating highlighted terminal changelog output
+ Used for debuging lexer """
return highlight(text, ChangelogLexer(),
Terminal256Formatter(style = ChangelogStyle))
def changelog_style_css():
+ "Shortcut for generating css style for pygments `ChangelogStyle`"
f = ChangelogHtmlFormater(style = ChangelogStyle)
return f.get_style_defs()
def group_tokens(text):
+ """Combine tokens to groups
+ Args:
+ text -- changelog text
+ Yields:
+ (group_type, group), where group_type are: `None`, `'version'` or \
+ `'message'`
+ group are array of tuples (toke, value)"""
c = ChangelogLexer()
queue = deque()
group_type = None
@@ -247,9 +264,11 @@ def tokens_to_text(lex):
return mystr
def latest_message(text):
+ "Return latest message text"
return tokens_to_text(latest_message_group(text))
def latest_group_messages(text):
+ "Returns latest messages like it done on packages.gentoo.org"
groups = latest_group_messages_group(text)
return tokens_to_text(tokensgroup_to_toknes(groups))
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/
@ 2012-08-20 13:03 Slava Bacherikov
0 siblings, 0 replies; 27+ messages in thread
From: Slava Bacherikov @ 2012-08-20 13:03 UTC (permalink / raw
To: gentoo-commits
commit: 21b8d78455479c3419e4535e93b0fabfa840fdee
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Aug 13 18:06:04 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Aug 13 18:06:04 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=21b8d784
Add cia.vc link to changelog
---
.../generic_metadata/changelog_highlight.py | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
index 5b2b503..9ee13f1 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
@@ -6,6 +6,7 @@ from pygments.token import *
from pygments import highlight
import re
from collections import deque
+from ..utils import ciavc_link
DATE_RE = r'\d\d? [A-Z][a-z]{2} \d{4}'
EMAIL_RE = r'[\w\.\-\+]+@(?:[\w\-]+\.)+\w+'
@@ -167,7 +168,12 @@ class ChangelogHtmlFormater(HtmlFormatter):
if num_m is not None:
num = num_m.group()
link = bugs_url_template.format(num)
- value = '<a href="{1}" class="defcolor">{0}</a>'.format(value, link)
+ value = '<a href="{1}" class="defcolor">{0}</a>'. \
+ format(value, link)
+ elif token == Email:
+ name, domain = value.split('@')
+ value = '<a href="{1}" class="defcolor">{0}</a>'. \
+ format(name, ciavc_link(name))
return value
class ChangelogStyle(Style):
^ permalink raw reply related [flat|nested] 27+ messages in thread
end of thread, other threads:[~2012-08-20 13:06 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-25 22:23 [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/generic_metadata/ Slava Bacherikov
-- strict thread matches above, loose matches on Subject: below --
2012-06-25 22:23 Slava Bacherikov
2012-06-25 22:23 Slava Bacherikov
2012-07-04 22:13 Slava Bacherikov
2012-07-04 22:13 Slava Bacherikov
2012-07-12 22:16 Slava Bacherikov
2012-07-12 22:16 Slava Bacherikov
2012-07-18 23:03 Slava Bacherikov
2012-07-22 23:46 Slava Bacherikov
2012-07-22 23:46 Slava Bacherikov
2012-07-22 23:46 Slava Bacherikov
2012-07-22 23:46 Slava Bacherikov
2012-07-23 23:09 Slava Bacherikov
2012-07-23 23:09 Slava Bacherikov
2012-07-25 22:47 Slava Bacherikov
2012-07-25 22:47 Slava Bacherikov
2012-07-30 12:59 Slava Bacherikov
2012-07-30 12:59 Slava Bacherikov
2012-07-30 12:59 Slava Bacherikov
2012-07-30 12:59 Slava Bacherikov
2012-07-31 14:22 Slava Bacherikov
2012-08-02 22:44 Slava Bacherikov
2012-08-02 22:44 Slava Bacherikov
2012-08-02 22:44 Slava Bacherikov
2012-08-02 22:44 Slava Bacherikov
2012-08-02 23:18 Slava Bacherikov
2012-08-20 13:03 Slava Bacherikov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox