429 for arg in args: |
429 for arg in args: |
430 tmp.append((arg and arg + ' ' or '') + cls) |
430 tmp.append((arg and arg + ' ' or '') + cls) |
431 return ', '.join(tmp) |
431 return ', '.join(tmp) |
432 |
432 |
433 styles = [(level, ttype, cls, style) |
433 styles = [(level, ttype, cls, style) |
434 for cls, (style, ttype, level) in self.class2style.iteritems() |
434 for cls, (style, ttype, level) in self.class2style.items() |
435 if cls and style] |
435 if cls and style] |
436 styles.sort() |
436 styles.sort() |
437 lines = ['%s { %s } /* %s */' % (prefix(cls), style, repr(ttype)[6:]) |
437 lines = ['%s { %s } /* %s */' % (prefix(cls), style, repr(ttype)[6:]) |
438 for (level, ttype, cls, style) in styles] |
438 for (level, ttype, cls, style) in styles] |
439 if arg and not self.nobackground and \ |
439 if arg and not self.nobackground and \ |
467 # pseudo files, e.g. name == '<fdopen>' |
467 # pseudo files, e.g. name == '<fdopen>' |
468 raise AttributeError |
468 raise AttributeError |
469 cssfilename = os.path.join(os.path.dirname(filename), |
469 cssfilename = os.path.join(os.path.dirname(filename), |
470 self.cssfile) |
470 self.cssfile) |
471 except AttributeError: |
471 except AttributeError: |
472 print >>sys.stderr, 'Note: Cannot determine output file name, ' \ |
472 print('Note: Cannot determine output file name, ' \ |
473 'using current directory as base for the CSS file name' |
473 'using current directory as base for the CSS file name', file=sys.stderr) |
474 cssfilename = self.cssfile |
474 cssfilename = self.cssfile |
475 # write CSS file only if noclobber_cssfile isn't given as an option. |
475 # write CSS file only if noclobber_cssfile isn't given as an option. |
476 try: |
476 try: |
477 if not os.path.exists(cssfilename) or not self.noclobber_cssfile: |
477 if not os.path.exists(cssfilename) or not self.noclobber_cssfile: |
478 cf = open(cssfilename, "w") |
478 cf = open(cssfilename, "w") |
479 cf.write(CSSFILE_TEMPLATE % |
479 cf.write(CSSFILE_TEMPLATE % |
480 {'styledefs': self.get_style_defs('body')}) |
480 {'styledefs': self.get_style_defs('body')}) |
481 cf.close() |
481 cf.close() |
482 except IOError, err: |
482 except IOError as err: |
483 err.strerror = 'Error writing CSS file: ' + err.strerror |
483 err.strerror = 'Error writing CSS file: ' + err.strerror |
484 raise |
484 raise |
485 |
485 |
486 yield 0, (DOC_HEADER_EXTERNALCSS % |
486 yield 0, (DOC_HEADER_EXTERNALCSS % |
487 dict(title = self.title, |
487 dict(title = self.title, |
496 for t, line in inner: |
496 for t, line in inner: |
497 yield t, line |
497 yield t, line |
498 yield 0, DOC_FOOTER |
498 yield 0, DOC_FOOTER |
499 |
499 |
500 def _wrap_tablelinenos(self, inner): |
500 def _wrap_tablelinenos(self, inner): |
501 dummyoutfile = StringIO.StringIO() |
501 dummyoutfile = io.StringIO() |
502 lncount = 0 |
502 lncount = 0 |
503 for t, line in inner: |
503 for t, line in inner: |
504 if t: |
504 if t: |
505 lncount += 1 |
505 lncount += 1 |
506 dummyoutfile.write(line) |
506 dummyoutfile.write(line) |