Merge lp:~blr/launchpad/dont-fear-the-repr into lp:launchpad

Proposed by Kit Randel on 2015-06-05
Status: Merged
Merged at revision: 17550
Proposed branch: lp:~blr/launchpad/dont-fear-the-repr
Merge into: lp:launchpad
Diff against target: 79 lines (+36/-0)
4 files modified
lib/lp/soyuz/model/packagediffjob.py (+13/-0)
lib/lp/soyuz/model/sourcepackagerelease.py (+6/-0)
lib/lp/soyuz/tests/test_packagediffjob.py (+9/-0)
lib/lp/soyuz/tests/test_sourcepackagerelease.py (+8/-0)
To merge this branch: bzr merge lp:~blr/launchpad/dont-fear-the-repr
Reviewer Review Type Date Requested Status
William Grant code 2015-06-05 Approve on 2015-06-05
Review via email: mp+261174@code.launchpad.net

Commit Message

Add a repr for PackageDiffJob and SourcePackageRelease.

Description of the Change

Adds a repr for PackageDiffJob in the form:

<PackageDiffJob from {from-sourcepkg-name} (id: {from-id}, version: {from-version}) to {to-sourcepkg-name} (id: {to-id}, version: {to-version}) for {requester}>

and a repr for SourcePackageRelease in the form:
<{name} (id: {id}, version: {version})>

To post a comment you must log in.
William Grant (wgrant) wrote :

from_source and to_source are NOT NULL in the DB, so checking for None there isn't really necessary. It might be worth giving SourcePackageRelease a sensible repr rather than manually formatting two of them here.

Kit Randel (blr) wrote :

> It might be worth giving SourcePackageRelease a
> sensible repr rather than manually formatting two of them here.
Sounds good, I'll look at that, thanks.

William Grant (wgrant) wrote :

The SourcePackageRelease repr should start with "<SourcePackageRelease", as it currently doesn't indicate which package it is. Might as well also call repr() on the object rather than manually invoking __repr__().

review: Needs Fixing (code)
Kit Randel (blr) wrote :

Thanks, have tidied that up.

On Fri, Jun 5, 2015 at 9:27 PM, William Grant <email address hidden> wrote:

> Review: Needs Fixing code
>
> The SourcePackageRelease repr should start with "<SourcePackageRelease",
> as it currently doesn't indicate which package it is. Might as well also
> call repr() on the object rather than manually invoking __repr__().
> --
> https://code.launchpad.net/~blr/launchpad/dont-fear-the-repr/+merge/261174
> You are the owner of lp:~blr/launchpad/dont-fear-the-repr.
>

--
Kit Randel (blr)
Canonical - Ubuntu Engineering - Launchpad & Continuous Integration Team

William Grant (wgrant) :
review: Approve (code)
Barki Mustapha (mustbarki) wrote :
Download full text (3.2 KiB)

please i need all help about
commands sudo
and how to be more efficient

Join me on tsū, they are sharing social revenues with all of us
http://mlmmomsndads.com/barki2015 #‎tsunation
https://www.tsu.co/barki2015
#‎workwithbarki #‎love
My Resume <http://sdrv.ms/1g78uwe>:
http://www.fourcornersalliancegroup.com/?a=barkimustapha
  https://skydrive.live.com/redir?resid=2DFE3F29565FB012%21273
1) BARKI MUSTAPHA
2) 3 Lot Redouane 20800 Mohammedia Morocco
3) +212678466468
4) Paypal : <email address hidden>
5) BMCE BANK
6) Agence BMCE Mohammedia Boulvard Palestine N 3031 Lotissement Redouane
7) 7870011200000022732
8) 011787000011200000022732/ BMCE MAMC
9) Engineer Marine 19/01/1976 Maried
10) Card id A766807
Engineer Automation http://www.fourcornersalliancegroup.com/?a=barkimustapha
SEA CAPTAIN
https://drive.google.com/file/d/0B-KpjpI-05IlcklPZmtOb2ZqZ2c/edit?usp=sharing
skype : barki.mustapha2
As engineer Marine GSE, I can bring my knowledge and expertise in
automation, servo, mechanical, hydraulic, traditional security, management
and HR / equipment,.

Responsive and very adaptable, I am convinced that a company like yours
will appreciate my motivation and drive that inspires me. Your goals become
mine and I know how to invest in your projects
YOU ask rigor, methodology and professionalism and personal attention at
all times. My internship allowed me to have a good view of this environment
and put into practice my knowledge. Rewarding, they convinced me of my
desire to get involved further on behalf of a company that will offer me a
position of responsibility.
I stand at your disposal and I think that an interview will allow me to
convince you of my serious.
B.M #mastercard <https://www.facebook.com/hashtag/mastercard> #free
<https://www.facebook.com/hashtag/free> #income
<https://www.facebook.com/hashtag/income> #program
<https://www.facebook.com/hashtag/program> join me for free http://
share.payoneer-affiliates.com/a/clk/1yW6bg #payoneer
<http://share.payoneer-affiliates.com/a/clk/1yW6bg#payoneer> #mastercard
<https://www.facebook.com/hashtag/mastercard> #free
<https://www.facebook.com/hashtag/free> #income
<https://www.facebook.com/hashtag/income> #program
<https://www.facebook.com/hashtag/program>
#success <https://www.facebook.com/hashtag/success> #instagood
<https://www.facebook.com/hashtag/instagood> #photooftheday
<https://www.facebook.com/hashtag/photooftheday> #picoftheday
<https://www.facebook.com/hashtag/picoftheday> #bestoftheday
<https://www.facebook.com/hashtag/bestoftheday> #instadaily
<https://www.facebook.com/hashtag/instadaily> #igdaily
<https://www.facebook.com/hashtag/igdaily> #follow
<https://www.facebook.com/hashtag/follow> #entrepreneur
<https://www.facebook.com/hashtag/entrepreneur> #money
<https://www.facebook.com/hashtag/money> #networkmarketing
<https://www.facebook.com/hashtag/networkmarketing> #mlm
<https://www.facebook.com/hashtag/mlm> #worldventures
<https://www.facebook.com/hashtag/worldventures> #motivation
<https://www.facebook.com/hashtag/motivation> #quotes
<https://www.facebook.com/hashtag/quotes>

2015-06-05 23:32 GMT+01:00 William Grant <email address hidden>:

> Review: Approve code
>
>
> --
> htt...

Read more...

Barki Mustapha (mustbarki) wrote :
Download full text (6.6 KiB)

shot down system thirth party
new config
about error
is sudo apt-get install-f
unknow for mine

Join me on tsū, they are sharing social revenues with all of us
http://mlmmomsndads.com/barki2015 #‎tsunation
https://www.tsu.co/barki2015
#‎workwithbarki #‎love
My Resume <http://sdrv.ms/1g78uwe>:
http://www.fourcornersalliancegroup.com/?a=barkimustapha
  https://skydrive.live.com/redir?resid=2DFE3F29565FB012%21273
1) BARKI MUSTAPHA
2) 3 Lot Redouane 20800 Mohammedia Morocco
3) +212678466468
4) Paypal : <email address hidden>
5) BMCE BANK
6) Agence BMCE Mohammedia Boulvard Palestine N 3031 Lotissement Redouane
7) 7870011200000022732
8) 011787000011200000022732/ BMCE MAMC
9) Engineer Marine 19/01/1976 Maried
10) Card id A766807
Engineer Automation http://www.fourcornersalliancegroup.com/?a=barkimustapha
SEA CAPTAIN
https://drive.google.com/file/d/0B-KpjpI-05IlcklPZmtOb2ZqZ2c/edit?usp=sharing
skype : barki.mustapha2
As engineer Marine GSE, I can bring my knowledge and expertise in
automation, servo, mechanical, hydraulic, traditional security, management
and HR / equipment,.

Responsive and very adaptable, I am convinced that a company like yours
will appreciate my motivation and drive that inspires me. Your goals become
mine and I know how to invest in your projects
YOU ask rigor, methodology and professionalism and personal attention at
all times. My internship allowed me to have a good view of this environment
and put into practice my knowledge. Rewarding, they convinced me of my
desire to get involved further on behalf of a company that will offer me a
position of responsibility.
I stand at your disposal and I think that an interview will allow me to
convince you of my serious.
B.M #mastercard <https://www.facebook.com/hashtag/mastercard> #free
<https://www.facebook.com/hashtag/free> #income
<https://www.facebook.com/hashtag/income> #program
<https://www.facebook.com/hashtag/program> join me for free http://
share.payoneer-affiliates.com/a/clk/1yW6bg #payoneer
<http://share.payoneer-affiliates.com/a/clk/1yW6bg#payoneer> #mastercard
<https://www.facebook.com/hashtag/mastercard> #free
<https://www.facebook.com/hashtag/free> #income
<https://www.facebook.com/hashtag/income> #program
<https://www.facebook.com/hashtag/program>
#success <https://www.facebook.com/hashtag/success> #instagood
<https://www.facebook.com/hashtag/instagood> #photooftheday
<https://www.facebook.com/hashtag/photooftheday> #picoftheday
<https://www.facebook.com/hashtag/picoftheday> #bestoftheday
<https://www.facebook.com/hashtag/bestoftheday> #instadaily
<https://www.facebook.com/hashtag/instadaily> #igdaily
<https://www.facebook.com/hashtag/igdaily> #follow
<https://www.facebook.com/hashtag/follow> #entrepreneur
<https://www.facebook.com/hashtag/entrepreneur> #money
<https://www.facebook.com/hashtag/money> #networkmarketing
<https://www.facebook.com/hashtag/networkmarketing> #mlm
<https://www.facebook.com/hashtag/mlm> #worldventures
<https://www.facebook.com/hashtag/worldventures> #motivation
<https://www.facebook.com/hashtag/motivation> #quotes
<https://www.facebook.com/hashtag/quotes>

2015-06-06 1:42 GMT+01:00 Barki Mustapha <email address hidden>:

> please i need...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/model/packagediffjob.py'
2--- lib/lp/soyuz/model/packagediffjob.py 2013-07-24 10:48:00 +0000
3+++ lib/lp/soyuz/model/packagediffjob.py 2015-06-05 21:27:05 +0000
4@@ -66,6 +66,19 @@
5 implements(IPackageDiffJob)
6 classProvides(IPackageDiffJobSource)
7
8+ def __repr__(self):
9+ """Returns an informative representation of a PackageDiff job."""
10+ diff = self.packagediff
11+ parts = ['{cls} from {from_spr} to {to_spr}'.format(
12+ cls=self.__class__.__name__,
13+ from_spr=repr(diff.from_source),
14+ to_spr=repr(diff.to_source))
15+ ]
16+ if diff.requester is not None:
17+ parts.append(' for {requester}'.format(
18+ requester=diff.requester.name))
19+ return '<{repr}>'.format(repr=''.join(parts))
20+
21 @property
22 def packagediff_id(self):
23 return simplejson.loads(self.base_json_data)['packagediff']
24
25=== modified file 'lib/lp/soyuz/model/sourcepackagerelease.py'
26--- lib/lp/soyuz/model/sourcepackagerelease.py 2015-02-11 14:43:44 +0000
27+++ lib/lp/soyuz/model/sourcepackagerelease.py 2015-06-05 21:27:05 +0000
28@@ -143,6 +143,12 @@
29 super(SourcePackageRelease, self).__init__(*args, **kwargs)
30 self.copyright = copyright
31
32+ def __repr__(self):
33+ """Returns an informative representation of a SourcePackageRelease."""
34+ return '<{cls} {pkg_name} (id: {id}, version: {version})>'.format(
35+ cls=self.__class__.__name__, pkg_name=self.name,
36+ id=self.id, version=self.version)
37+
38 @property
39 def copyright(self):
40 """See `ISourcePackageRelease`."""
41
42=== modified file 'lib/lp/soyuz/tests/test_packagediffjob.py'
43--- lib/lp/soyuz/tests/test_packagediffjob.py 2013-08-07 06:26:36 +0000
44+++ lib/lp/soyuz/tests/test_packagediffjob.py 2015-06-05 21:27:05 +0000
45@@ -64,6 +64,15 @@
46 jobs = list(PackageDiffJob.iterReady())
47 self.assertEqual(1, len(jobs))
48
49+ def test___repr__(self):
50+ _, job = self.makeJob()
51+ expected_repr = ('<PackageDiffJob from {from_spr}'
52+ ' to {to_spr} for {user}>').format(
53+ from_spr=repr(job.packagediff.from_source),
54+ to_spr=repr(job.packagediff.to_source),
55+ user=job.packagediff.requester.name)
56+ self.assertEqual(expected_repr, repr(job))
57+
58 def test_run(self):
59 diff, job = self.makeJob()
60 method = FakeMethod()
61
62=== modified file 'lib/lp/soyuz/tests/test_sourcepackagerelease.py'
63--- lib/lp/soyuz/tests/test_sourcepackagerelease.py 2014-10-31 10:34:51 +0000
64+++ lib/lp/soyuz/tests/test_sourcepackagerelease.py 2015-06-05 21:27:05 +0000
65@@ -25,6 +25,14 @@
66 spr = self.factory.makeSourcePackageRelease()
67 self.assertIs(None, spr.uploader)
68
69+ def test___repr__(self):
70+ spr = self.factory.makeSourcePackageRelease()
71+ expected_repr = ('<{cls} {pkg_name} (id: {id}, '
72+ 'version: {version})>').format(
73+ cls=spr.__class__.__name__, pkg_name=spr.name,
74+ id=spr.id, version=spr.version)
75+ self.assertEqual(expected_repr, repr(spr))
76+
77 def test_uploader_dsc_package(self):
78 owner = self.factory.makePerson()
79 key = self.factory.makeGPGKey(owner)