libbe.bugdir

Define BugDir for storing a collection of bugs.

class libbe.bugdir.BugDir(storage, uuid=None, from_storage=False)

A BugDir is a container for Bugs, with some additional attributes.

Parameters :

storage : Storage

Storage instance containing the bug directory. If from_storage is False, storage may be None.

uuid : str, optional

Set the bugdir UUID (see libbe.util.id). Useful if you are loading one of several bugdirs stored in a single Storage instance.

from_storage : bool, optional

If True, attempt to load from storage. Otherwise, setup in memory, saving to storage if it is not None.

See also

SimpleBugDir
bugdir manipulation exampes.

Methods

append(bug[, update])
bug_from_uuid(uuid)
clear_cached_setting([setting]) If setting=None, clear all cached settings
count(...)
extend L.extend(iterable) – extend list by appending elements from the iterable
from_xml(xml_string[, preserve_uuids, verbose]) Note: If a bugdir uuid is given, set .alt_id to it’s value.
has_bug(bug_uuid)
index((value, [start, ...) Raises ValueError if the value is not present.
insert L.insert(index, object) – insert object before index
load_all_bugs() Warning: this could take a while.
load_settings([settings_mapfile])
merge(other[, accept_changes, ...]) Merge info from other into this bugdir.
new_bug([summary, _uuid])
pop(...) Raises IndexError if list is empty or index is out of range.
remove L.remove(value) – remove first occurrence of value.
remove_bug(bug)
reverse L.reverse() – reverse IN PLACE
save() Save any loaded contents to storage.
save_settings()
sibling_uuids()
sort L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE;
uuids([use_cached_disk_uuids])
xml([indent, show_bugs, show_comments])
>>> bug.load_severities(bug.severity_def)
active_status

The allowed active bug states and their descriptions.

This property defaults to None.

append(bug, update=False)
bug_from_uuid(uuid)
extra_strings

Space for an array of extra strings. Useful for storing state for functionality implemented purely in becommands/<some_function>.py.

This property defaults to [].

This property is checked with <function _extra_strings_check_fn at 0xacc4ed4>.

from_xml(xml_string, preserve_uuids=False, verbose=True)

Note: If a bugdir uuid is given, set .alt_id to it’s value. >>> bug.load_severities(bug.severity_def) >>> bug.load_status( ... active_status_def=bug.active_status_def, ... inactive_status_def=bug.inactive_status_def) >>> bugdirA = SimpleBugDir(memory=True) >>> bugdirA.severities = ((‘minor’, ‘The standard bug level.’),) >>> bugdirA.inactive_status = ( ... (‘closed’, ‘The bug is no longer relevant.’),) >>> bugA = bugdirA.bug_from_uuid(‘a’) >>> commA = bugA.comment_root.new_reply(body=’comment A’) >>> commA.uuid = ‘commA’ >>> xml = bugdirA.xml(show_bugs=True, show_comments=True) >>> bugdirB = BugDir(storage=None) >>> bugdirB.from_xml(xml) >>> bugdirB.xml(show_bugs=True, show_comments=True) == xml False >>> bugdirB.uuid = bugdirB.alt_id >>> for bug_ in bugdirB: ... bug_.uuid = bug_.alt_id ... bug_.alt_id = None ... for comm in bug_.comments(): ... comm.uuid = comm.alt_id ... comm.alt_id = None >>> bugdirB.xml(show_bugs=True, show_comments=True) == xml True >>> bugdirB.explicit_attrs # doctest: +NORMALIZE_WHITESPACE [‘severities’, ‘inactive_status’] >>> bugdirC = BugDir(storage=None) >>> bugdirC.from_xml(xml, preserve_uuids=True) >>> bugdirC.uuid == bugdirA.uuid True >>> bugdirC.xml(show_bugs=True, show_comments=True) == xml True >>> bug.load_severities(bug.severity_def) >>> bug.load_status( ... active_status_def=bug.active_status_def, ... inactive_status_def=bug.inactive_status_def) >>> bugdirA.cleanup()

has_bug(bug_uuid)
inactive_status

The allowed inactive bug states and their descriptions.

This property defaults to None.

load_all_bugs()

Warning: this could take a while.

load_settings(settings_mapfile=None)
merge(other, accept_changes=True, accept_extra_strings=True, accept_bugs=True, accept_comments=True, change_exception=False)

Merge info from other into this bugdir.

Overrides any attributes in self that are listed in other.explicit_attrs.

>>> bugdirA = SimpleBugDir()
>>> bugdirA.extra_strings += ['TAG: favorite']
>>> bugdirB = SimpleBugDir()
>>> bugdirB.explicit_attrs = ['target']
>>> bugdirB.target = '1234'
>>> bugdirB.extra_strings += ['TAG: very helpful']
>>> bugdirB.extra_strings += ['TAG: useful']
>>> bugA = bugdirB.bug_from_uuid('a')
>>> commA = bugA.comment_root.new_reply(body='comment A')
>>> commA.uuid = 'uuid-commA'
>>> commA.date = 'Thu, 01 Jan 1970 00:01:00 +0000'
>>> bugC = bugdirB.new_bug(summary='bug C', _uuid='c')
>>> bugC.alt_id = 'alt-c'
>>> bugC.time_string = 'Thu, 01 Jan 1970 00:02:00 +0000'
>>> bugdirA.merge(
...     bugdirB, accept_changes=False, accept_extra_strings=False,
...     accept_bugs=False, change_exception=False)
>>> print(bugdirA.target)
None
>>> bugdirA.merge(
...     bugdirB, accept_changes=False, accept_extra_strings=False,
...     accept_bugs=False, change_exception=True)
Traceback (most recent call last):
  ...
ValueError: Merge would change target "None"->"1234" for bugdir abc123
>>> print(bugdirA.target)
None
>>> bugdirA.merge(
...     bugdirB, accept_changes=True, accept_extra_strings=False,
...     accept_bugs=False, change_exception=True)
Traceback (most recent call last):
  ...
ValueError: Merge would add extra string "TAG: useful" for bugdir abc123
>>> print(bugdirA.target)
1234
>>> print(bugdirA.extra_strings)
['TAG: favorite']
>>> bugdirA.merge(
...     bugdirB, accept_changes=True, accept_extra_strings=True,
...     accept_bugs=False, change_exception=True)
Traceback (most recent call last):
  ...
ValueError: Merge would add bug c (alt: alt-c) to bugdir abc123
>>> print(bugdirA.extra_strings)
['TAG: favorite', 'TAG: useful', 'TAG: very helpful']
>>> bugdirA.merge(
...     bugdirB, accept_changes=True, accept_extra_strings=True,
...     accept_bugs=True, change_exception=True)
>>> print(bugdirA.xml(show_bugs=True, show_comments=True))
... 
<bugdir>
  <uuid>abc123</uuid>
  <short-name>abc</short-name>
  <target>1234</target>
  <extra-string>TAG: favorite</extra-string>
  <extra-string>TAG: useful</extra-string>
  <extra-string>TAG: very helpful</extra-string>
  <bug>
    <uuid>a</uuid>
    <short-name>abc/a</short-name>
    <severity>minor</severity>
    <status>open</status>
    <creator>John Doe &lt;jdoe@example.com&gt;</creator>
    <created>Thu, 01 Jan 1970 00:00:00 +0000</created>
    <summary>Bug A</summary>
    <comment>
      <uuid>uuid-commA</uuid>
      <short-name>abc/a/uui</short-name>
      <author></author>
      <date>Thu, 01 Jan 1970 00:01:00 +0000</date>
      <content-type>text/plain</content-type>
      <body>comment A</body>
    </comment>
  </bug>
  <bug>
    <uuid>b</uuid>
    <short-name>abc/b</short-name>
    <severity>minor</severity>
    <status>closed</status>
    <creator>Jane Doe &lt;jdoe@example.com&gt;</creator>
    <created>Thu, 01 Jan 1970 00:00:00 +0000</created>
    <summary>Bug B</summary>
  </bug>
  <bug>
    <uuid>c</uuid>
    <short-name>abc/c</short-name>
    <severity>minor</severity>
    <status>open</status>
    <created>Thu, 01 Jan 1970 00:02:00 +0000</created>
    <summary>bug C</summary>
  </bug>
</bugdir>
>>> bugdirA.cleanup()
>>> bugdirB.cleanup()
new_bug(summary=None, _uuid=None)
remove_bug(bug)
required_saved_properties = []
save()

Save any loaded contents to storage. Because of lazy loading of bugs and comments, this is actually not too inefficient.

However, if self.storage.is_writeable() == True, then any changes are automatically written to storage as soon as they happen, so calling this method will just waste time (unless something else has been messing with your stored files).

save_settings()
settings_properties = ['target', 'severities', 'active_status', 'inactive_status', 'extra_strings']
severities

The allowed bug severities and their descriptions.

This property defaults to None.

sibling_uuids()
target

The current project development target.

This property defaults to None.

uuids(use_cached_disk_uuids=True)
xml(indent=0, show_bugs=False, show_comments=False)
>>> bug.load_severities(bug.severity_def)
>>> bug.load_status(
...     active_status_def=bug.active_status_def,
...     inactive_status_def=bug.inactive_status_def)
>>> bugdirA = SimpleBugDir(memory=True)
>>> bugdirA.severities
>>> bugdirA.severities = (('minor', 'The standard bug level.'),)
>>> bugdirA.inactive_status = (
...     ('closed', 'The bug is no longer relevant.'),)
>>> bugA = bugdirA.bug_from_uuid('a')
>>> commA = bugA.comment_root.new_reply(body='comment A')
>>> commA.uuid = 'commA'
>>> commA.date = 'Thu, 01 Jan 1970 00:03:00 +0000'
>>> print(bugdirA.xml(show_bugs=True, show_comments=True))
... 
<bugdir>
  <uuid>abc123</uuid>
  <short-name>abc</short-name>
  <severities>
    <entry>
      <key>minor</key>
      <value>The standard bug level.</value>
    </entry>
  </severities>
  <inactive-status>
    <entry>
      <key>closed</key>
      <value>The bug is no longer relevant.</value>
    </entry>
  </inactive-status>
  <bug>
    <uuid>a</uuid>
    <short-name>abc/a</short-name>
    <severity>minor</severity>
    <status>open</status>
    <creator>John Doe &lt;jdoe@example.com&gt;</creator>
    <created>Thu, 01 Jan 1970 00:00:00 +0000</created>
    <summary>Bug A</summary>
    <comment>
      <uuid>commA</uuid>
      <short-name>abc/a/com</short-name>
      <author></author>
      <date>Thu, 01 Jan 1970 00:03:00 +0000</date>
      <content-type>text/plain</content-type>
      <body>comment A</body>
    </comment>
  </bug>
  <bug>
    <uuid>b</uuid>
    <short-name>abc/b</short-name>
    <severity>minor</severity>
    <status>closed</status>
    <creator>Jane Doe &lt;jdoe@example.com&gt;</creator>
    <created>Thu, 01 Jan 1970 00:00:00 +0000</created>
    <summary>Bug B</summary>
  </bug>
</bugdir>
>>> bug.load_severities(bug.severity_def)
>>> bug.load_status(
...     active_status_def=bug.active_status_def,
...     inactive_status_def=bug.inactive_status_def)
>>> bugdirA.cleanup()
exception libbe.bugdir.NoBugMatches(*args, **kwargs)
class libbe.bugdir.RevisionedBugDir(bugdir, revision)

RevisionedBugDirs are read-only copies used for generating diffs between revisions.

Methods

append(bug[, update])
bug_from_uuid(uuid)
changed()
clear_cached_setting([setting]) If setting=None, clear all cached settings
count(...)
extend L.extend(iterable) – extend list by appending elements from the iterable
from_xml(xml_string[, preserve_uuids, verbose]) Note: If a bugdir uuid is given, set .alt_id to it’s value.
has_bug(bug_uuid)
index((value, [start, ...) Raises ValueError if the value is not present.
insert L.insert(index, object) – insert object before index
load_all_bugs() Warning: this could take a while.
load_settings([settings_mapfile])
merge(other[, accept_changes, ...]) Merge info from other into this bugdir.
new_bug([summary, _uuid])
pop(...) Raises IndexError if list is empty or index is out of range.
remove L.remove(value) – remove first occurrence of value.
remove_bug(bug)
reverse L.reverse() – reverse IN PLACE
save() Save any loaded contents to storage.
save_settings()
sibling_uuids()
sort L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE;
uuids([use_cached_disk_uuids])
xml([indent, show_bugs, show_comments])
>>> bug.load_severities(bug.severity_def)
changed()

This Page