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

Type NameParser

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.


Method Summary
  __init__(self, s)
Create a parser object for the given string.
  object(self)
Create the Category, Branch, Version or Revision object
    Specificity level

bool

is_category(self)
Is this a category name?

bool

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

bool

is_version(self)
Is this a version name?
    Presence name components

bool

has_archive(self)
Does this include an archive name?

bool

has_category(self)
Does this include an category name?

bool

has_package(self)
Does this include an package name?

bool

has_version(self)
Does this include a version name?

bool

has_patchlevel(self)
Does this include a revision name?
    Getting name components

str, None

get_archive(self)
Get the archive part of the name

str, None

get_nonarch(self)
Get Non-archive part of the name

str, None

get_category(self)
Get the Category name

str, None

get_branch(self)
Get the branch part of name

str, None

get_package(self)
Get the package name

str, None

get_version(self)
Get the version id part of the name

str, None

get_package_version(self)
Get the unqualified version name

str, None

get_patchlevel(self)
Get the patch-level part of the name
    Validating name components

bool

is_archive_name(klass, s)
Is this string a valid archive name? (Class method)

bool

is_category_name(klass, s)
Is this string a valid category name? (Class method)

bool

is_branch_name(klass, s)
Is this string a valid category name? (Class method)

bool

is_version_id(klass, s)
Is this string a valid version id? (Class method)

bool

is_patchlevel(klass, s)
Is this string a valid unqualified patch-level name? (Class method)
    Inherited from str
  __add__(x, y)
x.__add__(y) <==> x+y
  __contains__(x, y)
x.__contains__(y) <==> y in x
  __eq__(x, y)
x.__eq__(y) <==> x==y
  __ge__(x, y)
x.__ge__(y) <==> x>=y
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __getitem__(x, y)
x.__getitem__(y) <==> x[y]
  __getnewargs__(...)
  __getslice__(x, i, j)
Use of negative indices is not supported.
  __gt__(x, y)
x.__gt__(y) <==> x>y
  __hash__(x)
x.__hash__() <==> hash(x)
  __le__(x, y)
x.__le__(y) <==> x<=y
  __len__(x)
x.__len__() <==> len(x)
  __lt__(x, y)
x.__lt__(y) <==> x<y
  __mod__(x, y)
x.__mod__(y) <==> x%y
  __mul__(x, n)
x.__mul__(n) <==> x*n
  __ne__(x, y)
x.__ne__(y) <==> x!=y
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __repr__(x)
x.__repr__() <==> repr(x)
  __rmod__(x, y)
x.__rmod__(y) <==> y%x
  __rmul__(x, n)
x.__rmul__(n) <==> n*x
  __str__(x)
x.__str__() <==> str(x)
  capitalize(S)
Return a copy of the string S with only its first character capitalized.
  center(S, width)
Return S centered in a string of length width.
  count(S, sub, start, end)
Return the number of occurrences of substring sub in string S[start:end].
  decode(S, encoding, errors)
Decodes S using the codec registered for encoding.
  encode(S, encoding, errors)
Encodes S using the codec registered for encoding.
  endswith(S, suffix, start, end)
Return True if S ends with the specified suffix, False otherwise.
  expandtabs(S, tabsize)
Return a copy of S where all tab characters are expanded using spaces.
  find(S, sub, start, end)
Return the lowest index in S where substring sub is found, such that sub is contained within s[start,end].
  index(S, sub, start, end)
Like S.find() but raise ValueError when the substring is not found.
  isalnum(S)
Return True if all characters in S are alphanumeric and there is at least one character in S, False otherwise.
  isalpha(S)
Return True if all characters in S are alphabetic and there is at least one character in S, False otherwise.
  isdigit(S)
Return True if all characters in S are digits and there is at least one character in S, False otherwise.
  islower(S)
Return True if all cased characters in S are lowercase and there is at least one cased character in S, False otherwise.
  isspace(S)
Return True if all characters in S are whitespace and there is at least one character in S, False otherwise.
  istitle(S)
Return True if S is a titlecased string and there is at least one character in S, i.e.
  isupper(S)
Return True if all cased characters in S are uppercase and there is at least one cased character in S, False otherwise.
  join(S, sequence)
Return a string which is the concatenation of the strings in the sequence.
  ljust(S, width)
Return S left justified in a string of length width.
  lower(S)
Return a copy of the string S converted to lowercase.
  lstrip(S, chars)
Return a copy of the string S with leading whitespace removed.
  replace(...)
S.replace (old, new[, count]) -> string
  rfind(S, sub, start, end)
Return the highest index in S where substring sub is found, such that sub is contained within s[start,end].
  rindex(S, sub, start, end)
Like S.rfind() but raise ValueError when the substring is not found.
  rjust(S, width)
Return S right justified in a string of length width.
  rstrip(S, chars)
Return a copy of the string S with trailing whitespace removed.
  split(S, sep, maxsplit)
Return a list of the words in the string S, using sep as the delimiter string.
  splitlines(S, keepends)
Return a list of the lines in S, breaking at line boundaries.
  startswith(S, prefix, start, end)
Return True if S starts with the specified prefix, False otherwise.
  strip(S, chars)
Return a copy of the string S with leading and trailing whitespace removed.
  swapcase(S)
Return a copy of the string S with uppercase characters converted to lowercase and vice versa.
  title(S)
Return a titlecased version of S, i.e.
  translate(S, table, deletechars)
Return a copy of the string S, where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256.
  upper(S)
Return a copy of the string S converted to uppercase.
  zfill(S, width)
Pad a numeric string S with zeros on the left, to fill a field of the specified width.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Instance Method Details

is_category(self)

Is this a category name?

Returns:

bool

is_package(self)

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

Returns:

bool

is_version(self)

Is this a version name?

Returns:

bool

has_archive(self)

Does this include an archive name?

Returns:

bool

has_category(self)

Does this include an category name?

All valid names include a category.

Returns:

bool

has_package(self)

Does this include an package name?

All valid names include a package.

Returns:

bool

has_version(self)

Does this include a version name?

Returns:

bool

has_patchlevel(self)

Does this include a revision name?

Returns:

bool

get_archive(self)

Get the archive part of the name

Returns:

archive part of the name, or the default archive name, or None if the name is invalid.


           (type=

str, None

)

get_nonarch(self)

Get Non-archive part of the name

Returns:

the name without the archive component, or None if the name is invalid or has no archive component.


           (type=

str, None

)

get_category(self)

Get the Category name

Returns:

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


           (type=

str, None

)

get_branch(self)

Get the branch part of name

Returns:

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.


           (type=

str, None

)

get_package(self)

Get the package name

Returns:

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


           (type=

str, None

)

get_version(self)

Get the version id part of the name

Returns:

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


           (type=

str, None

)

get_package_version(self)

Get the unqualified version name

Returns:

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


           (type=

str, None

)

get_patchlevel(self)

Get the patch-level part of the name

Returns:

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


           (type=

str, None

)

__init__(self, s)
(Constructor)

Create a parser object for the given string.

Parameters:
s -

string to parse.


           (type=

str

)
Overrides:
__builtin__.object.__init__

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.


Class Method Details

is_archive_name(klass, s)

Is this string a valid archive name?

Parameters:
s -

string to validate.


           (type=

str

)
Returns:

bool

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.

Parameters:
s -

string to validate.


           (type=

str

)
Returns:

bool

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.

Parameters:
s -

string to validate.


           (type=

str

)
Returns:

bool

is_version_id(klass, s)

Is this string a valid version id?

Parameters:
s -

string to validate.


           (type=

str

)
Returns:

bool

is_patchlevel(klass, s)

Is this string a valid unqualified patch-level name?

Parameters:
s -

string to validate.


           (type=

str

)
Returns:

bool


Generated by Epydoc 2.1 on Fri Jul 7 17:05:30 2006 http://epydoc.sf.net