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

Sourcery refactored main branch #1

Closed
wants to merge 1 commit into from
Closed

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented May 23, 2023

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

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from Ragdata May 23, 2023 08:40
path = 'templates/' + templateFile
path = f'templates/{templateFile}'
Copy link
Author

Choose a reason for hiding this comment

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

Function applyTemplate refactored with the following changes:

Comment on lines -21 to +25
def fromJson(text):
tmp = json.loads(text, object_hook=lambda d: label(
d['name'], d['description'], d['color']))
def fromJson(self):
tmp = json.loads(
self,
object_hook=lambda d: label(d['name'], d['description'], d['color']),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function label.fromJson refactored with the following changes:

Comment on lines -38 to +56
cmd = 'gh label {}'.format(self.option)
repo = '-R {}/{}'.format(owner, repo)
cmd = f'gh label {self.option}'
repo = f'-R {owner}/{repo}'

append = str()

if self.option == 'create':
label = '\"{}\" --description \"{}\" --color {}'.format(
self.name, self.label.description, self.label.color.replace("#", ""))
append = '-f {}'.format(label)
label = f'\"{self.name}\" --description \"{self.label.description}\" --color {self.label.color.replace("#", "")}'
append = f'-f {label}'
elif self.option == 'edit':
nameChanged = self.name != self.label.name
append = '\"{}\" --description \"{}\" --color {}'.format(
self.name, self.label.description, self.label.color.replace("#", ""))
append = f'\"{self.name}\" --description \"{self.label.description}\" --color {self.label.color.replace("#", "")}'
if nameChanged:
append += ' --name \"{}\"'.format(self.label.name)
append += f' --name \"{self.label.name}\"'
elif self.option == 'delete':
append = '\"{}\" --yes'.format(self.name)
append = f'\"{self.name}\" --yes'

fullCommand = '{} {} {}'.format(cmd, repo, append)
fullCommand = f'{cmd} {repo} {append}'
Copy link
Author

Choose a reason for hiding this comment

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

Function action.execute refactored with the following changes:

Comment on lines -65 to +75
repo = '-R {}/{}'.format(owner, repo)
repo = f'-R {owner}/{repo}'
condition = '--json name,description,color'
jq = '--jq \".[]\"'

fullCommand = '{} {} {} {}'.format(cmd, repo, condition, jq)
fullCommand = f'{cmd} {repo} {condition} {jq}'

process = os.popen(fullCommand)
output = process.read().splitlines()
process.close()

labels = [label.fromJson(x) for x in output if x != '']

return labels
return [label.fromJson(x) for x in output if x != '']
Copy link
Author

Choose a reason for hiding this comment

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

Function getLabels refactored with the following changes:

Comment on lines -35 to +37
def build(path):
if os.path.exists(path):
with open(path, 'r') as file:
def build(self):
if os.path.exists(self):
with open(self, 'r') as file:
Copy link
Author

Choose a reason for hiding this comment

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

Function labelsTemplate.build refactored with the following changes:

process = os.popen('{} {} {} {}'.format(cmd, owner, json, jq))
process = os.popen(f'{cmd} {owner} {json} {jq}')
Copy link
Author

Choose a reason for hiding this comment

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

Function labelsTemplate.applyToRepos refactored with the following changes:

Comment on lines -102 to +106
for x in templateLabelsNames:
if not currentLabelsNames.__contains__(x):
actions.append(
action('create', x, self.labels[templateLabelsNames.index(x)]))

actions.extend(
action('create', x, self.labels[templateLabelsNames.index(x)])
for x in templateLabelsNames
if not currentLabelsNames.__contains__(x)
)
Copy link
Author

Choose a reason for hiding this comment

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

Function labelsTemplate.apply refactored with the following changes:

@Ragdata Ragdata closed this Jun 12, 2023
@Ragdata Ragdata deleted the sourcery/main branch June 12, 2023 10:32
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.

1 participant