[ditrack commit] r806 - in src/trunk/DITrack: . Command
Vlad Skvortsov
vss at 73rus.com
Fri Nov 10 12:51:17 PST 2006
Great, I was really annoyed that 'dt ls 0.5' wasn't working but haven't
had a chance to fix it myself. ;-)
oleg at ditrack.org wrote:
>Author: oleg
>Date: 2006-11-10 10:14:36 -0800 (Fri, 10 Nov 2006)
>New Revision: 806
>
>Modified:
> src/trunk/DITrack/Command/list.py
> src/trunk/DITrack/DB.py
>Log:
>added a new class for reading filter configuration file
>restored function of "dt list" with filters
>
>
It's worth adding a test case for 'dt ls' with predefined filter. Could
you do that (or at least add a note to TODO)?
>Modified: src/trunk/DITrack/Command/list.py
>===================================================================
>--- src/trunk/DITrack/Command/list.py 2006-11-08 00:10:47 UTC (rev 805)
>+++ src/trunk/DITrack/Command/list.py 2006-11-10 18:14:36 UTC (rev 806)
>@@ -51,10 +51,10 @@
>
> if not inplace_re.search(str):
> # Looks like a filter name
>- if not db.filter.has_key(str):
>+ if not db.cfg.filters.has_key(str):
>
>
Would
if str not in db.cfg.filters:
be more readable?
> raise FilterUnknownError(str)
>
>- str = db.filter[str]
>+ str = db.cfg.filters[str]
>
>
Since we are on topic here, I think it's worth moving the Filter class
into DITrack.DB, so that db.cfg.filter[str] returns ready-to-use filter
object to apply. Thus all clients (command-line client, web front-end)
will have the same notion of filter and wouldn't have to parse strings
and build filter obejcts themselves. Opinions?
> # Split into subclauses.
> clauses = filter(lambda x: len(x), str.split(","))
>
>Modified: src/trunk/DITrack/DB.py
>===================================================================
>--- src/trunk/DITrack/DB.py 2006-11-08 00:10:47 UTC (rev 805)
>+++ src/trunk/DITrack/DB.py 2006-11-10 18:14:36 UTC (rev 806)
>@@ -344,6 +344,44 @@
>
> has_key = __contains__
>
>+
>+class FilterCfg:
>+ """
>+ A representation of filters configuration.
>+ """
>+
>+ def __contains__(self, key):
>+ return self.items.has_key(key)
>+
>+ def __getitem__(self, key):
>+ return self.items[key]
>+
>+ def __init__(self, path):
>+ f = open(path)
>+ filters = email.message_from_file(f)
>+ f.close()
>+
>+ if len(filters.get_payload()):
>+ raise CorruptedDB_UnparseableFiltersError("Empty line in filter "
>+ "configuration file")
>
>
CorruptedDB_UnparseableFiltersError is not defined.
>+
>+ self.items = {}
>+ for s in filters.keys():
>+
>+ if s in self.items:
>+ raise CorruptedDB_UnparseableFiltersError("Duplicate filter "
>+ "set '" + s + "' definition")
>
>
Copy-paste error: "set" is not needed here.
>+
>+ filter = filters[s].strip()
>+
>+ if not filter:
>+ raise CorruptedDB_UnparseableFiltersError("Empty filter "
>+ "set '" + s + "' definition")
>
>
Same here.
>+
>+ self.items[s] = filter
>+
>+ has_key = __contains__
>+
> class Configuration:
> """
> Database configuration object (everything under /etc in a database).
>@@ -400,6 +438,8 @@
> self.category = CategoryCfg(self.path["categories"], self.users,
> self.versions)
>
>+ self.filters = FilterCfg(self.path["filters"])
>+
> class Issue:
> """
> A representation of an issue record.
>
>_______________________________________________
>Commit mailing list
>Commit at lists.ditrack.org
>http://lists.ditrack.org/mailman/listinfo/commit
>
>
--
Vlad Skvortsov, vss at 73rus.com, http://vss.73rus.com
More information about the Dev
mailing list