Skip to content

Instantly share code, notes, and snippets.

@monolithed
Created April 2, 2013 13:04
Show Gist options
  • Save monolithed/5292055 to your computer and use it in GitHub Desktop.
Save monolithed/5292055 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
'''
@name add_files
Adds file names into the Makefile like;
<@install -Dv src/32x32/mail.png 32x32/mail.ru.png>
File structure:
/
/src
/32x32
Makefile
@author Alexander Abashkin <[email protected]>
https://github.com/monolithed/
'''
import os
from glob import glob
class add_files:
def __init__(self):
self.install()
def install(self):
folders = os.listdir('./src')
for folder in folders:
os.chdir(folder)
self.write('all:\n')
for file in glob('*.png'):
self.write('\t@install -Dv src/{1}/{0} {1}/{0}\n'.format(file, folder))
def write(self, data):
try:
with open('../../Makefile', 'a') as name:
name.write(data)
except OSError, error:
self.LOG_INFO('fail', error)
else:
self.LOG_INFO('done', data.replace('\n', ''))
def LOG_INFO(self, name, callback):
print('{0}{2}{1}'.format('\033[%sm' % {'fail' : 91, 'done': 92}[name], '\033[0m', callback))
if __name__ == '__main__':
add_files()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment