* archive tp file done tasks*

        **Key Arguments:**
            - ``taskpaperPath`` -- path to a taskpaper file

        **Return:**
            - None
8542
def _archive_tp_file_done_tasks(
            self,
            taskpaperPath):
        
        self.log.info('starting the ``_archive_tp_file_done_tasks`` method')
        self.log.info("archiving taskpaper file %(taskpaperPath)s" % locals())
        taskLog = {}
        mdArchiveFile = taskpaperPath.replace(".taskpaper", "-tasklog.md")
        exists = os.path.exists(mdArchiveFile)
        if exists:
            pathToReadFile = mdArchiveFile
            try:
                self.log.debug("attempting to open the file %s" %
                               (pathToReadFile,))
                readFile = codecs.open(
                    pathToReadFile, encoding='utf-8', mode='r')
                thisData = readFile.read()
                readFile.close()
            except IOError, e:
                message = 'could not open the file %s' % (pathToReadFile,)
                self.log.critical(message)
                raise IOError(message)
            readFile.close()
            table = False
            for l in thisData.split("\n"):
                l = l.encode("utf-8")
                if ":---" in l:
                    table = True
                    continue
                if table == True and len(l) and l[0] == "|":
                    dictt = collections.OrderedDict(sorted({}.items()))
                    columns = l.split("|")

                    dictt["task"] = columns[1].strip().decode("utf-8")
                    dictt["completed"] = columns[2].strip().decode("utf-8")
                    dictt["project"] = columns[3].strip().decode("utf-8")
                    taskLog[dictt["task"] + dictt["completed"] +
                            dictt["project"]] = dictt

        doc = document(taskpaperPath)
        aProject = doc.get_project("Archive")
        if not aProject:
            return

        doneTasks = aProject.tagged_tasks("@done")

        for task in doneTasks:
            dateCompleted = ""
            project = ""
            for t in task.tags:
                if "done" in t:
                    dateCompleted = t.replace("done", "").replace(
                        "(", "").replace(")", "")
                if "project(" in t:
                    project = t.replace("project", "").replace(
                        "(", "").replace(")", "")

            dictt = collections.OrderedDict(sorted({}.items()))

            notes = ""
            if task.notes:
                for n in task.notes:
                    if len(notes) and notes[-2:] != ". ":
                        if notes[-1] == ".":
                            notes += " "
                        else:
                            notes += ". "
                    notes += n.title
            if len(notes):
                notes = "<br><br>**NOTES:**<br>" + \
                    "<br>".join(textwrap.wrap(
                        notes, 120, break_long_words=True))

            dictt["task"] = "<br>".join(textwrap.wrap(task.title[
                2:], 120, break_long_words=True)) + notes
            dictt["task"] = dictt["task"].encode("utf-8")
            dictt["completed"] = dateCompleted
            dictt["project"] = project

            # SET ENCODE ERROR RETURN VALUE

            # RECODE INTO ASCII
            dictt["task"] = dictt["task"].decode("utf-8")
            dictt["completed"] = dictt["completed"].decode("utf-8")
            dictt["project"] = dictt["project"].decode("utf-8")
            taskLog[dictt["task"] + dictt["completed"] +
                    dictt["project"]] = dictt

        taskLog = taskLog.values()

        taskLog = sorted(taskLog, key=itemgetter('task'), reverse=True)
        taskLog = sorted(taskLog, key=itemgetter('project'), reverse=True)
        taskLog = sorted(taskLog, key=itemgetter('completed'), reverse=True)

        dataSet = list_of_dictionaries(
            log=self.log,
            listOfDictionaries=taskLog
        )

        markdownData = dataSet.markdown(filepath=None)

        try:
            self.log.debug("attempting to open the file %s" % (mdArchiveFile,))
            writeFile = codecs.open(mdArchiveFile, encoding='utf-8', mode='w')
        except IOError, e:
            message = 'could not open the file %s' % (mdArchiveFile,)
            self.log.critical(message)
            raise IOError(message)

        writeFile.write(markdownData.decode("utf-8"))
        writeFile.close()

        aProject.delete()

        doc.save()

        self.log.info('completed the ``_archive_tp_file_done_tasks`` method')
        return None
1162752
def get_full_archive_path(self, path):
        
        return os.path.join(self.archive_dir, path.lstrip('/'))
134725
def view
      pager = ENV['PAGER'] || 'less'
      execute_external_command do
        unless in_zip?
          system %Q[#{pager} "#{current_item.path}"]
        else
          begin
            tmpdir, tmpfile_name = nil
            Zip::File.open(current_zip) do |zip|
              tmpdir = Dir.mktmpdir
              FileUtils.mkdir_p File.join(tmpdir, File.dirname(current_item.name))
              tmpfile_name = File.join(tmpdir, current_item.name)
              File.open(tmpfile_name, 'w') {|f| f.puts zip.file.read(current_item.name)}
            end
            system %Q[#{pager} "#{tmpfile_name}"]
          ensure
            FileUtils.remove_entry_secure tmpdir if tmpdir
          end
        end
      end
    end
262251
def create_on_task(self, task_id, file_content, file_name, file_content_type=None, **options):
        """"""
        path = '/tasks/%d/attachments' % (task_id)
        return self.client.request('post', path, files=[('file', (file_name, file_content, file_content_type))], **options)
182197
def tail(self, stream='stdout', num_lines=10):
        
        target = self._map_string_to_file(stream)
        if not target:  # no current temp file
            last_run = self.backend.get_latest_run_log(self.parent_job.job_id,
                                                       self.name)
            if not last_run:
                return None
            return self._tail_string(last_run['tasks'][self.name][stream],
                                     num_lines)
        else:
            return self._tail_temp_file(target, num_lines)
160190
def _archive(self):
        
        archive, archive_file = _retrieve_archive()

        if self.backup:
            self.backup.add_archive(archive)

        if archive:
            from topydo.commands.ArchiveCommand import ArchiveCommand
            command = ArchiveCommand(self.todolist, archive)
            command.execute()

            if archive.dirty:
                archive_file.write(archive.print_todos())
978690
def asset_save_callback(self, *args, **kwargs):
        
        tasksel = self.browser.assetbrws.selected_indexes(2)
        if not tasksel or not tasksel[0].isValid():
            self.statusbar.showMessage('No task selected! Cannot save!')
            return

        taskitem = tasksel[0].internalPointer()
        task = taskitem.internal_data()
        rtype = djadapter.RELEASETYPES['work']
        descriptor = self.asset_descriptor_le.text()
        if not self.check_selection_for_save(task, rtype, descriptor):
            return

        tfi = TaskFileInfo.get_next(task=task, releasetype=rtype,
                                    typ=self._filetype, descriptor=descriptor)
        self._save_tfi(tfi, asset=True)
1262209
def print_task_help(self, task, name):
        
        TerminalColor.set('GREEN')
        print(get_signature(name, task))

        # TODO: print the location does not work properly and sometimes returns None
        # print('    => defined in: {}'.format(inspect.getsourcefile(task)))
        help_msg = inspect.getdoc(task) or ''
        TerminalColor.reset()
        print('   ' + help_msg.replace('\n', '\n   '))
        TerminalColor.reset()
        print()
829395
def get_task_filelist(cls, task_factory, courseid, taskid):
        
        task_fs = task_factory.get_task_fs(courseid, taskid)
        if not task_fs.exists():
            return []

        tmp_out = {}
        entries = task_fs.list(True, True, True)
        for entry in entries:
            if os.path.splitext(entry)[0] == "task" and os.path.splitext(entry)[1][1:] in task_factory.get_available_task_file_extensions():
                continue

            data = entry.split("/")
            is_directory = False
            if data[-1] == "":
                is_directory = True
                data = data[0:len(data)-1]
            cur_pos = 0
            tree_pos = tmp_out
            while cur_pos != len(data):
                if data[cur_pos] not in tree_pos:
                    tree_pos[data[cur_pos]] = {} if is_directory or cur_pos != len(data) - 1 else None
                tree_pos = tree_pos[data[cur_pos]]
                cur_pos += 1

        def recur_print(current, level, current_name):
            iteritems = sorted(current.items())
            # First, the files
            recur_print.flattened += [(level, False, f, current_name+"/"+f) for f, t in iteritems if t is None]
            # Then, the dirs
            for name, sub in iteritems:
                if sub is not None:
                    recur_print.flattened.append((level, True, name, current_name+"/"+name+"/"))
                    recur_print(sub, level + 1, current_name + "/" + name)
        recur_print.flattened = []
        recur_print(tmp_out, 0, '')
        return recur_print.flattened
994598
def runRmFile(self, path, timeout=None, **kwargs):
        
        cmd_args = {'path': path, 'logEnviron': self.logEnviron}
        if timeout:
            cmd_args['timeout'] = timeout
        if self.workerVersionIsOlderThan('rmfile', '3.1'):
            cmd_args['dir'] = os.path.abspath(path)
            return self.runRemoteCommand('rmdir', cmd_args, **kwargs)
        return self.runRemoteCommand('rmfile', cmd_args, **kwargs)
1003679
def taskdir(self):
        
        return os.path.join(self.BASE, self.TAG, self.task_family)
1156124
private void moveTaskOutputs(TaskAttemptContext context,
                               FileSystem fs,
                               Path jobOutputDir,
                               Path taskOutput) 
  throws IOException {
    TaskAttemptID attemptId = context.getTaskAttemptID();
    context.progress();
    if (fs.isFile(taskOutput)) {
      Path finalOutputPath = getFinalPath(jobOutputDir, taskOutput, 
                                          workPath);
      if (!fs.rename(taskOutput, finalOutputPath)) {
        if (!fs.delete(finalOutputPath, true)) {
          throw new IOException("Failed to delete earlier output of task: " + 
                                 attemptId);
        }
        if (!fs.rename(taskOutput, finalOutputPath)) {
          throw new IOException("Failed to save output of task: " + 
        		  attemptId);
        }
      }
      LOG.debug("Moved " + taskOutput + " to " + finalOutputPath);
    } else if(fs.getFileStatus(taskOutput).isDir()) {
      FileStatus[] paths = fs.listStatus(taskOutput);
      Path finalOutputPath = getFinalPath(jobOutputDir, taskOutput, workPath);
      fs.mkdirs(finalOutputPath);
      if (paths != null) {
        for (FileStatus path : paths) {
          moveTaskOutputs(context, fs, jobOutputDir, path.getPath());
        }
      }
    }
  }
969372
private Path getTaskLogFileFromId(String taskId)
  {
    return new Path(mergePaths(config.getDirectory(), taskId.replace(':', '_')));
  }
589353
def load(self):
        

        try:
            _parser = parser.parse_config(self._paths['active_file'],
                                          self.HEADER_ACTIVE_FILE)

            # parse expected options into a dict to de-dupe
            keys = ('name', 'start_time')
            opts = dict(o for o in _parser.options if o[0] in keys)

            # check for all keys
            for k in keys:
                if not opts.get(k):
                    return False
            task_name = opts.get('name')[0]

            # setup the paths
            task_dir = self._get_task_dir(task_name)
            task_config = os.path.join(task_dir, 'task.cfg')

            # validate start time
            value = opts.get('start_time')[0]
            start_time = datetime.datetime.strptime(value,
                                                    '%Y-%m-%d %H:%M:%S.%f')

            # get user id for process ownership when running task
            # here, we use the owner of the active file
            file_meta = os.stat(self._paths['active_file'])
            owner = file_meta.st_uid

            # parse task config and send its options to registered plugins
            _parser = parser.parse_config(task_config, self.HEADER_TASK_CONFIG)
            registration.run_option_hooks(_parser)

            self._name = common.from_utf8(task_name)
            self._start_time = start_time
            self._owner = owner
            self._paths['task_dir'] = task_dir
            self._paths['task_config'] = task_config
            self._loaded = True

        except (parser.ParseError, ValueError, TypeError, OSError):
            # something failed, cleanup
            self._clean()

        self._clean_prior()
        return self._loaded
391383
def identify_raw_files(task: Task, test_mode: bool = False) -> List[str]:
    
    raw_files = set()
    all_sets = [task.test,] if test_mode else [task.train, task.dev, task.test]
    for file_sets in all_sets:
        for file_set in file_sets:
            for fname in file_set[:2]:
                raw_file = fname.split("/", 1)[0]
                if raw_file not in RAW_FILES:
                    raise RuntimeError("Unknown raw file %s found in path %s" % (raw_file, fname))
                raw_files.add(raw_file)
    return sorted(raw_files)
537890
function (arg) {
    var args = Array.isArray(arg) ? arg : [].slice.call(arguments);
    var channel = options.taskChannelPrefix + '.' + args[0];
    args[0] = channel;
    fs.write(tmpfile, JSON.stringify(args) + "\n", "a");
}
1087246
def _backup_dir_item(self, dir_path, process_bar):
        
        self.path_helper.set_src_filepath(dir_path)
        if self.path_helper.abs_src_filepath is None:
            self.total_errored_items += 1
            log.info("Can't backup %r", dir_path)

        # self.summary(no, dir_path.stat.st_mtime, end=" ")
        if dir_path.is_symlink:
            self.summary("TODO Symlink: %s" % dir_path)
            return

        if dir_path.resolve_error is not None:
            self.summary("TODO resolve error: %s" % dir_path.resolve_error)
            pprint_path(dir_path)
            return

        if dir_path.different_path:
            self.summary("TODO different path:")
            pprint_path(dir_path)
            return

        if dir_path.is_dir:
            self.summary("TODO dir: %s" % dir_path)
        elif dir_path.is_file:
            # self.summary("Normal file: %s", dir_path)

            file_backup = FileBackup(dir_path, self.path_helper, self.backup_run)
            old_backup_entry = self.fast_compare(dir_path)
            if old_backup_entry is not None:
                # We can just link the file from a old backup
                file_backup.fast_deduplication_backup(old_backup_entry, process_bar)
            else:
                file_backup.deduplication_backup(process_bar)

            assert file_backup.fast_backup is not None, dir_path.path
            assert file_backup.file_linked is not None, dir_path.path

            file_size = dir_path.stat.st_size
            if file_backup.file_linked:
                # os.link() was used
                self.total_file_link_count += 1
                self.total_stined_bytes += file_size
            else:
                self.total_new_file_count += 1
                self.total_new_bytes += file_size

            if file_backup.fast_backup:
                self.total_fast_backup += 1
        else:
            self.summary("TODO:" % dir_path)
            pprint_path(dir_path)