|
16 | 16 | except ImportError:
|
17 | 17 | toolshed = None
|
18 | 18 |
|
19 |
| -from planemo.io import error |
20 |
| -from planemo.io import untar_to |
| 19 | +from planemo.io import ( |
| 20 | + error, |
| 21 | + untar_to, |
| 22 | + can_write_to_path, |
| 23 | +) |
21 | 24 |
|
22 | 25 | SHED_CONFIG_NAME = '.shed.yml'
|
23 | 26 | NO_REPOSITORIES_MESSAGE = ("Could not find any .shed.yml files or a --name to "
|
|
57 | 60 | REPO_TYPE_TOOL_DEP = "tool_dependency_definition"
|
58 | 61 | REPO_TYPE_SUITE = "repository_suite_definition"
|
59 | 62 |
|
| 63 | +# Generate with python scripts/categories.py |
| 64 | +CURRENT_CATEGORIES = [ |
| 65 | + "Assembly", |
| 66 | + "ChIP-seq", |
| 67 | + "Combinatorial Selections", |
| 68 | + "Computational chemistry", |
| 69 | + "Convert Formats", |
| 70 | + "Data Managers", |
| 71 | + "Data Source", |
| 72 | + "Fasta Manipulation", |
| 73 | + "Fastq Manipulation", |
| 74 | + "Genome-Wide Association Study", |
| 75 | + "Genomic Interval Operations", |
| 76 | + "Graphics", |
| 77 | + "Imaging", |
| 78 | + "Metabolomics", |
| 79 | + "Metagenomics", |
| 80 | + "Micro-array Analysis", |
| 81 | + "Next Gen Mappers", |
| 82 | + "Ontology Manipulation", |
| 83 | + "Phylogenetics", |
| 84 | + "Proteomics", |
| 85 | + "RNA", |
| 86 | + "SAM", |
| 87 | + "Sequence Analysis", |
| 88 | + "Statistics", |
| 89 | + "Systems Biology", |
| 90 | + "Text Manipulation", |
| 91 | + "Tool Dependency Packages", |
| 92 | + "Tool Generators", |
| 93 | + "Transcriptomics", |
| 94 | + "Variant Analysis", |
| 95 | + "Visualization", |
| 96 | + "Web Services", |
| 97 | +] |
| 98 | + |
| 99 | + |
| 100 | +def shed_init(ctx, path, **kwds): |
| 101 | + if not os.path.exists(path): |
| 102 | + os.makedirs(path) |
| 103 | + shed_config_path = os.path.join(path, SHED_CONFIG_NAME) |
| 104 | + if not can_write_to_path(shed_config_path, **kwds): |
| 105 | + # .shed.yml exists and no --force sent. |
| 106 | + return 1 |
| 107 | + |
| 108 | + _create_shed_config(ctx, shed_config_path, **kwds) |
| 109 | + return 0 |
| 110 | + |
60 | 111 |
|
61 | 112 | def shed_repo_config(path):
|
62 | 113 | shed_yaml_path = os.path.join(path, SHED_CONFIG_NAME)
|
@@ -290,6 +341,34 @@ def realize_effective_repositories(path, **kwds):
|
290 | 341 | shutil.rmtree(temp_directory)
|
291 | 342 |
|
292 | 343 |
|
| 344 | +def _create_shed_config(ctx, path, **kwds): |
| 345 | + name = kwds.get("name", None) or path_to_repo_name(os.path.dirname(path)) |
| 346 | + owner = kwds.get("owner", None) |
| 347 | + if owner is None: |
| 348 | + owner = ctx.global_config.get("shed_username", None) |
| 349 | + description = kwds.get("description", None) or name |
| 350 | + long_description = kwds.get("long_description", None) |
| 351 | + remote_repository_url = kwds.get("remote_repository_url", None) |
| 352 | + homepage_url = kwds.get("homepage_url", None) |
| 353 | + categories = kwds.get("category", []) |
| 354 | + config = dict( |
| 355 | + name=name, |
| 356 | + owner=owner, |
| 357 | + description=description, |
| 358 | + long_description=long_description, |
| 359 | + remote_repository_url=remote_repository_url, |
| 360 | + homepage_url=homepage_url, |
| 361 | + categories=categories, |
| 362 | + ) |
| 363 | + # Remove empty entries... |
| 364 | + for k in list(config.keys()): |
| 365 | + if config[k] is None: |
| 366 | + del config[k] |
| 367 | + |
| 368 | + with open(path, "w") as f: |
| 369 | + yaml.dump(config, f) |
| 370 | + |
| 371 | + |
293 | 372 | def _find_raw_repositories(path, **kwds):
|
294 | 373 | name = kwds.get("name", None)
|
295 | 374 | recursive = kwds.get("recursive", False)
|
|
0 commit comments