Merge lp:~mvo/pkgme-devportal/less-silly-contents-file-based-db-backend into lp:~mvo/pkgme-devportal/run-specific-tests
Status: | Superseded |
---|---|
Proposed branch: | lp:~mvo/pkgme-devportal/less-silly-contents-file-based-db-backend |
Merge into: | lp:~mvo/pkgme-devportal/run-specific-tests |
Diff against target: |
386 lines (+271/-11) 5 files modified
README (+17/-8) devportalbinary/configuration.py (+5/-3) devportalbinary/database.py (+159/-0) devportalbinary/tests/data/apt-file-backend/Contents-oneiric-i386 (+47/-0) devportalbinary/tests/test_database.py (+43/-0) |
To merge this branch: | bzr merge lp:~mvo/pkgme-devportal/less-silly-contents-file-based-db-backend |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonathan Lange (community) | Approve | ||
Michael Vogt | Pending | ||
Review via email: mp+119874@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-08-22.
Description of the change
This branch makes the apt-file/
and most importantly fast. With that we could use it to run the scoreboard
once with the regular DB backend and once with the aptfile backend.
Unmerged revisions
- 87. By Michael Vogt
-
devportalbinary
/tests/ test_database. py: use self.assertIsIn stance( ) instead of trying to do the same manually, thanks to jml - 86. By Michael Vogt
-
fix configuration tests as the new default is the AptFilePackageD
atabase backend - 85. By Michael Vogt
-
use the python buildin filter() instead of passing a filter func to iter_contents_
file() - 84. By Michael Vogt
-
use a filter func for iter_contents_
file() instead of the contents path hardcoding - 83. By Michael Vogt
-
iter_contents_file yields a set of pkgnames now instead of a comma seperated string
- 82. By Michael Vogt
-
devportalbinary
/database. py: use (distroseries, arch) as cachekey instead of string, thanks to jml - 81. By Michael Vogt
-
fix typos (thanks to jml)
- 80. By Michael Vogt
-
devportalbinary
/tests/ test_database. py: also test that headers are skipped - 79. By Michael Vogt
-
add test docstrings
- 78. By Michael Vogt
-
another round of refactor/docstring cleanup
Thanks Michael.
The code is very clear and well-structured. I'd draw the lines in slightly different places, but I don't think they are necessary for this to land, or even necessary at all. "Approve with tweaks"
Minor typos:
* iter_contents_file has a typo in its header, "wiht" vs "with"
* _download_ and_prepare_ contents_ file_if_ needed has a typo in its docstring, "Conents" vs "Contents"
* "interessted" vs "interested" in comments in same function
Some other suggestions:
* _get_lib_ to_pkgs_ mapping defaultdict) . How annoying.
* 'cachekey' seems unnecessary. Why not use a tuple as the key?
* Python *almost* has something that does this for you (collections.
In case you're curious, here's what I think I'd do (or at least would muck around with):
* iter_contents_file
* return a set of pkgs, rather than a comma-separated string
* muck around with having it return a dict, or wrap it in something that returns a dict
* split out the filtering code. These three together would make it a proper parser.
* _get_mapping_ from_contents_ file
* after those changes to iter_contents_file, this can be expressed in terms of 'filter' and 'reduce' (well, if only Python had dict versions of basic HOFs)
* _download_ and_prepare_ contents_ file_if_ needed from_contents_ file to use that new 'open' method
* extract the bit inside the 'if' into a function (or method) that downloaded & prepared the file
* make a new method that tried to open the contents file, and then called the download & prepare method if it didn't exist (if e.errno == ENOENT)
* change _get_mapping_
Basically, I have a prejudice against look-before- you-leap and another prejudice toward functional programming.
cheers,
jml