Skip to content

Sourcery refactored master branch#2

Open
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master
Open

Sourcery refactored master branch#2
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Apr 24, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from kimocoder April 24, 2023 01:36
Comment on lines -42 to +52
retVal = []
retVal = []

# If there are no commands, or no user input, return null
if tree is None or len(tokens) == 0:
retVal = []
# If there is only one word, only auto-complete the primary commands
elif len(tokens) == 1:
retVal = [x+' ' for x in tree if x.startswith(tokens[0])]
# Else auto-complete for the sub-commands
elif tokens[0] in tree.keys():
retVal = self.traverse(tokens[1:],tree[tokens[0]])
# If there are no commands, or no user input, return null
if tree is None or len(tokens) == 0:
retVal = []
elif len(tokens) == 1:
retVal = [f'{x} ' for x in tree if x.startswith(tokens[0])]
elif tokens[0] in tree.keys():
retVal = self.traverse(tokens[1:],tree[tokens[0]])

return retVal
return retVal
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CmdCompleter.traverse refactored with the following changes:

This removes the following comments ( why? ):

# If there is only one word, only auto-complete the primary commands
# Else auto-complete for the sub-commands

Comment on lines -185 to +196
if socket == False:
socket = self.ssock
if socket == False:
socket = self.ssock

if self.TIMEOUT:
socket.setblocking(0)
ready = select.select([socket], [], [], self.TIMEOUT)[0]
else:
socket.setblocking(1)
ready = True

try:
if ready:
return socket.recv(size)
else:
return False
except:
return False
if self.TIMEOUT:
socket.setblocking(0)
ready = select.select([socket], [], [], self.TIMEOUT)[0]
else:
socket.setblocking(1)
ready = True

try:
return socket.recv(size) if ready else False
except:
return False
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function upnp.recv refactored with the following changes:

Comment on lines -228 to +235
delim = '://'
host = False
page = False
delim = '://'
host = False
page = False

#Split the host and page
try:
(host,page) = url.split(delim)[1].split('/',1)
page = '/' + page
except:
#If '://' is not in the url, then it's not a full URL, so assume that it's just a relative path
page = url
#Split the host and page
try:
(host,page) = url.split(delim)[1].split('/',1)
page = f'/{page}'
except:
#If '://' is not in the url, then it's not a full URL, so assume that it's just a relative path
page = url

return (host,page)
return (host,page)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function upnp.parseURL refactored with the following changes:

return string.split(delim1)[1].split(delim2,1)[0]
return False
return string.split(delim1)[1].split(delim2,1)[0]
return False
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function upnp.parseDeviceTypeName refactored with the following changes:

return string.split(delim1)[1].split(delim2,1)[0]
return False
return string.split(delim1)[1].split(delim2,1)[0]
return False
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function upnp.parseServiceTypeName refactored with the following changes:

Comment on lines -283 to +289
startTag = "<%s" % tag
endTag = "</%s>" % tag

try:
tmp = data.split(startTag)[1]
index = tmp.find('>')
if index != -1:
index += 1
return tmp[index:].split(endTag)[0].strip()
except:
pass
return None
startTag = f"<{tag}"
endTag = f"</{tag}>"

try:
tmp = data.split(startTag)[1]
index = tmp.find('>')
if index != -1:
index += 1
return tmp[index:].split(endTag)[0].strip()
except:
pass
return None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function upnp.extractSingleTag refactored with the following changes:

Comment on lines -1652 to +1647
if val:
return False
else:
return True
return not val
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function toggleVal refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants