Skip to content
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

Csv (Sourcery refactored) #451

Closed
wants to merge 1 commit into from
Closed

Csv (Sourcery refactored) #451

wants to merge 1 commit into from

Conversation

sourcery-ai[bot]
Copy link

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

Pull Request #447 refactored by Sourcery.

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

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

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 csv branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from botheis April 19, 2023 09:23
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Due to GitHub API limits, only the first 60 comments can be shown.

self.logger.info("Selecting computer manager: %s" % name)
self.logger.info(f"Selecting computer manager: {name}")
Copy link
Author

Choose a reason for hiding this comment

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

Function ComputerManager.select refactored with the following changes:

self.logger.debug("Registering computer manager %s / %s" % (name, str(klass)))
self.logger.debug(f"Registering computer manager {name} / {str(klass)}")
Copy link
Author

Choose a reason for hiding this comment

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

Function ComputerManager.register refactored with the following changes:

self.logger.error("Selected computer manager '%s' not available" % self.main)
self.logger.error(f"Selected computer manager '{self.main}' not available")
Copy link
Author

Choose a reason for hiding this comment

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

Function ComputerManager.validate refactored with the following changes:

self.logger.debug("getComputer %s" % filt)
self.logger.debug(f"getComputer {filt}")
Copy link
Author

Choose a reason for hiding this comment

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

Function ComputerManager.getComputer refactored with the following changes:

if ret == None:
if ret is 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 ComputerManager.getComputersListHeaders refactored with the following changes:

Comment on lines -397 to +402
if not isDynamicEnable():
return False
return xmlrpcCleanup(queryManager.getPossiblesCriterionsInModule(ctx, moduleName))
return (
xmlrpcCleanup(
queryManager.getPossiblesCriterionsInModule(ctx, moduleName)
)
if isDynamicEnable()
else 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 RpcProxy.getPossiblesCriterionsInModule refactored with the following changes:

Comment on lines -403 to +414
if not isDynamicEnable():
return False
return xmlrpcCleanup(queryManager.getTypeForCriterionInModule(ctx, moduleName, criterion))
return (
xmlrpcCleanup(
queryManager.getTypeForCriterionInModule(
ctx, moduleName, criterion
)
)
if isDynamicEnable()
else 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 RpcProxy.getTypeForCriterionInModule refactored with the following changes:

Comment on lines -409 to +426
if not isDynamicEnable():
return False
return xmlrpcCleanup(queryManager.getPossiblesValuesForCriterionInModule(ctx, moduleName, criterion))
return (
xmlrpcCleanup(
queryManager.getPossiblesValuesForCriterionInModule(
ctx, moduleName, criterion
)
)
if isDynamicEnable()
else 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 RpcProxy.getPossiblesValuesForCriterionInModule refactored with the following changes:

Comment on lines -466 to +485
need_update = {}
for m in machines:
if m['hostname'] != cache[m['uuid']]:
need_update[m['uuid']] = m['hostname']

need_update = {
m['uuid']: m['hostname']
for m in machines
if m['hostname'] != cache[m['uuid']]
}
Copy link
Author

Choose a reason for hiding this comment

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

Function RpcProxy.update_machine_cache refactored with the following changes:

Comment on lines -515 to +534
if not isDynamicEnable():
return ""
else:
return queryManager.getExtended(moduleName, criterion)
return (
queryManager.getExtended(moduleName, criterion)
if isDynamicEnable()
else ""
)
Copy link
Author

Choose a reason for hiding this comment

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

Function RpcProxy.getExtended refactored with the following changes:

Comment on lines -599 to +621
if query == None: return []
if __onlyIn(query, ComputerManager().main):
ComputerManager().main
filt = __addCtxFilters(ctx, filt)
filt['query'] = query
return xmlrpcCleanup(ComputerManager().getRestrictedComputersList(ctx, min, max, filt, False, justId, toH))
else:
if query is None: return []
if not __onlyIn(query, ComputerManager().main):
return xmlrpcCleanup(QueryManager().replyToQuery(ctx, query, bool, min, max))
ComputerManager().main
filt = __addCtxFilters(ctx, filt)
filt['query'] = query
return xmlrpcCleanup(ComputerManager().getRestrictedComputersList(ctx, min, max, filt, False, justId, toH))
Copy link
Author

Choose a reason for hiding this comment

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

Function replyToQuery refactored with the following changes:

Comment on lines -609 to +630
if query == None: return 0
if __onlyIn(query, ComputerManager().main):
ComputerManager().main
filt = __addCtxFilters(ctx, filt)
filt['query'] = query
return xmlrpcCleanup(ComputerManager().getRestrictedComputersListLen(ctx, filt))
else:
if query is None: return 0
if not __onlyIn(query, ComputerManager().main):
return xmlrpcCleanup(QueryManager().replyToQueryLen(ctx, query, bool))
ComputerManager().main
filt = __addCtxFilters(ctx, filt)
filt['query'] = query
return xmlrpcCleanup(ComputerManager().getRestrictedComputersListLen(ctx, filt))
Copy link
Author

Choose a reason for hiding this comment

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

Function replyToQueryLen refactored with the following changes:

Comment on lines -619 to -632
i = 1
module = ComputerManager().main
crit = elt
requests = []
bools = []
optimization = True
for val in values:
for i, val in enumerate(values, start=1):
# If there is a wildcard in a value, we don't flag this request for
# possible optimization
if optimization:
optimization = not "*" in val
optimization = "*" not in val
requests.append("%i==%s::%s==%s" % (i, module, crit, val))
bools.append(str(i))
i += 1
Copy link
Author

Choose a reason for hiding this comment

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

Function forgeRequest refactored with the following changes:

if 'gid' in params:
return self.__getMachines(ctx, params['gid'])
return []
return self.__getMachines(ctx, params['gid']) if 'gid' in params else []
Copy link
Author

Choose a reason for hiding this comment

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

Function DyngroupDatabase.getMachines refactored with the following changes:

Comment on lines -62 to +60
if join_tables == None:
if join_tables is 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 DyngroupDatabase.__getMachinesFirstStep refactored with the following changes:

Comment on lines -470 to +460
result = {}
for machine in query:
result[machine.uuid] = {
"id":machine.id,
"uuid":machine.uuid,
"hostname":machine.name
return {
machine.uuid: {
"id": machine.id,
"uuid": machine.uuid,
"hostname": machine.name,
}

return result
for machine in query
}
Copy link
Author

Choose a reason for hiding this comment

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

Function DyngroupDatabase.getRegisteredMachines refactored with the following changes:

Comment on lines -521 to +507
group = self.__get_group_permissions_request(ctx, session).filter(self.groups.c.id == id).first()
if group:
if (
group := self.__get_group_permissions_request(ctx, session)
.filter(self.groups.c.id == id)
.first()
):
Copy link
Author

Choose a reason for hiding this comment

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

Function DyngroupDatabase.setname_group refactored with the following changes:

Comment on lines -601 to +586
if not s:
return False
return (s.display_in_menu == 1)
return (s.display_in_menu == 1) if s else 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 DyngroupDatabase.canshow_group refactored with the following changes:

Comment on lines -655 to +638
return (q != None and q != '')
return q not in [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 DyngroupDatabase.isdyn_group refactored with the following changes:

Comment on lines -681 to +664
if g:
return (g.type == 1)
else:
return False
return (g.type == 1) if g else 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 DyngroupDatabase.isprofile refactored with the following changes:

Comment on lines -748 to +728
if group == None: return []
if group is None: return []
Copy link
Author

Choose a reason for hiding this comment

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

Function DyngroupDatabase.__getContent refactored with the following changes:

Comment on lines -777 to +757
content = self.__getContent(ctx, group, queryManager)
return content
return self.__getContent(ctx, group, queryManager)
Copy link
Author

Choose a reason for hiding this comment

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

Function DyngroupDatabase.result_group_by_name refactored with the following changes:

Comment on lines -813 to +792
if justId:
ret = map(lambda m:m.uuid, result.all())
else:
ret = result.all()
ret = map(lambda m:m.uuid, result.all()) if justId else result.all()
Copy link
Author

Choose a reason for hiding this comment

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

Function DyngroupDatabase.result_group refactored with the following changes:

Comment on lines -903 to +879
if self.isprofile(ctx, id):
resultTable = self.profilesResults
else:
resultTable = self.results

resultTable = self.profilesResults if self.isprofile(ctx, id) else self.results
Copy link
Author

Choose a reason for hiding this comment

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

Function DyngroupDatabase.delmembers_to_group refactored with the following changes:

Comment on lines -928 to +902
self.logger.error('Error where fetching deploy group for group %s (package %s): %s' % (gid, package_id, e))
self.logger.error(
f'Error where fetching deploy group for group {gid} (package {package_id}): {e}'
)
Copy link
Author

Choose a reason for hiding this comment

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

Function DyngroupDatabase.get_deploy_group_id refactored with the following changes:

Comment on lines -136 to +137
if filt == None or filt == '':
if filt is None or filt == '':
Copy link
Author

Choose a reason for hiding this comment

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

Function GlpiComputers.getRestrictedComputersListLen refactored with the following changes:

Comment on lines -155 to +156
if filt == None or filt == '':
if filt is None or filt == '':
Copy link
Author

Choose a reason for hiding this comment

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

Function GlpiComputers.getRestrictedComputersList refactored with the following changes:

Comment on lines -191 to +194
result = self.glpi.mini_computers_count()
return result
return self.glpi.mini_computers_count()
Copy link
Author

Choose a reason for hiding this comment

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

Function GlpiComputers.simple_computer_count refactored with the following changes:

Comment on lines -195 to +197
if filt == None or filt == '':
if filt is None or filt == '':
Copy link
Author

Choose a reason for hiding this comment

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

Function GlpiComputers.getComputerCount refactored with the following changes:

Comment on lines -244 to +246
if len(ret) != 0:
return ret[0]
else:
return None
return ret[0] if len(ret) != 0 else 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 GlpiComputers.getComputerByMac refactored with the following changes:

@neoclust neoclust closed this Apr 19, 2023
@neoclust neoclust deleted the sourcery/csv branch April 19, 2023 09:24
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.

None yet

1 participant