简单小练习_切换工作空间
Posted erick-l
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单小练习_切换工作空间相关的知识,希望对你有一定的参考价值。
#make space -> choose space -> switch space # how we start OOP ? -->space ‘‘‘ folder choose = input() if choose == workspace.name: workspace.switch() ‘‘‘ from sconfig import CONFIGS from subprocess import call import os class Workspace: def __init__(self, c): self.folders = c[‘folders‘] self.name = c[‘name‘] self.target = c[‘target‘] def switch(self): for link in os.listdir(self.target): if f.endswith(‘.wspc‘): path = self.target + f os.remove(path) #mklink for source in self.folders: real_target = self.target + source.split(‘/‘)[-1] + ‘.wspc‘ commands = [‘ln‘,‘-s‘,source,real_target] call(commands) w = Workspace([1,2,3]) w2 = Workspace([4,5,6]) workspace = [Workspace(c) for c in CONFIGS] print(‘pleace choice u workspace‘) choice = input() for w in workspace: if w.name ==choice: w.switch() print(w.folders) print(w2.folders)
sconfig.py
CONFIGS = [ { ‘name‘:‘WORK‘, ‘folders‘:[ ‘/User/zhangfulong/Desktop/Pdf‘, ‘/User/zhangfulong/Desktop/Bookmarks‘, ], ‘target‘:‘/User/zhangfulong/Desktop/‘ }, { ‘name‘:‘PLAY‘, ‘folders‘:[ ‘/User/zhangfulong/Desktop/Video‘, ‘/User/zhangfulong/Desktop/Codes‘, ], ‘target‘:‘/User/zhangfulong/Desktop/‘ }, ]
以上是关于简单小练习_切换工作空间的主要内容,如果未能解决你的问题,请参考以下文章