From: "Slawek Lis" <slis@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
Date: Mon, 24 Mar 2014 07:17:41 +0000 (UTC) [thread overview]
Message-ID: <1395642773.39c99972049624c2504358c8455680da6acaee08.slis@gentoo> (raw)
commit: 39c99972049624c2504358c8455680da6acaee08
Author: Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 24 06:32:53 2014 +0000
Commit: Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Mon Mar 24 06:32:53 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=39c99972
Moved option and config parsing into settings module
---
pym/gentoolkit/revdep_rebuild/collect.py | 34 +--------
pym/gentoolkit/revdep_rebuild/rebuild.py | 83 +-------------------
pym/gentoolkit/revdep_rebuild/settings.py | 121 ++++++++++++++++++++++++++++++
3 files changed, 123 insertions(+), 115 deletions(-)
diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 039dc76..2a431cb 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -12,6 +12,7 @@ import sys
import portage
from portage.output import blue, yellow
+from .settings import parse_revdep_config
if sys.hexversion < 0x3000000:
@@ -87,39 +88,6 @@ def prepare_search_dirs(logger, settings):
return (bin_dirs, lib_dirs)
-def parse_revdep_config(revdep_confdir):
- ''' Parses all files under and returns
- tuple of: (masked_dirs, masked_files, search_dirs)'''
-
- search_dirs = set()
- masked_dirs = set()
- masked_files = set()
-
- for _file in os.listdir(revdep_confdir):
- for line in open(os.path.join(revdep_confdir, _file)):
- line = line.strip()
- #first check for comment, we do not want to regex all lines
- if not line.startswith('#'):
- match = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
- if match is not None:
- masks = match.group(1).split(' ')
- masked_files.update(masks)
- continue
- match = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
- if match is not None:
- searches = match.group(1).split(' ')
- for search in searches:
- masked_dirs.update(glob.glob(search))
- continue
- match = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
- if match is not None:
- searches = match.group(1).split()
- for search in searches:
- search_dirs.update(glob.glob(search))
- continue
-
- return (masked_dirs, masked_files, search_dirs)
-
def collect_libraries_from_dir(dirs, mask, logger):
''' Collects all libraries from specified list of directories.
diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 314fb1f..9d5bf9b 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -18,7 +18,6 @@ from __future__ import print_function
import os
import sys
-import getopt
import logging
import subprocess
import time
@@ -30,7 +29,7 @@ from portage.output import bold, red, blue, yellow, nocolor
from .analyse import analyse
from .cache import check_temp_files, read_cache
from .assign import get_slotted_cps
-from .settings import DEFAULTS
+from .settings import DEFAULTS, parse_options
from .stuff import filter_masked
from . import __version__
@@ -43,39 +42,6 @@ __productname__ = "revdep-ng"
# functions
-def print_usage():
- """Outputs the help message"""
- print( APP_NAME + ': (' + VERSION +')')
- print()
- print('This is free software; see the source for copying conditions.')
- print()
- print('Usage: ' + APP_NAME + ' [OPTIONS] [--] [EMERGE_OPTIONS]')
- print()
- print('Broken reverse dependency rebuilder, python implementation.')
- print()
- print('Available options:')
- print('''
- -C, --nocolor Turn off colored output
- -d, --debug Print debug informations
- -e, --exact Emerge based on exact package version
- -h, --help Print this usage
- -i, --ignore Ignore temporary files from previous runs
- (also won't create any)
- -L, --library NAME Unconditionally emerge existing packages that use
- --library=NAME the library with NAME. NAME can be a full or partial
- library name
- -l, --no-ld-path Do not set LD_LIBRARY_PATH
- -o, --no-order Do not check the build order
- (Saves time, but may cause breakage.)
- -p, --pretend Do a trial run without actually emerging anything
- (also passed to emerge command)
- -q, --quiet Be less verbose (also passed to emerge command)
- -v, --verbose Be more verbose (also passed to emerge command)
-''')
- print( 'Calls emerge, options after -- are ignored by ' + APP_NAME)
- print('and passed directly to emerge.')
-
-
def init_logger(settings):
"""Creates and iitializes our logger according to the settings"""
logger = logging.getLogger()
@@ -94,53 +60,6 @@ def init_logger(settings):
return logger
-def parse_options():
- """Parses the command line options an sets settings accordingly"""
-
- # TODO: Verify: options: no-ld-path, no-order, no-progress
- #are not appliable
-
- settings = DEFAULTS.copy()
- try:
- opts, args = getopt.getopt(sys.argv[1:],
- 'dehiklopqvCL:P',
- ['nocolor', 'debug', 'exact', 'help', 'ignore',
- 'keep-temp', 'library=', 'no-ld-path', 'no-order',
- 'pretend', 'no-pretend', 'no-progress', 'quiet', 'verbose'])
-
- for key, val in opts:
- if key in ('-h', '--help'):
- print_usage()
- sys.exit(0)
- elif key in ('-q', '--quiet'):
- settings['quiet'] = True
- settings['VERBOSITY'] = 0
- elif key in ('-v', '--verbose'):
- settings['VERBOSITY'] = 2
- elif key in ('-d', '--debug'):
- settings['debug'] = True
- settings['VERBOSITY'] = 3
- elif key in ('-p', '--pretend'):
- settings['PRETEND'] = True
- elif key == '--no-pretend':
- settings['NO_PRETEND'] = True
- elif key in ('-e', '--exact'):
- settings['EXACT'] = True
- elif key in ('-C', '--nocolor', '--no-color'):
- settings['nocolor'] = True
- elif key in ('-L', '--library', '--library='):
- settings['library'].update(val.split(','))
- elif key in ('-i', '--ignore'):
- settings['USE_TMP_FILES'] = False
-
- settings['pass_through_options'] = " " + " ".join(args)
- except getopt.GetoptError:
- #logging.info(red('Unrecognized option\n'))
- print(red('Unrecognized option\n'))
- print_usage()
- sys.exit(2)
-
- return settings
def rebuild(logger, assigned, settings):
diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 2d6046f..057147c 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -4,8 +4,11 @@
from __future__ import print_function
+import getopt
import os
import sys
+import re
+import glob
import portage
@@ -43,3 +46,121 @@ DEFAULTS = {
'stdin': sys.stdin,
'stderr': sys.stderr
}
+
+
+def print_usage():
+ """Outputs the help message"""
+ print( APP_NAME + ': (' + VERSION +')')
+ print()
+ print('This is free software; see the source for copying conditions.')
+ print()
+ print('Usage: ' + APP_NAME + ' [OPTIONS] [--] [EMERGE_OPTIONS]')
+ print()
+ print('Broken reverse dependency rebuilder, python implementation.')
+ print()
+ print('Available options:')
+ print('''
+ -C, --nocolor Turn off colored output
+ -d, --debug Print debug informations
+ -e, --exact Emerge based on exact package version
+ -h, --help Print this usage
+ -i, --ignore Ignore temporary files from previous runs
+ (also won't create any)
+ -L, --library NAME Unconditionally emerge existing packages that use
+ --library=NAME the library with NAME. NAME can be a full or partial
+ library name
+ -l, --no-ld-path Do not set LD_LIBRARY_PATH
+ -o, --no-order Do not check the build order
+ (Saves time, but may cause breakage.)
+ -p, --pretend Do a trial run without actually emerging anything
+ (also passed to emerge command)
+ -q, --quiet Be less verbose (also passed to emerge command)
+ -v, --verbose Be more verbose (also passed to emerge command)
+''')
+ print( 'Calls emerge, options after -- are ignored by ' + APP_NAME)
+ print('and passed directly to emerge.')
+
+
+def parse_options():
+ """Parses the command line options an sets settings accordingly"""
+
+ # TODO: Verify: options: no-ld-path, no-order, no-progress
+ #are not appliable
+
+ settings = DEFAULTS.copy()
+ try:
+ opts, args = getopt.getopt(sys.argv[1:],
+ 'dehiklopqvCL:P',
+ ['nocolor', 'debug', 'exact', 'help', 'ignore',
+ 'keep-temp', 'library=', 'no-ld-path', 'no-order',
+ 'pretend', 'no-pretend', 'no-progress', 'quiet', 'verbose'])
+
+ for key, val in opts:
+ if key in ('-h', '--help'):
+ print_usage()
+ sys.exit(0)
+ elif key in ('-q', '--quiet'):
+ settings['quiet'] = True
+ settings['VERBOSITY'] = 0
+ elif key in ('-v', '--verbose'):
+ settings['VERBOSITY'] = 2
+ elif key in ('-d', '--debug'):
+ settings['debug'] = True
+ settings['VERBOSITY'] = 3
+ elif key in ('-p', '--pretend'):
+ settings['PRETEND'] = True
+ elif key == '--no-pretend':
+ settings['NO_PRETEND'] = True
+ elif key in ('-e', '--exact'):
+ settings['EXACT'] = True
+ elif key in ('-C', '--nocolor', '--no-color'):
+ settings['nocolor'] = True
+ elif key in ('-L', '--library', '--library='):
+ settings['library'].update(val.split(','))
+ elif key in ('-i', '--ignore'):
+ settings['USE_TMP_FILES'] = False
+
+ settings['pass_through_options'] = " " + " ".join(args)
+ except getopt.GetoptError:
+ #logging.info(red('Unrecognized option\n'))
+ print(red('Unrecognized option\n'))
+ print_usage()
+ sys.exit(2)
+
+ return settings
+
+
+def parse_revdep_config(revdep_confdir):
+ ''' Parses all files under and returns
+ tuple of: (masked_dirs, masked_files, search_dirs)'''
+
+ search_dirs = set()
+ masked_dirs = set()
+ masked_files = set()
+
+ for _file in os.listdir(revdep_confdir):
+ for line in open(os.path.join(revdep_confdir, _file)):
+ line = line.strip()
+ #first check for comment, we do not want to regex all lines
+ if not line.startswith('#'):
+ match = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
+ if match is not None:
+ masks = match.group(1).split(' ')
+ masked_files.update(masks)
+ continue
+ match = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
+ if match is not None:
+ searches = match.group(1).split(' ')
+ for search in searches:
+ masked_dirs.update(glob.glob(search))
+ continue
+ match = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
+ if match is not None:
+ searches = match.group(1).split()
+ for search in searches:
+ search_dirs.update(glob.glob(search))
+ continue
+
+ print (masked_dirs, masked_files, search_dirs)
+ return (masked_dirs, masked_files, search_dirs)
+
next reply other threads:[~2014-03-24 7:17 UTC|newest]
Thread overview: 115+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 7:17 Slawek Lis [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-05-27 17:27 [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/ Mike Gilbert
2014-11-12 21:29 Paul Varner
2014-11-12 7:16 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-10-30 18:56 Paul Varner
2014-08-28 7:37 Slawek Lis
2014-03-27 6:59 Slawek Lis
2014-03-26 8:21 Slawek Lis
2014-03-24 7:17 Slawek Lis
2014-03-17 6:50 Slawek Lis
2014-03-17 6:50 Slawek Lis
2014-03-11 21:43 Paul Varner
2014-03-11 21:22 Paul Varner
2014-02-19 5:01 Brian Dolbec
2014-02-19 4:33 Brian Dolbec
2014-02-19 4:33 Brian Dolbec
2014-02-19 3:14 Brian Dolbec
2014-02-19 3:14 Brian Dolbec
2014-02-19 3:14 Brian Dolbec
2014-02-19 3:14 Brian Dolbec
2014-02-19 3:14 Brian Dolbec
2014-02-19 3:14 Brian Dolbec
2014-02-19 3:14 Brian Dolbec
2014-02-19 3:14 Brian Dolbec
2014-02-18 18:51 Brian Dolbec
2014-02-18 18:51 Brian Dolbec
2014-02-18 17:59 Brian Dolbec
2014-02-18 17:23 Brian Dolbec
2014-02-18 7:30 Brian Dolbec
2014-02-18 6:15 Brian Dolbec
2014-02-17 10:31 Slawek Lis
2014-02-17 8:50 Slawek Lis
2014-02-16 20:55 Brian Dolbec
2014-02-13 22:08 Paul Varner
2014-02-12 21:12 Paul Varner
2014-02-12 16:20 Brian Dolbec
2014-02-12 16:20 Brian Dolbec
2014-02-12 10:42 Brian Dolbec
2014-02-12 10:22 Brian Dolbec
2014-02-12 10:22 Brian Dolbec
2014-02-12 10:22 Brian Dolbec
2014-02-12 10:22 Brian Dolbec
2014-02-11 19:39 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2014-02-11 8:40 Brian Dolbec
2012-11-09 14:16 Paul Varner
2012-03-19 6:50 Brian Dolbec
2012-03-04 7:41 Brian Dolbec
2012-03-02 17:47 Brian Dolbec
2011-10-10 17:36 Brian Dolbec
2011-10-10 16:09 Brian Dolbec
2011-07-14 18:29 Paul Varner
2011-07-14 18:29 Paul Varner
2011-07-14 2:32 Paul Varner
2011-07-14 1:44 Brian Dolbec
2011-07-14 1:44 Brian Dolbec
2011-07-13 20:06 Paul Varner
2011-07-13 16:01 Paul Varner
2011-07-13 15:35 Brian Dolbec
2011-07-13 5:53 Brian Dolbec
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395642773.39c99972049624c2504358c8455680da6acaee08.slis@gentoo \
--to=slis@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox