Package pybaz :: Class NameParser
[frames] | no frames]

Class NameParser

source code

object --+        
         |        
basestring --+    
             |    
           str --+
                 |
                NameParser

Parser for names in Arch archive namespace.

Implements name parsing natively for performance reasons. It
should behave exactly as tla, any discrepancy is to be considered
a bug, unless tla is obviously buggy.

Bare names of archives, category, branch, versions ids, and
unqualified patchlevel names are not part of the archive
namespace. They can be validated using static methods.

:group Specificity level: is_category, is_package, is_version

:group Presence name components: has_archive, has_category, has_package,
    has_version, has_revision, has_patchlevel

:group Getting name components: get_archive, get_nonarch, get_category,
    get_branch, get_package, get_version, get_package_version,
    get_patchlevel

:group Validating name components: is_archive_name, is_category_name,
    is_branch_name, is_version_id, is_patchlevel



Instance Methods
 
__init__(self, s)
Create a parser object for the given string.
 
get_archive(self)
Get the archive part of the name :return: archive part of the name, or the default archive name, or None if the name is invalid.
 
get_branch(self)
Get the branch part of name :return: part of the name which identifies the branch within the category, or None if the name is invalid or the empty string if the name has no branch component.
 
get_category(self)
Get the Category name :return: part of the name which identifies the category within the archive, or None if the name is invalid or has no category component.
 
get_nonarch(self)
Get Non-archive part of the name :return: the name without the archive component, or None if the name is invalid or has no archive component.
 
get_package(self)
Get the package name :return: part of the name including the category part and branch part (if present) of the name, or None if the name is not valid.
 
get_package_version(self)
Get the unqualified version name :return: part of the name identifying a version in an archive, or None if the name does not contain a version id or is invalid.
 
get_patchlevel(self)
Get the patch-level part of the name :return: part of the name identifying a patch in a version, or None if the name is not a revision or is invalid.
 
get_version(self)
Get the version id part of the name :return: part of the name identifying a version in a branch, or None if the name is invalid or does not contain a version id.
 
has_archive(self)
Does this include an archive name?...
 
has_category(self)
Does this include an category name? All valid names include a category.
 
has_package(self)
Does this include an package name? All valid names include a package.
 
has_patchlevel(self)
Does this include a revision name?...
 
has_version(self)
Does this include a version name?...
 
is_category(self)
Is this a category name?...
 
is_package(self)
Is this a package name (category or branch name)?...
 
is_version(self)
Is this a version name?...
 
object(self)
Create the Category, Branch, Version or Revision object Create the namespace object corresponding to the name.

Inherited from str: __add__, __contains__, __eq__, __ge__, __getattribute__, __getitem__, __getnewargs__, __getslice__, __gt__, __hash__, __le__, __len__, __lt__, __mod__, __mul__, __ne__, __new__, __repr__, __rmod__, __rmul__, __str__, capitalize, center, count, decode, encode, endswith, expandtabs, find, index, isalnum, isalpha, isdigit, islower, isspace, istitle, isupper, join, ljust, lower, lstrip, partition, replace, rfind, rindex, rjust, rpartition, rsplit, rstrip, split, splitlines, startswith, strip, swapcase, title, translate, upper, zfill

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__

Class Methods
 
is_archive_name(klass, s)
Is this string a valid archive name? :param s: string to validate.
 
is_branch_name(klass, s)
Is this string a valid category name? Currently does the same thing as is_category_name, but that might change in the future when the namespace evolves and it is more expressive to have different functions.
 
is_category_name(klass, s)
Is this string a valid category name? Currently does the same thing as is_branch_name, but that might change in the future when the namespace evolves and it is more expressive to have different functions.
 
is_patchlevel(klass, s)
Is this string a valid unqualified patch-level name? :param s: string to validate.
 
is_version_id(klass, s)
Is this string a valid version id? :param s: string to validate.
Properties

Inherited from object: __class__

Method Details

__init__(self, s)
(Constructor)

 
Create a parser object for the given string.

:param s: string to parse.
:type s: str

Overrides: object.__init__

get_archive(self)

 
Get the archive part of the name

:return: archive part of the name, or the default archive name, or None
    if the name is invalid.
:rtype: str, None

get_branch(self)

 
Get the branch part of name

:return: part of the name which identifies the branch within the
    category, or None if the name is invalid or the empty string if the
    name has no branch component.
:rtype: str, None

get_category(self)

 
Get the Category name

:return: part of the name which identifies the category within
    the archive, or None if the name is invalid or has no category
    component.
:rtype: str, None

get_nonarch(self)

 
Get Non-archive part of the name

:return: the name without the archive component, or None if the name is
    invalid or has no archive component.
:rtype: str, None

get_package(self)

 
Get the package name

:return: part of the name including the category part and branch part
    (if present) of the name, or None if the name is not valid.
:rtype: str, None

get_package_version(self)

 
Get the unqualified version name

:return: part of the name identifying a version in an archive, or None
    if the name does not contain a version id or is invalid.
:rtype: str, None

get_patchlevel(self)

 
Get the patch-level part of the name

:return: part of the name identifying a patch in a version, or None if
    the name is not a revision or is invalid.
:rtype: str, None

get_version(self)

 
Get the version id part of the name

:return: part of the name identifying a version in a branch, or None if
    the name is invalid or does not contain a version id.
:rtype: str, None

has_archive(self)

 
Does this include an archive name?

:rtype: bool

has_category(self)

 
Does this include an category name?

All valid names include a category.

:rtype: bool

has_package(self)

 
Does this include an package name?

All valid names include a package.

:rtype: bool

has_patchlevel(self)

 
Does this include a revision name?

:rtype: bool

has_version(self)

 
Does this include a version name?

:rtype: bool

is_archive_name(klass, s)
Class Method

 
Is this string a valid archive name?

:param s: string to validate.
:type s: str
:rtype: bool

is_branch_name(klass, s)
Class Method

 
Is this string a valid category name?

Currently does the same thing as is_category_name, but that might
change in the future when the namespace evolves and it is more
expressive to have different functions.

:param s: string to validate.
:type s: str
:rtype: bool

is_category(self)

 
Is this a category name?

:rtype: bool

is_category_name(klass, s)
Class Method

 
Is this string a valid category name?

Currently does the same thing as is_branch_name, but that might
change in the future when the namespace evolves and it is more
expressive to have different functions.

:param s: string to validate.
:type s: str
:rtype: bool

is_package(self)

 
Is this a package name (category or branch name)?

:rtype: bool

is_patchlevel(klass, s)
Class Method

 
Is this string a valid unqualified patch-level name?

:param s: string to validate.
:type s: str
:rtype: bool

is_version(self)

 
Is this a version name?

:rtype: bool

is_version_id(klass, s)
Class Method

 
Is this string a valid version id?

:param s: string to validate.
:type s: str
:rtype: bool

object(self)

 
Create the Category, Branch, Version or Revision object

Create the namespace object corresponding to the name. This
requires some guessing so, for example, nameless branches will
not be recognized.

This function is unsafe (categories and nameless branches are not
distinguished) and is not really useful. Internally, only namespace
objects should be used, and external output should be validated in a
more specific way.