PK!:Xzzignorio/__init__.py"""Package containing CLI and Ignorio class.""" from .ignorio import Ignorio __all__ = ['Ignorio'] __version__ = '0.2.0' PK!K:.A A ignorio/cli.py"""Command Line Interface for Ignorio.""" import os import click from ignorio import Ignorio IG = Ignorio() @click.command() @click.argument('lang', nargs=-1) @click.option('-l', '--langs', help='List supported languages', is_flag=True) @click.option('-o', '--output', help='Set destination', default='.gitignore', metavar='OUTPUT') @click.option('-a', '--append', help='Append instead of rewrite', is_flag=True) @click.option('-v', '--verbose', help='Verbose mode', is_flag=True) def main(lang, output, append, verbose, langs): """Download a version control exclusion list from gitignore.io.""" if langs: # count total languages supported by gitignore.io lang_count = IG.count_languages() lang_count = click.style(str(lang_count), fg='green', bold=True) print(f'{lang_count} supported languages:') # display each language supported_langs = IG.supported_languages() rocket = click.style('➜', fg='green') for supported_lang in supported_langs: print(rocket, supported_lang) exit() # if no language was given then complain, else, write report. if not lang: click.secho('Type a list of languages please.', bold=True, fg='yellow') exit() try: IG.write_gitignore(lang, output, append) except ValueError as lang_error: faulty_lang = lang_error.args[0] err_msg = click.style(f'Language not supported:', bold=True, fg='red') print(err_msg, faulty_lang) else: if verbose: # languages written print('Languages:', end='\t') languages = ', '.join(lang) click.secho(languages, fg='green', bold=True) # Output report abs_path = os.path.abspath(output) print('Output:', end='\t\t') click.secho(abs_path, fg='green', bold=True) # writting mode print('Write Mode:', end='\t') if append: mode = 'append' color = 'green' else: mode = 'overwrite' color = 'yellow' click.secho(mode, fg=color, bold=True) else: success_msg = 'Exclusions written successfully.' click.secho(success_msg, bold=True, fg='green') if __name__ == '__main__': main() PK!ignorio/ignorio.py"""Manage .gitignore with Ignorio.""" from requests import get as rget class Ignorio(): """Ignorio handles API requests from gitignore.io. supported_languages(): Return a list of supported languages. count_languages(): Return a Integer of the number of languages supported. is_lang_supported(lang): Return True or False if a language is supported. get_language_exclusion(langs): Return a list with the exclusions templates. write_gitignore(): Writes a template to the disk with the exlusion languages. """ @staticmethod def supported_languages(): """Get supported languages from gitignore.io. example: supported_languages() >>> [ruby, python, sublimetext, ...] """ raw_list = rget('https://www.gitignore.io/api/list').text # gitignore.io's API returns a multiline string # I have to remove new lines and split the languages. striped_list = raw_list.strip('\n') replaced_list = striped_list.replace('\n', ',') lang_list = replaced_list.split(',') return lang_list def count_languages(self): """Return how many languages are supported.""" return len(self.supported_languages()) def is_lang_supported(self, lang): """Return True or False if a language is supported.""" lang_list = self.supported_languages() return True if lang in lang_list else False def get_language_exclusion(self, langs): """Get languages exclusion list. languages must be in format 'lang1,lang2,lang3' for the API to work. """ # if language is not supported, raise a Value error. for lang in langs: if not self.is_lang_supported(lang): raise ValueError(lang) lang_list = ','.join(langs) exclusion_list = rget(f'https://www.gitignore.io/api/{lang_list}').text return exclusion_list def write_gitignore(self, langs, filename='.gitignore', append=False): """Write .gitignore.""" mode = 'w' if append: mode = 'a' lang_list = self.get_language_exclusion(langs) with open(filename, mode) as raw: raw.write(lang_list) PK!ignorio/version.pyversion = '0.2.0' PK!H$kc)'(ignorio-0.2.1.dist-info/entry_points.txtN+I/N.,()LL/KɴMPK!5DD"ignorio-0.2.1.dist-info/LICENSE.mdMIT License Copyright (c) 2018 Robertho Franchesko Orozco Parrales Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!HlŃTTignorio-0.2.1.dist-info/WHEEL A н#J@Z|Jmqvh&#hڭw!Ѭ"J˫( } %PK!HZ B ignorio-0.2.1.dist-info/METADATARn1+ʡ^ZhHTT5^\k!;$jyޛW*x+߈/LV5$R_]SnJe[j,ac|ĨfPKqySj*U4ORFc>.gnȦ.n=|EdزoMJ2EGRSe)9ZcE-wW9썆/n Yd;HMa\ז0 wT~ѲYUʚ1ip*^Oxwr5N 5__]R;! Uԗ7? @ 5ߴ*ۚǜuJJ!_f+vnΔuP+ݞ|s<І8r[e\a S!敩0X.0DA*e'ىqr'{1fCF1 /kh\6qsb9̅PK!Hlignorio-0.2.1.dist-info/RECORDuλ0~X)".0܄xI̙YwlULQ$8V:2pƎu <'";f U(I/EqܹaiUU|iwqq\Z9jI1}u;Z9Hr.jZ m<=54p43D Yt6mΙ^ˉC}Q\=*@\(8{BDQ(kx}H(AaB7ORC {4ݧt+)F՜FNrz n5V7djYVQ;}7JF{mn>PK!:Xzzignorio/__init__.pyPK!K:.A A ignorio/cli.pyPK! ignorio/ignorio.pyPK!1ignorio/version.pyPK!H$kc)'(signorio-0.2.1.dist-info/entry_points.txtPK!5DD"ignorio-0.2.1.dist-info/LICENSE.mdPK!HlŃTTfignorio-0.2.1.dist-info/WHEELPK!HZ B ignorio-0.2.1.dist-info/METADATAPK!Hl>ignorio-0.2.1.dist-info/RECORDPK /