def upload_file(self, source_path, dir_name):
row = self.get_task_db(source_path)<EOL>source_dir, filename = os.path.split(source_path)<EOL>path = os.path.join(dir_name, filename)<EOL>size = os.path.getsize(source_path)<EOL>total_size = util.get_human_size(size)[<NUM_LIT:0>]<EOL>tooltip = gutil.escape(_('<STR_LIT>').format(source_path, path))<EOL>if size < <NUM_LIT:2> ** <NUM_LIT>:           <EOL><INDENT>threshold = <NUM_LIT:2> ** <NUM_LIT>      <EOL><DEDENT>elif size < <NUM_LIT:2> ** <NUM_LIT>:         <EOL><INDENT>threshold =  <NUM_LIT:2> ** <NUM_LIT>     <EOL><DEDENT>elif size < <NUM_LIT:10> * (<NUM_LIT:2> ** <NUM_LIT:30>):  <EOL><INDENT>threshold = math.ceil(size / <NUM_LIT:1000>)<EOL><DEDENT>else:<EOL><INDENT>self.app.toast(_('<STR_LIT>').format(path))<EOL>return<EOL><DEDENT>task = [<EOL>filename,<EOL>source_path,<EOL>path,<EOL>size,<EOL><NUM_LIT:0>,<EOL>State.WAITING,<EOL>StateNames[State.WAITING],<EOL>'<STR_LIT>'.format(total_size),<EOL><NUM_LIT:0>,<EOL>tooltip,<EOL>threshold,<EOL>]<EOL>row_id = self.add_task_db(task, force=False)<EOL>task.insert(<NUM_LIT:0>, row_id)<EOL>self.liststore.append(task)<EOL>
上传一个文件