Inheritance |
|
This is a pattern matching object that can be constructed from an attribute pattern. It can be used with the pdg.AttributeOwner.attribMatch function to find the list of matching work item attribute names.
The pattern uses the rules specified in the attribute pattern syntax section.
Methods ¶
Static methods ¶
isValidName(attrib_name)
→ bool
Returns True
if the specified name is a valid attribute name, else returns
False
.
makeValidName(attrib_name)
→ bool
Converts the specified string into a valid attribute name.
splitByAttribute(work_items, attrib_names, partial_matches=False)
→ tuple
This method is deprecated. Use pdg.AttributeSplit.splitByAttribute instead.
splitByFloat(work_items, attrib_name)
→ tuple
This method is deprecated. Use pdg.AttributeSplit.splitByFloat instead.
splitByInt(work_items, attrib_name)
→ tuple
This method is deprecated. Use pdg.AttributeSplit.splitByInt instead.
splitByString(work_items, attrib_name)
→ tuple
This method is deprecated. Use pdg.AttributeSplit.splitByString instead.
Instance Methods ¶
__init__(pattern, default_match_type=pdg.attribMatchType.Plain, strict=True)
Constructs a new pattern object from the specified string. If strict is set
to False
, the attribute names in the pattern can use any characters except
for *
, ^
and white space. If strict is True, only _
or characters that
are alphanumeric can appear in an attribute name. When strict mode is off,
it is not possible to specify an attribute type using the :
separator.
The default_match_type
determines what type of pattern is used when a term in the input string has no explicit *
tokens. For example, if default_match_type
is set to pdg.attribMatchType.Both the pattern will automatically add a *
token on both ends of every term in the pattern, if the term has no existing *
tokens. The pattern example other*
would effectively be the same as *example* other*
in that case. By default, no extra *
tokens are added because the argument is set to pdg.attribMatchType.Plain.
components(name, type=pdg.attribType.Undefined)
→ tuple
Returns a tuple of components from name
that matched against the pattern, in the form (prefix, match, suffix)
. The prefix
component corresponds to the part of name
that matched with any leading *
characters in the pattern, the match
component corrpesonds to the portion of name
that matched the pattern, and suffix
corresponds to the part that matched with a trailing *
. If name
does not match the pattern, this function returns None
.
For example, given the pattern *example*
, the input string an_example
would return the tuple ("an_", "example", "")
. The input string an_example_string
would return ("an_", "example", "_string")
.
contains(name, type=pdg.attribType.Undefined)
→ bool
Returns True if the specified attribute name and type match the pattern,
else False. If type
is set to pdg.attribType.Undefined the type is
ignored when matching the attribute.
multiComponents(input_names=[], keep_plain=False)
→ dict
of tuple
Applies the pdg.AttributePattern.components function for each name in input_names
, and returns a dictionary mapping each input_names
entry to the resulting match component tuple. If an input name does not match the pattern at all, it won’t appear in the output dictionary. If keep_plain
is set to True
, any pattern components that don’t have a *
token in them will always be included in the output dictionary, even if they do not appear in the input_names
.
multiMatch(input_names=[], keep_plain=False)
→ list
of str
Returns an array of string names from the input list that match the pattern. If keep_plain
is set to True
, any pattern components that don’t have a *
token in them will always be included in the output list, even if they do not appear in the input_names
. Consequently, if input_names
is empty and keep_plain
is True
, this function returns the list of pattern components that are expressed as simple string names.
Methods from pdg.BasePattern ¶
errors
: str
Property
If the pattern is invalid, this string contains the parse errors.
isValid
: bool
Property
Set to True if the pattern is valid, else False.
pattern
: str
Property
The source string used to construct this pattern object.