Searches for JSON files in this repo and returns
    a map of amendment id ==> (`tag`, dir, amendment filepath)
    where `tag` is typically the shard name
178184
def create_id2amendment_info(path, tag):
    
    d = {}
    for triple in os.walk(path):
        root, files = triple[0], triple[2]
        for filename in files:
            if filename.endswith('.json'):
                # trim its file extension 
                amendment_id = n = filename[:-5]
                d[amendment_id] = (tag, root, os.path.join(root, filename))
    return d
135478
def load_json_or_yaml(file_path):
    
    with open(file_path, "r") as f:
        if os.path.splitext(file_path)[1] == ".json":
            return json.load(f)
        else:
            return inginious.common.custom_yaml.load(f)
722766
String getUIDFolderName() {
        if (uidFolderName == null) {
            String relPath = getAbsolutePath().replace(REPO_ABSOLUTE_PATH, "");
            relPath = relPath.substring(relPath.indexOf(SystemUtils.FILE_SEPARATOR) + 1);
            String[] parts = relPath.split("[\\\\/]");
            uidFolderName = StringUtils.isEmpty(parts[0]) ? "" : parts[0];
        }
        return uidFolderName;
    }
1113295
def get_git_tag(hash_, git_path='git'):
    
    tag, status = call((git_path, 'describe', '--exact-match',
                        '--tags', hash_), returncode=True)
    if status == 0:
        return tag
    else:
        return None
723165
private boolean searchHarDir(FileStatus stat) 
      throws IOException {
    if (!stat.isDir()) {
      return false;
    }
    String pattern = stat.getPath().toString() + "/*" + RaidNode.HAR_SUFFIX 
        + "*";
    FileStatus[] stats = globStatus(new Path(pattern));
    if (stats != null && stats.length > 0) {
      return true;
    }
      
    stats = fs.listStatus(stat.getPath());
   
    // search deeper.
    for (FileStatus status : stats) {
      if (searchHarDir(status)) {
        return true;
      }
    }
    return false;
  }
114265
def yaml_read_irred_perts(filename, doc_tag="!IrredPerts"):
    """"""
    with YamlTokenizer(filename) as r:
        doc = r.next_doc_with_tag(doc_tag)
        d = yaml.safe_load(doc.text_notag)

        return [AttrDict(**pert) for pert in d["irred_perts"]]
227007
def getrawfile(self, project_id, sha1, filepath):
        
        data = {'filepath': filepath}

        request = requests.get(
            '{0}/{1}/repository/blobs/{2}'.format(self.projects_url, project_id, sha1),
            params=data, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout,
            headers=self.headers)

        if request.status_code == 200:
            return request.content
        else:
            return False
281424
private long getIndexVersion(List<ShardIndexVersion> shards) {
    long version = 1;

    // order shards per their id before computing the hash
    Collections.sort(shards, new Comparator<ShardIndexVersion>() {
      @Override
      public int compare(ShardIndexVersion o1, ShardIndexVersion o2) {
        return o1.getShardRouting().id() - o2.getShardRouting().id();
      }
    });

    // compute hash
    for (ShardIndexVersion shard : shards) {
      version = 31 * version + shard.getVersion();
    }

    return version;
  }
685916
public static JSONArray getRepositoryNames() {
        final JSONArray ret = new JSONArray();

        if (null == repositoriesDescription) {
            LOGGER.log(Level.INFO, "Not found repository description[repository.json] file under classpath");

            return ret;
        }

        final JSONArray repositories = repositoriesDescription.optJSONArray("repositories");

        for (int i = 0; i < repositories.length(); i++) {
            final JSONObject repository = repositories.optJSONObject(i);

            ret.put(repository.optString("name"));
        }

        return ret;
    }
421552
def ids(type)

      Dir[File.join(dir_for(type), '**', '*.json')].collect { |path|
        File.basename(path, '.json')
      }.sort
    end
479896
def tag_versions(repo_path):
    
    repo = dulwich.repo.Repo(repo_path)
    tags = get_tags(repo)
    maj_version = 0
    feat_version = 0
    fix_version = 0
    last_maj_version = 0
    last_feat_version = 0
    result = []

    for commit_sha, children in reversed(
            get_children_per_first_parent(repo_path).items()
    ):
        commit = get_repo_object(repo, commit_sha)
        maj_version, feat_version, fix_version = get_version(
            commit=commit,
            tags=tags,
            maj_version=maj_version,
            feat_version=feat_version,
            fix_version=fix_version,
            children=children,
        )
        if (
            last_maj_version != maj_version or
            last_feat_version != feat_version
        ):
            last_maj_version = maj_version
            last_feat_version = feat_version
            tag_name = 'refs/tags/v%d.%d' % (maj_version, feat_version)
            if ON_PYTHON3:
                repo[str.encode(tag_name)] = commit
            else:
                repo[tag_name] = commit

            result.append(
                'v%d.%d -> %s' % (maj_version, feat_version, commit_sha)
            )

    return '\n'.join(result)
423750
def search(self, searchString, category="", math=False, game=False, searchFiles=False, extension=""):
		""""""
		data = []
		nameData = {}
		fileData = {}
		
		#Search the name index
		if searchFiles:
			fileData = self.searchNamesIndex(self.fileIndex, fileData, searchString, category, math, game, extension, searchFiles)
		else:
			nameData = self.searchNamesIndex(self.nameIndex, nameData, searchString)
			
		#Now search the file index
		if searchFiles:
			nameData, fileData = self.searchFilesIndex(fileData, nameData, self.nameIndex, searchString)
		else:
			fileData, nameData = self.searchFilesIndex(nameData, fileData, self.fileIndex, searchString, category, math, game, extension)
			
		# Bail out if we failed to do either of those things.
		if fileData is None or nameData is None:
			self.repo.printd("Error: failed to load one or more of the index files for this repo. Exiting.")
			self.repo.printd("Please run 'calcpkg update' and retry this command.")
			sys.exit(1)
			
		# Prepare output to parse
		space = 0
		longestFile = len("File Name:")
		for key, value in nameData.iteritems():
			fileValue = fileData[key]
			data.append([fileValue, value])
			if not fileValue is None:
				folder = fileValue.rpartition("/")[0]
				if space < len(folder):
					space = len(folder)
			if not value is None:
				if longestFile < len(value):
					longestFile = len(value)

		#Print output
		space += 5
		if len(data) != 0:
			self.repo.printd("Results for repo: " + self.repo.name)
			self.repo.printd(structureOutput("File Category:", "File Name:", False, False, space))
			self.repo.printd("-" * (space + longestFile))
		else:
			self.repo.printd("No packages found")
		returnData = []
		for datum in data:
			try:
				self.repo.printd(structureOutput(datum[0], datum[1], searchFiles, True, space))
				returnData.append([datum[0], datum[1]])
			except:
				pass
		self.repo.printd(" ")
		
		#Return data
		return returnData
938423
def parse_mapping_file(file):
        
        id_map = {}
        if os.path.exists(os.path.join(os.path.dirname(__file__), file)):
            with open(os.path.join(os.path.dirname(__file__), file)) as tsvfile:
                reader = csv.reader(tsvfile, delimiter="\t")
                for row in reader:
                    key = row[0]
                    value = row[1]
                    id_map[key] = value

        return id_map
21441
def get_json_schema(filename):
    
    file_path = os.path.join("schemas", filename)
    with open(file_path) as f:
        schema = yaml.load(f)
    return schema
1169784
def load_tags
      Hash[@grit_repo.tags.map { |b| [b.name, b.commit.id] }]
    end
1109365
def find_file(self, path, tgt_env):
        '''
        
        '''
        tree = self.get_tree(tgt_env)
        if not tree:
            # Branch/tag/SHA not found in repo
            return None, None, None
        blob = None
        mode = None
        depth = 0
        while True:
            depth += 1
            if depth > SYMLINK_RECURSE_DEPTH:
                blob = None
                break
            try:
                entry = tree[path]
                mode = entry.filemode
                if stat.S_ISLNK(mode):
                    # Path is a symlink. The blob data corresponding to this
                    # path's object ID will be the target of the symlink. Follow
                    # the symlink and set path to the location indicated
                    # in the blob data.
                    link_tgt = self.repo[entry.oid].data
                    path = salt.utils.path.join(
                        os.path.dirname(path), link_tgt, use_posixpath=True)
                else:
                    blob = self.repo[entry.oid]
                    if isinstance(blob, pygit2.Tree):
                        # Path is a directory, not a file.
                        blob = None
                    break
            except KeyError:
                blob = None
                break
        if isinstance(blob, pygit2.Blob):
            return blob, blob.hex, mode
        return None, None, None
732788
def file_path(self, request, response=None, info=None):
        
        return json.dumps(self._extract_key_info(request))