PK!"N?> > dotup/__init__.py__version__ = '0.3.2' import sys import os import pwd from pathlib import Path import click import crayons def update_symlink(directory, filename, force=None): force = False if force is None else force home = str(Path.home()) try: os.symlink(f'{home}/{directory}/{filename}', f'{home}/{filename}') return True except FileExistsError: if force: os.remove(f'{home}/{filename}') os.symlink(f'{home}/{directory}/{filename}', f'{home}/{filename}') return True return False def get_dotfiles(home, directory): dotfile_dirlist = map( lambda filename: f'{home}/{directory}/{filename}', os.listdir(f'{home}/{directory}'), ) dotfile_paths = filter(os.path.isfile, dotfile_dirlist) dotfiles = map(lambda path: path.replace(f'{home}/{directory}/', ''), dotfile_paths) return dotfiles def check_dotfiles_directory_exists(home, directory): return os.path.isdir(f'{home}/{directory}') @click.command() @click.option( '--directory', '-d', default="dotfiles", help="Dotfiles directory name. Must be located in home dir.", ) @click.option('--force', is_flag=True, help="Overwrite existing symlinks.") def dotup(directory, force): home = str(Path.home()) exists = check_dotfiles_directory_exists(home, directory) if not exists: print( f'\nError: no dotfile directory found at {crayons.yellow(f"{home}/{directory}")}\n' ) print( f'Use {crayons.cyan("dotup --directory")} to specify your dotfile directory name.' ) return print(f'\nSymlinking dotfiles found in {crayons.cyan(f"{home}/{directory}")}\n') non_dotfiles = [] dotfiles = get_dotfiles(home, directory) for filename in dotfiles: if filename[0] != '.': non_dotfiles.append(filename) continue success = update_symlink(directory, filename, force) if success: print( f'Symlinked {crayons.red(filename)}@ -> {home}/{directory}/{filename}' ) else: prompt_remove = click.confirm( f'\nFile already exists at {crayons.yellow(f"{home}/{filename}")}, overwrite it?' ) if prompt_remove: update_symlink(directory, filename, True) print( f'Symlinked {crayons.red(filename)}@ -> {home}/{directory}/{filename}' ) else: print(f'{crayons.magenta("Skipping")} {filename}') for filename in non_dotfiles: print( f'\n{crayons.magenta("Skipped")} {crayons.yellow(f"{home}/{directory}/{filename}")}', f'-- filename does not begin with \033[4m{crayons.cyan(".")}\033[0m', ) if __name__ == "__main__": dotup() # pragma: no cover PK!H=B %&dotup-0.3.2.dist-info/entry_points.txtN+I/N.,()J/)-V` PK!^--dotup-0.3.2.dist-info/LICENSEMIT License Copyright (c) 2019 Ryan Castner 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!HڽTUdotup-0.3.2.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H6dotup-0.3.2.dist-info/METADATAU[SF~_q }gt<[j' 頵t,mXnwWGm.mb0LKGع(q e[ŀ>Tp>եjSt)zXP #+rT`(sV 2U&qs*SԞl?}ze\GTɾ`% q#A[ #,T#H;)w44%YI>ɖN?~lr)^8;QRp*t^Q^0"yּk#߹rR27;>WNFf~<}4DחT6`\fѧN@hft@R>.3+ظP2דj/kgmq\ dqXNoƱ61c1eޥMBvyXͩLxחYyu>GJw(b7Diµ2n-AGQ73R?lV-/^gjzٯ Ssĩpi^qN贠x*NLcfx! cm@)ȑv6 !:D ,AN_]F4mtTyRQK NO8cp}J1$/^?"eg޶_kp)*pۚ>Xly.%QOH 3H6ܓc&;3Z]#@.t%y L* 7 ZE6.6ē`4$Z&}0QR6 QWmFQ[Rf]TG7=V8*\SEmenMqWH}p>X*ӂ L2P؅+B(]V $_I$gta䑼@y*z\'U?5ӲْvNؐÌ"Úgg𰨤v\jBPK!H]-s,dotup-0.3.2.dist-info/RECORDu9v@>gdHbD@!l 800祠UCIse[!ʧg2+aYI@Nnնe}͈}99BӮ*Dzw-DdD̫)qJvd@i؟#ֵ@ԅ9L70糠L+$p}\cvsoF}amtsaƤ7tm & >aqz00pcl͜j?H ˡ)_vi2d (B{1w`?PK!"N?> > dotup/__init__.pyPK!H=B %&m dotup-0.3.2.dist-info/entry_points.txtPK!^-- dotup-0.3.2.dist-info/LICENSEPK!HڽTU9dotup-0.3.2.dist-info/WHEELPK!H6dotup-0.3.2.dist-info/METADATAPK!H]-s,dotup-0.3.2.dist-info/RECORDPKg