예제 #1
0
    def get(self, part_key=None):
        if not part_key:
            part_key = black_stars_rise.getDefaultPartKey()

        template_values = dict()
        part = black_stars_rise.getPartByKey(part_key)
        if hasattr(part, 'getSections'):
            template_values['sections'] = part.getSections()
        if hasattr(part, 'getCareers'):
            template_values['career_names'] = part.getCareerNames()
            template_values['careers'] = part.getCareers()
        if hasattr(part, 'getSetups'):
            template_values['setup_titles'] = part.getSetupTitles()
            template_values['setups'] = part.getSetups()
        if hasattr(part, 'getMoves'):
            template_values['moves'] = part.getMoves()
        if hasattr(part, 'getBreaks'):
            template_values['breaks'] = part.getBreaksInPairs()
        template_values['parts'] = black_stars_rise.getParts()
        template_values['current'] = part_key

        template = jinja_environment.get_template('chapter.html')
        self.response.write(template.render(template_values))
예제 #2
0
 def get(self, part_key=None):
   if not part_key:
     part_key = black_stars_rise.getDefaultPartKey()
   
   template_values = dict()
   part = black_stars_rise.getPartByKey(part_key)
   if hasattr(part, 'getSections'):
     template_values['sections'] = part.getSections()
   if hasattr(part, 'getCareers'):
     template_values['career_names'] = part.getCareerNames()
     template_values['careers'] = part.getCareers()
   if hasattr(part, 'getSetups'):
     template_values['setup_titles'] = part.getSetupTitles()
     template_values['setups'] = part.getSetups()
   if hasattr(part, 'getMoves'):
     template_values['moves'] = part.getMoves()
   if hasattr(part, 'getBreaks'):
     template_values['breaks'] = part.getBreaksInPairs()
   template_values['parts'] = black_stars_rise.getParts()
   template_values['current'] = part_key
   
   template = jinja_environment.get_template('chapter.html')
   self.response.write(template.render(template_values))
예제 #3
0
import shutil
import os
import codecs

if __name__ == '__main__':

    # Always build from scratch.
    # We're just doing a little xml parsing, the work in making it incremental
    # just doesn't seem worth it. Instead we invent the universe to make an
    # apple pie.
    if os.path.isdir('build'):
        shutil.rmtree('build')
    if not os.path.isdir('build'):
        os.mkdir('build')

    for part in black_stars_rise.getParts():
        # Check to see if it's a chapter
        if hasattr(part, 'getSections'):
            with codecs.open(os.path.join('build',
                                          part.getKey() + '.xml'), 'w',
                             "utf-8") as f:
                f.write(
                    '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'
                )
                f.write('<chapter>')
                for section in part.getSections():
                    f.write(section.getText())
                    f.write('\n')
                f.write('</chapter>')
        elif hasattr(part, 'getCareers'):  # It's a setting
            with codecs.open(os.path.join('build',
예제 #4
0
import shutil
import os
import codecs

if __name__ == '__main__':
  
  # Always build from scratch.
  # We're just doing a little xml parsing, the work in making it incremental
  # just doesn't seem worth it. Instead we invent the universe to make an 
  # apple pie.
  if os.path.isdir('build'):
    shutil.rmtree('build')
  if not os.path.isdir('build'):
    os.mkdir('build')
    
  for part in black_stars_rise.getParts():
    # Check to see if it's a chapter
    if hasattr(part, 'getSections'):
      with codecs.open(os.path.join('build', part.getKey()+'.xml'), 'w', "utf-8") as f:
        f.write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n')
        f.write('<chapter>')
        for section in part.getSections():
          f.write(section.getText())
          f.write('\n')
        f.write('</chapter>')
    elif hasattr(part, 'getCareers'): # It's a setting
      with codecs.open(os.path.join('build', part.getKey()+'.xml'), 'w', "utf-8") as f:
        f.write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n')
        f.write('<setting><careers>')
        for career in part.getCareers():
          f.write('<career>')