Skip to content

Commit

Permalink
Add count commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Jul 11, 2024
1 parent e03a01e commit a94efe6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
42 changes: 42 additions & 0 deletions isimip_publisher/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,48 @@ def match_public_links():
print(file.path)


def count_remote():
remote_files = files.list_files(settings.REMOTE_PATH, settings.PATH,
remote_dest=settings.REMOTE_DEST, suffix=settings.PATTERN['suffix'])
datasets = patterns.match_datasets(settings.PATTERN, settings.REMOTE_PATH, remote_files,
include=settings.INCLUDE, exclude=settings.EXCLUDE)
validation.validate_datasets(settings.SCHEMA, settings.PATH, datasets)
print(len([file for dataset in datasets for file in dataset.files]))


def count_remote_links():
remote_links = files.list_links(settings.REMOTE_PATH, settings.PATH,
remote_dest=settings.REMOTE_DEST, suffix=settings.PATTERN['suffix'])
datasets = patterns.match_datasets(settings.PATTERN, settings.REMOTE_PATH, remote_links,
include=settings.INCLUDE, exclude=settings.EXCLUDE)
validation.validate_datasets(settings.SCHEMA, settings.PATH, datasets)
print(len([file for dataset in datasets for file in dataset.files]))


def count_local():
local_files = files.list_files(settings.LOCAL_PATH, settings.PATH)
datasets = patterns.match_datasets(settings.PATTERN, settings.LOCAL_PATH, local_files,
include=settings.INCLUDE, exclude=settings.EXCLUDE)
validation.validate_datasets(settings.SCHEMA, settings.PATH, datasets)
print(len([file for dataset in datasets for file in dataset.files]))


def count_public():
public_files = files.list_files(settings.PUBLIC_PATH, settings.PATH)
datasets = patterns.match_datasets(settings.PATTERN, settings.PUBLIC_PATH, public_files,
include=settings.INCLUDE, exclude=settings.EXCLUDE)
validation.validate_datasets(settings.SCHEMA, settings.PATH, datasets)
print(len([file for dataset in datasets for file in dataset.files]))


def count_public_links():
public_links = files.list_links(settings.PUBLIC_PATH, settings.PATH)
datasets = patterns.match_datasets(settings.PATTERN, settings.PUBLIC_PATH, public_links,
include=settings.INCLUDE, exclude=settings.EXCLUDE)
validation.validate_datasets(settings.SCHEMA, settings.PATH, datasets)
print(len([file for dataset in datasets for file in dataset.files]))


def fetch_files():
remote_files = files.list_files(settings.REMOTE_PATH, settings.PATH,
remote_dest=settings.REMOTE_DEST, suffix=settings.PATTERN['suffix'])
Expand Down
6 changes: 6 additions & 0 deletions isimip_publisher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
check,
check_doi,
clean,
count_local,
count_public,
count_public_links,
count_remote,
count_remote_links,
diff_remote,
diff_remote_links,
fetch_files,
Expand Down Expand Up @@ -99,6 +104,7 @@ def get_parser(add_path=False, add_subparsers=False):
# add a subparser for each subcommand
for func in [list_remote, list_remote_links, list_local, list_public, list_public_links,
match_remote, match_remote_links, match_local, match_public, match_public_links,
count_remote, count_remote_links, count_local, count_public, count_public_links,
fetch_files, write_local_jsons, write_public_jsons,
insert_datasets, update_datasets, publish_datasets, archive_datasets,
diff_remote, diff_remote_links, check, clean, update_search, update_tree, run]:
Expand Down

0 comments on commit a94efe6

Please sign in to comment.