MCPcopy
hub / github.com/lektor/lektor / from_path

Method from_path

lektor/project.py:57–83  ·  view source on GitHub ↗

Locates the project for a path.

(cls, path, extension_required=False)

Source from the content-addressed store, hash-verified

55
56 @classmethod
57 def from_path(cls, path, extension_required=False):
58 """Locates the project for a path."""
59 path = os.path.abspath(path)
60 if os.path.isfile(path) and (
61 not extension_required or path.endswith(".lektorproject")
62 ):
63 return cls.from_file(path)
64
65 try:
66 files = [
67 x for x in os.listdir(path) if x.lower().endswith(".lektorproject")
68 ]
69 except OSError:
70 return None
71
72 if len(files) == 1:
73 return cls.from_file(os.path.join(path, files[0]))
74
75 if os.path.isdir(path) and os.path.isfile(
76 os.path.join(path, "content/contents.lr")
77 ):
78 return cls(
79 name=os.path.basename(path),
80 project_file=None,
81 tree=path,
82 )
83 return None
84
85 @classmethod
86 def discover(cls, base=None):

Callers 10

discoverMethod · 0.80
get_projectMethod · 0.80
no_alt_padFunction · 0.80
pntest_projectFunction · 0.80
theme_projectFunction · 0.80
projectFunction · 0.80
scratch_projectFunction · 0.80
get_unicode_builderFunction · 0.80

Calls 2

endswithMethod · 0.80
from_fileMethod · 0.80

Tested by 8

no_alt_padFunction · 0.64
pntest_projectFunction · 0.64
theme_projectFunction · 0.64
projectFunction · 0.64
scratch_projectFunction · 0.64
get_unicode_builderFunction · 0.64