Move music transfer main code into main() function

This is both good practice, and also useful for some soon-to-be-added
test cases for the script.
master
Jordan Atwood 9 months ago
parent 4619c677ab
commit 8c2f67f31f
Signed by: nightfirecat
GPG Key ID: 615A619C2D73A6DF
  1. 4
      src/.bin/music-transfer.py

@ -32,6 +32,7 @@ KNOWN_EXTENSIONS: Set[str] = set([
def munge_path(path: str) -> str: def munge_path(path: str) -> str:
return re.sub(r'[\:*?"|<>]+', '-', path) return re.sub(r'[\:*?"|<>]+', '-', path)
def main():
if len(sys.argv) != 3: if len(sys.argv) != 3:
print(f'Usage: {os.path.basename(__file__)} PATHS-FILE DESTINATION-DIR', file=sys.stderr) print(f'Usage: {os.path.basename(__file__)} PATHS-FILE DESTINATION-DIR', file=sys.stderr)
sys.exit(1) sys.exit(1)
@ -156,3 +157,6 @@ for source_file in source_files:
# TODO: improve this output (number of deleted files, number of new files, correct plural of 'files') # TODO: improve this output (number of deleted files, number of new files, correct plural of 'files')
print(f'Finished copying {len(source_files)} new files to {destination_dir}') print(f'Finished copying {len(source_files)} new files to {destination_dir}')
if __name__ == '__main__':
main()

Loading…
Cancel
Save