码迷,mamicode.com
首页 > 其他好文 > 详细

简单小练习_切换工作空间

时间:2018-06-25 15:08:20      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:input   eal   real   self   style   split   def   VID   process   

#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/
    },


]

 

简单小练习_切换工作空间

标签:input   eal   real   self   style   split   def   VID   process   

原文地址:https://www.cnblogs.com/Erick-L/p/9223932.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!