Esempio n. 1
0
File: Tab.py Progetto: balu/fm
    def create(app, cwd = ''):
        import os
        t = Tab(app)

        if cwd == '':
            d = Dir.create(t, os.getcwd())
        else:
            d = Dir.create(t, cwd)
        if d is None:
            d = Dir.create(t)

        t.wd = [d]
        t.curwd = 0

        return t
Esempio n. 2
0
File: Tab.py Progetto: balu/fm
 def goto_path(self, path):
     d = Dir.create(self, path)
     if d:
         self.wd[self.curwd].winexit()
         self.wd.append(d)
         self.curwd = len(self.wd) - 1
         self.wd[self.curwd].wininit()
     else:
         self.getapp().UI.err("Failed to open %s" % (path,))
Esempio n. 3
0
File: Tab.py Progetto: balu/fm
 def open_dir(self, new_tab = False):
     curdir = self.wd[self.curwd]
     d = curdir.dentry()
     if d.isdir():
         newd = Dir.create(self, d.path())
         if newd:
             curdir.winexit()
             self.wd = self.wd[:self.curwd + 1] + [newd]
             self.curwd = self.curwd + 1
             newd.wininit()
         else:
             self.getapp().UI.err("Failed to open %s" % (d.path(),))
Esempio n. 4
0
File: Tab.py Progetto: balu/fm
 def up(self, count = 1):
     import os.path
     curd = self.wd[self.curwd].path()
     if curd != '/':
         for i in range(count):
             curd = new = os.path.dirname(curd)
         d = Dir.create(self, new)
         if d:
             self.wd[self.curwd].winexit()
             self.wd = self.wd[:self.curwd+1] + [d]
             self.curwd = self.curwd + 1
             self.wd[self.curwd].wininit()
         else:
             self.getapp().UI.err("Failed to open %s" % (new,))
Esempio n. 5
0
def createDirObject(inDir, reqs):
    newDir = Dir()
    dirList = os.listdir(inDir)
    for item in dirList:
        newFile = createFileObject(item, inDir)
        if (newFile.getFileName() in reqs):
            newDir.appendReqList(newFile)
        elif (newFile.getFileName() == 'dir.xml'):
            #fake news
            pass
        else:
            newDir.appendOtherList(newFile)
    return newDir
Esempio n. 6
0
File: Tab.py Progetto: balu/fm
 def __reinittab(self):
     d = Dir.create(self)
     self.wd = [d]
     self.curwd = 0
Esempio n. 7
0
   root_commit = f.read(10)
 finally:
   if f:
     f.close()
 #print(root_commit)
 os.remove('tmp.txt')
 if len(root_commit) == 0:
   print('getting root commit id failed')
 else:
   os.chdir(work_path)
   root = Module(glob.module_list[0])
   root.git_clone('root')
   #print(root.url)
   os.chdir(root.url)
   os.system('git reset --hard ' + root_commit)
   root_dir = Dir(dir, dir, root.url)
   root_dir.dir_init()
   #root_dir.print_dir_plus()
   os.chdir(work_path)  
   for i in glob.module_wkspc:
     os.chdir(i.url)
     tmp = Dir(dir, dir, i.url, {i.name})
     tmp.dir_init()
     #tmp.print_dir_plus()
     glob.file_wkspc[i.name] = tmp
   for i in glob.file_wkspc.values():
     #root_dir.compare_report_plus(i)
     root_dir.merge_with(i)
   print('after merge:')
   root_dir.print_dir_plus()
   root_dir.check_change()
Esempio n. 8
0
data_root = "/home/nd/datasets/crop_256"
save_root = "/home/nd/datasets/crop_256-train"
train_dir = save_root + "/train"
val_dir = save_root + "/val"

if not os.path.exists(save_root):
    os.mkdir(save_root)
if not os.path.exists(train_dir):
    os.mkdir(train_dir)
if not os.path.exists(val_dir):
    os.mkdir(val_dir)

train_ratio = 0.9

dir_op = Dir()

data_dirs = dir_op.getNamesFromDir(data_root)
num_cls = len(data_dirs)
print "Total class num: ", num_cls

count = 0
for dir in data_dirs:
    index = 0
    if count % 100 == 0:
        print "processing: {}/{}".format(count, num_cls)

    img_paths = dir_op.getImagePaths(data_root + "/" + dir)
    random.shuffle(img_paths)
    num_img = len(img_paths)