##// END OF EJS Templates
Merge pull request #4085 from jdfreder/fix_sphinx_data_win_again...
Thomas Kluyver -
r12411:5e4d9f3b merge
parent child Browse files
Show More
@@ -33,7 +33,7 from IPython.config import Config
33 from IPython.nbformat import current as nbformat
33 from IPython.nbformat import current as nbformat
34 from IPython.utils.traitlets import MetaHasTraits, DottedObjectName, Unicode, List, Dict, Any
34 from IPython.utils.traitlets import MetaHasTraits, DottedObjectName, Unicode, List, Dict, Any
35 from IPython.utils.importstring import import_item
35 from IPython.utils.importstring import import_item
36 from IPython.utils.text import indent
36 from IPython.utils import text
37 from IPython.utils import py3compat
37 from IPython.utils import py3compat
38
38
39 from IPython.nbconvert import preprocessors as nbpreprocessors
39 from IPython.nbconvert import preprocessors as nbpreprocessors
@@ -47,7 +47,7 from IPython.nbconvert import filters
47 JINJA_EXTENSIONS = ['jinja2.ext.loopcontrols']
47 JINJA_EXTENSIONS = ['jinja2.ext.loopcontrols']
48
48
49 default_filters = {
49 default_filters = {
50 'indent': indent,
50 'indent': text.indent,
51 'markdown2html': filters.markdown2html,
51 'markdown2html': filters.markdown2html,
52 'ansi2html': filters.ansi2html,
52 'ansi2html': filters.ansi2html,
53 'filter_data_type': filters.DataTypeFilter,
53 'filter_data_type': filters.DataTypeFilter,
@@ -283,7 +283,7 class Exporter(LoggingConfigurable):
283 resources['metadata']['name'] = notebook_name
283 resources['metadata']['name'] = notebook_name
284
284
285 modified_date = datetime.datetime.fromtimestamp(os.path.getmtime(filename))
285 modified_date = datetime.datetime.fromtimestamp(os.path.getmtime(filename))
286 resources['metadata']['modified_date'] = modified_date.strftime("%B %d, %Y")
286 resources['metadata']['modified_date'] = modified_date.strftime(text.date_format)
287
287
288 with io.open(filename) as f:
288 with io.open(filename) as f:
289 return self.from_notebook_node(nbformat.read(f, 'json'), resources=resources,**kw)
289 return self.from_notebook_node(nbformat.read(f, 'json'), resources=resources,**kw)
@@ -29,6 +29,7 from pygments.formatters import LatexFormatter
29 # Our own imports
29 # Our own imports
30 # Configurable traitlets
30 # Configurable traitlets
31 from IPython.utils.traitlets import Unicode, Bool
31 from IPython.utils.traitlets import Unicode, Bool
32 from IPython.utils import text
32
33
33 # Needed to override preprocessor
34 # Needed to override preprocessor
34 from .base import (Preprocessor)
35 from .base import (Preprocessor)
@@ -157,7 +158,7 class SphinxPreprocessor(Preprocessor):
157 if self.publish_date:
158 if self.publish_date:
158 resources["sphinx"]["date"] = self.publish_date
159 resources["sphinx"]["date"] = self.publish_date
159 elif len(resources['metadata']['modified_date'].strip()) == 0:
160 elif len(resources['metadata']['modified_date'].strip()) == 0:
160 resources["sphinx"]["date"] = date.today().strftime("%B %-d, %Y")
161 resources["sphinx"]["date"] = date.today().strftime(text.date_format)
161 else:
162 else:
162 resources["sphinx"]["date"] = resources['metadata']['modified_date']
163 resources["sphinx"]["date"] = resources['metadata']['modified_date']
163
164
@@ -219,7 +220,7 class SphinxPreprocessor(Preprocessor):
219 if resources['metadata']['modified_date']:
220 if resources['metadata']['modified_date']:
220 default_date = resources['metadata']['modified_date']
221 default_date = resources['metadata']['modified_date']
221 else:
222 else:
222 default_date = date.today().strftime("%B %-d, %Y")
223 default_date = date.today().strftime(text.date_format)
223
224
224 user_date = console.input("Date (deafults to \"" + default_date + "\"): ")
225 user_date = console.input("Date (deafults to \"" + default_date + "\"): ")
225 if len(user_date.strip()) == 0:
226 if len(user_date.strip()) == 0:
@@ -261,4 +262,3 class SphinxPreprocessor(Preprocessor):
261 6: "(for international documents)"}
262 6: "(for international documents)"}
262
263
263 return console.prompt_dictionary(styles, menu_comments=comments)
264 return console.prompt_dictionary(styles, menu_comments=comments)
264
@@ -21,6 +21,7 Inheritance diagram:
21
21
22 import os
22 import os
23 import re
23 import re
24 import sys
24 import textwrap
25 import textwrap
25 from string import Formatter
26 from string import Formatter
26
27
@@ -28,6 +29,18 from IPython.external.path import path
28 from IPython.testing.skipdoctest import skip_doctest_py3, skip_doctest
29 from IPython.testing.skipdoctest import skip_doctest_py3, skip_doctest
29 from IPython.utils import py3compat
30 from IPython.utils import py3compat
30
31
32
33 #-----------------------------------------------------------------------------
34 # Declarations
35 #-----------------------------------------------------------------------------
36
37 # datetime.strftime date format for ipython
38 if sys.platform == 'win32':
39 date_format = "%B %d, %Y"
40 else:
41 date_format = "%B %-d, %Y"
42
43
31 #-----------------------------------------------------------------------------
44 #-----------------------------------------------------------------------------
32 # Code
45 # Code
33 #-----------------------------------------------------------------------------
46 #-----------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now