def status(self): print prf(u'OK'), u'Structure of project', u'[' + unicode(len(config.sections)) + u' slides]' print os.popen(u''' find . -print 2>/dev/null | awk '!/\.$/ { \ for (i=1; i<NF; i++) { \ printf("%4s", "|") \ } \ print "-- "$NF \ }' FS='/' ''').read()
def parse(self, content=[], html=u'', id=u''): for file in config.sections: print prf(u'OK'), u'Parsing file', file, u'...' id = file.split(u'.')[-2].split(u'/')[-1] if file.split(u'.')[-1] == u'md': html = markdown.markdown(open(file, u'r').read()) elif file.split(u'.')[-1] == u'html': html = open(file, u'r').read() if config.settings.has_option(u'sections', id): content.append([html, config.settings.get(u'sections', id)]) else: content.append([html, u' ']) return content
def create(self): if not os.path.exists('assets'): shutil.copytree(config.path[0] + 'assets', 'assets') else: print(prf('WARNING'), 'Path already exists assets/', '!') if not os.path.exists('sections'): shutil.copytree(config.path[0] + 'sections', 'sections') else: print(prf('WARNING'), 'Path already exists sections/', '!') if not os.path.exists('default.cfg'): shutil.copyfile(config.path[0] + 'default.cfg', 'default.cfg') else: print(prf('WARNING'), 'Path already exists default.cfg', '!') print(prf('OK'), 'New project created!')
def create(self): if not os.path.exists('assets'): shutil.copytree(config.path[0] + 'assets', 'assets') else: print (prf('WARNING'), 'Path already exists assets/', '!') if not os.path.exists('sections'): shutil.copytree(config.path[0] + 'sections', 'sections') else: print (prf('WARNING'), 'Path already exists sections/', '!') if not os.path.exists('default.cfg'): shutil.copyfile(config.path[0] + 'default.cfg', 'default.cfg') else: print (prf('WARNING'), 'Path already exists default.cfg', '!') print (prf('OK'), 'New project created!')
def parse(self, content=[], html=u"", id=u""): for file in config.sections: print prf(u"OK"), u"Parsing file", file, u"..." id = file.split(u".")[-2].split(u"/")[-1] if file.split(u".")[-1] == u"md": html = markdown.markdown(open(file, u"r").read()) elif file.split(u".")[-1] == u"html": html = open(file, u"r").read() if config.settings.has_option(u"sections", id): content.append([html, config.settings.get(u"sections", id)]) else: content.append([html, u" "]) return content
def status(self): print (prf('OK'), 'Structure of project', '[' + str(len(config.sections)) + ' slides]') print (os.popen(''' find . -print 2>/dev/null | awk '!/\.$/ { \ for (i=1; i<NF; i++) { \ printf("%4s", "|") \ } \ print "-- "$NF \ }' FS='/' ''').read())
def status(self): print(prf('OK'), 'Structure of project', '[' + str(len(config.sections)) + ' slides]') print( os.popen(''' find . -print 2>/dev/null | awk '!/\.$/ { \ for (i=1; i<NF; i++) { \ printf("%4s", "|") \ } \ print "-- "$NF \ }' FS='/' ''').read())
def build(self): if os.path.exists('build'): shutil.rmtree('build') if not os.path.exists('assets') \ and not os.path.exists('sections') \ and not os.path.exists(config.file): print(prf('FAIL'), 'Structure does not exist', '!') sys.exit(1) shutil.copytree('assets', 'build') with open(config.settings.get('core', 'build'), 'w') as build: build.write(collector.html()) os.remove('build/index.jinja') for (top, dirs, files) in os.walk('build/'): for nm in files: if os.path.join(top, nm).split('.')[-1] == 'js': with open(os.path.join(top, nm)) as f: file_str = f.read() file_str = jsmin(file_str) with open(os.path.join(top, nm), 'w') as f: f.write(file_str) print(prf('OK'), 'Compressing file', nm, '...') if os.path.join(top, nm).split('.')[-1] == 'css': with open(os.path.join(top, nm)) as f: file_str = f.read() file_str = cssmin(file_str) with open(os.path.join(top, nm), 'w') as f: f.write(file_str) print(prf('OK'), 'Compressing file', nm, '...') print(prf('OK'), 'Saved in', config.settings.get('core', 'build'), '->', config.settings.get('head', 'title'))
def build(self): if os.path.exists('build'): shutil.rmtree('build') if not os.path.exists('assets') \ and not os.path.exists('sections') \ and not os.path.exists(config.file): print (prf('FAIL'), 'Structure does not exist', '!') sys.exit(1) shutil.copytree('assets', 'build') with open(config.settings.get('core', 'build'), 'w') as build: build.write(collector.html()) os.remove('build/index.jinja') for (top, dirs, files) in os.walk('build/'): for nm in files: if os.path.join(top, nm).split('.')[-1] == 'js': with open(os.path.join(top, nm)) as f: file_str = f.read() file_str = jsmin(file_str) with open(os.path.join(top, nm), 'w') as f: f.write(file_str) print (prf('OK'), 'Compressing file', nm, '...') if os.path.join(top, nm).split('.')[-1] == 'css': with open(os.path.join(top, nm)) as f: file_str = f.read() file_str = cssmin(file_str) with open(os.path.join(top, nm), 'w') as f: f.write(file_str) print (prf('OK'), 'Compressing file', nm, '...') print (prf('OK'), 'Saved in', config.settings.get('core', 'build'), '->', config.settings.get('head', 'title'))
def create(self): if not os.path.exists(u'assets'): shutil.copytree(config.path[0] + u'assets', u'assets') else: print prf(u'WARNING'), u'Path already exists assets/', u'!' if not os.path.exists(u'sections'): shutil.copytree(config.path[0] + u'sections', u'sections') else: print prf(u'WARNING'), u'Path already exists sections/', u'!' if not os.path.exists(u'default.cfg'): shutil.copyfile(config.path[0] + u'default.cfg', u'default.cfg') else: print prf(u'WARNING'), u'Path already exists default.cfg', u'!' print prf(u'OK'), u'New project created!'
def parse(self, content=[], html='', id=''): for file in config.sections: print (prf('OK'), 'Parsing file', file, '...') id = file.split('.')[-2].split('/')[-1] if file.split('.')[-1] == 'md': html = markdown.markdown(open(file, 'r').read()) elif file.split('.')[-1] == 'html': html = open(file, 'r').read() if config.settings.has_option('sections', id): content.append([html, config.settings.get('sections', id)]) else: content.append([html, ' ']) return content