Skip to content

Allow for comment lines starting with '#' in databases#987

Open
SpiralBrad wants to merge 1 commit intofrederic-mahe:masterfrom
SpiralBrad:allow-database-comments
Open

Allow for comment lines starting with '#' in databases#987
SpiralBrad wants to merge 1 commit intofrederic-mahe:masterfrom
SpiralBrad:allow-database-comments

Conversation

@SpiralBrad
Copy link
Contributor

This patch allows database files to have comment lines starting with '#'.

Useful for dates, descriptions, data source info...

Copy link
Owner

@frederic-mahe frederic-mahe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @SpiralBrad that's a good idea! Could you please make the following changes?

1 - Isolate the conditional branch to limit the indentation level inside the loop, like in function extract_file().

for line in target_database:
    # skip comments
    if line.startswith("#"):
        continue
    hash_sha256, filename, _, _, hash_crc = line.strip().split("\t")[0:5]
    ...

2 - (optional) Store the comment character '#' in a variable at the beginning of the function. Maybe comment_prefix = '#'? (naming is hard)

@hotelvictorcharlie
Copy link
Contributor

Whenever you update an SMDB file by running parse_pack (e.g. to create a commit/PR), all of the comments from the old file will get deleted. Is that what you want?

@SpiralBrad
Copy link
Contributor Author

Whenever you update an SMDB file by running parse_pack (e.g. to create a commit/PR), all of the comments from the old file will get deleted. Is that what you want?

Nope! Hadn't thought that far ahead - good point.

Hold off on this PR thusly :)

@Drakonas
Copy link
Contributor

Drakonas commented Jan 10, 2025

Why not inline comments instead? Might be easier to handle in parsing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants