Show More
@@ -33,7 +33,7 b' 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 |
|
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 b' 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, | |
@@ -282,7 +282,7 b' class Exporter(LoggingConfigurable):' | |||||
282 | resources['metadata']['name'] = notebook_name |
|
282 | resources['metadata']['name'] = notebook_name | |
283 |
|
283 | |||
284 | modified_date = datetime.datetime.fromtimestamp(os.path.getmtime(filename)) |
|
284 | modified_date = datetime.datetime.fromtimestamp(os.path.getmtime(filename)) | |
285 |
resources['metadata']['modified_date'] = |
|
285 | resources['metadata']['modified_date'] = modified_date.strftime(text.date_format) | |
286 |
|
286 | |||
287 | with io.open(filename) as f: |
|
287 | with io.open(filename) as f: | |
288 | return self.from_notebook_node(nbformat.read(f, 'json'), resources=resources,**kw) |
|
288 | return self.from_notebook_node(nbformat.read(f, 'json'), resources=resources,**kw) |
@@ -30,7 +30,7 b' from pygments.formatters import LatexFormatter' | |||||
30 | # Our own imports |
|
30 | # Our own imports | |
31 | # Configurable traitlets |
|
31 | # Configurable traitlets | |
32 | from IPython.utils.traitlets import Unicode, Bool |
|
32 | from IPython.utils.traitlets import Unicode, Bool | |
33 |
from IPython.utils |
|
33 | from IPython.utils import text | |
34 |
|
34 | |||
35 | # Needed to override preprocessor |
|
35 | # Needed to override preprocessor | |
36 | from .base import (Preprocessor) |
|
36 | from .base import (Preprocessor) | |
@@ -159,7 +159,7 b' class SphinxPreprocessor(Preprocessor):' | |||||
159 | if self.publish_date: |
|
159 | if self.publish_date: | |
160 | resources["sphinx"]["date"] = self.publish_date |
|
160 | resources["sphinx"]["date"] = self.publish_date | |
161 | elif len(resources['metadata']['modified_date'].strip()) == 0: |
|
161 | elif len(resources['metadata']['modified_date'].strip()) == 0: | |
162 |
resources["sphinx"]["date"] = |
|
162 | resources["sphinx"]["date"] = date.today().strftime(text.date_format) | |
163 | else: |
|
163 | else: | |
164 | resources["sphinx"]["date"] = resources['metadata']['modified_date'] |
|
164 | resources["sphinx"]["date"] = resources['metadata']['modified_date'] | |
165 |
|
165 | |||
@@ -221,7 +221,7 b' class SphinxPreprocessor(Preprocessor):' | |||||
221 | if resources['metadata']['modified_date']: |
|
221 | if resources['metadata']['modified_date']: | |
222 | default_date = resources['metadata']['modified_date'] |
|
222 | default_date = resources['metadata']['modified_date'] | |
223 | else: |
|
223 | else: | |
224 |
default_date = |
|
224 | default_date = date.today().strftime(text.date_format) | |
225 |
|
225 | |||
226 | user_date = console.input("Date (deafults to \"" + default_date + "\"): ") |
|
226 | user_date = console.input("Date (deafults to \"" + default_date + "\"): ") | |
227 | if len(user_date.strip()) == 0: |
|
227 | if len(user_date.strip()) == 0: |
@@ -29,6 +29,18 b' from IPython.external.path import path' | |||||
29 | from IPython.testing.skipdoctest import skip_doctest_py3, skip_doctest |
|
29 | from IPython.testing.skipdoctest import skip_doctest_py3, skip_doctest | |
30 | from IPython.utils import py3compat |
|
30 | from IPython.utils import py3compat | |
31 |
|
31 | |||
|
32 | ||||
|
33 | #----------------------------------------------------------------------------- | |||
|
34 | # Declarations | |||
|
35 | #----------------------------------------------------------------------------- | |||
|
36 | ||||
|
37 | # datetime.strftime date format for ipython | |||
|
38 | if sys.platform == 'win32': | |||
|
39 | date_format = date.strftime("%B %d, %Y") | |||
|
40 | else: | |||
|
41 | date_format = date.strftime("%B %-d, %Y") | |||
|
42 | ||||
|
43 | ||||
32 | #----------------------------------------------------------------------------- |
|
44 | #----------------------------------------------------------------------------- | |
33 | # Code |
|
45 | # Code | |
34 | #----------------------------------------------------------------------------- |
|
46 | #----------------------------------------------------------------------------- | |
@@ -712,21 +724,3 b" def columnize(items, separator=' ', displaywidth=80):" | |||||
712 | fmatrix = [filter(None, x) for x in matrix] |
|
724 | fmatrix = [filter(None, x) for x in matrix] | |
713 | sjoin = lambda x : separator.join([ y.ljust(w, ' ') for y, w in zip(x, info['columns_width'])]) |
|
725 | sjoin = lambda x : separator.join([ y.ljust(w, ' ') for y, w in zip(x, info['columns_width'])]) | |
714 | return '\n'.join(map(sjoin, fmatrix))+'\n' |
|
726 | return '\n'.join(map(sjoin, fmatrix))+'\n' | |
715 |
|
||||
716 |
|
||||
717 | def format_date(date): |
|
|||
718 | """ Format a datetime object as a string. |
|
|||
719 |
|
||||
720 | Parameters |
|
|||
721 | ---------- |
|
|||
722 | date : datetime object |
|
|||
723 | Date to be formatted. |
|
|||
724 |
|
||||
725 | Returns |
|
|||
726 | ------- |
|
|||
727 | The formatted date string (ie "July 1, 1990") |
|
|||
728 | """ |
|
|||
729 | if sys.platform == 'win32': |
|
|||
730 | return date.strftime("%B {0}, %Y").format(date.day) |
|
|||
731 | else: |
|
|||
732 | return date.strftime("%B %-d, %Y") No newline at end of file |
|
General Comments 0
You need to be logged in to leave comments.
Login now