Skip to content

Instantly share code, notes, and snippets.

@draganmarjanovic
Last active February 16, 2016 21:15
Show Gist options
  • Save draganmarjanovic/0bef6c298da767bf38b1 to your computer and use it in GitHub Desktop.
Save draganmarjanovic/0bef6c298da767bf38b1 to your computer and use it in GitHub Desktop.
The script scans the current directory for polymer elements and then automatically generates a master import file - to save the user time.
# README
# How to use:
# This script creates a file called 'element-import.html' which is filled with
# the polymer import statements automatically from the folders in the directory
# from which this script is run.
# Import OS to allow reading of directories
import os
# Gets list of folders within the current directory
list_of_files = next(os.walk('.'))[1]
# Create the file
output_file = open("element-import.html",'w')
# Add Polymer elements to main import file
for element in list_of_files:
if os.path.isfile(element+"/"+element+".html"):
output_file.write('<link rel="import" href="' + element +
'/' + element + '.html">\n')
else:
pass
output_file.close()
@draganmarjanovic
Copy link
Author

The script now checks whether the file of the same name exists in the folder before adding it to the import file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment