Prepare the file manager for the files embedded in the scale description field
969244
public function on_scales_start() {
        $syscontextid  = $this->converter->get_contextid(CONTEXT_SYSTEM);
        $this->fileman = $this->converter->get_file_manager($syscontextid, 'grade', 'scale');
    }
293408
protected function setDataContendFileManager()
    {
        if ($this->data_access) {

            $data = $this->command->getView($this->data_command, array($this->data_file, $this));

            if (is_string($data)) {
                $this->setMessageFileManager($data, 'warning');
            } else {

                settype($data, 'array');

                $template_data = reset($data);
                $template = key($data);
                $template_data['file'] = $this->data_file;
                $template_data['breadcrumbs'] = $this->getPathBreadcrumbsFileManager();
                $rendered = $this->render($template, array_merge($template_data, $this->data));

                $this->setData('content', $rendered);
            }
        }
    }
1087228
protected function prepareProjectData(): void
  {
    parent::prepareProjectData();

    // Get file list form the project by fileset ID.
    $sources               = $this->getProject()->getReference($this->sourcesFilesetId);
    $this->sourceFileNames = $sources->getDirectoryScanner($this->getProject())->getIncludedFiles();
    $suc                   = ksort($this->sourceFileNames);
    if ($suc===false) $this->logError("ksort failed.");
  }
316816
protected function prepareImportData()
    {
        $this->initParentCategory();
        $this->setActiveField();

        $this->initPreviewImage();
        $this->initImageList();

        parent::prepareImportData();
    }
159475
def _prepare_temp_dir(self):
    """"""
    shell_call(['rm', '-rf', os.path.join(self._temp_dir, '*')])
    # NOTE: we do not create self._extracted_submission_dir
    # this is intentional because self._tmp_extracted_dir or it's subdir
    # will be renames into self._extracted_submission_dir
    os.mkdir(self._tmp_extracted_dir)
    os.mkdir(self._sample_input_dir)
    os.mkdir(self._sample_output_dir)
    # make output dir world writable
    shell_call(['chmod', 'a+rwX', '-R', self._sample_output_dir])
748171
function prepareEPUBDataForIndexing(metaData, data) {
    if(!metaData.spineItems.length) {
        return;
    }

    if (!data.FirstSpineItemsId) {
        data.FirstSpineItemsId = [];
    }

    data.FirstSpineItemsId.push(
        metaData.spineItems[0].id + ':' + metaData.title
    );

    metaData.spineItems.forEach( spineItem => {
        const spineItemPath = metaData.manifestPath + '/' + spineItem.href;
        const json = htmlToJSON(spineItemPath);
        setMetaData(json, metaData, spineItem);
        data.push(json);
    });
}
418717
function(el, settings) {
    this.setSettings(settings);
    this.manager = this.settings.manager || new FileUploadManager(this.settings);
    this.setElement(el);
}
1369700
protected function prepareImportData()
    {
        $this->setActiveField();
        $this->setBrandField();
        $this->setCategoryField();

        $this->initPreviewImage();
        $this->initImageList();
        $this->initAdditionalCategoryField();

        parent::prepareImportData();
    }
138678
protected function prepareTempFolder()
    {
        $this->tmpFolder = sys_get_temp_dir() . '/PrestaSitemaps-' . uniqid();
        $this->filesystem->mkdir($this->tmpFolder);
    }
1072724
def load_metadata(self, data_dir, feature_name=None):
    """"""
    # Restore names if defined
    filepath = _get_metadata_filepath(data_dir, feature_name)
    if tf.io.gfile.exists(filepath):
      with tf.io.gfile.GFile(filepath, 'r') as f:
        info_data = json.load(f)
      self.set_encoding_format(info_data['encoding_format'])
      self.set_shape([None if d == -1 else d for d in info_data['shape']])
1165190
def configure_file_logger(name, log_dir, log_level=logging.DEBUG):
    """"""
    from .srothandler import SizeRotatingFileHandler

    root = logging.getLogger()
    root.setLevel(log_level)
    handler = SizeRotatingFileHandler(os.path.join(log_dir, '%s.log' % name))
    handler.setLevel(log_level)
    handler.setFormatter(logging.Formatter(LOG_FORMAT_STANDARD))

    root.addHandler(handler)
1289615
def fileprep(self):
        """"""
        # Create and start threads
        for i in range(self.cpus):
            # Send the threads to the appropriate destination function
            threads = Thread(target=self.prep, args=())
            # Set the daemon to true - something to do with thread management
            threads.setDaemon(True)
            # Start the threading
            threads.start()
        for sample in self.metadata:
            # Set the name of the decompressed, combined .fastq file
            sample.general.combined = os.path.join(sample.general.outputdirectory, '{sample_name}_combined.fastq'
                                                   .format(sample_name=sample.name))
            self.queue.put(sample)
        self.queue.join()
349212
protected void prepareExpansion() throws IOException {
        WsResource expansionResource = deployedAppServices.getLocationAdmin().resolveResource(AppManagerConstants.EXPANDED_APPS_DIR);
        expansionResource.create();
    }
291602
def setDescription(self, desc='No description'):
        """"""
        try:
            self._put_named_file('description', desc)
        except Exception, e:
            raise RepoError(e)
932725
def prepare_filename_decorator(fn):
    
    @wraps(fn)
    def inner(self, normalized_url, request):
        ext = settings.ROUGHPAGES_TEMPLATE_FILE_EXT
        if not normalized_url:
            normalized_url = settings.ROUGHPAGES_INDEX_FILENAME
        filenames = fn(self, normalized_url, request)
        filenames = [x + ext for x in filenames if x]
        return filenames
    return inner
589351
def upscale(file_name, scale=1.5, margin_x=0, margin_y=0, suffix='scaled', tempdir=None):
    """"""
    def adjust(page):
        info = PageMerge().add(page)
        x1, y1, x2, y2 = info.xobj_box
        viewrect = (margin_x, margin_y, x2 - x1 - 2 * margin_x, y2 - y1 - 2 * margin_y)
        page = PageMerge().add(page, viewrect=viewrect)
        page[0].scale(scale)
        return page.render()

    # Set output file name
    if tempdir:
        output = NamedTemporaryFile(suffix='.pdf', dir=tempdir, delete=False).name
    elif suffix:
        output = os.path.join(os.path.dirname(file_name), add_suffix(file_name, suffix))
    else:
        output = NamedTemporaryFile(suffix='.pdf').name

    reader = PdfReader(file_name)
    writer = PdfWriter(output)
    for i in list(range(0, len(reader.pages))):
        writer.addpage(adjust(reader.pages[i]))
    writer.trailer.Info = IndirectPdfDict(reader.Info or {})
    writer.write()
    return output
816123
def _initFilesystemInfo(self):
        """"""
        self._mapFSpathDev = {}
        fsinfo = FilesystemInfo()
        for fs in fsinfo.getFSlist():
            devpath = fsinfo.getFSdev(fs)
            dev = self._getUniqueDev(devpath)
            if dev is not None:
                self._mapFSpathDev[fs] = dev