MCPcopy Create free account
hub / github.com/PageBot/PageBot / elementFromPath

Function elementFromPath

Lib/pagebot/elements/__init__.py:75–94  ·  view source on GitHub ↗

Answer the element that is best suitable to hold the data in the path.

(path, context=None, name=None, **kwargs)

Source from the content-addressed store, hash-verified

73from pagebot.elements.variablefonts.specimen import TypeList, TypeFeatures, TypeGlyphSet, Waterfall
74
75def elementFromPath(path, context=None, name=None, **kwargs):
76 """Answer the element that is best suitable to hold the data in the path.
77 """
78 extension = path2Extension(path).lower()
79
80 if extension in IMAGE_TYPES:
81 e = newImage(path, context=context, name=name, **kwargs)
82 elif extension in TEXT_TYPES:
83 e = newText(path, context=context, name=name, **kwargs)
84 elif extension in FONT_TYPES:
85 # TODO: Answer a default specimen element to show the font.
86 e = None
87 elif extension in MOVIE_TYPES:
88 # TODO: Answer a MovieElement instance (to be developed)
89 e = None
90 else:
91 # If no extension-->element can be found.
92 e = None
93
94 return e
95
96# S H O R T C U T S F O R C H I L D E L E M E N T G E N E R A T O R S
97

Callers 1

findMethod · 0.90

Calls 3

path2ExtensionFunction · 0.90
newImageFunction · 0.85
newTextFunction · 0.85

Tested by

no test coverage detected