Skip to content

Sourcery refactored master branch - #5

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

Sourcery refactored master branch#5
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Apr 29, 2022

Copy link
Copy Markdown

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 zopyx April 29, 2022 01:25
if not which('ebook-convert'):
return False
return True
return bool(which('ebook-convert'))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function _check_calibre refactored with the following changes:

Comment on lines -29 to +27
shutil.copy(html_filename, html_filename + '.html')
shutil.copy(html_filename, f'{html_filename}.html')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function html2calibre refactored with the following changes:

converter = registry.converter_registry.get(format)
if converter is None:
raise ValueError('Unsupported format: %s' % format)
raise ValueError(f'Unsupported format: {format}')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Converter.convert refactored with the following changes:

Comment on lines -64 to +65
if self.cleanup:
if self.fo_filename:
os.unlink(self.fo_filename)
if self.cleanup and self.fo_filename:
os.unlink(self.fo_filename)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function BaseConverter.__del__ refactored with the following changes:

Comment thread src/zopyx/convert2/fo.py
Comment on lines -43 to +47
if output_filename:
fo_filename = output_filename
else:
fo_filename = newTempfile(suffix='.fo')

fo_filename = output_filename or newTempfile(suffix='.fo')
csstoxslfo = os.path.abspath(os.path.join(dirname, 'lib', 'csstoxslfo', 'css2xslfo.jar'))
if not os.path.exists(csstoxslfo):
raise IOError('%s does not exist' % csstoxslfo)
raise IOError(f'{csstoxslfo} does not exist')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function HTML2FO.convert refactored with the following changes:

Comment on lines -51 to +54
if not v.startswith('#'):
codepoint = name2codepoint.get(v)
return codepoint and '&#%d;' % codepoint or ''
else:
if v.startswith('#'):
return e
codepoint = name2codepoint.get(v)
return codepoint and '&#%d;' % codepoint or ''

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function tidyhtml.handler refactored with the following changes:

dirname = os.environ.get(envname, None)
if dirname is None:
LOG.debug('Environment variable $%s is unset' % envname)
LOG.debug(f'Environment variable ${envname} is unset')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function checkEnvironment refactored with the following changes:

Comment thread src/zopyx/convert2/xfc.py
full_exe_name = os.path.join(xfc_dir, 'fo2rtf')
if not os.path.exists(full_exe_name):
LOG.debug('%s does not exist' % full_exe_name)
LOG.debug(f'{full_exe_name} does not exist')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function _check_xfc refactored with the following changes:

Comment thread src/zopyx/convert2/xfc.py
Comment on lines -36 to +40
if not format in ('rtf', 'docx', 'wml', 'odt'):
raise ValueError('Unsupported format: %s' % format)
if format not in ('rtf', 'docx', 'wml', 'odt'):
raise ValueError(f'Unsupported format: {format}')

if not output_filename:
output_filename = newTempfile(suffix='.%s' % format)
output_filename = newTempfile(suffix=f'.{format}')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function fo2xfc refactored with the following changes:

Comment on lines -22 to +25
exe_name = win32 and '\\bin\\windows\\xinc.exe' or 'bin/unix/xinc'
exe_name = '\\bin\\windows\\xinc.exe' if win32 else 'bin/unix/xinc'
full_exe_name = os.path.join(xinc_home, exe_name)
if not os.path.exists(full_exe_name):
LOG.debug('%s does not exist' % full_exe_name)
LOG.debug(f'{full_exe_name} does not exist')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function _check_xinc 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