| Conditions | 7 |
| Total Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | """A setuptools based setup module. |
||
| 28 | def _post(): |
||
| 29 | import icon_font_to_png |
||
| 30 | from pkg_resources import get_distribution |
||
| 31 | from appdirs import AppDirs |
||
| 32 | import os |
||
| 33 | |||
| 34 | # fontawesome 4.7 |
||
| 35 | dirs = AppDirs( |
||
| 36 | os.path.join( |
||
| 37 | 'pandoc_latex_tip', |
||
| 38 | get_distribution('pandoc_latex_tip').version, |
||
| 39 | '4.7' |
||
| 40 | ) |
||
| 41 | ) |
||
| 42 | directory = dirs.user_data_dir |
||
| 43 | if not path.exists(directory): |
||
| 44 | makedirs(directory) |
||
| 45 | downloader = icon_font_to_png.FontAwesomeDownloader(directory) |
||
| 46 | downloader.css_url = 'https://cdn.rawgit.com/FortAwesome/Font-Awesome/v4.7.0/css/font-awesome.css' |
||
| 47 | downloader.ttf_url = 'https://cdn.rawgit.com/FortAwesome/Font-Awesome/v4.7.0/fonts/fontawesome-webfont.ttf' |
||
| 48 | downloader.download_files() |
||
| 49 | |||
| 50 | # fontawesome 5.0 |
||
| 51 | dirs = AppDirs( |
||
| 52 | os.path.join( |
||
| 53 | 'pandoc_latex_tip', |
||
| 54 | get_distribution('pandoc_latex_tip').version, |
||
| 55 | '5.0' |
||
| 56 | ) |
||
| 57 | ) |
||
| 58 | directory = dirs.user_data_dir |
||
| 59 | if not path.exists(directory): |
||
| 60 | makedirs(directory) |
||
| 61 | |||
| 62 | import requests |
||
| 63 | import re |
||
| 64 | from distutils.version import StrictVersion |
||
| 65 | try: |
||
| 66 | versions = requests.get('https://api.github.com/repos/FortAwesome/Font-Awesome/tags').json() |
||
| 67 | except ValueError: |
||
| 68 | import sys |
||
| 69 | sys.stderr.write('Unable to get the last version number of the Font-Awesome package on github\n') |
||
| 70 | sys.exit(1) |
||
| 71 | |||
| 72 | latest = '5.0' |
||
| 73 | for version in versions: |
||
| 74 | if re.match('^5.0', version['name']) and StrictVersion(version['name']) > StrictVersion(latest): |
||
| 75 | latest = version['name'] |
||
| 76 | |||
| 77 | downloader = icon_font_to_png.FontAwesomeDownloader(directory) |
||
| 78 | downloader.css_url = 'https://cdn.rawgit.com/FortAwesome/Font-Awesome/' + latest + '/web-fonts-with-css/css/fontawesome.css' |
||
| 79 | # brands |
||
| 80 | downloader.ttf_url = 'https://cdn.rawgit.com/FortAwesome/Font-Awesome/' + latest + '/web-fonts-with-css/webfonts/fa-brands-400.ttf' |
||
| 81 | downloader.download_files() |
||
| 82 | # regular |
||
| 83 | downloader.ttf_url = 'https://cdn.rawgit.com/FortAwesome/Font-Awesome/' + latest + '/web-fonts-with-css/webfonts/fa-regular-400.ttf' |
||
| 84 | downloader.download_files() |
||
| 85 | # solid |
||
| 86 | downloader.ttf_url = 'https://cdn.rawgit.com/FortAwesome/Font-Awesome/' + latest + '/web-fonts-with-css/webfonts/fa-solid-900.ttf' |
||
| 87 | downloader.download_files() |
||
| 88 | |||
| 203 |