adding a family_directory condition
That is used as precondition to a few other conditions.
(issue
@@ -149,10 +149,24 @@ def check_all_files_in_a_single_directory(fb, fonts):
@register_condition
@condition
-def descfile(fonts):
+def family_directory(fonts):
+ """Get the path of font project directory."""
+ if len(fonts) == 0:
+ # We're being extra-careful here. But probably
+ # the only situation in which fonts would be an
+ # empty would really indicate bad user input on the
+ # commandline. So perhaps we should detect this earlier.
+ return None
+ else:
+ return os.path.dirname(fonts[0])
+
+
+@register_condition
+@condition
+def descfile(family_directory):
"""Get the path of the DESCRIPTION file of a given font project."""
- family_dir = os.path.dirname(fonts[0])
- descfilepath = os.path.join(family_dir, "DESCRIPTION.en_us.html")
+ if family_directory:
+ descfilepath = os.path.join(family_directory, "DESCRIPTION.en_us.html")
if os.path.exists(descfilepath):
return descfilepath
@@ -264,9 +278,9 @@ def check_DESCRIPTION_min_length(fb, descfile):
@register_condition
@condition
-def metadata(fonts):
- family_dir = os.path.dirname(fonts[0])
- pb_file = os.path.join(family_dir, "METADATA.pb")
+def metadata(family_directory):
+ if family_directory:
+ pb_file = os.path.join(family_directory, "METADATA.pb")
if os.path.exists(pb_file):
return get_FamilyProto_Message(pb_file)
@@ -732,13 +746,13 @@ def check_OS2_achVendID(fb, ttFont, registered_vendor_ids):
@register_condition
@condition
-def licenses(fonts):
+def licenses(family_directory):
"""Get a list of paths for every license
file found in a font project."""
+ if family_directory:
licenses = []
- font_project_path = os.path.dirname(fonts[0])
for license in ['OFL.txt', 'LICENSE.txt']:
- license_path = os.path.join(font_project_path, license)
+ license_path = os.path.join(family_directory, license)
if os.path.exists(license_path):
licenses.append(license_path)
return licenses
