def key_file(self, value): if self.connected: raise SFTPSetOnConnectedError('key_file', value) kfile = None if value is None: kfile = DEFAULT_SSH_KEY else: if isinstance(value, Path): kfile = value else: kfile = PosixPath(str(value)) if str(kfile).startswith('~'): kfile = kfile.expanduser() self._key_file = kfile
def log(self, msg, *args): """Logs a message to stderr.""" if args: msg %= args click.echo(msg, file=sys.stderr) def vlog(self, msg, *args): """Logs a message to stderr only if verbose is enabled.""" if self.verbose: self.log(msg, *args) pass_environment = click.make_pass_decorator(Environment, ensure=True) cmd_folder = PosixPath(PosixPath.cwd()) / 'jeeves' / 'commands' cmd_folder = cmd_folder.expanduser() class ComplexCLI(click.MultiCommand): def list_commands(self, ctx): rv = [] for filename in cmd_folder.glob('*.py'): filename = str(filename) if '__init__.py' in filename: continue cmd = filename.partition('/commands/')[2][:-3] rv.append(cmd) rv.sort() return rv
def get_migration_files_path(): path = PosixPath('/workspace/bigquery/migrations') path.expanduser() return path
from shutil import copy2, copytree, rmtree # Config config_dest = "./configurations" config_index = "./config_index.csv" # Read file list config_list = pd.read_csv(config_index) # For all config files for index, row in config_list.iterrows(): # Get row data path = PosixPath(row['path']) private = row['is_private'] == 1 # Destination resolving expendad_path = path.expanduser() if path.is_absolute(): dest = config_dest + "/" + str(path) elif path.parts[0] == "~": dest = config_dest + "/HOME/" + str(path.relative_to("~")) else: dest = config_dest + expendad_path dest_dir = os.path.dirname(dest) # Backup if expendad_path.exists(): # Make parent dir if necessary os.makedirs(dest_dir, exist_ok=True) # Make dummy placeholders for private files if private: dest = dest + "_DUMMY" if expendad_path.is_file():