New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM7183: Port to Python 3 #2
Conversation
Two quick observations:
|
Squashed commits: [448ae0b] Fixing warnings from flake8
Squashed commits: [b173929] more flake8 cleanup
…llowed in python 3 converted command line output reading from bin to utf-8 Fixed ShareData references
…ackages (like cat)
Fixing api docs flake8 cleanup Ran futurize -2 -x division_safe -n -w .
ec2eb03
to
00a7e68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very similar comments to those I made in lsst/ctrl_execute#2 -- lots of if False
that I don't think are needed. Asserts need modernizing.
Also, the review system killed the performance of Safari...
@@ -66,26 +73,26 @@ def _extract(self, field, repos, policy, pipelinePolicySet): | |||
if policy.getValueType(field) == pol.Policy.FILE: | |||
filename = policy.getFile(field).getPath() | |||
filename = os.path.join(repos, filename) | |||
if (filename in self.policySet) == False: | |||
if (filename in self.policySet) is False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if filename not in self.policySet:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in DM-7183
self.policySet.add(filename) | ||
if (filename in pipelinePolicySet) == False: | ||
if (filename in pipelinePolicySet) is False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use not in
and drop the is False
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in DM-7183
if bFirst == True: | ||
item = list[0] | ||
while os.path.exists(item) == False: | ||
if bFirst is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if bFirst
is a boolean type then we don't need the is True
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in DM-7183
while os.path.exists(item) == False: | ||
if bFirst is True: | ||
item = fileList[0] | ||
while os.path.exists(item) is False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while not os.path.exists(item):
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in DM-7183
newlist = [ item for item in list if (os.path.exists(item) == False)] | ||
list = newlist | ||
while len(fileList) > 0: | ||
newlist = [item for item2 in fileList if (os.path.exists(item) is False)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... if not os.path.exists(item)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-wrote this loop in DM-7639
self.sd.release() | ||
self.assert_(not self.sd._is_owned(), "lock not released") | ||
self.assertTrue(not self.sd._is_owned(), "lock not released") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertFalse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in DM-7639
@@ -157,59 +158,60 @@ def testNoLockRead(self): | |||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with self.assertRaises
for key in "name test config".split(): | ||
self.assert_(key in attrs, "Missing attr: " + key) | ||
self.assertTrue(key in attrs, "Missing attr: " + key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertIn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in DM-7639
self.assert_(isinstance(self.sd.test, bool)) | ||
self.assert_(self.sd.test) | ||
self.assertEqual(self.sd.name, "Ray") | ||
self.assertTrue(isinstance(self.sd.test, bool)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertIsInstance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in DM-7639
protected = self.sd.config | ||
self.assert_(isinstance(protected, dict)) | ||
self.assertEquals(len(protected), 0) | ||
self.assertTrue(isinstance(protected, dict)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertIsInstance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in DM-7639
fix list(keys()) redundancy is SharedData
newlist = [ item for item in list if (os.path.exists(item) == False)] | ||
list = newlist | ||
while len(fileList) > 0: | ||
newlist = [item for item2 in fileList if (os.path.exists(item) is False)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this item
is changed to item2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent catch. It would seem this should be
newlist = [item for item in fileList if not os.path.exists(item)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in DM-7639; rewrote this loop.
def dir(self): | ||
return filter(lambda k: k != "__", self._d.keys()) | ||
|
||
return list([k for k in self._d if k != "__"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this list()
needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The [...]
is already a list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in DM-7639
@srp3rd I'm not sure what happened here because this branch really needed to be rebased and there's a weird "merge from master" in the history. Also, you did not address the |
This was merge was an error because I when I looked for the pull on Monday, I didn't see it, and merge on Tuesday when I saw the message in jira that code had been reviewed. In between marking it for review and this pull, I made additional changes to the "is True", "is False", and list(keys()) code (which is why I marked them here as fixed in DM-7183). |
No description provided.