def list_url(pyconfig): message = \ """ USAGE: pycomic.py list-url COMICNAME [PATTERN] """ try: comic_name = sys.argv[2] except IndexError: print(message) sys.exit(1) try: pattern = sys.argv[3] except IndexError: pattern = '' # Check directory structure pylib.check_structure(pyconfig, SECTION) # Find comic from menu csv eng_name, ch_name, number, _status = _check_comic_existence( pyconfig, comic_name) # Define comic object comic = pylib.Comic(eng_name, ch_name, number) comic.file_path(pyconfig.links(SECTION), 'links-dir') # Show matching data _print_files(pylib.list_files(comic.path['links-dir'], pattern))
def list_url(pyconfig): _message = \ """ USAGE: pycomic.py list-url [PATTERN] """ try: pattern = sys.argv[2] except IndexError: pattern = '' # Chekc config file integrity try: pyconfig.config_test(SECTION, output=False) except pycomic_err.NoSectionError: sys.exit(102) except pycomic_err.NoOptionError: sys.exit(103) # Check directory structure pylib.check_structure(pyconfig, SECTION) _check(pyconfig, SECTION) # Show all matching data _print_files(pylib.list_files(pyconfig.refine(SECTION), pattern))
def list_books(pyconfig): message = \ """ USAGE: pycomic.py list-books origin|format COMICNAME [PATTERN] """ _ORIGIN = 'origin' _FORMAT = 'format' source_type = '' try: source_type = sys.argv[2] comic_name = sys.argv[3] except IndexError: print(message) sys.exit(1) try: pattern = sys.argv[4] except IndexError: pattern = '' # Check directory structure pylib.check_structure(pyconfig, SECTION) # Find comic from menu csv eng_name, ch_name, number, _status = _check_comic_existence( pyconfig, comic_name) # Define comic object comic = pylib.Comic(eng_name, ch_name, number) comic.file_path(pyconfig.origin(SECTION), 'origin') comic.file_path(pyconfig.formatted(SECTION), 'format') # Show matching data list if source_type == _ORIGIN: _print_files(pylib.list_files(comic.path['origin'], pattern)) elif source_type == _FORMAT: _print_files(pylib.list_files(comic.path['format'], pattern)) else: print(message) sys.exit(1)
def list_books(pyconfig): message = \ """ USAGE: pycomic.py list-books origin|format [PATTERN] """ _ORIGIN = 'origin' _FORMAT = 'format' source_type = '' try: source_type = sys.argv[2] pattern = sys.argv[3] except IndexError: pattern = '' # Chekc config file integrity try: pyconfig.config_test(SECTION, output=False) except pycomic_err.NoSectionError: sys.exit(102) except pycomic_err.NoOptionError: sys.exit(103) # Check directory structure pylib.check_structure(pyconfig, SECTION) _check(pyconfig, SECTION) # Show all matching csv_data # pylib.list_files(pyconfig.images(SECTION), pattern) if source_type == _ORIGIN: _print_files(pylib.list_files(pyconfig.origin(SECTION), pattern)) # pylib.list_files(pyconfig.origin(SECTION), pattern) elif source_type == _FORMAT: _print_files(pylib.list_files(pyconfig.formatted(SECTION), pattern)) # pylib.list_files(pyconfig.format(SECTION), pattern) else: print(message) sys.exit(1)