Package repoman :: Module utilities
[hide private]

Module utilities

source code

This module contains utility functions to help repoman find ebuilds to scan

Classes [hide private]
  basestring
str(object='') -> string
  UnknownHerdsError
  _vcs_type
_vcs_type(name, dir_name)
  _copyright_repl
Functions [hide private]
 
detect_vcs_conflicts(options, vcs)
Determine if the checkout has problems like cvs conflicts.
source code
 
have_profile_dir(path, maxdepth=3, filename=u'profiles.desc')
Try to figure out if 'path' has a profiles/ dir in it by checking for the given filename.
source code
 
have_ebuild_dir(path, maxdepth=3)
Try to figure out if 'path' or a subdirectory contains one or more ebuild files named appropriately for their parent directory.
source code
 
parse_metadata_use(xml_tree)
Records are wrapped in XML as per GLEP 56 returns a dict with keys constisting of USE flag names and values containing their respective descriptions
source code
 
check_metadata_herds(xml_tree, herd_base) source code
 
check_metadata(xml_tree, herd_base) source code
 
FindPackagesToScan(settings, startdir, reposplit)
Try to find packages that need to be scanned
source code
 
format_qa_output(formatter, stats, fails, dofull, dofail, options, qawarnings)
Helper function that formats output properly
source code
 
format_qa_output_column(formatter, stats, fails, dofull, dofail, options, qawarnings)
Helper function that formats output in a machine-parseable column format
source code
bool
editor_is_executable(editor)
Given an EDITOR string, validate that it refers to an executable.
source code
string or None
get_commit_message_with_editor(editor, message=None)
Execute editor with a temporary file as it's argument and return the file content afterwards.
source code
string or None
get_commit_message_with_stdin()
Read a commit message from the user and return it.
source code
 
FindPortdir(settings)
Try to figure out what repo we are in and whether we are in a regular tree or an overlay.
source code
 
FindVCS()
Try to figure out in what VCS' working tree we are.
source code
 
_update_copyright_year(year, line)
These two regexes are taken from echangelog update_copyright(), except that we don't hardcode 1999 here (in order to be more generic).
source code
 
update_copyright(fn_path, year, pretend=False)
Check file for a Copyright statement, and update its year.
source code
 
get_committer_name(env=None)
Generate a committer string like echangelog does.
source code
 
UpdateChangeLog(pkgdir, user, msg, skel_path, category, package, new=(), removed=(), changed=(), pretend=False, quiet=False)
Write an entry to an existing ChangeLog, or create a new one.
source code
Variables [hide private]
  _FindVCS_data = (_vcs_type(name=u'git', dir_name=u'.git'), _vc...
  _copyright_re1 = re.compile(r'^(# Copyright \d\d\d\d)-\d\d\d\d ')
  _copyright_re2 = re.compile(r'^(# Copyright )(\d\d\d\d) ')
  __package__ = 'repoman'

Imports: collections, errno, io, chain, logging, pwd, re, stat, sys, subprocess, time, textwrap, difflib, mkstemp, portage, os, shutil, _encodings, _unicode_decode, _unicode_encode, output, BASH_BINARY, _, red, green, find_binary, exception, util, normalize_path


Function Details [hide private]

detect_vcs_conflicts(options, vcs)

source code 
Determine if the checkout has problems like cvs conflicts.

If you want more vcs support here just keep adding if blocks...
This could be better.

TODO(antarus): Also this should probably not call sys.exit() as
repoman is run on >1 packages and one failure should not cause
subsequent packages to fail.

Args:
        vcs - A string identifying the version control system in use
Returns:
        None (calls sys.exit on fatal problems)

FindPackagesToScan(settings, startdir, reposplit)

source code 
Try to find packages that need to be scanned

Args:
        settings - portage.config instance, preferably repoman_settings
        startdir - directory that repoman was run in
        reposplit - root of the repository
Returns:
        A list of directories to scan

format_qa_output(formatter, stats, fails, dofull, dofail, options, qawarnings)

source code 
Helper function that formats output properly

Args:
        formatter - a subclass of Formatter
        stats - a dict of qa status items
        fails - a dict of qa status failures
        dofull - boolean to print full results or a summary
        dofail - boolean to decide if failure was hard or soft

Returns:
        None (modifies formatter)

format_qa_output_column(formatter, stats, fails, dofull, dofail, options, qawarnings)

source code 

Helper function that formats output in a machine-parseable column format

Parameters:
  • formatter (Formatter) - an instance of Formatter
  • path (dict) - dict of qa status items
  • fails (dict) - dict of qa status failures
  • dofull (boolean) - Whether to print full results or a summary
  • dofail (boolean) - Whether failure was hard or soft
  • options (Namespace) - The command-line options provided to repoman
  • qawarnings (set) - the set of warning types
Returns:
None (modifies formatter)

editor_is_executable(editor)

source code 

Given an EDITOR string, validate that it refers to an executable. This uses shlex_split() to split the first component and do a PATH lookup if necessary.

Parameters:
  • editor - An EDITOR value from the environment.
Returns: bool
True if an executable is found, False otherwise.

get_commit_message_with_editor(editor, message=None)

source code 

Execute editor with a temporary file as it's argument and return the file content afterwards.

Parameters:
  • editor - An EDITOR value from the environment
  • message - An iterable of lines to show in the editor.
Returns: string or None
A string on success or None if an error occurs.

get_commit_message_with_stdin()

source code 

Read a commit message from the user and return it.

Returns: string or None
A string on success or None if an error occurs.

FindPortdir(settings)

source code 
Try to figure out what repo we are in and whether we are in a regular
tree or an overlay.

Basic logic is:

1. Determine what directory we are in (supports symlinks).
2. Build a list of directories from / to our current location
3. Iterate over PORTDIR_OVERLAY, if we find a match, search for a profiles directory
         in the overlay.  If it has one, make it portdir, otherwise make it portdir_overlay.
4. If we didn't find an overlay in PORTDIR_OVERLAY, see if we are in PORTDIR; if so, set
         portdir_overlay to PORTDIR.  If we aren't in PORTDIR, see if PWD has a profiles dir, if
         so, set portdir_overlay and portdir to PWD, else make them False.
5. If we haven't found portdir_overlay yet, it means the user is doing something odd, report
         an error.
6. If we haven't found a portdir yet, set portdir to PORTDIR.

Args:
        settings - portage.config instance, preferably repoman_settings
Returns:
        list(portdir, portdir_overlay, location)

update_copyright(fn_path, year, pretend=False)

source code 

Check file for a Copyright statement, and update its year. The patterns used for replacing copyrights are taken from echangelog. Only the first lines of each file that start with a hash ('#') are considered, until a line is found that doesn't start with a hash. Files are read and written in binary mode, so that this function will work correctly with files encoded in any character set, as long as the copyright statements consist of plain ASCII.

UpdateChangeLog(pkgdir, user, msg, skel_path, category, package, new=(), removed=(), changed=(), pretend=False, quiet=False)

source code 

Write an entry to an existing ChangeLog, or create a new one. Updates copyright year on changed files, and updates the header of ChangeLog with the contents of skel.ChangeLog.


Variables Details [hide private]

_FindVCS_data

Value:
(_vcs_type(name=u'git', dir_name=u'.git'),
 _vcs_type(name=u'bzr', dir_name=u'.bzr'),
 _vcs_type(name=u'hg', dir_name=u'.hg'),
 _vcs_type(name=u'svn', dir_name=u'.svn'))