Skip to content

Commit

Permalink
Add filtering of Enhancement Chip ROMs, other enhancements
Browse files Browse the repository at this point in the history
Also makes --no-all not include --no-unlicensed
Enhance help message
Include summary of filtering done in verbose mode
  • Loading branch information
andrebrait committed Feb 19, 2020
1 parent 402ef60 commit 5e79326
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 64 deletions.
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,42 @@ For a comprehensive guide on how to use this tool, check out the [wiki page](htt
```
Usage: python3 generate.py [options] -d input_file.dat
Options:
-h,--help Prints this usage message
# ROM selection and file manipulation:
-r,--regions=REGIONS A list of regions separated by commas. Ex.: -r USA,EUR,JPN
-l,--languages=LANGS An optional list of languages separated by commas. Ex.: -l en,es,ru
-d,--dat=DAT_FILE The DAT file to be used
-i,--input-dir=PATH Provides an input directory (i.e.: where your ROMs are)
-e,--extension=EXT ROM names will use this extension. Ex.: -e zip
-o,--output-dir=PATH If provided, ROMs will be copied to an output directory
--move If set, ROMs will be moved, instead of copied, to the output directory
# Filtering:
--no-bios Filter out BIOSes
--no-program Filter out Programs and Test Programs
--no-enhancement-chip Filter out Ehancement Chips
--no-proto Filter out prototype ROMs
--no-unlicensed Filter out unlicensed ROMs
--no-beta Filter out beta ROMs
--no-demo Filter out demo ROMs
--no-sample Filter out sample ROMs
--no-all Apply all filters above
--no-all Apply all filters above (WILL STILL ALLOW UNLICENSED ROMs)
--no-unlicensed Filter out unlicensed ROMs
--all-regions Includes files of unselected regions, if a selected one if not available
--all-regions-with-lang Same as --all-regions, but only if a ROM has at least one selected language
# Adjustment and customization:
-w,--language-weight=N The degree of priority the first selected languages receive over the latter ones. Default: 3
--prioritize-languages If set, ROMs matching more languages will be prioritized over ROMs matching regions
--early-revisions ROMs of earlier revisions will be prioritized
--early-versions ROMs of earlier versions will be prioritized
--input-order ROMs will be prioritized by the order they appear in the DAT file
--prefer-parents Parent ROMs will be prioritized over clones
--prefer-prereleases Prerelease (Beta, Proto, etc.) ROMs will be prioritized
-b,--blacklist=WORDS ROMs containing these words will be avoided. Ex.: -b "Virtual Console,GameCube"
-b,--blacklist=WORDS ROMs containing these words will be avoided (but not excluded). Ex.: -b "Virtual Console,GameCube"
--ignore-case If set, the blacklist will be case-insensitive
-i,--input-dir=PATH Provides an input directory (i.e.: where your ROMs are)
-e,--extension=EXT ROM names will use this extension. Ex.: -e zip
-o,--output-dir=PATH If provided, ROMs will be copied to an output directory
--move If set, ROMs will be moved, intead of copied, to the output directory
# Help and debugging:
-h,--help Prints this usage message
-v,--verbose Prints more messages (useful when troubleshooting)
--debug Prints even more messages (useful when troubleshooting)
```
Expand Down
147 changes: 91 additions & 56 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def set_proto(self, proto: str) -> None:
sections_regex = re.compile(r'\(([^()]+)\)')
bios_regex = re.compile(re.escape('[BIOS]'), re.IGNORECASE)
program_regex = re.compile(r'\((?:Test\s*)?Program\)', re.IGNORECASE)
enhancement_chip_regex = re.compile(r'\(Enhancement\s*Chip\)', re.IGNORECASE)
unl_regex = re.compile(re.escape('(Unl)'), re.IGNORECASE)
beta_regex = re.compile(r'\(Beta(?:\s*([a-z0-9.]+))?\)', re.IGNORECASE)
proto_regex = re.compile(r'\(Proto(?:\s*([a-z0-9.]+))?\)', re.IGNORECASE)
Expand Down Expand Up @@ -240,6 +241,7 @@ def parse_games(
file: str,
filter_bios: bool,
filter_program: bool,
filter_enhancement_chip: bool,
filter_unlicensed: bool,
filter_proto: bool,
filter_beta: bool,
Expand All @@ -259,6 +261,8 @@ def parse_games(
continue
if filter_program and program_regex.search(game.name):
continue
if filter_enhancement_chip and enhancement_chip_regex.search(game.name):
continue
if filter_beta and beta_match:
continue
if filter_demo and demo_match:
Expand Down Expand Up @@ -360,12 +364,13 @@ def main(argv: List[str]):
'regions=',
'no-bios',
'no-program',
'no-unlicensed',
'no-enhancement-chip',
'no-beta',
'no-demo',
'no-sample',
'no-proto',
'no-all',
'no-unlicensed',
'all-regions',
'early-revisions',
'early-versions',
Expand Down Expand Up @@ -393,6 +398,7 @@ def main(argv: List[str]):
dat_file = ""
filter_bios = False
filter_program = False
filter_enhancement_chip = False
filter_unlicensed = False
filter_proto = False
filter_beta = False
Expand Down Expand Up @@ -441,13 +447,14 @@ def main(argv: List[str]):
print_help()
sys.exit(2)
prioritize_languages |= opt == '--prioritize-languages'
filter_bios |= opt == '--no-bios' or opt == '--no-all'
filter_program |= opt == '--no-program' or opt == '--no-all'
filter_unlicensed |= opt == '--no-unlicensed' or opt == '--no-all'
filter_proto |= opt == '--no-proto' or opt == '--no-all'
filter_beta |= opt == '--no-beta' or opt == '--no-all'
filter_demo |= opt == '--no-demo' or opt == '--no-all'
filter_sample |= opt == '--no-sample' or opt == '--no-all'
filter_bios |= opt in ('--no-bios', '--no-all')
filter_program |= opt in ('--no-program', '--no-all')
filter_enhancement_chip |= opt in ('--no-enhancement-chip', '--no-all')
filter_proto |= opt in ('--no-proto', '--no-all')
filter_beta |= opt in ('--no-beta', '--no-all')
filter_demo |= opt in ('--no-demo', '--no-all')
filter_sample |= opt in ('--no-sample', '--no-all')
filter_unlicensed |= opt == '--no-unlicensed'
all_regions |= opt == '--all-regions'
all_regions_with_lang |= opt == '--all-regions-with-lang'
revision_asc |= opt == '--early-revisions'
Expand Down Expand Up @@ -541,6 +548,7 @@ def main(argv: List[str]):
dat_file,
filter_bios,
filter_program,
filter_enhancement_chip,
filter_unlicensed,
filter_proto,
filter_beta,
Expand All @@ -552,30 +560,48 @@ def main(argv: List[str]):
lang_text = 'Best language match'
parents_text = 'Parent ROMs'
index_text = 'Input order'
print('Sorting with the following criteria:\n'
'\t1. Good dumps\n'
'\t2. %s\n'
'\t3. Non-blacklisted items\n'
'\t4. %s\n'
'\t5. %s\n'
'\t6. %s\n'
'\t7. %s\n'
'\t8. %s revision\n'
'\t9. %s version\n'
'\t10. Latest sample\n'
'\t11. Latest demo\n'
'\t12. Latest beta\n'
'\t13. Latest prototype\n'
'\t14. Most languages supported\n'
'\t15. Parent ROMs' %
('Prelease ROMs' if prefer_prereleases else 'Released ROMs',
lang_text if prioritize_languages else region_text,
region_text if prioritize_languages else lang_text,
parents_text if prefer_parents else parents_text + ' (Ignored)',
index_text if input_order else index_text + ' (Ignored)',
'Earliest' if revision_asc else 'Latest',
'Earliest' if version_asc else 'Latest'),
file=sys.stderr)
filters = [
(filter_bios, 'BIOSes'),
(filter_program, 'Programs'),
(filter_enhancement_chip, 'Enhancement Chips'),
(filter_proto, 'Prototypes'),
(filter_beta, 'Betas'),
(filter_demo, 'Demos'),
(filter_sample, 'Samples'),
(filter_unlicensed, 'Unlicensed ROMs')
]
enabled_filters = ['\t%d. %s\n' % (i + 1, filters[i][1])
for i in range(0, len(filters)) if filters[i][0]]
if enabled_filters:
print(
'Filtering out:\n'
+ "".join(enabled_filters),
file=sys.stderr)
print(
'Sorting with the following criteria:\n'
'\t1. Good dumps\n'
'\t2. %s\n'
'\t3. Non-blacklisted items\n'
'\t4. %s\n'
'\t5. %s\n'
'\t6. %s\n'
'\t7. %s\n'
'\t8. %s revision\n'
'\t9. %s version\n'
'\t10. Latest sample\n'
'\t11. Latest demo\n'
'\t12. Latest beta\n'
'\t13. Latest prototype\n'
'\t14. Most languages supported\n'
'\t15. Parent ROMs\n' %
('Prelease ROMs' if prefer_prereleases else 'Released ROMs',
lang_text if prioritize_languages else region_text,
region_text if prioritize_languages else lang_text,
parents_text if prefer_parents else parents_text + ' (Ignored)',
index_text if input_order else index_text + ' (Ignored)',
'Earliest' if revision_asc else 'Latest',
'Earliest' if version_asc else 'Latest'),
file=sys.stderr)

for key in parsed_games:
games = parsed_games[key]
Expand Down Expand Up @@ -703,10 +729,7 @@ def print_help():
'Usage: python3 %s [options] -d input_file.dat' % sys.argv[0],
file=sys.stderr)
print('Options:', file=sys.stderr)
print(
'\t-h,--help\t\t'
'Prints this usage message',
file=sys.stderr)
print('\n# ROM selection and file manipulation:', file=sys.stderr)
print(
'\t-r,--regions=REGIONS\t'
'A list of regions separated by commas. Ex.: -r USA,EUR,JPN',
Expand All @@ -719,6 +742,24 @@ def print_help():
'\t-d,--dat=DAT_FILE\t'
'The DAT file to be used',
file=sys.stderr)
print(
'\t-i,--input-dir=PATH\t'
'Provides an input directory (i.e.: where your ROMs are)',
file=sys.stderr)
print(
'\t-e,--extension=EXT\t'
'ROM names will use this extension. Ex.: -e zip',
file=sys.stderr)
print(
'\t-o,--output-dir=PATH\t'
'If provided, ROMs will be copied to an output directory',
file=sys.stderr)
print(
'\t--move\t\t\t'
'If set, ROMs will be moved, instead of copied, '
'to the output directory',
file=sys.stderr)
print('\n# Filtering:', file=sys.stderr)
print(
'\t--no-bios\t\t'
'Filter out BIOSes',
Expand All @@ -728,12 +769,12 @@ def print_help():
'Filter out Programs and Test Programs',
file=sys.stderr)
print(
'\t--no-proto\t\t'
'Filter out prototype ROMs',
'\t--no-enhancement-chip\t'
'Filter out Ehancement Chips',
file=sys.stderr)
print(
'\t--no-unlicensed\t\t'
'Filter out unlicensed ROMs',
'\t--no-proto\t\t'
'Filter out prototype ROMs',
file=sys.stderr)
print(
'\t--no-beta\t\t'
Expand All @@ -749,7 +790,11 @@ def print_help():
file=sys.stderr)
print(
'\t--no-all\t\t'
'Apply all filters above',
'Apply all filters above (WILL STILL ALLOW UNLICENSED ROMs)',
file=sys.stderr)
print(
'\t--no-unlicensed\t\t'
'Filter out unlicensed ROMs',
file=sys.stderr)
print(
'\t--all-regions\t\t'
Expand All @@ -761,6 +806,7 @@ def print_help():
'Same as --all-regions, but only if a ROM has at least one selected '
'language',
file=sys.stderr)
print('\n# Adjustment and customization:', file=sys.stderr)
print(
'\t-w,--language-weight=N\t'
'The degree of priority the first selected languages receive over the '
Expand Down Expand Up @@ -794,28 +840,17 @@ def print_help():
file=sys.stderr)
print(
'\t-b,--blacklist=WORDS\t'
'ROMs containing these words will be avoided. '
'ROMs containing these words will be avoided (but not excluded). '
'Ex.: -b "Virtual Console,GameCube"',
file=sys.stderr)
print(
'\t--ignore-case\t\t'
'If set, the blacklist will be case-insensitive ',
file=sys.stderr)
print('\n# Help and debugging:', file=sys.stderr)
print(
'\t-i,--input-dir=PATH\t'
'Provides an input directory (i.e.: where your ROMs are)',
file=sys.stderr)
print(
'\t-e,--extension=EXT\t'
'ROM names will use this extension. Ex.: -e zip',
file=sys.stderr)
print(
'\t-o,--output-dir=PATH\t'
'If provided, ROMs will be copied to an output directory',
file=sys.stderr)
print(
'\t--move\t\t\t'
'If set, ROMs will be moved, intead of copied, to the output directory',
'\t-h,--help\t\t'
'Prints this usage message',
file=sys.stderr)
print(
'\t-v,--verbose\t\t'
Expand Down

0 comments on commit 5e79326

Please sign in to comment.