Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup Fonts doesn't back up all fonts #111

Closed
alichtman opened this issue Oct 19, 2018 · 7 comments
Closed

Backup Fonts doesn't back up all fonts #111

alichtman opened this issue Oct 19, 2018 · 7 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@alichtman
Copy link
Owner

alichtman commented Oct 19, 2018

def backup_fonts(path):
	"""
	Creates list of all .ttf and .otf files in ~/Library/Fonts/
	"""
	print_section_header("FONTS", Fore.BLUE)
	make_dir_warn_overwrite(path)
	print(Fore.BLUE + "Copying '.otf' and '.ttf' fonts..." + Style.RESET_ALL)
	fonts_path = _home_prefix("/Library/Fonts/")
	# TODO: For some reason, this doesn't get all the fonts in fonts_path dir
	fonts = [os.path.join(fonts_path, font) for font in os.listdir(fonts_path) if font.endswith(".otf") or font.endswith(".ttf")]

	# pprint(fonts)
	for font in fonts:
		# print(font, " TO ", os.path.join(path, font.split("/")[-1]))
		if os.path.exists(font):
			copyfile(font, os.path.join(path, font.split("/")[-1]))

One solution could be to use copytree and then remove all files that don't end in .ttf or .otf

@alichtman alichtman added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers Hacktoberfest labels Oct 19, 2018
@alichtman alichtman added this to the v1.4 milestone Oct 19, 2018
@giancarloGiuffra
Copy link
Contributor

Hi, I would like to work on this.

@alichtman
Copy link
Owner Author

@giancarloGiuffra, best of luck. Let me know if you have any questions.

@giancarloGiuffra
Copy link
Contributor

giancarloGiuffra commented Oct 19, 2018

@alichtman hi again. I have setup my environment and run a backup of the fonts. It got them all actually. Do you have any tips on how to reproduce the bug?

@alichtman
Copy link
Owner Author

If you run ls ~/Library/Fonts/ and compare that with what's actually backed up, the lists are different.

@giancarloGiuffra
Copy link
Contributor

giancarloGiuffra commented Oct 19, 2018

I see, I actually compared the backup with the fonts in /Library/Fonts and they were exactly the same. So the function is reading from that directory most probably. I will check what the _home_prefix function is doing.

@alichtman
Copy link
Owner Author

The function is definitely reading from the right directory, since some fonts are copied correctly.

However, the issue is that not all fonts are copied correctly, and I'm not sure why. The issue is almost definitely not with the _home_prefix() function.

@giancarloGiuffra
Copy link
Contributor

giancarloGiuffra commented Oct 19, 2018

I left a comment on the PR. The problem was that the path was absolute and how os.path.join behaves in such a case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants