def get_dirs_in_db(): print "getting db items" db = sqlite3.connect(dbfilename) c = db.cursor() c.execute('SELECT * FROM dirs') for d in c.fetchall(): print d print Folder.strfunixtime(d[3]) db.close()
elif global_steps % 1000 == 0: _ = model_dir + "ratio-{:3f}-loss-{:3f}-score-{:3f}-steps-{:d}-model.pkl".format( teacher_forcing_ratio, all_loss, score, global_steps) torch.save(net.state_dict(), _) del all_label, all_loss, all_pre net.train() if __name__ == '__main__': batch_size = 128 nb_samples = 9698532 path = '/data/xuwenshen/ai_challenge/data/train/train/ibm_train-50-60.h5py' train_folder = Folder(filepath=path, is_test=False, nb_samples=nb_samples) train_loader = DataLoader(train_folder, batch_size=batch_size, num_workers=1, shuffle=True) path = '/data/xuwenshen/ai_challenge/data/valid/valid/ibm_valid-50-60.h5py' nb_samples = 640 valid_folder = Folder(filepath=path, is_test=False, nb_samples=nb_samples) valid_loader = DataLoader(valid_folder, batch_size=batch_size, num_workers=1, shuffle=True) en_voc_path = '/data/xuwenshen/ai_challenge/data/train/train/en_voc.json' zh_voc_path = '/data/xuwenshen/ai_challenge/data/train/train/zh_voc.json'
fout = open( '/data/xuwenshen/ai_challenge/code/fix_lens/pred' + str(index) + '.txt', 'w') for i in range(len(all_pre)): fout.write(all_pre[i] + '\n') fout.close() if __name__ == '__main__': batch_size = 312 nb_samples = 8000 #path = '/data/xuwenshen/ai_challenge/data/test/ibm_test-50.h5py' path = '/data/xuwenshen/ai_challenge/data/valid/valid/ibm_valid-50-60.h5py' test_folder = Folder(filepath=path, is_test=True, nb_samples=nb_samples) test_loader = DataLoader(test_folder, batch_size=batch_size, num_workers=1, shuffle=False) en_voc_path = '/data/xuwenshen/ai_challenge/data/train/train/en_voc.json' zh_voc_path = '/data/xuwenshen/ai_challenge/data/train/train/zh_voc.json' transform = Transform(en_voc_path=en_voc_path, zh_voc_path=zh_voc_path) en_dims = 712 en_hidden = 900 zh_hidden = 1800 zh_dims = 712 input_dropout_p = 0.5 dropout_p = 0.5
import PIL from streamdeck import render_key_image from Folder import Folder from Key import Key from LaTeX import LaTeX_Folder from Hue import Hue_Folder from Xournal import Xournal_Folder from OBS import OBS_Folder ICON_PATH = os.path.join(os.path.dirname(__file__), "icons") root = Folder("root", 32) folder_latex = LaTeX_Folder(32) folder_xournal = Xournal_Folder(32) folder_obs = OBS_Folder(32) folder_epson = Folder("Epson", 32) #folder_hue = Hue_Folder(32) root.set_key(0, "LaTeX", "latex.png", folder_latex) root.set_key(1, "Xournal", "xournal/xournal.png", folder_xournal) root.set_key(2, "OBS", "obs.png", folder_obs) root.set_key(3, "Epson", "epson.jpg", folder_epson) #root.set_key(4, "Hue", "hue.png", folder_hue) '''root.current_dir() root.key_pressed_callback(5) root.key_pressed_callback(6)
def mangle_folder(self, node): f = Folder(node) self.folders[f.get_id()] = f
import os from CommandFunctions import * from Terminal import Terminal from Folder import Folder from File import File from art import art terminal = Terminal() folder = Folder() file = File() def run(): while True: folder.setPath(terminal.getPath()) file.setPath(terminal.getPath()) print(terminal.getPath() + '>', end='') string = input('') stringList = string.split(' ') if stringList[0] == 'change': terminal.changePath(stringList[1]) elif stringList[0] == 'back': terminal.backPath() elif stringList[0] == 'help': commandsHelp('Help') elif stringList[0] == 'list':
def __init__(self): self.root=Folder("C")
def handle_files(self): """ Process files :return: None """ if not self.files: return total_lines = 0 covered_lines = 0 dirs = {} for file_ in self.files: Statistics.calculate(file_) dir_name = os.path.dirname(file_.path) if dir_name not in dirs: dirs[dir_name] = Folder(dir_name) dirs[dir_name].add_file(file_) for dir_ in dirs.values(): total_lines = total_lines + dir_.total_lines covered_lines = covered_lines + dir_.covered_lines open_file = open( os.path.join(CC_BASE, HTML.INDEX_FILE + HTML.FILE_EXT), "w") root_link = HTML.get_link(CC_BASE, HTML.LINK_ROOT, "") open_file.write(HTML.get_header(root_link, HTML.TABLE_HEADER)) for dir_ in dirs.values(): path = os.path.join(self.ROOT_PATH, dir_.name[1:], HTML.INDEX_FILE + HTML.FILE_EXT).replace( '//', '/') last_pos = dir_.name.rfind("/") open_file.write( HTML.get_line(path, dir_.name[last_pos + 1:], dir_.total_lines, dir_.covered_lines)) open_file.write(HTML.get_footer(total_lines, covered_lines)) open_file.close() for dir_ in dirs.values(): path = (CC_BASE + "/" + self.ROOT_PATH + dir_.name)\ .replace('//', '/') if not os.path.exists(path): os.makedirs(path) open_file = open( os.path.join(path, HTML.INDEX_FILE + HTML.FILE_EXT), "w") open_file.write( HTML.get_header(root_link + dir_.basename, HTML.TABLE_HEADER)) for file_ in dir_.files: open_file.write( HTML.get_line(file_.basename + HTML.FILE_EXT, file_.basename, file_.total_lines, file_.covered_lines)) open_file.write( HTML.get_footer(dir_.total_lines, dir_.covered_lines)) open_file.close() for file_ in self.files: self.handle_file(file_)
def selectFolder(imgdir): folder = Folder(imgdir) return os.listdir(imgdir)
from Folder import Folder from File import File from Memento import Memento from CareTaker import CareTaker from FileSystem import FileSystem C = FileSystem() Winduks = Folder("Видовс") picture = File("Озеро.жпг") system32 = Folder("сустем32") Winduks.addContent(system32) #0 Winduks.addContent(picture) #1 picture1 = File("гора1.жпг") picture2 = File("гора2.жпг") picture3 = File("лужайка.жпг") system32.addContent(picture1) #0 system32.addContent(picture2) #1 Winduks.addContent(picture3) #2 C.root.addContent(Winduks) Security = CareTaker() C.root.viewContent() Security.saveState(C.createMemento()) C.root.delete() C.root.viewContent() C.restore(Security.restoreMemento(0)) C.root.viewContent()
from Folder import Folder from SubFile import SubFile ''' 这样也对,真正起作用的是File类,Folder只不过是FIle类的集合而已,不干实事 ''' if __name__ == '__main__': folder = Folder('Main folder') file = SubFile('File') subfolder = Folder('Sub Folder') subfolder.AddFile(SubFile('File1')) subfolder.AddFile(SubFile('File2')) subfolder.AddFile(Folder('Sub Folder 1')) folder.AddFile(file) folder.AddFile(subfolder) folder.DisplayName()
import sqlite3 from Folder import Folder #import sys #print sys.platform # print "cwd is %s" % os.getcwd() # print "listdir is %s" % os.listdir(os.getcwd()) dbfilename = 'cms.db' # cmsdir = os.getcwd() # cmsdir = "D:/Client Files" # cmsdir = "~/ClientFiles" #cmsdir = "C:/Users/Hugh/ClientFiles" cmsdir = "/home/huy/.config" cmsfolder = Folder(cmsdir) print cmsfolder child_dirs = cmsfolder.get_child_dirs() print child_dirs dir_objs = [Folder(os.path.join(cmsdir, child_dir)) for child_dir in child_dirs] # dirvals = [d.get_cms_client_id_from_dirname() for d in dir_objs] # dirvals = [d.getval() for d in dir_objs] # print dirvals #for d in dir_objs: #print d print "*" * 50