Пример #1
0
	def get_templates(self, dir):
		'''
		templates 				= object that contains the file, filename, folder instances
		templates.files 			= file instance
		templates.filenames 		= filename instance
		templates.folder 			= folder instance
		'''
		templates = EasyDict()
		templates_files = []
		templates_filenames = []
		templates_folders = []
		templates_folderfiles = []
		templates_transferNames = []

		for root, dirs, filenames in os.walk(dir):
			for filename in filenames:
				if self.is_template(filename):
					path = os.path.join(root, filename)
					folderfile = path[(len(dir)+1):len(path)]
					transferNames = folderfile.replace("/", "_").replace("_", "-")

					templates_files.append(path)
					templates_filenames.append(filename)
					templates_folderfiles.append(folderfile)
					templates_transferNames.append(transferNames)

		templates.files = templates_files
		templates.filenames = templates_filenames
		templates.folderfiles = templates_folderfiles
		templates.transferNames = templates_transferNames
		
		return templates
Пример #2
0
	def get_templates(self, dir):
		'''
		templates 				= object that contains the file, filename, folder instances
		templates.files 			= file instance
		templates.filenames 		= filename instance
		templates.folder 			= folder instance
		'''
		templates = EasyDict()
		templates_files = []
		templates_filenames = []
		templates_folders = []
		templates_basepaths = []
		templates_transfer_filename_underscores = []
		templates_transfer_filename_dashes = []

		for root, dirs, filenames in os.walk(dir):
			for filename in filenames:
				if root == self.THEME_DIR:
					folder = "root"
				else:
					folder = os.path.basename(root).replace("/", "-")
				path = os.path.join(root, filename)
				basepath = path[(len(dir)+1):len(path)]
				transfer_filename_underscore = basepath.replace("/", "_")
				transfer_filename_dash = transfer_filename_underscore.replace("_", "-")

				if self.is_template(filename):
					templates_files.append(path)
					templates_filenames.append(filename)
					templates_folders.append(folder)
					templates_basepaths.append(basepath)
					templates_transfer_filename_underscores.append(transfer_filename_underscore)
					templates_transfer_filename_dashes.append(transfer_filename_dash)

		templates.files = templates_files
		templates.folders = templates_folders
		templates.basepaths = templates_basepaths

		templates.filenames = templates_filenames
		templates.transferNamesUS = templates_transfer_filename_underscores
		templates.transferNames = templates_transfer_filename_dashes
		
		return templates
Пример #3
0
    def get_templates(self, dir):
        """
		templates 				= object that contains the file, filename, folder instances
		templates.files 			= file instance
		templates.filenames 		= filename instance
		templates.folder 			= folder instance
		"""
        templates = EasyDict()
        templates_files = []
        templates_filenames = []
        templates_folders = []
        templates_folderfiles = []
        templates_transferNames = []

        for root, dirs, filenames in os.walk(dir):
            for filename in filenames:
                if self.is_template(filename):
                    # if root == dir:
                    # 	folder = "root"
                    # else:
                    # 	folder = os.path.basename(root).replace("/", "_").replace("_", "-")

                    # print "%s -------------- root = %s ------------ DIR = %s -------- Folder = %s" % (filename, root, dir, folder)
                    path = os.path.join(root, filename)
                    folderfile = path[(len(dir) + 1) : len(path)]
                    transferNames = folderfile.replace("/", "_").replace("_", "-")

                    templates_files.append(path)
                    templates_filenames.append(filename)
                    # templates_folders.append(folder)
                    templates_folderfiles.append(folderfile)
                    templates_transferNames.append(transferNames)

        templates.files = templates_files
        templates.filenames = templates_filenames
        # templates.folders = templates_folders
        templates.folderfiles = templates_folderfiles
        templates.transferNames = templates_transferNames

        return templates
Пример #4
0
	def get_templates(self, dir):
		'''
		templates 				= object that contains the file, filename, folder instances
		templates.files 			= file instance
		templates.filenames 		= filename instance
		templates.folder 		= folder instance
		'''
		templates = EasyDict()
		templates_files = []
		templates_filenames = []
		templates_folders = []
		templates_basepaths = []
		templates_transfer_filename_underscores = []
		templates_transfer_filename_dashes = []

		for root, dirs, filenames in os.walk(dir):
			for filename in filenames:
				folder = os.path.basename(root)
				path = os.path.join(root, filename)
				basepath = path[(len(dir)+1):len(path)]
				transfer_filename_underscore = basepath.replace("/", "_")
				transfer_filename_dash = transfer_filename_underscore.replace("_", "-")

				if filename.lower().endswith('.html'):
					templates_files.append(path)
					templates_filenames.append(filename)
					templates_folders.append(folder)
					templates_basepaths.append(basepath)
					templates_transfer_filename_underscores.append(transfer_filename_underscore)
					templates_transfer_filename_dashes.append(transfer_filename_dash)

		templates.files = templates_files
		templates.filenames = templates_filenames
		templates.folders = templates_folders
		templates.basepaths = templates_basepaths
		templates.transferNameUnderscores = templates_transfer_filename_underscores
		templates.transferName = templates_transfer_filename_dashes
		
		return templates