zoukankan      html  css  js  c++  java
  • 简单小练习_切换工作空间

    #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/'
        },
    
    
    ]
  • 相关阅读:
    广州公交百态之座位
    遍地大头者,岂尽聪明人
    小和尚
    c++中调用其他应用程序的方法(winexec shellexecute createprocess)
    MFC Is MVC
    Dialog Data Exchange
    MFC Extension dll VS Regular Dll
    Don't optimize prematurely
    Menu Basic
    Don't pessimize prematurely
  • 原文地址:https://www.cnblogs.com/Erick-L/p/9223932.html
Copyright © 2011-2022 走看看