ThirdParty/Pygments/pygments/formatters/html.py

branch
Py2 comp.
changeset 3079
0233bbe9a9c4
parent 2525
8b507a9a2d40
child 4172
4f20dba37ab6
equal deleted inserted replaced
3066:76a310bc7bba 3079:0233bbe9a9c4
7 7
8 :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 from __future__ import unicode_literals # __IGNORE_WARNING__ 12 try:
13 basestring # __IGNORE_WARNING__
14 except NameError:
15 basestring = str
13 16
14 import os 17 import os
15 import sys 18 import sys
16 import os.path 19 import os.path
17 import io 20 import io
453 highlighting style. ``arg`` can be a string or list of selectors to 456 highlighting style. ``arg`` can be a string or list of selectors to
454 insert before the token type classes. 457 insert before the token type classes.
455 """ 458 """
456 if arg is None: 459 if arg is None:
457 arg = ('cssclass' in self.options and '.'+self.cssclass or '') 460 arg = ('cssclass' in self.options and '.'+self.cssclass or '')
458 if isinstance(arg, str): 461 if isinstance(arg, basestring):
459 args = [arg] 462 args = [arg]
460 else: 463 else:
461 args = list(arg) 464 args = list(arg)
462 465
463 def prefix(cls): 466 def prefix(cls):
505 # pseudo files, e.g. name == '<fdopen>' 508 # pseudo files, e.g. name == '<fdopen>'
506 raise AttributeError 509 raise AttributeError
507 cssfilename = os.path.join(os.path.dirname(filename), 510 cssfilename = os.path.join(os.path.dirname(filename),
508 self.cssfile) 511 self.cssfile)
509 except AttributeError: 512 except AttributeError:
510 print('Note: Cannot determine output file name, ' \ 513 sys.stderr.write('Note: Cannot determine output file name, ' \
511 'using current directory as base for the CSS file name', file=sys.stderr) 514 'using current directory as base for the CSS file name')
512 cssfilename = self.cssfile 515 cssfilename = self.cssfile
513 # write CSS file only if noclobber_cssfile isn't given as an option. 516 # write CSS file only if noclobber_cssfile isn't given as an option.
514 try: 517 try:
515 if not os.path.exists(cssfilename) or not self.noclobber_cssfile: 518 if not os.path.exists(cssfilename) or not self.noclobber_cssfile:
516 cf = open(cssfilename, "w") 519 cf = open(cssfilename, "w")

eric ide

mercurial