The secret sauce behind the addByPart workflow
        Inputs:
           itemParatmers - ItemParamter class
           filePath - full disk path location.
        Output:
           UserItem class
425322
def _addItemMultiPart(self,
                          itemParameters,
                          filePath):
        
        url = self._location + "/addItem"
        params = {
            "f": "json",
            'multipart' : 'true',
            "filename"	: os.path.basename(filePath)
        }
        res = self._post(url=url,
                         param_dict=params,
                         securityHandler=self._securityHandler)
        if 'id' in res:
            itemID = res['id']
            iUrl = "%s/items/%s" % (self.location, itemID)
            ui = UserItem(url=iUrl,
                          securityHandler=self._securityHandler,
                          proxy_url=self._proxy_url,
                          proxy_port=self._proxy_port)
            res = ui.addByPart(filePath=filePath)
            res = ui.commit(wait=True)
            up = ItemParameter()
            up.title = itemParameters.title
            up.tags = itemParameters.tags
            up.filename = os.path.basename(filePath)
            up.type = itemParameters.type
            ui.updateItem(itemParameters=up)

            update_url = ui.root.replace('/rest/', '/') + "/update"

            data = {'title': itemParameters.title,
                   'tags': itemParameters.tags,
                   'filename': os.path.basename(filePath),
                   'type': itemParameters.type,
                   'f': 'json'}
            for k,v in itemParameters.value.items():
                if k not in data.keys():
                    if isinstance(v, bool):
                        data[k] = json.dumps(v)
                    else:
                        data[k] = v
            res = self._post(url=update_url,
                             param_dict=data,
                            securityHandler=self._securityHandler)
            ui.refresh()
            return ui
        return None
788462
@Override
    protected FileInfo getFileInfoFromInputDataImpl(HTTPRequest inputData)
    {
        //get content
        Map<String,ContentPart<?>> contentPartsMap=this.getContentPartsAsMap(inputData);

        //get file info
        FileInfo fileInfo=null;
        ContentPart<?> contentPart=contentPartsMap.get(this.fileContentParameter);
        if(contentPart==null)
        {
            throw new FaxException("File info not provided.");
        }
        ContentPartType contentPartType=contentPart.getType();
        switch(contentPartType)
        {
            case FILE:
                File file=(File)contentPart.getContent();
                fileInfo=new FileInfo(file);
                break;
            case BINARY:
                byte[] data=(byte[])contentPart.getContent();

                //get file name
                String fileName=this.getContentPartAsString(contentPartsMap,this.fileNameParameter);

                fileInfo=new FileInfo(fileName,data);
                break;
            default:
                throw new FaxException("Unsupported content part type: "+contentPartType);
        }

        return fileInfo;
    }
1208152
def _preprocess_add_items(self, items):
        
        paths = []
        entries = []

        for item in items:
            if isinstance(item, string_types):
                paths.append(self._to_relative_path(item))
            elif isinstance(item, (Blob, Submodule)):
                entries.append(BaseIndexEntry.from_blob(item))
            elif isinstance(item, BaseIndexEntry):
                entries.append(item)
            else:
                raise TypeError("Invalid Type: %r" % item)
        # END for each item
        return (paths, entries)
1094774
def registerRti(self, fullName, fullClassName, extensions=None, pythonPath=''):
        
        check_is_a_sequence(extensions)
        extensions = extensions if extensions is not None else []
        extensions = [prepend_point_to_extension(ext) for ext in extensions]

        regRti = RtiRegItem(fullName, fullClassName, extensions, pythonPath=pythonPath)
        self.registerItem(regRti)
826254
function addUserAddedCatalog(terria, initSources) {
  const localDataFilterRemembering = rememberRejections(
    CatalogMember.itemFilters.noLocalData
  );

  const userAddedCatalog = terria.catalog.serializeToJson({
    itemFilter: combineFilters([
      localDataFilterRemembering.filter,
      CatalogMember.itemFilters.userSuppliedOnly,
      function(item) {
        // If the parent has a URL then this item will just load from that, so don't bother serializing it.
        // Properties that change when an item is enabled like opacity will be included in the shared members
        // anyway.
        return !item.parent || !item.parent.url;
      }
    ])
  });

  // Add an init source with user-added catalog members.
  if (userAddedCatalog.length > 0) {
    initSources.push({
      catalog: userAddedCatalog
    });
  }

  return localDataFilterRemembering.rejections;
}
491416
private ExcelWicketToDoItem createToDoItemForUser(final String description, final Category category, Subcategory subcategory, String user, final LocalDate dueBy, final BigDecimal cost, ExecutionContext executionContext) {
        final ExcelWicketToDoItem toDoItem = toDoItems.newToDo(description, category, subcategory, user, dueBy, cost);
        executionContext.add(this, toDoItem);
        return toDoItem;
    }
582101
function handleFileRename() {
        // Prefer selected sidebar item (which could be a folder)
        var entry = ProjectManager.getContext();
        if (!entry) {
            // Else use current file (not selected in ProjectManager if not visible in tree or workingset)
            entry = MainViewManager.getCurrentlyViewedFile();
        }
        if (entry) {
            ProjectManager.renameItemInline(entry);
        }
    }
763425
private void scanUserPaths(PackageSymbol p, boolean includeSourcePath) throws IOException {
        Set<JavaFileObject.Kind> kinds = getPackageFileKinds();

        Set<JavaFileObject.Kind> classKinds = EnumSet.copyOf(kinds);
        classKinds.remove(JavaFileObject.Kind.SOURCE);
        boolean wantClassFiles = !classKinds.isEmpty();

        Set<JavaFileObject.Kind> sourceKinds = EnumSet.copyOf(kinds);
        sourceKinds.remove(JavaFileObject.Kind.CLASS);
        boolean wantSourceFiles = !sourceKinds.isEmpty();

        boolean haveSourcePath = includeSourcePath && fileManager.hasLocation(SOURCE_PATH);

        if (verbose && verbosePath) {
            if (fileManager instanceof StandardJavaFileManager) {
                StandardJavaFileManager fm = (StandardJavaFileManager)fileManager;
                if (haveSourcePath && wantSourceFiles) {
                    List<Path> path = List.nil();
                    for (Path sourcePath : fm.getLocationAsPaths(SOURCE_PATH)) {
                        path = path.prepend(sourcePath);
                    }
                    log.printVerbose("sourcepath", path.reverse().toString());
                } else if (wantSourceFiles) {
                    List<Path> path = List.nil();
                    for (Path classPath : fm.getLocationAsPaths(CLASS_PATH)) {
                        path = path.prepend(classPath);
                    }
                    log.printVerbose("sourcepath", path.reverse().toString());
                }
                if (wantClassFiles) {
                    List<Path> path = List.nil();
                    for (Path platformPath : fm.getLocationAsPaths(PLATFORM_CLASS_PATH)) {
                        path = path.prepend(platformPath);
                    }
                    for (Path classPath : fm.getLocationAsPaths(CLASS_PATH)) {
                        path = path.prepend(classPath);
                    }
                    log.printVerbose("classpath",  path.reverse().toString());
                }
            }
        }

        String packageName = p.fullname.toString();
        if (wantSourceFiles && !haveSourcePath) {
            fillIn(p, CLASS_PATH,
                   list(CLASS_PATH,
                        p,
                        packageName,
                        kinds));
        } else {
            if (wantClassFiles)
                fillIn(p, CLASS_PATH,
                       list(CLASS_PATH,
                            p,
                            packageName,
                            classKinds));
            if (wantSourceFiles)
                fillIn(p, SOURCE_PATH,
                       list(SOURCE_PATH,
                            p,
                            packageName,
                            sourceKinds));
        }
    }
377070
@Override
    public String findClassAbsoluteFileName(String fileName, String className, List<String> sourceRoots) {
        // usually the fileName is just the name of the file without any package information
        // so lets turn the package name into a path
        int lastIdx = className.lastIndexOf('.');
        if (lastIdx > 0 && !(fileName.contains("/") || fileName.contains(File.separator))) {
            String packagePath = className.substring(0, lastIdx).replace('.', File.separatorChar);
            fileName = packagePath + File.separator + fileName;
        }
        File baseDir = getBaseDir();
        String answer = findInSourceFolders(baseDir, fileName);
        if (answer == null && sourceRoots != null) {
            for (String sourceRoot : sourceRoots) {
                answer = findInSourceFolders(new File(sourceRoot), fileName);
                if (answer != null) break;
            }
        }
        return answer;
    }
623033
public static String getUserFolderPath(final boolean appendFileSeprator) {
		String path = USER_LOCAL_PATH;
		checkFolderPath(path, true);// to create the folder if not exist
		if (appendFileSeprator) {
			path += FILE_SEPARATOR;
		}
		return path;
	}
482415
def CollectionItemToAff4Path(item, client_id=None):
  """"""
  if isinstance(item, rdf_flows.GrrMessage):
    client_id = item.source
    item = item.payload
  elif isinstance(item, rdf_flow_objects.FlowResult):
    client_id = item.client_id
    item = item.payload

  if not client_id:
    raise ValueError("Could not determine client_id.")
  elif isinstance(client_id, string_types):
    client_id = rdf_client.ClientURN(client_id)

  if isinstance(item, rdf_client_fs.StatEntry):
    return item.AFF4Path(client_id)
  elif isinstance(item, rdf_file_finder.FileFinderResult):
    return item.stat_entry.AFF4Path(client_id)
  elif isinstance(item, collectors.ArtifactFilesDownloaderResult):
    if item.HasField("downloaded_file"):
      return item.downloaded_file.AFF4Path(client_id)

  raise ItemNotExportableError(item)
361687
private String getContentType(List<FileItem> items) {
        for (FileItem i : items) {
            if (!i.isFormField() && i.getFieldName().equals(CONTENT_PARAMETER)) {
                return i.getContentType();
            }
        }
        return null;
    }
1315497
def visit_file(self, item, parent):
        
        if item.need_to_send:
            if item.size > self.settings.config.upload_bytes_per_chunk:
                msg = "Programmer Error: Trying to upload large file as small item size:{} name:{}"
                raise ValueError(msg.format(item.size, item.name))
            else:
                command = CreateSmallFileCommand(self.settings, item, parent,
                                                 self.settings.file_upload_post_processor)
                self.task_runner_add(parent, item, command)
154405
function getOutputFilePath(input, outputDir, suffix) {
  var inputArr = input.split(path.sep);
  var originFileName = inputArr[inputArr.length - 1];
  var newFileName = originFileName.replace(/\.png$/, suffix + '.png');
  var outputFilePath = path.join(outputDir, newFileName);
  return outputFilePath;
}
82750
def add(self, filetype, **kwargs):
        

        location = self.location(filetype, **kwargs)
        source = self.url(filetype, sasdir='sas' if not self.public else '', **kwargs)
        if 'full' not in kwargs:
            destination = self.full(filetype, **kwargs)
        else:
            destination = kwargs.get('full')

        if location and source and destination:
            self.initial_stream.append_task(location=location, source=source, destination=destination)
        else:
            print("There is no file with filetype=%r to access in the tree module loaded" % filetype)
373223
String getResourceName(String fileName) {
        // FIXME: there is probably a more robust way to do this

        // Strip off the directory part.
        String dirPath = directory.getPath();
        if (!fileName.startsWith(dirPath)) {
            throw new IllegalStateException("Filename " + fileName + " not inside directory " + dirPath);
        }

        // The problem here is that we need to take the relative part of the
        // filename
        // and break it into components that we can then reconstruct into
        // a resource name (using '/' characters to separate the components).
        // Unfortunately, the File class does not make this task particularly
        // easy.

        String relativeFileName = fileName.substring(dirPath.length());
        File file = new File(relativeFileName);
        LinkedList<String> partList = new LinkedList<>();
        do {
            partList.addFirst(file.getName());
        } while ((file = file.getParentFile()) != null);

        StringBuilder buf = new StringBuilder();
        for (String part : partList) {
            if (buf.length() > 0) {
                buf.append('/');
            }
            buf.append(part);
        }

        return buf.toString();
    }
1286070
def _parse__item(self, item_type: Type[T], item_file_prefix: str,
                     file_mapping_conf: FileMappingConfiguration = None,
                     options: Dict[str, Dict[str, Any]] = None) -> T:
        

        # for consistency : if options is None, default to the default values of create_parser_options
        options = options or create_parser_options()

        # creating the persisted object (this performs required checks)
        file_mapping_conf = file_mapping_conf or WrappedFileMappingConfiguration()
        obj = file_mapping_conf.create_persisted_object(item_file_prefix, logger=self.logger)
        # print('')
        self.logger.debug('')

        # create the parsing plan
        pp = self.create_parsing_plan(item_type, obj, logger=self.logger)
        # print('')
        self.logger.debug('')

        # parse
        res = pp.execute(logger=self.logger, options=options)
        # print('')
        self.logger.debug('')

        return res