#NEWLINE# @ classmethod #NEWLINE# def from_path( cls , path , extension_required = False ) : #NEWLINE# #INDENT# 'Locates the project for a path.' #NEWLINE# path = os . path . abspath ( path ) #NEWLINE# if ( os . path . isfile ( path ) and ( ( not extension_required ) or path . endswith ( '.lektorproject' ) ) ) : #NEWLINE# #INDENT# return cls . from_file ( path ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# files = [ x for x in os . listdir ( x ) if x . lower ( ) . endswith ( '.lektorproject' ) ] #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# if ( len ( files ) == 1 ) : #NEWLINE# #INDENT# return cls . from_file ( os . path . join ( path , files [ 0 ] ) ) #NEWLINE# #UNINDENT# if ( os . path . isdir ( path ) and os . path . isfile ( os . path . join ( path , 'content/contents.lr' ) ) ) : #NEWLINE# #INDENT# return cls ( name = os . path . basename ( path ) , project_file = None , tree = path )