|
3 | 3 | import json
|
4 | 4 | import tarfile
|
5 | 5 | import warnings
|
| 6 | +from pathlib import Path |
6 | 7 | from typing import Any, Generator, Tuple
|
7 | 8 |
|
8 | 9 | from ruamel import yaml
|
@@ -114,27 +115,32 @@ def info_json_from_tar_generator(
|
114 | 115 | # e.g. linux-64/clangxx_osx-64-16.0.6-h027b494_6.conda
|
115 | 116 | YAML.allow_duplicate_keys = True
|
116 | 117 | for tar, member in tar_tuples:
|
117 |
| - if member.name.endswith("index.json"): |
| 118 | + path = Path(member.name) |
| 119 | + if len(path.parts) > 1 and path.parts[0] == "info": |
| 120 | + path = Path(*path.parts[1:]) |
| 121 | + if path.parts and path.parts[0] in ("test", "licenses"): |
| 122 | + continue |
| 123 | + if path.name == "index.json": |
118 | 124 | index = json.loads(_extract_read(tar, member, default="{}"))
|
119 | 125 | data["name"] = index.get("name", "")
|
120 | 126 | data["version"] = index.get("version", "")
|
121 | 127 | data["index"] = index
|
122 |
| - elif member.name.endswith("about.json"): |
| 128 | + elif path.name == "about.json": |
123 | 129 | data["about"] = json.loads(_extract_read(tar, member, default="{}"))
|
124 |
| - elif member.name.endswith("conda_build_config.yaml"): |
| 130 | + elif path.name == "conda_build_config.yaml": |
125 | 131 | data["conda_build_config"] = YAML.load(
|
126 | 132 | _extract_read(tar, member, default="{}")
|
127 | 133 | )
|
128 |
| - elif member.name.endswith("files"): |
| 134 | + elif path.name == "files": |
129 | 135 | files = _extract_read(tar, member, default="").splitlines()
|
130 | 136 | if skip_files_suffixes:
|
131 | 137 | files = [
|
132 | 138 | f for f in files if not f.lower().endswith(skip_files_suffixes)
|
133 | 139 | ]
|
134 | 140 | data["files"] = files
|
135 |
| - elif member.name.endswith("meta.yaml.template"): |
| 141 | + elif path.name == "meta.yaml.template": |
136 | 142 | data["raw_recipe"] = _extract_read(tar, member, default="")
|
137 |
| - elif member.name.endswith("meta.yaml"): |
| 143 | + elif path.name == "meta.yaml": |
138 | 144 | x = _extract_read(tar, member, default="{}")
|
139 | 145 | if ("{{" in x or "{%" in x) and not data["raw_recipe"]:
|
140 | 146 | data["raw_recipe"] = x
|
|
0 commit comments