Gets a doc-id-to-file map for the input, either directly or making a fake one based on an input
file list.
191478
private static ImmutableMap<Symbol, File> loadDocIdToFileMap(
      final Optional<File> inputFileListFile,
      final Optional<File> inputFileMapFile) throws IOException {
    checkArgument(inputFileListFile.isPresent() || inputFileMapFile.isPresent());

    final Optional<ImmutableList<File>> fileList;
    if (inputFileListFile.isPresent()) {
      fileList = Optional.of(FileUtils.loadFileList(inputFileListFile.get()));
    } else {
      fileList = Optional.absent();
    }

    final Optional<ImmutableMap<Symbol, File>> fileMap;
    if (inputFileMapFile.isPresent()) {
      fileMap = Optional.of(FileUtils.loadSymbolToFileMap(inputFileMapFile.get()));
    } else {
      fileMap = Optional.absent();
    }

    // sanity checks

    if (fileList.isPresent()) {
      // file list may not contain duplicates
      final boolean containsDuplicates =
          ImmutableSet.copyOf(fileList.get()).size() != fileList.get().size();
      if (containsDuplicates) {
        throw new RuntimeException("Input file list contains duplicates");
      }
    }

    // if both a file map and a file list are given, they must be compatible.
    if (fileList.isPresent() && fileMap.isPresent()) {
      if (fileList.get().size() != fileMap.get().size()) {
        throw new RuntimeException("Input file list and file map do not match in size ("
            + fileList.get().size() + " vs " + fileMap.get().size());
      }
      final boolean haveExactlyTheSameFiles =
          ImmutableSet.copyOf(fileList.get()).equals(ImmutableSet.copyOf(fileMap.get().values()));
      if (!haveExactlyTheSameFiles) {
        throw new RuntimeException(
            "Input file list and file map do not containe exactly the same files");
      }
    }

    // output

    if (fileMap.isPresent()) {
      return fileMap.get();
    } else {
      // if we only had a file list as input, we make a fake doc-id-to-file-map using
      // the absolute path as the document ID.  This won't get output, so it doesn't matter
      // that this is a little hacky
      final Function<File, Symbol> fileNameAsSymbolFunction =
          compose(SymbolUtils.symbolizeFunction(), FileUtils.toAbsolutePathFunction());
      return Maps.uniqueIndex(fileList.get(), fileNameAsSymbolFunction);
    }
  }
64017
def get_mapping(self, doc_type=None, indices=None, raw=False):
        
        if doc_type is None and indices is None:
            path = make_path("_mapping")
            is_mapping = False
        else:
            indices = self.conn._validate_indices(indices)
            if doc_type:
                path = make_path(','.join(indices), doc_type, "_mapping")
                is_mapping = True
            else:
                path = make_path(','.join(indices), "_mapping")
                is_mapping = False
        result = self.conn._send_request('GET', path)
        if raw:
            return result
        from pyes.mappings import Mapper
        mapper = Mapper(result, is_mapping=False,
                        connection=self.conn,
                        document_object_field=self.conn.document_object_field)
        if doc_type:
            return mapper.mappings[doc_type]
        return mapper
1129957
def get_document(self, id):
        
        obj_list = self.document_list
        matches = [i for i in obj_list if str(i.id) == str(id)]
        if not matches:
            raise DoesNotExistError("The resource you've requested does not \
exist or is unavailable without the proper credentials.")
        return matches[0]
767709
def get_docstring(filename, verbose=False):
    

    doc = None

    try:
        # Thank you, Habbie, for this bit of code :-)
        M = ast.parse(''.join(open(filename)))
        for child in M.body:
            if isinstance(child, ast.Assign):
                if 'DOCUMENTATION' in (t.id for t in child.targets):
                    doc = yaml.load(child.value.s)
    except:
        if verbose == True:
            traceback.print_exc()
            print "unable to parse %s" % filename
    return doc
1304116
def find_input_documents(self):
        
        paths = []
        itr = chain(texutils.input_pattern.finditer(self.text),
                    texutils.input_ifexists_pattern.finditer(self.text))
        for match in itr:
            fname = match.group(1)
            if not fname.endswith('.tex'):
                full_fname = ".".join((fname, 'tex'))
            else:
                full_fname = fname
            paths.append(full_fname)
        return paths
35720
function getFileTypeReg(type) {
  var map = [];
  if (type === 'text') {
    map = TEXT_FILE_EXTS;
  } else if (type === 'image') {
    map = IMAGE_FILE_EXTS;
  } else {
    throw new Error('invalid file type [' + type + ']');
  }
  map = map.join('|');
  return new RegExp('\\.(?:' + map + ')$', 'i');
}
1149431
private Integer getNumberOfDocuments(List<File> inputFiles) throws ResourceInitializationException{
	  String directory = (String) getConfigParameterValue(PARAM_INPUTDIR);
	  String filename = directory+"/"+FILE_BASE_SEGMENTATION;
	  for (File file : inputFiles) {
		if (file.getAbsolutePath().equals(filename)){
			try {
				String line;
				BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
				while ((line = bf.readLine()) != null){
					String docName = (line.split("\t"))[0];
					if (!(filenames.contains(docName))){
						filenames.add(docName);
					}
				}
				bf.close();
			} catch (IOException e) {
				throw new ResourceInitializationException(e);
			}
		}
	  }	  
	  int  docCounter = filenames.size();
	  return docCounter;
  }
693514
def copy_doc(doc, dest)
      raise ArgumentError, "_id is required for copying" unless doc['_id']
      slug = escape_docid(doc['_id'])
      destination = if dest.respond_to?(:has_key?) && dest['_id'] && dest['_rev']
        "#{dest['_id']}?rev=#{dest['_rev']}"
      else
        dest
      end
      connection.copy "#{path}/#{slug}", destination
    end
816513
function() {
      var ids = [];
      // search localstorage for saved documents
      for ( var i = 0, max = localStorage.length; i < max; i++) {
        var key = localStorage.key(i);
        // value is a document if key confirms to prefix
        if (key.indexOf(prefix) == 0) {
          ids.push(key.substring(prefix.length));
        }
      }
      return ids;
    }
435769
def get_file_by_id(self, file_id):
        
        return self._create_item_response(
            self.data_service.get_file(file_id),
            File
        )
591251
def doc2id(self, doc):
        
        doc = map(self.process_token, doc)
        return [self.token_to_id(token) for token in doc]
550372
public Map<String, Object> getFileMetaData() {
    if (file == null) {
      file = new HashMap<String, Object>();
    }
    Map<String, Object> meta;
    if (!file.containsKey(FILE_META)) {
      meta = new HashMap<String, Object>();
      meta.put(FILE_SIZE, actualFile.getSize());
    } else {
      meta = (Map<String, Object>) file.get(FILE_META);
    }
    return meta;
  }
902714
def docs(self, fileids=None) -> Generator[str, str, None]:
        
        if not fileids:
            fileids = self.fileids()
        # Create a generator, loading one document into memory at a time.
        for path, encoding in self.abspaths(fileids, include_encoding=True):
            with codecs.open(path, 'r', encoding=encoding) as reader:
                if self.skip_keywords:
                    tmp_data = []
                    for line in reader:
                        skip = False
                        for keyword in self.skip_keywords:
                            if keyword in line:
                                skip = True
                        if not skip:
                            tmp_data.append(line)
                    yield ''.join(tmp_data)
                else:
                    yield reader.read()
634694
def get_file_by_id(self, file_id):
        
        file_ref = self.objects[file_id]
        if not isinstance(file_ref, PBXFileReference):
            return None
        return file_ref
793733
def path_for_doc(self, doc_id):
        
        full_path = self.path_for_doc_fn(self.repo, doc_id)
        # _LOG.debug('>>>>>>>>>> GitActionBase.path_for_doc_fn: {}'.format(self.path_for_doc_fn))
        # _LOG.debug('>>>>>>>>>> GitActionBase.path_for_doc returning: [{}]'.format(full_path))
        return full_path
1103962
def iter_doc_filepaths(self, **kwargs):
        
        for shard in self._shards:
            for doc_id, blob in shard.iter_doc_filepaths(**kwargs):
                yield doc_id, blob
552785
def get_file(self,pattern):
        '''
         
        '''
        flag=[fnmatch.fnmatch(l,pattern) for l in self.filelist]
        id=self.fid_list.compress(flag)
        flag = self.fileid == id
        return flag